Manos Chorianopoulos

Wallet changes

......@@ -13,28 +13,9 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
@IBOutlet weak var couponImage: UIImageView!
@IBOutlet weak var borderView: UIView!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var dicountLabel: UILabel!
@IBOutlet weak var discriptionLabel: UILabel!
@IBOutlet weak var expirationLabel: UILabel!
var postImageURL: String? {
didSet {
if let url = postImageURL {
self.couponImage.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.couponImage.image = image
}
}
}
else {
self.couponImage.image = nil
}
}
}
public override func awakeFromNib() {
super.awakeFromNib()
......@@ -61,37 +42,25 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
}
func configureCell(coupon: swiftApi.CouponItemModel) {
// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
func configureCell(coupon: swiftApi.UnifiedCouponModel) {
var activeCouponsCount:Int = 0
for coupon in coupon._coupons {
if (coupon.status == 1) {
activeCouponsCount += 1
}
}
let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data
nameLabel.text = "COSMOTE SuperMarket Deals"
nameLabel.text = ""
discriptionLabel.text =
activeCouponsCount == 1 ? "έχεις " + String(activeCouponsCount) + " ενεργό κουπόνι"
: "έχεις " + String(activeCouponsCount) + " ενεργά κουπόνια"
for merchant in merchantList {
if (merchant._uuid == couponSetData?.merchant_uuid) {
// couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache())
// self.postImageURL = merchant._img_preview
nameLabel.text = merchant._admin_name
break;
}
if let earliestExpiration = coupon._coupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
expirationLabel.text = "Ισχύει έως " + (earliestExpiration.expiration ?? "")
} else {
expirationLabel.text = ""
}
// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
// nameLabel.text = couponSetData?.name ?? ""
let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€")
: couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%")
: couponSetData?.discount_type == "plus_one" ? "1+1"
: ((coupon.discount ?? "") + "€")
dicountLabel.text = discount
// let htmlText = couponSetData?.inner_text ?? ""
// discriptionLabel.text = htmlText.htmlToString
discriptionLabel.text = couponSetData?.inner_text ?? ""
expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
}
}
......