Manos Chorianopoulos

CouponVC expandables functionality

......@@ -56,6 +56,9 @@ import UIKit
// Constraints for animation
@IBOutlet weak var couponQRContentHeightConstraint: NSLayoutConstraint!
@IBOutlet weak var termsButtonView: UIView!
@IBOutlet weak var termsButtonTitleLabel: UILabel!
@IBOutlet weak var termsButtonArrowImage: UIImageView!
@IBOutlet weak var termsButton: UIButton!
@IBOutlet weak var termsLabel: UILabel!
@IBOutlet weak var termsLabelHeight: NSLayoutConstraint!
......@@ -67,7 +70,7 @@ import UIKit
var coupon: OfferModel?
private var isDetailsExpanded = false
private var isCouponCodeExpanded = false
private var isCouponBarcodeExpanded = false
private var isCouponQRExpanded = false
private var isTermsExpanded = false
public override func viewDidLoad() {
......@@ -89,6 +92,7 @@ import UIKit
copyButtonImage.image = UIImage(named: "copy", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponQRArrowImage.image = UIImage(named: "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
couponQRImage.image = UIImage(named: "barcode", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
termsButtonArrowImage.image = UIImage(named: "arrow_down", in: MyEmptyClass.resourceBundle(), compatibleWith: nil)
infoLabel.font = UIFont(name: "PingLCG-Regular", size: 13)
infoLabel.textColor = UIColor(rgb: 0x020E1C)
......@@ -99,22 +103,19 @@ import UIKit
couponCodeContainerView.backgroundColor = UIColor(rgb: 0xFFFFFF)
couponCodeContainerView.layer.cornerRadius = 8.0
couponCodeContainerView.clipsToBounds = true
couponCodeButton.addTarget(self, action: #selector(toggleCouponCode), for: .touchUpInside)
couponCodeContentHeightConstraint.constant = 0
couponQRContainerView.backgroundColor = UIColor(rgb: 0xFFFFFF)
couponQRContainerView.layer.cornerRadius = 8.0
couponQRContainerView.clipsToBounds = true
couponQRButton.addTarget(self, action: #selector(toggleCouponQR), for: .touchUpInside)
couponQRContentHeightConstraint.constant = 0
termsButton.titleLabel?.font = UIFont(name: "PingLCG-Bold", size: 16)
// termsButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5)
termsButton.setTitle("Όροι Χρήσης", for: .normal)
termsButton.setTitleColor(UIColor(rgb: 0x020E1C), for: .normal)
termsButton.setImage(UIImage(named: "arrow_down.png", in: MyEmptyClass.resourceBundle(), compatibleWith: nil), for: .normal)
termsButton.semanticContentAttribute = .forceRightToLeft
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)
termsButtonTitleLabel.font = UIFont(name: "PingLCG-Bold", size: 16)
termsButtonTitleLabel.textColor = UIColor(rgb: 0x020E1C)
termsButtonTitleLabel.text = "Όροι Χρήσης"
termsButton.addTarget(self, action: #selector(toggleTerms), for: .touchUpInside)
termsLabelHeight.constant = 0
mapButton.titleLabel?.font = UIFont(name: "PingLCG-Bold", size: 16)
......@@ -180,12 +181,12 @@ import UIKit
detailsLabel.textColor = UIColor(rgb: 0x020E1C)
// Add tap gesture
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(toggleDetailsExpansion))
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(toggleDetails))
detailsLabel.isUserInteractionEnabled = true
detailsLabel.addGestureRecognizer(tapGesture)
}
@objc private func toggleDetailsExpansion() {
@objc private func toggleDetails() {
isDetailsExpanded.toggle()
UIView.animate(withDuration: 0.3) {
......@@ -193,4 +194,34 @@ import UIKit
self.view.layoutIfNeeded()
}
}
@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.view.layoutIfNeeded()
}
}
@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.view.layoutIfNeeded()
}
}
@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.termsLabelHeight.constant = self.isTermsExpanded ? self.termsLabel.intrinsicContentSize.height : 0
self.view.layoutIfNeeded()
}
}
}
......
......@@ -38,7 +38,10 @@
<outlet property="mapButton" destination="j1U-rV-0FP" id="K5C-V5-ejo"/>
<outlet property="shareImage" destination="WjF-6P-8Wn" id="f7E-u8-Efc"/>
<outlet property="subtitleLabel" destination="VJr-Mc-WMf" id="D5i-m9-5pG"/>
<outlet property="termsButton" destination="Id4-Xw-01i" id="K7V-uP-07v"/>
<outlet property="termsButton" destination="Id4-Xw-01i" id="rZ1-hr-bSI"/>
<outlet property="termsButtonArrowImage" destination="C8k-TU-LiL" id="8mu-8b-a7K"/>
<outlet property="termsButtonTitleLabel" destination="6Vj-gt-dKJ" id="hsv-5A-Sgk"/>
<outlet property="termsButtonView" destination="HAh-BZ-4Ka" id="dVr-YX-Wmt"/>
<outlet property="termsLabel" destination="Ak8-Tc-k8X" id="lGl-Bm-k5q"/>
<outlet property="termsLabelHeight" destination="ZA1-TX-m9Y" id="zDj-wU-mre"/>
<outlet property="titleLabel" destination="u54-xs-f5a" id="jG6-28-Q0R"/>
......@@ -54,10 +57,10 @@
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="XaT-fU-eNh" userLabel="Main View">
<rect key="frame" x="0.0" y="59" width="393" height="793"/>
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YpC-uS-mhw">
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" ambiguous="YES" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" translatesAutoresizingMaskIntoConstraints="NO" id="YpC-uS-mhw">
<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">
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="qrm-40-JLT" userLabel="Scroll Content View">
<rect key="frame" x="0.0" y="0.0" width="393" height="1225.6666666666667"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="Xiw-td-OMd" userLabel="Coupon Image View">
......@@ -305,12 +308,47 @@
<constraint firstAttribute="bottom" secondItem="xqU-7k-Vxg" secondAttribute="bottom" id="wUN-aQ-c9t"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="HAh-BZ-4Ka" userLabel="TermsButtonView">
<rect key="frame" x="24" y="1349.3333333333333" width="75" height="35"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" 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="53" height="25"/>
<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="C8k-TU-LiL" userLabel="TermsButtonArrowImage">
<rect key="frame" x="61" y="15" width="9" height="5"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="height" constant="5" id="ERb-FD-j0Y"/>
<constraint firstAttribute="width" constant="9" id="Sc1-QU-NCU"/>
</constraints>
</imageView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Id4-Xw-01i" userLabel="TermsButton">
<rect key="frame" x="24" y="944.33333333333337" width="345" height="35"/>
<rect key="frame" x="0.0" y="0.0" width="75" height="35"/>
<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"/>
<buttonConfiguration key="configuration" style="plain" title="Button">
<color key="baseForegroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</buttonConfiguration>
</button>
<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">
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="Id4-Xw-01i" secondAttribute="trailing" id="9yF-mL-I1z"/>
<constraint firstItem="6Vj-gt-dKJ" firstAttribute="top" secondItem="HAh-BZ-4Ka" secondAttribute="top" constant="5" id="D14-g1-o0D"/>
<constraint firstItem="6Vj-gt-dKJ" firstAttribute="leading" secondItem="HAh-BZ-4Ka" secondAttribute="leading" id="NXA-J1-wrD"/>
<constraint firstItem="Id4-Xw-01i" firstAttribute="leading" secondItem="HAh-BZ-4Ka" secondAttribute="leading" id="VXd-Q2-8zj"/>
<constraint firstAttribute="trailing" secondItem="C8k-TU-LiL" secondAttribute="trailing" constant="5" id="Yh6-uV-EBT"/>
<constraint firstItem="C8k-TU-LiL" firstAttribute="centerY" secondItem="HAh-BZ-4Ka" secondAttribute="centerY" id="eps-sQ-Uah"/>
<constraint firstAttribute="bottom" secondItem="6Vj-gt-dKJ" secondAttribute="bottom" constant="5" id="gRE-jP-z4y"/>
<constraint firstItem="C8k-TU-LiL" firstAttribute="leading" secondItem="6Vj-gt-dKJ" secondAttribute="trailing" constant="8" id="had-S0-3Sm"/>
<constraint firstItem="Id4-Xw-01i" firstAttribute="top" secondItem="HAh-BZ-4Ka" secondAttribute="top" id="htm-a2-Hbc"/>
<constraint firstAttribute="bottom" secondItem="Id4-Xw-01i" secondAttribute="bottom" id="xfI-kZ-4H2"/>
</constraints>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" ambiguous="YES" 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"/>
<constraints>
<constraint firstAttribute="height" constant="20.329999999999998" id="ZA1-TX-m9Y"/>
......@@ -319,7 +357,7 @@
<nil key="textColor"/>
<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">
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" 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"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="BZv-RS-JfU"/>
......@@ -327,7 +365,7 @@
<state key="normal" title="Button"/>
<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">
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" 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"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="EUh-DN-fJh"/>
......@@ -342,7 +380,7 @@
<constraint firstItem="1Kx-s2-p1l" firstAttribute="leading" secondItem="u54-xs-f5a" secondAttribute="trailing" constant="11" id="22w-QH-w0I"/>
<constraint firstItem="Cwz-uh-Zn5" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" constant="24" id="2Cq-bG-OqH"/>
<constraint firstItem="HLR-Nk-7Gm" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" constant="24" id="3IS-pt-47I"/>
<constraint firstItem="Id4-Xw-01i" firstAttribute="top" secondItem="Cwz-uh-Zn5" secondAttribute="bottom" constant="50" id="CwG-Ev-Rvi"/>
<constraint firstItem="HAh-BZ-4Ka" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" constant="24" id="3wX-re-5mu"/>
<constraint firstItem="WjF-6P-8Wn" firstAttribute="top" secondItem="Xiw-td-OMd" secondAttribute="bottom" constant="17" id="DTU-uH-exC"/>
<constraint firstItem="Xiw-td-OMd" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" id="GFv-Mo-QN0"/>
<constraint firstAttribute="trailing" secondItem="t8z-s1-rIA" secondAttribute="trailing" constant="24" id="Hel-rG-nvJ"/>
......@@ -352,14 +390,12 @@
<constraint firstAttribute="trailing" secondItem="89U-JU-Imv" secondAttribute="trailing" constant="16" id="QJ1-AA-bn9"/>
<constraint firstItem="u54-xs-f5a" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" constant="24" id="ScM-kH-ZEe"/>
<constraint firstItem="VJr-Mc-WMf" firstAttribute="top" secondItem="u54-xs-f5a" secondAttribute="bottom" id="Ssw-da-ntM"/>
<constraint firstItem="Id4-Xw-01i" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" constant="24" id="T08-vK-q5K"/>
<constraint firstItem="HAh-BZ-4Ka" firstAttribute="top" secondItem="X7C-0H-IhU" secondAttribute="bottom" constant="1000" id="Su5-M8-vrC"/>
<constraint firstAttribute="trailing" secondItem="Xiw-td-OMd" secondAttribute="trailing" id="TGH-lz-pn5"/>
<constraint firstAttribute="trailing" secondItem="Id4-Xw-01i" secondAttribute="trailing" constant="24" id="YjW-2Y-Pgv"/>
<constraint firstItem="ElJ-Te-N4M" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" constant="24" id="abd-4G-pI5"/>
<constraint firstItem="Xiw-td-OMd" firstAttribute="top" secondItem="qrm-40-JLT" secondAttribute="top" id="ajI-sR-3Pt"/>
<constraint firstAttribute="trailing" secondItem="j1U-rV-0FP" secondAttribute="trailing" constant="24" id="bBU-zw-nbU"/>
<constraint firstAttribute="bottom" secondItem="t8z-s1-rIA" secondAttribute="bottom" constant="46" id="bBi-iY-kAp"/>
<constraint firstItem="Ak8-Tc-k8X" firstAttribute="top" secondItem="Id4-Xw-01i" secondAttribute="bottom" constant="10" id="bGA-mQ-RpV"/>
<constraint firstItem="WjF-6P-8Wn" firstAttribute="leading" secondItem="1Kx-s2-p1l" secondAttribute="trailing" constant="11" id="bI6-jl-1U8"/>
<constraint firstAttribute="trailing" secondItem="X7C-0H-IhU" secondAttribute="trailing" constant="24" id="cXA-ke-cJ7"/>
<constraint firstItem="X7C-0H-IhU" firstAttribute="leading" secondItem="qrm-40-JLT" secondAttribute="leading" constant="24" id="d5O-SJ-gva"/>
......