Manos Chorianopoulos

added couponEarnings dynamic data

......@@ -94,9 +94,9 @@ import UIKit
couponEarnView.layer.shadowOpacity = 1.0
couponEarnView.layer.shadowRadius = 3.0
// TODO: dynamic
couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει 20,00€ σε προσφορές από 3 κουπόνια!"
couponEarnAmountLabel.text = "20,00€"
couponEarnLabel.text = ""
couponEarnAmountLabel.text = ""
activeCodeView.layer.cornerRadius = 5.0
activeCodeView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
......@@ -122,6 +122,13 @@ import UIKit
DispatchQueue.main.async {
self.tableView.reloadData()
var totalCouponDiscount = self.coupons.reduce(0) { $0 + (Float($1.discount ?? "") ?? 0) }
totalCouponDiscount = Float(round(100 * totalCouponDiscount) / 100)
let totalCouponDiscountString = String(format: "%.2f", totalCouponDiscount).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil)
self.couponEarnLabel.text = "Μέχρι τώρα έχεις κερδίσει " + totalCouponDiscountString + "€ σε προσφορές από " + String(activeCouponData.count) + " κουπόνια!"
self.couponEarnAmountLabel.text = totalCouponDiscountString + "€"
}
} else {
self.coupons = []
......