Showing
3 changed files
with
23 additions
and
135 deletions
No preview for this file type
| ... | @@ -38,39 +38,14 @@ import UIKit | ... | @@ -38,39 +38,14 @@ import UIKit |
| 38 | @IBOutlet weak var expirationLabel: UILabel! | 38 | @IBOutlet weak var expirationLabel: UILabel! |
| 39 | @IBOutlet weak var detailsLabel: UILabel! | 39 | @IBOutlet weak var detailsLabel: UILabel! |
| 40 | 40 | ||
| 41 | - // MARK: - IBOutlets for Coupon Code Section | 41 | + // MARK: - IBOutlets for Unified Available Code Card |
| 42 | - @IBOutlet weak var couponCodeContainerView: UIView! | 42 | + @IBOutlet weak var couponQRContainerView: UIView! // outer light-blue card |
| 43 | - @IBOutlet weak var couponCodeHeaderView: UIView! | 43 | + @IBOutlet weak var couponQRTitleLabel: UILabel! // "Available code" |
| 44 | - @IBOutlet weak var couponCodeContentView: UIView! | 44 | + @IBOutlet weak var couponQRContentView: UIView! // inner white card |
| 45 | - | 45 | + @IBOutlet weak var couponQRImage: UIImageView! // barcode image |
| 46 | - // Header elements | 46 | + @IBOutlet weak var couponCodeValueLabel: UILabel! // code text |
| 47 | - @IBOutlet weak var couponCodeTitleLabel: UILabel! | 47 | + @IBOutlet weak var copyButtonImage: UIImageView! // copy icon |
| 48 | - @IBOutlet weak var couponCodeArrowImage: UIImageView! | 48 | + @IBOutlet weak var copyButton: UIButton! // invisible tap target |
| 49 | - @IBOutlet weak var couponCodeButton: UIButton! | ||
| 50 | - | ||
| 51 | - // Content elements (initially hidden) | ||
| 52 | - @IBOutlet weak var couponCodeValueLabel: UILabel! | ||
| 53 | - @IBOutlet weak var copyButtonImage: UIImageView! | ||
| 54 | - @IBOutlet weak var copyButton: UIButton! | ||
| 55 | - | ||
| 56 | - // Constraints for animation | ||
| 57 | - @IBOutlet weak var couponCodeContentHeightConstraint: NSLayoutConstraint! | ||
| 58 | - | ||
| 59 | - // MARK: - IBOutlets for Coupon Code Section | ||
| 60 | - @IBOutlet weak var couponQRContainerView: UIView! | ||
| 61 | - @IBOutlet weak var couponQRHeaderView: UIView! | ||
| 62 | - @IBOutlet weak var couponQRContentView: UIView! | ||
| 63 | - | ||
| 64 | - // Header elements | ||
| 65 | - @IBOutlet weak var couponQRTitleLabel: UILabel! | ||
| 66 | - @IBOutlet weak var couponQRArrowImage: UIImageView! | ||
| 67 | - @IBOutlet weak var couponQRButton: UIButton! | ||
| 68 | - | ||
| 69 | - // Content elements (initially hidden) | ||
| 70 | - @IBOutlet weak var couponQRImage: UIImageView! | ||
| 71 | - | ||
| 72 | - // Constraints for animation | ||
| 73 | - @IBOutlet weak var couponQRContentHeightConstraint: NSLayoutConstraint! | ||
| 74 | 49 | ||
| 75 | @IBOutlet weak var termsButtonView: UIView! | 50 | @IBOutlet weak var termsButtonView: UIView! |
| 76 | @IBOutlet weak var termsButtonTitleLabel: UILabel! | 51 | @IBOutlet weak var termsButtonTitleLabel: UILabel! |
| ... | @@ -85,8 +60,6 @@ import UIKit | ... | @@ -85,8 +60,6 @@ import UIKit |
| 85 | 60 | ||
| 86 | var coupon: CouponItemModel? | 61 | var coupon: CouponItemModel? |
| 87 | private var isDetailsExpanded = false | 62 | private var isDetailsExpanded = false |
| 88 | - private var isCouponCodeExpanded = false | ||
| 89 | - private var isCouponQRExpanded = false | ||
| 90 | private var isTermsExpanded = false | 63 | private var isTermsExpanded = false |
| 91 | 64 | ||
| 92 | public override func viewDidLoad() { | 65 | public override func viewDidLoad() { |
| ... | @@ -113,10 +86,8 @@ import UIKit | ... | @@ -113,10 +86,8 @@ import UIKit |
| 113 | infoView.layer.borderColor = UIColor(red: 0.01, green: 0.05, blue: 0.11, alpha: 0.19).cgColor | 86 | infoView.layer.borderColor = UIColor(red: 0.01, green: 0.05, blue: 0.11, alpha: 0.19).cgColor |
| 114 | 87 | ||
| 115 | infoImage.image = UIImage(named: "info", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | 88 | infoImage.image = UIImage(named: "info", in: Bundle.frameworkResourceBundle, compatibleWith: nil) |
| 116 | - shareImage.image = UIImage(named: "share", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | 89 | + shareImage.image = UIImage(named: "share_circle", in: Bundle.frameworkResourceBundle, compatibleWith: nil) |
| 117 | - couponCodeArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | 90 | + copyButtonImage.image = UIImage(named: "copy_circle", in: Bundle.frameworkResourceBundle, compatibleWith: nil) |
| 118 | - copyButtonImage.image = UIImage(named: "copy", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | ||
| 119 | - couponQRArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | ||
| 120 | couponQRImage.image = UIImage(named: "barcode_2", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | 91 | couponQRImage.image = UIImage(named: "barcode_2", in: Bundle.frameworkResourceBundle, compatibleWith: nil) |
| 121 | termsButtonArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | 92 | termsButtonArrowImage.image = UIImage(named: "arrow_down", in: Bundle.frameworkResourceBundle, compatibleWith: nil) |
| 122 | expirationImage.image = UIImage(named: "clock", in: Bundle.frameworkResourceBundle, compatibleWith: nil) | 93 | expirationImage.image = UIImage(named: "clock", in: Bundle.frameworkResourceBundle, compatibleWith: nil) |
| ... | @@ -125,19 +96,15 @@ import UIKit | ... | @@ -125,19 +96,15 @@ import UIKit |
| 125 | infoLabel.textColor = UIColor(rgb: 0x020E1C) | 96 | infoLabel.textColor = UIColor(rgb: 0x020E1C) |
| 126 | infoLabel.text = "Περισσότερα" | 97 | infoLabel.text = "Περισσότερα" |
| 127 | 98 | ||
| 128 | - couponCodeContainerView.backgroundColor = UIColor(rgb: 0xFFFFFF) | 99 | + // Unified Available Code card — outer container |
| 129 | - couponCodeContainerView.layer.cornerRadius = 8.0 | 100 | + couponQRContainerView.backgroundColor = UIColor(rgb: 0xDDEFFB) |
| 130 | - couponCodeContainerView.clipsToBounds = true | 101 | + couponQRContainerView.layer.cornerRadius = 12.0 |
| 131 | - couponCodeButton.addTarget(self, action: #selector(toggleCouponCode), for: .touchUpInside) | ||
| 132 | - couponCodeContentHeightConstraint.constant = 0 | ||
| 133 | - couponCodeContentView.isHidden = true | ||
| 134 | - | ||
| 135 | - couponQRContainerView.backgroundColor = UIColor(rgb: 0xFFFFFF) | ||
| 136 | - couponQRContainerView.layer.cornerRadius = 8.0 | ||
| 137 | couponQRContainerView.clipsToBounds = true | 102 | couponQRContainerView.clipsToBounds = true |
| 138 | - couponQRButton.addTarget(self, action: #selector(toggleCouponQR), for: .touchUpInside) | 103 | + |
| 139 | - couponQRContentHeightConstraint.constant = 0 | 104 | + // Inner white card |
| 140 | - couponQRContentView.isHidden = true | 105 | + couponQRContentView.backgroundColor = UIColor(rgb: 0xFFFFFF) |
| 106 | + couponQRContentView.layer.cornerRadius = 10.0 | ||
| 107 | + couponQRContentView.clipsToBounds = true | ||
| 141 | 108 | ||
| 142 | expirationView.backgroundColor = UIColor(rgb: 0xDDEFFB) | 109 | expirationView.backgroundColor = UIColor(rgb: 0xDDEFFB) |
| 143 | expirationView.layer.cornerRadius = 6.0 | 110 | expirationView.layer.cornerRadius = 6.0 |
| ... | @@ -252,21 +219,16 @@ import UIKit | ... | @@ -252,21 +219,16 @@ import UIKit |
| 252 | // Description — from couponset_data description | 219 | // Description — from couponset_data description |
| 253 | setupExpandableDetails(with: coupon) | 220 | setupExpandableDetails(with: coupon) |
| 254 | 221 | ||
| 255 | - // Coupon Code section | 222 | + // Unified Available Code section |
| 256 | - couponCodeTitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16) | 223 | + couponQRTitleLabel.font = UIFont(name: "PingLCG-Bold", size: 14) |
| 257 | - couponCodeTitleLabel.textColor = UIColor(rgb: 0x000F1E) | 224 | + couponQRTitleLabel.textColor = UIColor(rgb: 0x000F1E) |
| 258 | - couponCodeTitleLabel.text = "Κωδικός Κουπονιού" | 225 | + couponQRTitleLabel.text = "Available code" |
| 259 | 226 | ||
| 260 | - couponCodeValueLabel.font = UIFont(name: "PingLCG-Bold", size: 24) | 227 | + couponCodeValueLabel.font = UIFont(name: "PingLCG-Bold", size: 18) |
| 261 | couponCodeValueLabel.textColor = UIColor(rgb: 0x000F1E) | 228 | couponCodeValueLabel.textColor = UIColor(rgb: 0x000F1E) |
| 262 | couponCodeValueLabel.text = coupon.coupon ?? "" | 229 | couponCodeValueLabel.text = coupon.coupon ?? "" |
| 263 | copyButton.addTarget(self, action: #selector(copyButtonTapped), for: .touchUpInside) | 230 | copyButton.addTarget(self, action: #selector(copyButtonTapped), for: .touchUpInside) |
| 264 | 231 | ||
| 265 | - // QR Code section | ||
| 266 | - couponQRTitleLabel.font = UIFont(name: "PingLCG-Regular", size: 16) | ||
| 267 | - couponQRTitleLabel.textColor = UIColor(rgb: 0x000F1E) | ||
| 268 | - couponQRTitleLabel.text = "Barcode Κουπονιού" | ||
| 269 | - | ||
| 270 | // Terms — from couponset_data terms | 232 | // Terms — from couponset_data terms |
| 271 | termsLabel.font = UIFont(name: "PingLCG-Regular", size: 15) | 233 | termsLabel.font = UIFont(name: "PingLCG-Regular", size: 15) |
| 272 | termsLabel.textColor = UIColor(rgb: 0x5C6369) | 234 | termsLabel.textColor = UIColor(rgb: 0x5C6369) |
| ... | @@ -398,80 +360,6 @@ import UIKit | ... | @@ -398,80 +360,6 @@ import UIKit |
| 398 | } | 360 | } |
| 399 | } | 361 | } |
| 400 | 362 | ||
| 401 | - @objc private func toggleCouponCode() { | ||
| 402 | - isCouponCodeExpanded.toggle() | ||
| 403 | - | ||
| 404 | - // Calculate the target height before animation | ||
| 405 | - let targetHeight: CGFloat = isCouponCodeExpanded ? 80.67 : 0 // Set a fixed height instead of intrinsicContentSize | ||
| 406 | - | ||
| 407 | - // Show content immediately if expanding | ||
| 408 | - if isCouponCodeExpanded { | ||
| 409 | - couponCodeContentView.isHidden = false | ||
| 410 | - couponCodeContentView.alpha = 0 | ||
| 411 | - } | ||
| 412 | - | ||
| 413 | - UIView.animate(withDuration: 0.3, animations: { | ||
| 414 | - // // Update arrow image | ||
| 415 | - // self.couponCodeArrowImage.image = UIImage(named: self.isCouponCodeExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
| 416 | - | ||
| 417 | - // Update arrow with rotation | ||
| 418 | - let rotation = self.isCouponCodeExpanded ? CGAffineTransform(rotationAngle: .pi) : .identity | ||
| 419 | - self.couponCodeArrowImage.transform = rotation | ||
| 420 | - | ||
| 421 | - // Update height constraint | ||
| 422 | - self.couponCodeContentHeightConstraint.constant = targetHeight | ||
| 423 | - | ||
| 424 | - // Update alpha for smooth fade | ||
| 425 | - self.couponCodeContentView.alpha = self.isCouponCodeExpanded ? 1.0 : 0.0 | ||
| 426 | - | ||
| 427 | - // Force layout update | ||
| 428 | - self.view.layoutIfNeeded() | ||
| 429 | - | ||
| 430 | - }) { _ in | ||
| 431 | - // Hide content after animation completes if collapsing | ||
| 432 | - if !self.isCouponCodeExpanded { | ||
| 433 | - self.couponCodeContentView.isHidden = true | ||
| 434 | - } | ||
| 435 | - } | ||
| 436 | - } | ||
| 437 | - | ||
| 438 | - @objc private func toggleCouponQR() { | ||
| 439 | - isCouponQRExpanded.toggle() | ||
| 440 | - | ||
| 441 | - // Calculate the target height before animation | ||
| 442 | - let targetHeight: CGFloat = isCouponQRExpanded ? 250 : 0 // Set a fixed height for QR code | ||
| 443 | - | ||
| 444 | - // Show content immediately if expanding | ||
| 445 | - if isCouponQRExpanded { | ||
| 446 | - couponQRContentView.isHidden = false | ||
| 447 | - couponQRContentView.alpha = 0 | ||
| 448 | - } | ||
| 449 | - | ||
| 450 | - UIView.animate(withDuration: 0.3, animations: { | ||
| 451 | - // Update arrow image | ||
| 452 | - // self.couponQRArrowImage.image = UIImage(named: self.isCouponQRExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil) | ||
| 453 | - | ||
| 454 | - // Update arrow with rotation | ||
| 455 | - let rotation = self.isCouponQRExpanded ? CGAffineTransform(rotationAngle: .pi) : .identity | ||
| 456 | - self.couponQRArrowImage.transform = rotation | ||
| 457 | - | ||
| 458 | - // Update height constraint | ||
| 459 | - self.couponQRContentHeightConstraint.constant = targetHeight | ||
| 460 | - | ||
| 461 | - // Update alpha for smooth fade | ||
| 462 | - self.couponQRContentView.alpha = self.isCouponQRExpanded ? 1.0 : 0.0 | ||
| 463 | - | ||
| 464 | - // Force layout update | ||
| 465 | - self.view.layoutIfNeeded() | ||
| 466 | - | ||
| 467 | - }) { _ in | ||
| 468 | - // Hide content after animation completes if collapsing | ||
| 469 | - if !self.isCouponQRExpanded { | ||
| 470 | - self.couponQRContentView.isHidden = true | ||
| 471 | - } | ||
| 472 | - } | ||
| 473 | - } | ||
| 474 | - | ||
| 475 | @objc private func toggleTerms() { | 363 | @objc private func toggleTerms() { |
| 476 | isTermsExpanded.toggle() | 364 | isTermsExpanded.toggle() |
| 477 | 365 | ... | ... |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment