Manos Chorianopoulos

CouponViewController fixes

......@@ -26,7 +26,6 @@ import UIKit
@IBOutlet weak var couponCodeContainerView: UIView!
@IBOutlet weak var couponCodeHeaderView: UIView!
@IBOutlet weak var couponCodeContentView: UIView!
@IBOutlet weak var couponCodeContainerViewHeight: NSLayoutConstraint!
// Header elements
@IBOutlet weak var couponCodeTitleLabel: UILabel!
......@@ -45,7 +44,6 @@ import UIKit
@IBOutlet weak var couponQRContainerView: UIView!
@IBOutlet weak var couponQRHeaderView: UIView!
@IBOutlet weak var couponQRContentView: UIView!
@IBOutlet weak var couponQRContainerViewHeight: NSLayoutConstraint!
// Header elements
@IBOutlet weak var couponQRTitleLabel: UILabel!
......@@ -108,7 +106,6 @@ import UIKit
couponCodeButton.addTarget(self, action: #selector(toggleCouponCode), for: .touchUpInside)
couponCodeContentHeightConstraint.constant = 0
couponCodeContentView.isHidden = true
couponCodeContainerViewHeight.constant = couponCodeContainerView.intrinsicContentSize.height
couponQRContainerView.backgroundColor = UIColor(rgb: 0xFFFFFF)
couponQRContainerView.layer.cornerRadius = 8.0
......@@ -116,7 +113,6 @@ import UIKit
couponQRButton.addTarget(self, action: #selector(toggleCouponQR), for: .touchUpInside)
couponQRContentHeightConstraint.constant = 0
couponQRContentView.isHidden = true
couponQRContainerViewHeight.constant = couponQRContainerView.intrinsicContentSize.height
termsButtonTitleLabel.font = UIFont(name: "PingLCG-Bold", size: 16)
termsButtonTitleLabel.textColor = UIColor(rgb: 0x020E1C)
......@@ -204,32 +200,87 @@ import UIKit
@objc private func toggleCouponCode() {
isCouponCodeExpanded.toggle()
UIView.animate(withDuration: 0.3) {
self.couponCodeArrowImage.image = UIImage(named: self.isCouponCodeExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
self.couponCodeContentHeightConstraint.constant = self.isCouponCodeExpanded ? self.couponCodeContentView.intrinsicContentSize.height : 0
self.couponCodeContentView.isHidden = !self.isCouponCodeExpanded
self.couponCodeContainerViewHeight.constant = self.couponCodeContainerView.intrinsicContentSize.height
// 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()
UIView.animate(withDuration: 0.3) {
self.couponQRArrowImage.image = UIImage(named: self.isCouponQRExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
self.couponQRContentHeightConstraint.constant = self.isCouponQRExpanded ? self.couponQRContentView.intrinsicContentSize.height : 0
self.couponQRContentView.isHidden = !self.isCouponQRExpanded
self.couponQRContainerViewHeight.constant = self.couponQRContainerView.intrinsicContentSize.height
// 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()
UIView.animate(withDuration: 0.3) {
self.termsButtonArrowImage.image = UIImage(named: self.isTermsExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// self.termsButtonArrowImage.image = UIImage(named: self.isTermsExpanded ? "arrow_up" : "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
// Update arrow with rotation
let rotation = self.isTermsExpanded ? CGAffineTransform(rotationAngle: .pi) : .identity
self.termsButtonArrowImage.transform = rotation
self.termsLabelHeight.constant = self.isTermsExpanded ? self.termsLabel.intrinsicContentSize.height : 0
self.view.layoutIfNeeded()
}
......
......@@ -15,7 +15,6 @@
<outlet property="couponCodeArrowImage" destination="YoJ-w2-mm9" id="oQm-Mm-FL8"/>
<outlet property="couponCodeButton" destination="5sx-2G-cCM" id="vuv-NX-y5I"/>
<outlet property="couponCodeContainerView" destination="ElJ-Te-N4M" id="84s-Ab-iAG"/>
<outlet property="couponCodeContainerViewHeight" destination="z8d-Ki-jJz" id="Mtb-K9-4Mj"/>
<outlet property="couponCodeContentHeightConstraint" destination="ky8-Xs-cjh" id="P1b-xY-vde"/>
<outlet property="couponCodeContentView" destination="wT1-HY-mg9" id="PEK-wT-l4v"/>
<outlet property="couponCodeHeaderView" destination="cTO-BG-Gzi" id="6Xm-p8-F13"/>
......@@ -25,7 +24,6 @@
<outlet property="couponQRArrowImage" destination="OXW-Jx-8wp" id="ijU-6O-hcN"/>
<outlet property="couponQRButton" destination="xd4-3b-eOl" id="ElE-cn-nPX"/>
<outlet property="couponQRContainerView" destination="Cwz-uh-Zn5" id="igH-cb-FMa"/>
<outlet property="couponQRContainerViewHeight" destination="KLs-q8-eNp" id="WoC-Xo-Dyu"/>
<outlet property="couponQRContentHeightConstraint" destination="odW-jh-UiA" id="LfK-Hl-1Ks"/>
<outlet property="couponQRContentView" destination="xqU-7k-Vxg" id="t1n-V2-Tv3"/>
<outlet property="couponQRHeaderView" destination="eEy-8l-te2" id="0U3-5V-9BB"/>
......@@ -63,7 +61,7 @@
<rect key="frame" x="0.0" y="0.0" width="393" height="793"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="qrm-40-JLT" userLabel="Scroll Content View">
<rect key="frame" x="0.0" y="0.0" width="393" height="1225.6666666666667"/>
<rect key="frame" x="0.0" y="0.0" width="393" height="1177"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Xiw-td-OMd" userLabel="Coupon Image View">
<rect key="frame" x="0.0" y="0.0" width="393" height="211"/>
......@@ -140,19 +138,19 @@
<nil key="highlightedColor"/>
</label>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="ElJ-Te-N4M" userLabel="CouponCodeContainerView">
<rect key="frame" x="24" y="383.33333333333331" width="345" height="182.99999999999994"/>
<rect key="frame" x="24" y="383.33333333333331" width="345" height="134.33333333333331"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="cTO-BG-Gzi" userLabel="CouponCodeHeaderView">
<rect key="frame" x="0.0" y="0.0" width="345" height="55"/>
<rect key="frame" x="0.0" y="0.0" width="345" height="54.333333333333336"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="lEF-bh-hOi" userLabel="CouponCodeTitleLabel">
<rect key="frame" x="17" y="17" width="277" height="21"/>
<rect key="frame" x="17" y="17" width="277" height="20.333333333333329"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="YoJ-w2-mm9" userLabel="CouponCodeArrowImage">
<rect key="frame" x="311" y="21" width="13" height="13"/>
<rect key="frame" x="311" y="20.666666666666686" width="13" height="13"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="width" constant="13" id="627-N9-Nwq"/>
......@@ -160,7 +158,7 @@
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="5sx-2G-cCM" userLabel="CouponCodeButton">
<rect key="frame" x="0.0" y="0.0" width="345" height="55"/>
<rect key="frame" x="0.0" y="0.0" width="345" height="54.333333333333336"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Button">
......@@ -183,16 +181,16 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="wT1-HY-mg9" userLabel="CouponCodeContentView">
<rect key="frame" x="0.0" y="55" width="345" height="128"/>
<rect key="frame" x="0.0" y="54.333333333333371" width="345" height="80"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2Fn-5d-j8v" userLabel="CouponCodeValueLabel" customClass="CopyableLabel">
<rect key="frame" x="16.999999999999996" y="26.000000000000057" width="56.666666666666657" height="76"/>
<rect key="frame" x="16.999999999999996" y="25.999999999999943" width="56.666666666666657" height="28"/>
<fontDescription key="fontDescription" type="system" pointSize="24"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="AXc-Yh-5Ek" userLabel="CopyButtonImage">
<rect key="frame" x="84.666666666666671" y="47.666666666666686" width="33" height="33"/>
<rect key="frame" x="84.666666666666671" y="23.666666666666686" width="33" height="33"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="33" id="7ds-Ao-fBn"/>
......@@ -200,7 +198,7 @@
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="uPp-hJ-U97" userLabel="CouponCopyButton">
<rect key="frame" x="84.666666666666671" y="47.666666666666686" width="33" height="33"/>
<rect key="frame" x="84.666666666666671" y="23.666666666666686" width="33" height="33"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Button">
......@@ -218,7 +216,7 @@
<constraint firstItem="2Fn-5d-j8v" firstAttribute="top" secondItem="wT1-HY-mg9" secondAttribute="top" constant="26" id="XpY-aU-BzN"/>
<constraint firstAttribute="bottom" secondItem="2Fn-5d-j8v" secondAttribute="bottom" constant="26" id="Y10-PC-eP5"/>
<constraint firstItem="uPp-hJ-U97" firstAttribute="top" secondItem="AXc-Yh-5Ek" secondAttribute="top" id="hSS-7f-MiM"/>
<constraint firstAttribute="height" constant="128" id="ky8-Xs-cjh"/>
<constraint firstAttribute="height" constant="80" id="ky8-Xs-cjh"/>
<constraint firstItem="uPp-hJ-U97" firstAttribute="bottom" secondItem="AXc-Yh-5Ek" secondAttribute="bottom" id="v1F-S6-muO"/>
<constraint firstItem="AXc-Yh-5Ek" firstAttribute="leading" secondItem="2Fn-5d-j8v" secondAttribute="trailing" constant="11" id="vuS-Bk-Q0J"/>
</constraints>
......@@ -233,11 +231,10 @@
<constraint firstAttribute="trailing" secondItem="wT1-HY-mg9" secondAttribute="trailing" id="ssf-Xv-Bxx"/>
<constraint firstAttribute="trailing" secondItem="cTO-BG-Gzi" secondAttribute="trailing" id="umy-qN-JFu"/>
<constraint firstItem="wT1-HY-mg9" firstAttribute="top" secondItem="cTO-BG-Gzi" secondAttribute="bottom" id="wkk-WM-rVY"/>
<constraint firstAttribute="height" constant="183" id="z8d-Ki-jJz"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Cwz-uh-Zn5" userLabel="CouponQRContainerView">
<rect key="frame" x="24" y="589.33333333333337" width="345" height="305"/>
<rect key="frame" x="24" y="540.66666666666663" width="345" height="305"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="eEy-8l-te2" userLabel="CouponQRHeaderView">
<rect key="frame" x="0.0" y="0.0" width="345" height="55"/>
......@@ -304,7 +301,6 @@
<constraints>
<constraint firstAttribute="trailing" secondItem="xqU-7k-Vxg" secondAttribute="trailing" id="JEa-Zg-JIu"/>
<constraint firstItem="xqU-7k-Vxg" firstAttribute="top" secondItem="eEy-8l-te2" secondAttribute="bottom" id="Jf6-P1-9qS"/>
<constraint firstAttribute="height" constant="305" id="KLs-q8-eNp"/>
<constraint firstItem="eEy-8l-te2" firstAttribute="leading" secondItem="Cwz-uh-Zn5" secondAttribute="leading" id="iZp-kc-tZ2"/>
<constraint firstItem="xqU-7k-Vxg" firstAttribute="leading" secondItem="Cwz-uh-Zn5" secondAttribute="leading" id="nxQ-kb-BhT"/>
<constraint firstItem="eEy-8l-te2" firstAttribute="top" secondItem="Cwz-uh-Zn5" secondAttribute="top" id="qho-3x-oyY"/>
......@@ -313,7 +309,7 @@
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HAh-BZ-4Ka" userLabel="TermsButtonView">
<rect key="frame" x="23.999999999999993" y="944.33333333333337" width="123.33333333333331" height="35"/>
<rect key="frame" x="23.999999999999993" y="895.66666666666663" width="123.33333333333331" height="35"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Όροι Χρήσης" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="6Vj-gt-dKJ" userLabel="TermsButtonTitleLabel">
<rect key="frame" x="0.0" y="5" width="101.33333333333333" height="25"/>
......@@ -353,7 +349,7 @@
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Ak8-Tc-k8X" userLabel="TermsLabel">
<rect key="frame" x="24" y="989.33333333333326" width="345" height="20.333333333333371"/>
<rect key="frame" x="24" y="940.66666666666663" width="345" height="20.333333333333371"/>
<constraints>
<constraint firstAttribute="height" constant="20.329999999999998" id="ZA1-TX-m9Y"/>
</constraints>
......@@ -362,7 +358,7 @@
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="j1U-rV-0FP" userLabel="MapButton">
<rect key="frame" x="24" y="1049.6666666666667" width="345" height="55"/>
<rect key="frame" x="24" y="1001" width="345" height="55"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="BZv-RS-JfU"/>
</constraints>
......@@ -370,7 +366,7 @@
<buttonConfiguration key="configuration" style="plain" title="Button"/>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="t8z-s1-rIA" userLabel="WebsiteButton">
<rect key="frame" x="24" y="1124.6666666666667" width="345" height="55"/>
<rect key="frame" x="24" y="1076" width="345" height="55"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="EUh-DN-fJh"/>
</constraints>
......