Manos Chorianopoulos

MyRewardsBannerOffersScrollTableViewCell paging added

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -14,6 +14,7 @@ import UIKit
@IBOutlet weak var tagLabel2: UILabel!
@IBOutlet weak var profileImage: UIImageView!
@IBOutlet weak var collectionView: UICollectionView!
@IBOutlet weak var pageControl: UIPageControl!
var data: SectionModel?
......@@ -65,6 +66,12 @@ import UIKit
// Set delegates
collectionView.delegate = self
collectionView.dataSource = self
// Configure page control
pageControl.currentPageIndicatorTintColor = UIColor(rgb: 0xEE437E)
pageControl.pageIndicatorTintColor = UIColor(rgb: 0xD8D8D8)
pageControl.hidesForSinglePage = true
pageControl.isUserInteractionEnabled = false // Disable direct tapping on page control
}
public override func setSelected(_ selected: Bool, animated: Bool) {
......@@ -75,6 +82,12 @@ import UIKit
func configureCell(data: SectionModel?) {
self.data = data
// Configure page control
let numberOfPages = self.data?.offers.count ?? 0
pageControl.numberOfPages = numberOfPages
pageControl.currentPage = 0
self.collectionView.reloadData();
}
}
......@@ -122,4 +135,17 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets.zero
}
// MARK: - UIScrollViewDelegate
public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) {
let pageWidth = scrollView.frame.width
let currentPage = Int(scrollView.contentOffset.x / pageWidth)
pageControl.currentPage = currentPage
}
public func scrollViewDidEndScrollingAnimation(_ scrollView: UIScrollView) {
let pageWidth = scrollView.frame.width
let currentPage = Int(scrollView.contentOffset.x / pageWidth)
pageControl.currentPage = currentPage
}
}
......
......@@ -111,19 +111,25 @@
<outlet property="delegate" destination="KGk-i7-Jjw" id="fQ4-0u-38c"/>
</connections>
</collectionView>
<pageControl opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="lOm-CZ-dVG">
<rect key="frame" x="170" y="136" width="73" height="26"/>
</pageControl>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="bottom" secondItem="I7z-Fz-SNP" secondAttribute="bottom" id="0xG-dd-XJl"/>
<constraint firstItem="lOm-CZ-dVG" firstAttribute="top" secondItem="I7z-Fz-SNP" secondAttribute="bottom" id="0xG-dd-XJl"/>
<constraint firstAttribute="bottom" secondItem="lOm-CZ-dVG" secondAttribute="bottom" id="7gm-Kg-nCS"/>
<constraint firstItem="JTs-J5-DO2" firstAttribute="top" secondItem="VzF-dQ-3Wa" secondAttribute="top" constant="36" id="Ac5-fx-J3w"/>
<constraint firstItem="JTs-J5-DO2" firstAttribute="leading" secondItem="VzF-dQ-3Wa" secondAttribute="leading" constant="24" id="B98-id-FLf"/>
<constraint firstAttribute="trailing" secondItem="JTs-J5-DO2" secondAttribute="trailing" constant="24" id="Rdi-FK-2Ft"/>
<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="JTs-J5-DO2" secondAttribute="bottom" constant="10" id="vJF-jy-p83"/>
<constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="JTs-J5-DO2" secondAttribute="bottom" constant="5" id="vJF-jy-p83"/>
<constraint firstItem="lOm-CZ-dVG" firstAttribute="centerX" secondItem="VzF-dQ-3Wa" secondAttribute="centerX" id="xpw-tV-NcW"/>
</constraints>
</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"/>
......@@ -135,6 +141,7 @@
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
<outlet property="collectionView" destination="I7z-Fz-SNP" id="yrF-mR-aQu"/>
<outlet property="pageControl" destination="lOm-CZ-dVG" id="Skf-hV-rjH"/>
<outlet property="profileImage" destination="fZO-NB-UyL" id="l05-qG-DJv"/>
<outlet property="tagLabel1" destination="4m7-JY-MDY" id="Min-YW-AN2"/>
<outlet property="tagLabel2" destination="WN9-wM-hV8" id="yWk-1S-4Zk"/>
......