MFYInboxTableViewCell.swift
4.63 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
//
// MFYInboxTableViewCell.swift
// SwiftWarplyFramework
//
// Created by Manos Chorianopoulos on 24/6/22.
//
import UIKit
@objc public class MFYInboxTableViewCell: UITableViewCell {
@IBOutlet weak var inboxView: UIView!
@IBOutlet weak var campaignImage: UIImageView!
@IBOutlet weak var newBadgeImage: UIImageView!
@IBOutlet weak var campaignTitleLabel: UILabel!
@IBOutlet weak var curvedBgImage: UIImageView!
@IBOutlet weak var subtitleLabel: UILabel!
@IBOutlet weak var descriptionLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.campaignImage.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.campaignImage.image = image
}
}
}
else {
self.campaignImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
// inboxView.layer.cornerRadius = 5.0
// inboxView.clipsToBounds = true
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 1.0
newBadgeImage.image = UIImage(named: "new_icon_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
curvedBgImage.image = UIImage(named: "curved_bg_white_2", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
newBadgeImage.isHidden = true
}
public override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
public override func layoutSubviews() {
super.layoutSubviews()
//set the values for top,left,bottom,right margins
let margins = UIEdgeInsets(top: 0, left: 0, bottom: 10, right: 0)
contentView.frame = contentView.frame.inset(by: margins)
// Add different corner radius - Do it here, otherwise it won't be applied to all cells
inboxView.roundCorners(topLeft: 20, topRight: 45, bottomLeft: 20, bottomRight: 0)
// // Delete extra borderLayers added
// for layer in (inboxView.layer.sublayers ?? []) {
// if(layer.name == "MFYItemBorderLayer"){
// layer.removeFromSuperlayer()
// }
// }
//
// // Add borderLayer
// let borderLayer = CAShapeLayer()
// borderLayer.path = (inboxView.layer.mask! as! CAShapeLayer).path! // Reuse the Bezier path
// borderLayer.strokeColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00).cgColor
// borderLayer.fillColor = UIColor.clear.cgColor
// borderLayer.lineWidth = 1
// borderLayer.frame = inboxView.bounds
// borderLayer.name = "MFYItemBorderLayer"
// inboxView.layer.addSublayer(borderLayer)
}
func configureCell(campaign: swiftApi.CampaignItemModel) {
// campaignImage.load(link: campaign.logo_url ?? "", placeholder: UIImage(), cache: URLCache())
self.postImageURL = campaign.logo_url ?? ""
campaignTitleLabel.text = campaign.title ?? ""
campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
subtitleLabel.text = campaign.subtitle ?? ""
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
descriptionLabel.text = campaign.message ?? ""
descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
if (campaign.is_new == true) {
newBadgeImage.isHidden = false
} else{
newBadgeImage.isHidden = true
}
}
func configureCell(ccms: swiftApi.LoyaltyContextualOfferModel) {
// campaignImage.load(link: ccms._imageUrl , placeholder: UIImage(), cache: URLCache())
self.postImageURL = ccms._imageUrl
campaignTitleLabel.text = ccms._title
campaignTitleLabel.font = UIFont(name: "BTCosmo-Bold", size: 17)
subtitleLabel.text = ccms._subtitle
subtitleLabel.font = UIFont(name: "PeridotPE-Regular", size: 15)
descriptionLabel.text = ccms._description
descriptionLabel.font = UIFont(name: "PeridotPE-SBold", size: 15)
newBadgeImage.isHidden = true
}
}