MyRewardsBannerOfferCollectionViewCell.swift
1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//
// MyRewardsBannerOfferCollectionViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 23/5/25.
//
import UIKit
@objc(MyRewardsBannerOfferCollectionViewCell)
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
self.postImageURL = data._banner_img_mobile ?? ""
}
func configureCell(data: ArticleModel) {
// Use article's preview image - same visual treatment as campaigns
self.postImageURL = data.img_preview ?? ""
}
}