Manos Chorianopoulos

add dynamic profile data to wallet

{
"images" : [
{
"filename" : "default_profile_image.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "default_profile_image-1.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "default_profile_image-2.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -35,6 +35,7 @@ import SwiftEventBus
public var coupons:Array<swiftApi.CouponItemModel> = swiftApi().getCouponList()
public var dfyCoupons:Array<swiftApi.ActiveDFYCouponModel> = swiftApi().getActiveDFYCoupons()
public var loyaltyBadge:swiftApi.LoyaltyBadgeModel = swiftApi().getLoyaltyBadge()
public var profile:swiftApi.ProfileModel? = swiftApi().getConsumer()
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -54,9 +55,12 @@ import SwiftEventBus
profileImage.layer.cornerRadius = 32.5
profileImage.layer.borderWidth = 1
profileImage.layer.borderColor = UIColor(red: 0.13, green: 0.66, blue: 0.71, alpha: 1.00).cgColor
// TODO: dynamic
// profileImage.load(link: profile_image ?? "", placeholder: UIImage(), cache: URLCache())
profileNameLabel.text = "Γιώργος Γεωργίου"
if (profile != nil && profile?.image_url != nil && profile?.image_url != "") {
profileImage.load(link: profile?.image_url ?? "", placeholder: UIImage(), cache: URLCache())
} else {
profileImage.image = UIImage(named: "default_profile_image", in: Bundle(for: MyEmptyClass.self), compatibleWith: nil)
}
let userTag = swiftApi().getUserTag()
if (userTag != "") {
......@@ -90,7 +94,8 @@ import SwiftEventBus
var totalCouponValue = self.dfyCoupons.reduce(0) { $0 + (Float($1._value) ?? 0) }
totalCouponValue = Float(round(100 * totalCouponValue) / 100)
let totalCouponValueString = String(format: "%.2f", totalCouponValue).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
var totalCouponValueString = "0"
totalCouponValueString = String(format: "%.2f", totalCouponValue).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
dfyEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponValueString + "€ με το DEALS for YOU!"
dfyEarnAmountLabel.text = totalCouponValueString + "€"
......@@ -102,7 +107,8 @@ import SwiftEventBus
couponEarnView.layer.shadowRadius = 3.0
let totalCouponDiscount = Float(round(100 * loyaltyBadge._value) / 100)
let totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
var totalCouponDiscountString = "0"
totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(loyaltyBadge._couponCount) + " κουπόνια!"
couponEarnAmountLabel.text = totalCouponDiscountString + "€"
......