Manos Chorianopoulos

add submitButton at UnifiedCouponsViewController

...@@ -4863,6 +4863,20 @@ ...@@ -4863,6 +4863,20 @@
4863 <outlet property="delegate" destination="3uV-Le-crf" id="3Mq-HR-Udb"/> 4863 <outlet property="delegate" destination="3uV-Le-crf" id="3Mq-HR-Udb"/>
4864 </connections> 4864 </connections>
4865 </tableView> 4865 </tableView>
4866 + <button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qz6-OH-kIb">
4867 + <rect key="frame" x="20" y="763" width="374" height="55"/>
4868 + <constraints>
4869 + <constraint firstAttribute="height" constant="55" id="Jgw-dF-afS"/>
4870 + </constraints>
4871 + <fontDescription key="fontDescription" name="PeridotPE-SBold" family="Peridot PE" pointSize="16"/>
4872 + <inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
4873 + <state key="normal" title="Συνδύασε τις προσφορές σε ένα κουπόνι">
4874 + <color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
4875 + </state>
4876 + <connections>
4877 + <action selector="submitButtonAction:" destination="3uV-Le-crf" eventType="touchUpInside" id="RhR-Dq-X8G"/>
4878 + </connections>
4879 + </button>
4866 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U5I-GH-geX"> 4880 <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U5I-GH-geX">
4867 <rect key="frame" x="20" y="0.0" width="374" height="0.0"/> 4881 <rect key="frame" x="20" y="0.0" width="374" height="0.0"/>
4868 <subviews> 4882 <subviews>
...@@ -4888,13 +4902,16 @@ ...@@ -4888,13 +4902,16 @@
4888 <constraint firstAttribute="bottom" secondItem="YVv-xm-y2W" secondAttribute="bottom" id="2Sd-z8-rwY"/> 4902 <constraint firstAttribute="bottom" secondItem="YVv-xm-y2W" secondAttribute="bottom" id="2Sd-z8-rwY"/>
4889 <constraint firstAttribute="trailing" secondItem="YVv-xm-y2W" secondAttribute="trailing" id="38N-7Z-jr0"/> 4903 <constraint firstAttribute="trailing" secondItem="YVv-xm-y2W" secondAttribute="trailing" id="38N-7Z-jr0"/>
4890 <constraint firstItem="YVv-xm-y2W" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" id="93P-If-3rc"/> 4904 <constraint firstItem="YVv-xm-y2W" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" id="93P-If-3rc"/>
4905 + <constraint firstItem="Qz6-OH-kIb" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" constant="20" id="9EW-pJ-DQx"/>
4891 <constraint firstAttribute="bottom" secondItem="QKV-Lk-E2a" secondAttribute="bottom" id="IeT-AJ-BlK"/> 4906 <constraint firstAttribute="bottom" secondItem="QKV-Lk-E2a" secondAttribute="bottom" id="IeT-AJ-BlK"/>
4907 + <constraint firstAttribute="trailing" secondItem="Qz6-OH-kIb" secondAttribute="trailing" constant="20" id="MxK-Uo-07g"/>
4892 <constraint firstItem="QKV-Lk-E2a" firstAttribute="top" secondItem="BQW-dX-NwZ" secondAttribute="top" id="TRn-cU-wHn"/> 4908 <constraint firstItem="QKV-Lk-E2a" firstAttribute="top" secondItem="BQW-dX-NwZ" secondAttribute="top" id="TRn-cU-wHn"/>
4893 <constraint firstItem="U5I-GH-geX" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" constant="20" id="U9E-ku-HqF"/> 4909 <constraint firstItem="U5I-GH-geX" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" constant="20" id="U9E-ku-HqF"/>
4894 <constraint firstItem="YVv-xm-y2W" firstAttribute="top" secondItem="BQW-dX-NwZ" secondAttribute="top" constant="2" id="XeB-29-8xb"/> 4910 <constraint firstItem="YVv-xm-y2W" firstAttribute="top" secondItem="BQW-dX-NwZ" secondAttribute="top" constant="2" id="XeB-29-8xb"/>
4895 <constraint firstItem="QKV-Lk-E2a" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" id="ZP8-kd-9RI"/> 4911 <constraint firstItem="QKV-Lk-E2a" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" id="ZP8-kd-9RI"/>
4896 <constraint firstAttribute="trailing" secondItem="U5I-GH-geX" secondAttribute="trailing" constant="20" id="ex6-de-ech"/> 4912 <constraint firstAttribute="trailing" secondItem="U5I-GH-geX" secondAttribute="trailing" constant="20" id="ex6-de-ech"/>
4897 <constraint firstAttribute="trailing" secondItem="QKV-Lk-E2a" secondAttribute="trailing" id="tzT-5O-w7Q"/> 4913 <constraint firstAttribute="trailing" secondItem="QKV-Lk-E2a" secondAttribute="trailing" id="tzT-5O-w7Q"/>
4914 + <constraint firstAttribute="bottom" secondItem="Qz6-OH-kIb" secondAttribute="bottom" constant="30" id="vyB-w0-TFK"/>
4898 </constraints> 4915 </constraints>
4899 <variation key="default"> 4916 <variation key="default">
4900 <mask key="subviews"> 4917 <mask key="subviews">
...@@ -4917,6 +4934,7 @@ ...@@ -4917,6 +4934,7 @@
4917 <outlet property="emptyLabel" destination="VW1-eq-kSh" id="Lva-nM-uXu"/> 4934 <outlet property="emptyLabel" destination="VW1-eq-kSh" id="Lva-nM-uXu"/>
4918 <outlet property="emptyView" destination="U5I-GH-geX" id="lhU-3z-yKl"/> 4935 <outlet property="emptyView" destination="U5I-GH-geX" id="lhU-3z-yKl"/>
4919 <outlet property="emptyViewHeight" destination="Ooe-1Z-EJ8" id="SRF-jF-7to"/> 4936 <outlet property="emptyViewHeight" destination="Ooe-1Z-EJ8" id="SRF-jF-7to"/>
4937 + <outlet property="submitButton" destination="Qz6-OH-kIb" id="9Dq-GE-NMA"/>
4920 <outlet property="tableView" destination="YVv-xm-y2W" id="kle-or-Ckg"/> 4938 <outlet property="tableView" destination="YVv-xm-y2W" id="kle-or-Ckg"/>
4921 </connections> 4939 </connections>
4922 </viewController> 4940 </viewController>
......
...@@ -15,6 +15,7 @@ import SwiftEventBus ...@@ -15,6 +15,7 @@ import SwiftEventBus
15 @IBOutlet weak var emptyView: UIView! 15 @IBOutlet weak var emptyView: UIView!
16 @IBOutlet weak var emptyViewHeight: NSLayoutConstraint! 16 @IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
17 @IBOutlet weak var emptyLabel: UILabel! 17 @IBOutlet weak var emptyLabel: UILabel!
18 + @IBOutlet weak var submitButton: UIButton!
18 19
19 public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = [] 20 public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
20 public var smCoupons:Array<swiftApi.CouponItemModel> = [] 21 public var smCoupons:Array<swiftApi.CouponItemModel> = []
...@@ -76,10 +77,28 @@ import SwiftEventBus ...@@ -76,10 +77,28 @@ import SwiftEventBus
76 // tableView.layer.cornerRadius = 30 77 // tableView.layer.cornerRadius = 30
77 // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius 78 // tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
78 // tableView.contentInset.top = 30 79 // tableView.contentInset.top = 30
79 - // TODO: Change
80 tableView.contentInset.bottom = 115 80 tableView.contentInset.bottom = 115
81 81
82 emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!" 82 emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!"
83 +
84 + submitButton.setTitle("Συνδύασε τις προσφορές σε ένα κουπόνι", for: .normal)
85 + submitButton.setTitleColor(.white, for: .normal)
86 + submitButton.layer.cornerRadius = 16.0
87 +// submitButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
88 + submitButton.backgroundColor = UIColor(rgb: 0x9D9D9C)
89 + submitButton.isEnabled = false
90 +// submitButton.frame = CGRect(x: 0.0, y: 0.0, width: submitButton.intrinsicContentSize.width, height: 50)
91 +// submitButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
92 + // Fix width for ipad
93 + if UIDevice.current.userInterfaceIdiom == .pad {
94 + // iPad
95 + submitButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 18)
96 +// submitButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
97 + } else {
98 + // not iPad (iPhone, mac, tv, carPlay, unspecified)
99 + submitButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 16)
100 +// submitButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
101 + }
83 } 102 }
84 103
85 public override func viewWillAppear(_ animated: Bool) { 104 public override func viewWillAppear(_ animated: Bool) {
...@@ -117,6 +136,8 @@ import SwiftEventBus ...@@ -117,6 +136,8 @@ import SwiftEventBus
117 smCouponsSelected = [] 136 smCouponsSelected = []
118 } 137 }
119 138
139 + handleSubmitButtonUI()
140 +
120 // Reload the SM Coupons section only 141 // Reload the SM Coupons section only
121 tableView.reloadSections(IndexSet(integer: 1), with: .automatic) 142 tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
122 } 143 }
...@@ -147,6 +168,27 @@ import SwiftEventBus ...@@ -147,6 +168,27 @@ import SwiftEventBus
147 tableView.reloadRows(at: [indexPath], with: .automatic) // Reload the specific row 168 tableView.reloadRows(at: [indexPath], with: .automatic) // Reload the specific row
148 } 169 }
149 } 170 }
171 + handleSubmitButtonUI()
172 + }
173 +
174 +
175 + func handleSubmitButtonUI() {
176 + if (self.smCouponsSelected.count > 0) {
177 + submitButton.backgroundColor = UIColor(rgb: 0x0EA600)
178 + submitButton.isEnabled = true
179 +
180 + } else {
181 + submitButton.backgroundColor = UIColor(rgb: 0x9D9D9C)
182 + submitButton.isEnabled = false
183 + }
184 + }
185 +
186 + // MARK: - Actions
187 + @IBAction func submitButtonAction(_ sender: Any) {
188 +// let smCouponsString = self.smCouponsSelected.map { $0.coupon ?? "" }.joined(separator: ",")
189 +// swiftApi().logTrackersEvent("click", ("UnifySMCoupons:" + (smCouponsString)))
190 +
191 + // TODO: Add action
150 192
151 } 193 }
152 } 194 }
......