Manos Chorianopoulos

CouponViewController redesign part2

......@@ -38,39 +38,14 @@ import UIKit
@IBOutlet weak var expirationLabel: UILabel!
@IBOutlet weak var detailsLabel: UILabel!
// MARK: - IBOutlets for Coupon Code Section
@IBOutlet weak var couponCodeContainerView: UIView!
@IBOutlet weak var couponCodeHeaderView: UIView!
@IBOutlet weak var couponCodeContentView: UIView!
// Header elements
@IBOutlet weak var couponCodeTitleLabel: UILabel!
@IBOutlet weak var couponCodeArrowImage: UIImageView!
@IBOutlet weak var couponCodeButton: UIButton!
// Content elements (initially hidden)
@IBOutlet weak var couponCodeValueLabel: UILabel!
@IBOutlet weak var copyButtonImage: UIImageView!
@IBOutlet weak var copyButton: UIButton!
// Constraints for animation
@IBOutlet weak var couponCodeContentHeightConstraint: NSLayoutConstraint!
// MARK: - IBOutlets for Coupon Code Section
@IBOutlet weak var couponQRContainerView: UIView!
@IBOutlet weak var couponQRHeaderView: UIView!
@IBOutlet weak var couponQRContentView: UIView!
// Header elements
@IBOutlet weak var couponQRTitleLabel: UILabel!
@IBOutlet weak var couponQRArrowImage: UIImageView!
@IBOutlet weak var couponQRButton: UIButton!
// Content elements (initially hidden)
@IBOutlet weak var couponQRImage: UIImageView!
// Constraints for animation
@IBOutlet weak var couponQRContentHeightConstraint: NSLayoutConstraint!
// MARK: - IBOutlets for Unified Available Code Card
@IBOutlet weak var couponQRContainerView: UIView! // outer light-blue card
@IBOutlet weak var couponQRTitleLabel: UILabel! // "Available code"
@IBOutlet weak var couponQRContentView: UIView! // inner white card
@IBOutlet weak var couponQRImage: UIImageView! // barcode image
@IBOutlet weak var couponCodeValueLabel: UILabel! // code text
@IBOutlet weak var copyButtonImage: UIImageView! // copy icon
@IBOutlet weak var copyButton: UIButton! // invisible tap target
@IBOutlet weak var termsButtonView: UIView!
@IBOutlet weak var termsButtonTitleLabel: UILabel!
......@@ -85,8 +60,6 @@ import UIKit
var coupon: CouponItemModel?
private var isDetailsExpanded = false
private var isCouponCodeExpanded = false
private var isCouponQRExpanded = false
private var isTermsExpanded = false
public override func viewDidLoad() {
......@@ -113,10 +86,8 @@ import UIKit
infoView.layer.borderColor = UIColor(red: 0.01, green: 0.05, blue: 0.11, alpha: 0.19).cgColor
infoImage.image = UIImage(named: "info", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
shareImage.image = UIImage(named: "share", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
couponCodeArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
copyButtonImage.image = UIImage(named: "copy", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
couponQRArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
shareImage.image = UIImage(named: "share_circle", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
copyButtonImage.image = UIImage(named: "copy_circle", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
couponQRImage.image = UIImage(named: "barcode_2", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
termsButtonArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
expirationImage.image = UIImage(named: "clock", in: Bundle.frameworkResourceBundle, compatibleWith: nil)
......@@ -125,19 +96,15 @@ import UIKit
infoLabel.textColor = UIColor(rgb: 0x020E1C)
infoLabel.text = "Περισσότερα"
couponCodeContainerView.backgroundColor = UIColor(rgb: 0xFFFFFF)
couponCodeContainerView.layer.cornerRadius = 8.0
couponCodeContainerView.clipsToBounds = true
couponCodeButton.addTarget(self, action: #selector(toggleCouponCode), for: .touchUpInside)
couponCodeContentHeightConstraint.constant = 0
couponCodeContentView.isHidden = true
couponQRContainerView.backgroundColor = UIColor(rgb: 0xFFFFFF)
couponQRContainerView.layer.cornerRadius = 8.0
// Unified Available Code card — outer container
couponQRContainerView.backgroundColor = UIColor(rgb: 0xDDEFFB)
couponQRContainerView.layer.cornerRadius = 12.0
couponQRContainerView.clipsToBounds = true
couponQRButton.addTarget(self, action: #selector(toggleCouponQR), for: .touchUpInside)
couponQRContentHeightConstraint.constant = 0
couponQRContentView.isHidden = true
// Inner white card
couponQRContentView.backgroundColor = UIColor(rgb: 0xFFFFFF)
couponQRContentView.layer.cornerRadius = 10.0
couponQRContentView.clipsToBounds = true
expirationView.backgroundColor = UIColor(rgb: 0xDDEFFB)
expirationView.layer.cornerRadius = 6.0
......@@ -252,21 +219,16 @@ import UIKit
// Description — from couponset_data description
setupExpandableDetails(with: coupon)
// Coupon Code section
couponCodeTitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16)
couponCodeTitleLabel.textColor = UIColor(rgb: 0x000F1E)
couponCodeTitleLabel.text = "Κωδικός Κουπονιού"
// Unified Available Code section
couponQRTitleLabel.font = UIFont(name: "PingLCG-Bold", size: 14)
couponQRTitleLabel.textColor = UIColor(rgb: 0x000F1E)
couponQRTitleLabel.text = "Available code"
couponCodeValueLabel.font = UIFont(name: "PingLCG-Bold", size: 24)
couponCodeValueLabel.font = UIFont(name: "PingLCG-Bold", size: 18)
couponCodeValueLabel.textColor = UIColor(rgb: 0x000F1E)
couponCodeValueLabel.text = coupon.coupon ?? ""
copyButton.addTarget(self, action: #selector(copyButtonTapped), for: .touchUpInside)
// QR Code section
couponQRTitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16)
couponQRTitleLabel.textColor = UIColor(rgb: 0x000F1E)
couponQRTitleLabel.text = "Barcode Κουπονιού"
// Terms — from couponset_data terms
termsLabel.font = UIFont(name: "PingLCG-Regular", size: 15)
termsLabel.textColor = UIColor(rgb: 0x5C6369)
......@@ -398,80 +360,6 @@ import UIKit
}
}
@objc private func toggleCouponCode() {
isCouponCodeExpanded.toggle()
// Calculate the target height before animation
let targetHeight: CGFloat = isCouponCodeExpanded ? 80.67 : 0 // Set a fixed height instead of intrinsicContentSize
// Show content immediately if expanding
if isCouponCodeExpanded {
couponCodeContentView.isHidden = false
couponCodeContentView.alpha = 0
}
UIView.animate(withDuration: 0.3, animations: {
// // Update arrow image
// self.couponCodeArrowImage.image = UIImage(named: self.isCouponCodeExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// Update arrow with rotation
let rotation = self.isCouponCodeExpanded ? CGAffineTransform(rotationAngle: .pi) : .identity
self.couponCodeArrowImage.transform = rotation
// Update height constraint
self.couponCodeContentHeightConstraint.constant = targetHeight
// Update alpha for smooth fade
self.couponCodeContentView.alpha = self.isCouponCodeExpanded ? 1.0 : 0.0
// Force layout update
self.view.layoutIfNeeded()
}) { _ in
// Hide content after animation completes if collapsing
if !self.isCouponCodeExpanded {
self.couponCodeContentView.isHidden = true
}
}
}
@objc private func toggleCouponQR() {
isCouponQRExpanded.toggle()
// Calculate the target height before animation
let targetHeight: CGFloat = isCouponQRExpanded ? 250 : 0 // Set a fixed height for QR code
// Show content immediately if expanding
if isCouponQRExpanded {
couponQRContentView.isHidden = false
couponQRContentView.alpha = 0
}
UIView.animate(withDuration: 0.3, animations: {
// Update arrow image
// self.couponQRArrowImage.image = UIImage(named: self.isCouponQRExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// Update arrow with rotation
let rotation = self.isCouponQRExpanded ? CGAffineTransform(rotationAngle: .pi) : .identity
self.couponQRArrowImage.transform = rotation
// Update height constraint
self.couponQRContentHeightConstraint.constant = targetHeight
// Update alpha for smooth fade
self.couponQRContentView.alpha = self.isCouponQRExpanded ? 1.0 : 0.0
// Force layout update
self.view.layoutIfNeeded()
}) { _ in
// Hide content after animation completes if collapsing
if !self.isCouponQRExpanded {
self.couponQRContentView.isHidden = true
}
}
}
@objc private func toggleTerms() {
isTermsExpanded.toggle()
......