Manos Chorianopoulos

MyRewardsBannerOffersScrollTableViewCell redesign

......@@ -34,6 +34,8 @@ public class MyRewardsBannerOfferCollectionViewCell: UICollectionViewCell {
// Initialization code
backgroundImage.contentMode = .scaleAspectFill
contentView.layer.cornerRadius = 12
contentView.layer.masksToBounds = true
}
func configureCell(data: CampaignItemModel) {
......
......@@ -10,17 +10,17 @@
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="MyRewardsBannerOfferCollectionViewCell" id="gTV-IL-0wX" customClass="MyRewardsBannerOfferCollectionViewCell">
<rect key="frame" x="0.0" y="0.0" width="329" height="235"/>
<rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
<autoresizingMask key="autoresizingMask"/>
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
<rect key="frame" x="0.0" y="0.0" width="329" height="235"/>
<rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UtL-2K-6j5" userLabel="Content View">
<rect key="frame" x="0.0" y="0.0" width="329" height="235"/>
<rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0vR-l5-Rgp">
<rect key="frame" x="0.0" y="0.0" width="329" height="235"/>
<rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</imageView>
</subviews>
......@@ -41,7 +41,7 @@
<constraint firstItem="UtL-2K-6j5" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="fVw-LI-PWH"/>
<constraint firstAttribute="trailing" secondItem="UtL-2K-6j5" secondAttribute="trailing" id="uSL-t1-ATu"/>
</constraints>
<size key="customSize" width="329" height="235"/>
<size key="customSize" width="365" height="126"/>
<connections>
<outlet property="backgroundImage" destination="0vR-l5-Rgp" id="uTh-Ji-cdm"/>
</connections>
......
......@@ -43,13 +43,13 @@ public class MyRewardsBannerOffersScrollTableViewCell: UITableViewCell {
// Configure collection view layout
if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 0
layout.minimumLineSpacing = 10
layout.minimumInteritemSpacing = 0
layout.sectionInset = UIEdgeInsets.zero
}
// Enable paging for smooth banner scrolling
collectionView.isPagingEnabled = true
// Disable paging so cards smaller than screen width scroll freely
collectionView.isPagingEnabled = false
collectionView.showsHorizontalScrollIndicator = false
// Set delegates
......@@ -134,12 +134,12 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
// MARK: - UICollectionViewDelegateFlowLayout
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
let screenWidth = UIScreen.main.bounds.width
return CGSize(width: screenWidth, height: 348)
return CGSize(width: screenWidth - 48, height: 126)
}
// Distance Between Item Cells
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
return 10
}
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
......@@ -148,19 +148,19 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
// Cell Margin
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets.zero
return UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
}
// MARK: - UIScrollViewDelegate
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let pageWidth = scrollView.frame.width
let currentPage = Int(scrollView.contentOffset.x / pageWidth)
let itemWidth = UIScreen.main.bounds.width - 48 + 10 // card width + spacing
let currentPage = Int((scrollView.contentOffset.x + itemWidth / 2) / itemWidth)
pageControl.currentPage = currentPage
}
public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
let pageWidth = scrollView.frame.width
let currentPage = Int(scrollView.contentOffset.x / pageWidth)
let itemWidth = UIScreen.main.bounds.width - 48 + 10 // card width + spacing
let currentPage = Int((scrollView.contentOffset.x + itemWidth / 2) / itemWidth)
pageControl.currentPage = currentPage
}
}
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="23094" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="24506" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24504"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MyRewardsBannerOffersScrollTableViewCell" rowHeight="349" id="KGk-i7-Jjw" customClass="MyRewardsBannerOffersScrollTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="413" height="349"/>
<tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MyRewardsBannerOffersScrollTableViewCell" rowHeight="126" id="KGk-i7-Jjw" customClass="MyRewardsBannerOffersScrollTableViewCell">
<rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="413" height="349"/>
<rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VzF-dQ-3Wa" userLabel="Parent View">
<rect key="frame" x="0.0" y="0.0" width="413" height="349"/>
<rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
<subviews>
<collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="I7z-Fz-SNP">
<rect key="frame" x="0.0" y="20" width="413" height="348"/>
<rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="348" id="aEf-Xl-A2C"/>
<constraint firstAttribute="height" constant="126" id="aEf-Xl-A2C"/>
</constraints>
<collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" automaticEstimatedItemSize="YES" minimumLineSpacing="5" minimumInteritemSpacing="5" id="yIw-sc-1jC">
<size key="itemSize" width="128" height="120"/>
......@@ -47,16 +47,22 @@
<constraint firstAttribute="bottom" secondItem="lOm-CZ-dVG" secondAttribute="bottom" id="7gm-Kg-nCS"/>
<constraint firstAttribute="trailing" secondItem="I7z-Fz-SNP" secondAttribute="trailing" id="avB-Gc-ttI"/>
<constraint firstItem="I7z-Fz-SNP" firstAttribute="leading" secondItem="VzF-dQ-3Wa" secondAttribute="leading" id="pTY-7d-s1S"/>
<constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="VzF-dQ-3Wa" secondAttribute="top" constant="20" id="vJF-jy-p83"/>
<constraint firstAttribute="bottom" secondItem="I7z-Fz-SNP" secondAttribute="bottom" id="sLs-wO-lfd"/>
<constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="VzF-dQ-3Wa" secondAttribute="top" id="vJF-jy-p83"/>
<constraint firstItem="lOm-CZ-dVG" firstAttribute="centerX" secondItem="VzF-dQ-3Wa" secondAttribute="centerX" id="xpw-tV-NcW"/>
</constraints>
<variation key="default">
<mask key="subviews">
<exclude reference="lOm-CZ-dVG"/>
</mask>
</variation>
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="VzF-dQ-3Wa" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="7Ut-VE-YGv"/>
<constraint firstAttribute="trailing" secondItem="VzF-dQ-3Wa" secondAttribute="trailing" id="Hic-ok-g96"/>
<constraint firstItem="VzF-dQ-3Wa" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="PZE-CV-H0c"/>
<constraint firstItem="VzF-dQ-3Wa" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="20" id="PZE-CV-H0c"/>
<constraint firstAttribute="bottom" secondItem="VzF-dQ-3Wa" secondAttribute="bottom" id="hVw-ot-Ywc"/>
</constraints>
</tableViewCellContentView>
......
......@@ -668,7 +668,7 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
extension MyRewardsViewController: MyRewardsProfileInfoTableViewCellDelegate {
func didTapProfileButton() {
// Navigate to ProfileViewController
openProfileViewController()
// openProfileViewController()
}
}
......