Manos Chorianopoulos

MyRewardsBannerOffersScrollTableViewCell redesign

...@@ -34,6 +34,8 @@ public class MyRewardsBannerOfferCollectionViewCell: UICollectionViewCell { ...@@ -34,6 +34,8 @@ public class MyRewardsBannerOfferCollectionViewCell: UICollectionViewCell {
34 // Initialization code 34 // Initialization code
35 35
36 backgroundImage.contentMode = .scaleAspectFill 36 backgroundImage.contentMode = .scaleAspectFill
37 + contentView.layer.cornerRadius = 12
38 + contentView.layer.masksToBounds = true
37 } 39 }
38 40
39 func configureCell(data: CampaignItemModel) { 41 func configureCell(data: CampaignItemModel) {
......
...@@ -10,17 +10,17 @@ ...@@ -10,17 +10,17 @@
10 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> 10 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
11 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 11 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
12 <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="MyRewardsBannerOfferCollectionViewCell" id="gTV-IL-0wX" customClass="MyRewardsBannerOfferCollectionViewCell"> 12 <collectionViewCell opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" reuseIdentifier="MyRewardsBannerOfferCollectionViewCell" id="gTV-IL-0wX" customClass="MyRewardsBannerOfferCollectionViewCell">
13 - <rect key="frame" x="0.0" y="0.0" width="329" height="235"/> 13 + <rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
14 <autoresizingMask key="autoresizingMask"/> 14 <autoresizingMask key="autoresizingMask"/>
15 <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center"> 15 <view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
16 - <rect key="frame" x="0.0" y="0.0" width="329" height="235"/> 16 + <rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
17 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> 17 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
18 <subviews> 18 <subviews>
19 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UtL-2K-6j5" userLabel="Content View"> 19 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="UtL-2K-6j5" userLabel="Content View">
20 - <rect key="frame" x="0.0" y="0.0" width="329" height="235"/> 20 + <rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
21 <subviews> 21 <subviews>
22 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0vR-l5-Rgp"> 22 <imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="0vR-l5-Rgp">
23 - <rect key="frame" x="0.0" y="0.0" width="329" height="235"/> 23 + <rect key="frame" x="0.0" y="0.0" width="365" height="126"/>
24 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> 24 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
25 </imageView> 25 </imageView>
26 </subviews> 26 </subviews>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
41 <constraint firstItem="UtL-2K-6j5" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="fVw-LI-PWH"/> 41 <constraint firstItem="UtL-2K-6j5" firstAttribute="leading" secondItem="gTV-IL-0wX" secondAttribute="leading" id="fVw-LI-PWH"/>
42 <constraint firstAttribute="trailing" secondItem="UtL-2K-6j5" secondAttribute="trailing" id="uSL-t1-ATu"/> 42 <constraint firstAttribute="trailing" secondItem="UtL-2K-6j5" secondAttribute="trailing" id="uSL-t1-ATu"/>
43 </constraints> 43 </constraints>
44 - <size key="customSize" width="329" height="235"/> 44 + <size key="customSize" width="365" height="126"/>
45 <connections> 45 <connections>
46 <outlet property="backgroundImage" destination="0vR-l5-Rgp" id="uTh-Ji-cdm"/> 46 <outlet property="backgroundImage" destination="0vR-l5-Rgp" id="uTh-Ji-cdm"/>
47 </connections> 47 </connections>
......
...@@ -43,13 +43,13 @@ public class MyRewardsBannerOffersScrollTableViewCell: UITableViewCell { ...@@ -43,13 +43,13 @@ public class MyRewardsBannerOffersScrollTableViewCell: UITableViewCell {
43 // Configure collection view layout 43 // Configure collection view layout
44 if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout { 44 if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
45 layout.scrollDirection = .horizontal 45 layout.scrollDirection = .horizontal
46 - layout.minimumLineSpacing = 0 46 + layout.minimumLineSpacing = 10
47 layout.minimumInteritemSpacing = 0 47 layout.minimumInteritemSpacing = 0
48 layout.sectionInset = UIEdgeInsets.zero 48 layout.sectionInset = UIEdgeInsets.zero
49 } 49 }
50 50
51 - // Enable paging for smooth banner scrolling 51 + // Disable paging so cards smaller than screen width scroll freely
52 - collectionView.isPagingEnabled = true 52 + collectionView.isPagingEnabled = false
53 collectionView.showsHorizontalScrollIndicator = false 53 collectionView.showsHorizontalScrollIndicator = false
54 54
55 // Set delegates 55 // Set delegates
...@@ -134,12 +134,12 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource, ...@@ -134,12 +134,12 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
134 // MARK: - UICollectionViewDelegateFlowLayout 134 // MARK: - UICollectionViewDelegateFlowLayout
135 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 135 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {
136 let screenWidth = UIScreen.main.bounds.width 136 let screenWidth = UIScreen.main.bounds.width
137 - return CGSize(width: screenWidth, height: 348) 137 + return CGSize(width: screenWidth - 48, height: 126)
138 } 138 }
139 139
140 // Distance Between Item Cells 140 // Distance Between Item Cells
141 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { 141 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
142 - return 0 142 + return 10
143 } 143 }
144 144
145 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { 145 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
...@@ -148,19 +148,19 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource, ...@@ -148,19 +148,19 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
148 148
149 // Cell Margin 149 // Cell Margin
150 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { 150 public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
151 - return UIEdgeInsets.zero 151 + return UIEdgeInsets(top: 0, left: 18, bottom: 0, right: 18)
152 } 152 }
153 153
154 // MARK: - UIScrollViewDelegate 154 // MARK: - UIScrollViewDelegate
155 public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 155 public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
156 - let pageWidth = scrollView.frame.width 156 + let itemWidth = UIScreen.main.bounds.width - 48 + 10 // card width + spacing
157 - let currentPage = Int(scrollView.contentOffset.x / pageWidth) 157 + let currentPage = Int((scrollView.contentOffset.x + itemWidth / 2) / itemWidth)
158 pageControl.currentPage = currentPage 158 pageControl.currentPage = currentPage
159 } 159 }
160 160
161 public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) { 161 public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
162 - let pageWidth = scrollView.frame.width 162 + let itemWidth = UIScreen.main.bounds.width - 48 + 10 // card width + spacing
163 - let currentPage = Int(scrollView.contentOffset.x / pageWidth) 163 + let currentPage = Int((scrollView.contentOffset.x + itemWidth / 2) / itemWidth)
164 pageControl.currentPage = currentPage 164 pageControl.currentPage = currentPage
165 } 165 }
166 } 166 }
......
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 -<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"> 2 +<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">
3 <device id="retina6_12" orientation="portrait" appearance="light"/> 3 <device id="retina6_12" orientation="portrait" appearance="light"/>
4 <dependencies> 4 <dependencies>
5 - <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="23084"/> 5 + <plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24504"/>
6 <capability name="Safe area layout guides" minToolsVersion="9.0"/> 6 <capability name="Safe area layout guides" minToolsVersion="9.0"/>
7 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> 7 <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
8 </dependencies> 8 </dependencies>
9 <objects> 9 <objects>
10 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/> 10 <placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
11 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/> 11 <placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
12 - <tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MyRewardsBannerOffersScrollTableViewCell" rowHeight="349" id="KGk-i7-Jjw" customClass="MyRewardsBannerOffersScrollTableViewCell"> 12 + <tableViewCell contentMode="scaleToFill" selectionStyle="none" indentationWidth="10" reuseIdentifier="MyRewardsBannerOffersScrollTableViewCell" rowHeight="126" id="KGk-i7-Jjw" customClass="MyRewardsBannerOffersScrollTableViewCell">
13 - <rect key="frame" x="0.0" y="0.0" width="413" height="349"/> 13 + <rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
14 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> 14 <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
15 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM"> 15 <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" ambiguous="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
16 - <rect key="frame" x="0.0" y="0.0" width="413" height="349"/> 16 + <rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
17 <autoresizingMask key="autoresizingMask"/> 17 <autoresizingMask key="autoresizingMask"/>
18 <subviews> 18 <subviews>
19 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VzF-dQ-3Wa" userLabel="Parent View"> 19 <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="VzF-dQ-3Wa" userLabel="Parent View">
20 - <rect key="frame" x="0.0" y="0.0" width="413" height="349"/> 20 + <rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
21 <subviews> 21 <subviews>
22 <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="I7z-Fz-SNP"> 22 <collectionView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" dataMode="none" translatesAutoresizingMaskIntoConstraints="NO" id="I7z-Fz-SNP">
23 - <rect key="frame" x="0.0" y="20" width="413" height="348"/> 23 + <rect key="frame" x="0.0" y="0.0" width="413" height="126"/>
24 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> 24 <color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
25 <constraints> 25 <constraints>
26 - <constraint firstAttribute="height" constant="348" id="aEf-Xl-A2C"/> 26 + <constraint firstAttribute="height" constant="126" id="aEf-Xl-A2C"/>
27 </constraints> 27 </constraints>
28 <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" automaticEstimatedItemSize="YES" minimumLineSpacing="5" minimumInteritemSpacing="5" id="yIw-sc-1jC"> 28 <collectionViewFlowLayout key="collectionViewLayout" scrollDirection="horizontal" automaticEstimatedItemSize="YES" minimumLineSpacing="5" minimumInteritemSpacing="5" id="yIw-sc-1jC">
29 <size key="itemSize" width="128" height="120"/> 29 <size key="itemSize" width="128" height="120"/>
...@@ -47,16 +47,22 @@ ...@@ -47,16 +47,22 @@
47 <constraint firstAttribute="bottom" secondItem="lOm-CZ-dVG" secondAttribute="bottom" id="7gm-Kg-nCS"/> 47 <constraint firstAttribute="bottom" secondItem="lOm-CZ-dVG" secondAttribute="bottom" id="7gm-Kg-nCS"/>
48 <constraint firstAttribute="trailing" secondItem="I7z-Fz-SNP" secondAttribute="trailing" id="avB-Gc-ttI"/> 48 <constraint firstAttribute="trailing" secondItem="I7z-Fz-SNP" secondAttribute="trailing" id="avB-Gc-ttI"/>
49 <constraint firstItem="I7z-Fz-SNP" firstAttribute="leading" secondItem="VzF-dQ-3Wa" secondAttribute="leading" id="pTY-7d-s1S"/> 49 <constraint firstItem="I7z-Fz-SNP" firstAttribute="leading" secondItem="VzF-dQ-3Wa" secondAttribute="leading" id="pTY-7d-s1S"/>
50 - <constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="VzF-dQ-3Wa" secondAttribute="top" constant="20" id="vJF-jy-p83"/> 50 + <constraint firstAttribute="bottom" secondItem="I7z-Fz-SNP" secondAttribute="bottom" id="sLs-wO-lfd"/>
51 + <constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="VzF-dQ-3Wa" secondAttribute="top" id="vJF-jy-p83"/>
51 <constraint firstItem="lOm-CZ-dVG" firstAttribute="centerX" secondItem="VzF-dQ-3Wa" secondAttribute="centerX" id="xpw-tV-NcW"/> 52 <constraint firstItem="lOm-CZ-dVG" firstAttribute="centerX" secondItem="VzF-dQ-3Wa" secondAttribute="centerX" id="xpw-tV-NcW"/>
52 </constraints> 53 </constraints>
54 + <variation key="default">
55 + <mask key="subviews">
56 + <exclude reference="lOm-CZ-dVG"/>
57 + </mask>
58 + </variation>
53 </view> 59 </view>
54 </subviews> 60 </subviews>
55 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> 61 <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
56 <constraints> 62 <constraints>
57 <constraint firstItem="VzF-dQ-3Wa" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="7Ut-VE-YGv"/> 63 <constraint firstItem="VzF-dQ-3Wa" firstAttribute="leading" secondItem="H2p-sc-9uM" secondAttribute="leading" id="7Ut-VE-YGv"/>
58 <constraint firstAttribute="trailing" secondItem="VzF-dQ-3Wa" secondAttribute="trailing" id="Hic-ok-g96"/> 64 <constraint firstAttribute="trailing" secondItem="VzF-dQ-3Wa" secondAttribute="trailing" id="Hic-ok-g96"/>
59 - <constraint firstItem="VzF-dQ-3Wa" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" id="PZE-CV-H0c"/> 65 + <constraint firstItem="VzF-dQ-3Wa" firstAttribute="top" secondItem="H2p-sc-9uM" secondAttribute="top" constant="20" id="PZE-CV-H0c"/>
60 <constraint firstAttribute="bottom" secondItem="VzF-dQ-3Wa" secondAttribute="bottom" id="hVw-ot-Ywc"/> 66 <constraint firstAttribute="bottom" secondItem="VzF-dQ-3Wa" secondAttribute="bottom" id="hVw-ot-Ywc"/>
61 </constraints> 67 </constraints>
62 </tableViewCellContentView> 68 </tableViewCellContentView>
......
...@@ -668,7 +668,7 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{ ...@@ -668,7 +668,7 @@ extension MyRewardsViewController: UITableViewDelegate, UITableViewDataSource{
668 extension MyRewardsViewController: MyRewardsProfileInfoTableViewCellDelegate { 668 extension MyRewardsViewController: MyRewardsProfileInfoTableViewCellDelegate {
669 func didTapProfileButton() { 669 func didTapProfileButton() {
670 // Navigate to ProfileViewController 670 // Navigate to ProfileViewController
671 - openProfileViewController() 671 + // openProfileViewController()
672 } 672 }
673 } 673 }
674 674
......