Manos Chorianopoulos

redesign UnifiedCouponBarcodeViewController

......@@ -100,14 +100,19 @@ import UIKit
// COUPON: coupon, expiration, discount, status
// MERCHANT: _img_preview,_admin_name
if (coupon.status == 1) {
expirationLabel.isHidden = true
expirationRedView.isHidden = true
expirationLabel.text = ""
expirationRedLabel.text = ""
if (coupon.status == 1) { // Active status 1
// Add shadow
self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
self.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
self.layer.shadowOpacity = 1.0
self.layer.shadowRadius = 6.0
// self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.16).cgColor
// self.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
// self.layer.shadowOpacity = 1.0
// self.layer.shadowRadius = 6.0
couponBgImage.image = UIImage(named: "coupon_bg", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// couponBgImage.image = UIImage(named: "coupon_bg", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
expirationLabel.isHidden = false
expirationRedView.isHidden = true
......@@ -132,15 +137,15 @@ import UIKit
expirationLabel.isHidden = true
expirationRedView.isHidden = false
expirationRedView.layer.cornerRadius = 10.0
expirationRedView.backgroundColor = UIColor(red: 0.94, green: 0.90, blue: 0.90, alpha: 1.00)
expirationRedView.backgroundColor = UIColor(red: 0.72, green: 0.88, blue: 0.94, alpha: 1.00)
expirationRedImage.image = UIImage(named: "ic_time_forward", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
expirationRedImage.image = UIImage(named: "ic_time_forward_blue", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
let normalText1 = "Ισχύει έως "
let redText = (coupon.expiration ?? "")
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PFSquareSansPro-Medium", size: 12) ?? UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor(red: 0.38, green: 0.44, blue: 0.51, alpha: 1.00)]
let attrRed = [NSAttributedString.Key.font : UIFont(name: "PFSquareSansPro-Medium", size: 12) ?? UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor(red: 1.00, green: 0.42, blue: 0.42, alpha: 1.00)]
let attrRegular = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-SBold", size: 12) ?? UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)]
let attrRed = [NSAttributedString.Key.font : UIFont(name: "PeridotPE-SBold", size: 12) ?? UIFont.systemFont(ofSize: 11), NSAttributedString.Key.foregroundColor: UIColor(red: 0.00, green: 0.29, blue: 0.53, alpha: 1.00)]
let attributedString = NSMutableAttributedString(string:normalText1, attributes:attrRegular)
let RedString = NSMutableAttributedString(string: redText, attributes:attrRed)
......@@ -156,18 +161,30 @@ import UIKit
}
}
} else if (coupon.status == 0) {
couponBgImage.image = UIImage(named: "coupon_bg_grey", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
} else if (coupon.status == 0) { // Redeemed status 0
// couponBgImage.image = UIImage(named: "coupon_bg_grey", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
expirationLabel.isHidden = false
expirationRedView.isHidden = true
expirationLabel.text = "Το κουπόνι έληξε"
couponImage.layer.opacity = 0.29
borderView.layer.opacity = 0.29
nameLabel.layer.opacity = 0.29
dicountLabel.layer.opacity = 0.29
discriptionLabel.layer.opacity = 0.29
} else { // Expired status -1
expirationLabel.isHidden = false
expirationRedView.isHidden = true
expirationLabel.text = "Το κουπόνι έληξε"
couponImage.layer.opacity = 0.23
borderView.layer.opacity = 0.15
nameLabel.layer.opacity = 0.15
dicountLabel.layer.opacity = 0.15
discriptionLabel.layer.opacity = 0.15
couponImage.layer.opacity = 0.29
borderView.layer.opacity = 0.29
nameLabel.layer.opacity = 0.29
dicountLabel.layer.opacity = 0.29
discriptionLabel.layer.opacity = 0.29
}
......
......@@ -24,13 +24,13 @@ import AVFoundation
termsTextView.delegate = self
mapButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
mapButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 17)
mapButton.setTitle("Δες τα supermarket", for: .normal)
mapButton.setTitleColor(UIColor(red: 1.00, green: 1.00, blue: 1.00, alpha: 1.00), for: .normal)
mapButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00)
mapButton.layer.cornerRadius = 8.0
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
mapButton.contentEdgeInsets = UIEdgeInsets(top: 1, left: 16, bottom: 0, right: 16)
mapButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
mapButton.layer.cornerRadius = 15.0
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 55)
mapButton.contentEdgeInsets = UIEdgeInsets(top: 1, left: 28, bottom: 0, right: 28)
// mapButton.isHidden = true
// mapButtonHeight.constant = 0
......@@ -79,22 +79,22 @@ import AVFoundation
// mapButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
termsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 16)
termsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
termsButton.setTitle("Όροι χρήσης", for: .normal)
termsButton.setTitleColor(UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00), for: .normal)
termsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
termsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.semanticContentAttribute = .forceRightToLeft
termsButton.tintColor = UIColor(red: 0.21, green: 0.32, blue: 0.41, alpha: 1.00)
termsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
termsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
termsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
termsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
let termsText = "1. Το εκπτωτικό κουπόνι ισχύει έως την ημερομηνία που αναφέρεται παραπάνω\n2. To εκπτωτικό κουπόνι αφορά στα ενεργά κουπόνια προσφορών όπως αναφέρονται παραπάνω.\n3. Το εκπτωτικό κουπόνι μπορεί να χρησιμοποιηθεί σε μια μόνο συναλλαγή.\n4. Εάν δεν γίνει χρήση ενός επιμέρους κουπονιού προσφοράς από το εκπτωτικό κουπόνι, το κουπόνι προσφοράς επιστρέφει στο καλάθι στην ενότητα COSMOTE SuperMarket Deals"
termsTextView.attributedText = NSAttributedString(string: termsText)
termsTextView.font = UIFont(name: "PFSquareSansPro-Regular", size: 15)
termsTextView.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
termsTextView.textAlignment = .center
termsTextView.font = UIFont(name: "PeridotPE-Regular", size: 16)
termsTextView.textColor = UIColor(red: 0.62, green: 0.62, blue: 0.61, alpha: 1.00)
termsTextView.textAlignment = .left
termsTextView.isScrollEnabled = false
termsTextView.isUserInteractionEnabled = true
......
......@@ -90,23 +90,23 @@ import AVFoundation
// }
showBarcodeButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
showBarcodeButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
showBarcodeButton.setTitleColor(UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00), for: .normal)
showBarcodeButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showBarcodeButton.semanticContentAttribute = .forceRightToLeft
showBarcodeButton.tintColor = UIColor(red: 0.21, green: 0.32, blue: 0.41, alpha: 1.00)
showBarcodeButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
showBarcodeButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
showBarcodeButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
showBarcodeButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
showCouponsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 16)
showCouponsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
showCouponsButton.setTitle("Εμφάνιση κουπονιών", for: .normal)
showCouponsButton.setTitleColor(UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00), for: .normal)
showCouponsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
showCouponsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showCouponsButton.semanticContentAttribute = .forceRightToLeft
showCouponsButton.tintColor = UIColor(red: 0.21, green: 0.32, blue: 0.41, alpha: 1.00)
showCouponsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
showCouponsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
showCouponsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
showCouponsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
......@@ -121,7 +121,7 @@ import AVFoundation
func configureCell(coupon: swiftApi.UnifiedCouponModel?, couponsVisible: Bool) {
couponView.layer.cornerRadius = 8
couponView.layer.cornerRadius = 16
// couponNumberLabel.text = ((coupon?._code != 0) ? String(coupon?._code ?? 0) : "")
couponNumberLabel.text = coupon?._barcode ?? ""
couponView.frame = CGRect(x: 0.0, y: 0.0, width: couponView.intrinsicContentSize.width, height: 55)
......@@ -145,6 +145,14 @@ import AVFoundation
showBarcodeButton.isHidden = true
showBarcodeButtonHeight.constant = 0
showBarcodeButtonTopSpace.constant = 0
borderViewHeight.constant = CGFloat(0)
borderView2Height.constant = CGFloat(0)
border1TopSpace.constant = CGFloat(0) // 20
barcodeImageTopSpace.constant = CGFloat(0) // 10
barcodeLabelTopSpace.constant = CGFloat(0) // 10
border2TopSpace.constant = CGFloat(0) // 15
}
// ===
......
......@@ -108,22 +108,22 @@ extension UITableView {
// scrollView.layer.cornerRadius = 30
// scrollView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
var aspectR: CGFloat = 0.0
aspectR = image.size.width/image.size.height
topBorderLine.translatesAutoresizingMaskIntoConstraints = false
topBorderLine.image = image
topBorderLine.contentMode = .scaleAspectFill
NSLayoutConstraint.activate([
topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
])
// let image = UIImage(named: "top_border_line", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)!
// var aspectR: CGFloat = 0.0
//
// aspectR = image.size.width/image.size.height
//
// topBorderLine.translatesAutoresizingMaskIntoConstraints = false
// topBorderLine.image = image
// topBorderLine.contentMode = .scaleAspectFill
//
// NSLayoutConstraint.activate([
// topBorderLine.topAnchor.constraint(equalTo: mainView.topAnchor, constant: 0),
// topBorderLine.leadingAnchor.constraint(equalTo: mainView.leadingAnchor, constant: 0),
// topBorderLine.trailingAnchor.constraint(equalTo: mainView.trailingAnchor, constant: 0),
// topBorderLine.widthAnchor.constraint(equalToConstant: UIScreen.main.bounds.width),
// topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR)
// ])
// COUPONSET: desc, img_preview, name, terms
// COUPON: coupon, expiration, discount, status
......@@ -151,8 +151,8 @@ extension UITableView {
//
// if (htmlMerchDescrText != "") {
// merchantDescrTextView.attributedText = htmlMerchDescrText.htmlToAttributedString
// merchantDescrTextView.font = UIFont(name: "PFSquareSansPro-Regular", size: 17)
// merchantDescrTextView.textColor = UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00)
// merchantDescrTextView.font = UIFont(name: "PeridotPE-Regular", size: 16)
// merchantDescrTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00)
// merchantDescrTextView.textAlignment = .center
// merchantDescrTextView.isScrollEnabled = false
// merchantDescrTextView.isUserInteractionEnabled = true
......@@ -170,7 +170,7 @@ extension UITableView {
// }
// }
couponView.layer.cornerRadius = 8
couponView.layer.cornerRadius = 16
couponNumberLabel.text = ((coupon?._code != 0) ? String(coupon?._code ?? 0) : "")
couponView.frame = CGRect(x: 0.0, y: 0.0, width: couponView.intrinsicContentSize.width, height: 55)
......@@ -214,7 +214,7 @@ extension UITableView {
showBarcodeButtonTopSpace.constant = 0
// ===
showBarcodeButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16)
showBarcodeButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 16)
showBarcodeButton.setTitle("Εμφάνιση barcode", for: .normal)
showBarcodeButton.setTitleColor(UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00), for: .normal)
showBarcodeButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
......@@ -285,13 +285,13 @@ extension UITableView {
// mapButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
// }
showCouponsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Regular", size: 16)
showCouponsButton.titleLabel?.font = UIFont(name: "PeridotPE-Bold", size: 15)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
showCouponsButton.setTitle("Εμφάνιση κουπονιών", for: .normal)
showCouponsButton.setTitleColor(UIColor(red: 0.25, green: 0.33, blue: 0.39, alpha: 1.00), for: .normal)
showCouponsButton.setTitleColor(UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00), for: .normal)
showCouponsButton.setImage(UIImage(named: "ic_down_dark_2.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
showCouponsButton.semanticContentAttribute = .forceRightToLeft
showCouponsButton.tintColor = UIColor(red: 0.21, green: 0.32, blue: 0.41, alpha: 1.00)
showCouponsButton.tintColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 1.00)
showCouponsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0);
showCouponsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5);
showCouponsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8)
......@@ -558,7 +558,7 @@ extension UnifiedCouponBarcodeViewController: UITableViewDelegate, UITableViewDa
return UITableView.automaticDimension
} else if (indexPath.section == 1) {
if (couponsVisible == true) {
return 120.0 + 8.0
return 130.0 + 8.0
} else {
return 0.0
}
......@@ -613,4 +613,74 @@ extension UnifiedCouponBarcodeViewController: UITableViewDelegate, UITableViewDa
// self.navigationController?.pushViewController(vc, animated: true)
}
public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (couponsVisible == true) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 8))
view.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
return view
} else {
return nil
}
} else {
return nil
}
}
public func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (couponsVisible == true) {
return 8.0
} else {
return 0.0
}
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
if (section == 0) {
return 0.0
} else if (section == 1) {
if (couponsVisible == true) {
return 8.0
} else {
return 0.0
}
} else {
return 0.0
}
}
public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
if (section == 0){
return nil
} else if (section == 1) {
if (couponsVisible == true) {
let view = UIView(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 8))
view.backgroundColor = UIColor(red: 0.95, green: 0.95, blue: 0.95, alpha: 1.00)
return view
} else {
return nil
}
} else {
return nil
}
}
}
......
......@@ -43,12 +43,15 @@ import UIKit
func configureCell(coupon: swiftApi.UnifiedCouponModel) {
var activeCouponsCount:Int = 0
for coupon in coupon._coupons {
if (coupon.status == 1) {
activeCouponsCount += 1
}
}
let activeCoupons = coupon._coupons.filter { $0.status == 1 }
let activeCouponsCount = activeCoupons.count
// var activeCouponsCount:Int = 0
// for coupon in coupon._coupons {
// if (coupon.status == 1) {
// activeCouponsCount += 1
// }
// }
nameLabel.text = "COSMOTE SuperMarket Deals"
......@@ -56,7 +59,7 @@ import UIKit
activeCouponsCount == 1 ? "έχεις " + String(activeCouponsCount) + " ενεργό κουπόνι"
: "έχεις " + String(activeCouponsCount) + " ενεργά κουπόνια"
if let earliestExpiration = coupon._coupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
if let earliestExpiration = activeCoupons.min(by: { ($0.expiration ?? "") < ($1.expiration ?? "") }) {
expirationLabel.text = "Ισχύει έως " + (earliestExpiration.expiration ?? "")
} else {
expirationLabel.text = ""
......
......@@ -6816,12 +6816,14 @@ public class swiftApi {
}
// Example "created":"Mon, 03 Apr 2023 15:05:14 GMT"
// Example created = “2023-04-10 14:44:57.515402”;
let dateString = dictionary["created"] as? String? ?? ""
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSSIX")
dateFormatter.dateFormat = "E, dd MMM yyyy HH:mm:ss 'GMT'"
// dateFormatter.locale = Locale(identifier: "en_US_POSSIX")
// dateFormatter.dateFormat = "E, dd MMM yyyy HH:mm:ss 'GMT'"
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSSSS"
if let date = dateFormatter.date(from: dateString ?? "") {
dateFormatter.dateFormat = "dd/MM/yyyy"
// dateFormatter.dateFormat = "dd/MM/yyyy"
let resultString = dateFormatter.string(from: date)
self.created = resultString
} else {
......@@ -6911,7 +6913,8 @@ public class swiftApi {
// Sort by date
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "dd/MM/yyyy"
// dateFormatter.dateFormat = "dd/MM/yyyy"
dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSSSS"
let sortedUnifiedCouponsArray = unifiedCouponsArray.sorted(by: { dateFormatter.date(from:$0._created)?.compare(dateFormatter.date(from:$1._created)!) == .orderedDescending })
swiftApi().setUnifiedCouponList(sortedUnifiedCouponsArray)
......