Manos Chorianopoulos

Wallet changes

...@@ -13,28 +13,9 @@ class UnifiedCouponsTableViewCell: UITableViewCell { ...@@ -13,28 +13,9 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
13 @IBOutlet weak var couponImage: UIImageView! 13 @IBOutlet weak var couponImage: UIImageView!
14 @IBOutlet weak var borderView: UIView! 14 @IBOutlet weak var borderView: UIView!
15 @IBOutlet weak var nameLabel: UILabel! 15 @IBOutlet weak var nameLabel: UILabel!
16 - @IBOutlet weak var dicountLabel: UILabel!
17 @IBOutlet weak var discriptionLabel: UILabel! 16 @IBOutlet weak var discriptionLabel: UILabel!
18 @IBOutlet weak var expirationLabel: UILabel! 17 @IBOutlet weak var expirationLabel: UILabel!
19 18
20 - var postImageURL: String? {
21 - didSet {
22 - if let url = postImageURL {
23 - self.couponImage.image = UIImage() // UIImage(named: "loading")
24 -
25 - UIImage.loadImageUsingCacheWithUrlString(url) { image in
26 - // set the image only when we are still displaying the content for the image we finished downloading
27 - if url == self.postImageURL {
28 - self.couponImage.image = image
29 - }
30 - }
31 - }
32 - else {
33 - self.couponImage.image = nil
34 - }
35 - }
36 - }
37 -
38 19
39 public override func awakeFromNib() { 20 public override func awakeFromNib() {
40 super.awakeFromNib() 21 super.awakeFromNib()
...@@ -61,37 +42,25 @@ class UnifiedCouponsTableViewCell: UITableViewCell { ...@@ -61,37 +42,25 @@ class UnifiedCouponsTableViewCell: UITableViewCell {
61 } 42 }
62 43
63 44
64 - func configureCell(coupon: swiftApi.CouponItemModel) { 45 + func configureCell(coupon: swiftApi.UnifiedCouponModel) {
65 -// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price 46 + var activeCouponsCount:Int = 0
66 -// COUPON: coupon, expiration, discount, status 47 + for coupon in coupon._coupons {
67 -// MERCHANT: _img_preview,_admin_name 48 + if (coupon.status == 1) {
68 - 49 + activeCouponsCount += 1
69 - let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() 50 + }
51 + }
70 52
71 - let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data 53 + nameLabel.text = "COSMOTE SuperMarket Deals"
72 54
73 - nameLabel.text = "" 55 + discriptionLabel.text =
56 + activeCouponsCount == 1 ? "έχεις " + String(activeCouponsCount) + " ενεργό κουπόνι"
57 + : "έχεις " + String(activeCouponsCount) + " ενεργά κουπόνια"
74 58
75 - for merchant in merchantList { 59 + if let earliestExpiration = coupon._coupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
76 - if (merchant._uuid == couponSetData?.merchant_uuid) { 60 + expirationLabel.text = "Ισχύει έως " + (earliestExpiration.expiration ?? "")
77 - // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) 61 + } else {
78 -// self.postImageURL = merchant._img_preview 62 + expirationLabel.text = ""
79 - nameLabel.text = merchant._admin_name
80 - break;
81 - }
82 } 63 }
83 -
84 -// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache())
85 -// nameLabel.text = couponSetData?.name ?? ""
86 - let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€")
87 - : couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%")
88 - : couponSetData?.discount_type == "plus_one" ? "1+1"
89 - : ((coupon.discount ?? "") + "€")
90 - dicountLabel.text = discount
91 - // let htmlText = couponSetData?.inner_text ?? ""
92 - // discriptionLabel.text = htmlText.htmlToString
93 - discriptionLabel.text = couponSetData?.inner_text ?? ""
94 - expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "")
95 } 64 }
96 65
97 } 66 }
......