Manos Chorianopoulos

MyRewardsBannerOffersScrollTableViewCell collectionView fixes

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -36,6 +36,35 @@ import UIKit
// Register XIBs for collection view cells
collectionView.register(UINib(nibName: "MyRewardsBannerOfferCollectionViewCell", bundle: Bundle(for: MyEmptyClass.self)), forCellWithReuseIdentifier: "MyRewardsBannerOfferCollectionViewCell")
// Fix background colors
collectionView.backgroundColor = UIColor.clear
self.backgroundColor = UIColor.clear
self.contentView.backgroundColor = UIColor.clear
// Remove content insets and gaps
collectionView.contentInset = UIEdgeInsets.zero
collectionView.scrollIndicatorInsets = UIEdgeInsets.zero
if #available(iOS 11.0, *) {
collectionView.contentInsetAdjustmentBehavior = .never
}
// Configure collection view layout
if let layout = collectionView.collectionViewLayout as? UICollectionViewFlowLayout {
layout.scrollDirection = .horizontal
layout.minimumLineSpacing = 0
layout.minimumInteritemSpacing = 0
layout.sectionInset = UIEdgeInsets.zero
}
// Enable paging for smooth banner scrolling
collectionView.isPagingEnabled = true
collectionView.showsHorizontalScrollIndicator = false
// Set delegates
collectionView.delegate = self
collectionView.dataSource = self
}
public override func setSelected(_ selected: Bool, animated: Bool) {
......@@ -50,7 +79,8 @@ import UIKit
}
}
extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,UICollectionViewDelegate {
extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
public func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
......@@ -72,15 +102,24 @@ extension MyRewardsBannerOffersScrollTableViewCell: UICollectionViewDataSource,U
public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// TODO: open offer
}
// 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)
}
// Distance Between Item Cells
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
// // Distance Between Item Cells
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
// return 5
// }
//
// // Cell Margin
// func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
// return UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0)
// }
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
return 0
}
// Cell Margin
public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
return UIEdgeInsets.zero
}
}
......
......@@ -120,7 +120,7 @@
<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="20" id="vJF-jy-p83"/>
<constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="JTs-J5-DO2" secondAttribute="bottom" constant="10" id="vJF-jy-p83"/>
</constraints>
</view>
</subviews>
......