Manos Chorianopoulos

MyRewardsBannerOffers dynamic banner image

......@@ -11,19 +11,33 @@ import UIKit
public class MyRewardsBannerOfferCollectionViewCell: UICollectionViewCell {
@IBOutlet weak var backgroundImage: UIImageView!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.backgroundImage.image = UIImage() // UIImage(named: "loading")
UIImage.loadImageUsingCacheWithUrlString(url) { image in
// set the image only when we are still displaying the content for the image we finished downloading
if url == self.postImageURL {
self.backgroundImage.image = image
}
}
}
else {
self.backgroundImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
backgroundImage.contentMode = .scaleAspectFill
}
func configureCell(data: CampaignItemModel) {
// Use campaign's banner image - no hardcoded defaults
let imageName = data._banner_img_mobile ?? ""
if !imageName.isEmpty {
backgroundImage.image = UIImage(named: imageName, in: Bundle.frameworkResourceBundle, compatibleWith: nil)
} else {
backgroundImage.image = nil
}
self.postImageURL = data._banner_img_mobile ?? ""
}
}
......
......@@ -17,7 +17,7 @@
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="VzF-dQ-3Wa" userLabel="Parent View">
<rect key="frame" x="0.0" y="0.0" width="413" height="450"/>
<rect key="frame" x="0.0" y="0.0" width="413" height="465"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="JTs-J5-DO2" userLabel="Top View">
<rect key="frame" x="24" y="36" width="365" height="35"/>
......@@ -106,7 +106,7 @@
</constraints>
</view>
<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="76" width="413" height="348"/>
<rect key="frame" x="0.0" y="91" width="413" height="348"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="348" id="aEf-Xl-A2C"/>
......@@ -124,7 +124,7 @@
</connections>
</collectionView>
<pageControl opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" numberOfPages="3" translatesAutoresizingMaskIntoConstraints="NO" id="lOm-CZ-dVG">
<rect key="frame" x="170" y="424" width="73" height="26"/>
<rect key="frame" x="170" y="439" width="73" height="26"/>
</pageControl>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
......@@ -136,7 +136,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="5" id="vJF-jy-p83"/>
<constraint firstItem="I7z-Fz-SNP" firstAttribute="top" secondItem="JTs-J5-DO2" secondAttribute="bottom" constant="20" id="vJF-jy-p83"/>
<constraint firstItem="lOm-CZ-dVG" firstAttribute="centerX" secondItem="VzF-dQ-3Wa" secondAttribute="centerX" id="xpw-tV-NcW"/>
</constraints>
</view>
......