Manos Chorianopoulos

add dynamic profile data to wallet

1 +{
2 + "images" : [
3 + {
4 + "filename" : "default_profile_image.png",
5 + "idiom" : "universal",
6 + "scale" : "1x"
7 + },
8 + {
9 + "filename" : "default_profile_image-1.png",
10 + "idiom" : "universal",
11 + "scale" : "2x"
12 + },
13 + {
14 + "filename" : "default_profile_image-2.png",
15 + "idiom" : "universal",
16 + "scale" : "3x"
17 + }
18 + ],
19 + "info" : {
20 + "author" : "xcode",
21 + "version" : 1
22 + }
23 +}
...@@ -35,6 +35,7 @@ import SwiftEventBus ...@@ -35,6 +35,7 @@ import SwiftEventBus
35 public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList() 35 public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
36 public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons() 36 public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
37 public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge() 37 public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
38 + public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
38 39
39 public override func viewDidLoad() { 40 public override func viewDidLoad() {
40 super.viewDidLoad() 41 super.viewDidLoad()
...@@ -54,9 +55,12 @@ import SwiftEventBus ...@@ -54,9 +55,12 @@ import SwiftEventBus
54 profileImage.layer.cornerRadius = 32.5 55 profileImage.layer.cornerRadius = 32.5
55 profileImage.layer.borderWidth = 1 56 profileImage.layer.borderWidth = 1
56 profileImage.layer.borderColor = UIColor(red: 0.13, green: 0.66, blue: 0.71, alpha: 1.00).cgColor 57 profileImage.layer.borderColor = UIColor(red: 0.13, green: 0.66, blue: 0.71, alpha: 1.00).cgColor
57 - // TODO: dynamic 58 +
58 -// profileImage.load(link: profile_image ?? "", placeholder: UIImage(), cache: URLCache()) 59 + if (profile != nil && profile?.image_url != nil && profile?.image_url != "") {
59 - profileNameLabel.text = "Γιώργος Γεωργίου" 60 + profileImage.load(link: profile?.image_url ?? "", placeholder: UIImage(), cache: URLCache())
61 + } else {
62 + profileImage.image = UIImage(named: "default_profile_image", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
63 + }
60 64
61 let userTag = swiftApi().getUserTag() 65 let userTag = swiftApi().getUserTag()
62 if (userTag != "") { 66 if (userTag != "") {
...@@ -90,7 +94,8 @@ import SwiftEventBus ...@@ -90,7 +94,8 @@ import SwiftEventBus
90 94
91 var totalCouponValue = self.dfyCoupons.reduce(0) { $0 + (Float($1._value) ?? 0) } 95 var totalCouponValue = self.dfyCoupons.reduce(0) { $0 + (Float($1._value) ?? 0) }
92 totalCouponValue = Float(round(100 * totalCouponValue) / 100) 96 totalCouponValue = Float(round(100 * totalCouponValue) / 100)
93 - let totalCouponValueString = String(format: "%.2f", totalCouponValue).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) 97 + var totalCouponValueString = "0"
98 + totalCouponValueString = String(format: "%.2f", totalCouponValue).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
94 99
95 dfyEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponValueString + "€ με το DEALS for YOU!" 100 dfyEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponValueString + "€ με το DEALS for YOU!"
96 dfyEarnAmountLabel.text = totalCouponValueString + "€" 101 dfyEarnAmountLabel.text = totalCouponValueString + "€"
...@@ -102,7 +107,8 @@ import SwiftEventBus ...@@ -102,7 +107,8 @@ import SwiftEventBus
102 couponEarnView.layer.shadowRadius = 3.0 107 couponEarnView.layer.shadowRadius = 3.0
103 108
104 let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100) 109 let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
105 - let totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) 110 + var totalCouponDiscountString = "0"
111 + totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
106 112
107 couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!" 113 couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
108 couponEarnAmountLabel.text = totalCouponDiscountString + "€" 114 couponEarnAmountLabel.text = totalCouponDiscountString + "€"
......