Manos Chorianopoulos

handle SubmitButton visibility at UnifiedCouponsViewController

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -4934,6 +4934,7 @@ ...@@ -4934,6 +4934,7 @@
4934 <outlet property="emptyView" destination="U5I-GH-geX" id="lhU-3z-yKl"/> 4934 <outlet property="emptyView" destination="U5I-GH-geX" id="lhU-3z-yKl"/>
4935 <outlet property="emptyViewHeight" destination="Ooe-1Z-EJ8" id="SRF-jF-7to"/> 4935 <outlet property="emptyViewHeight" destination="Ooe-1Z-EJ8" id="SRF-jF-7to"/>
4936 <outlet property="submitButton" destination="Qz6-OH-kIb" id="9Dq-GE-NMA"/> 4936 <outlet property="submitButton" destination="Qz6-OH-kIb" id="9Dq-GE-NMA"/>
4937 + <outlet property="submitButtonHeight" destination="Jgw-dF-afS" id="Jrt-eo-KbP"/>
4937 <outlet property="tableView" destination="YVv-xm-y2W" id="kle-or-Ckg"/> 4938 <outlet property="tableView" destination="YVv-xm-y2W" id="kle-or-Ckg"/>
4938 </connections> 4939 </connections>
4939 </viewController> 4940 </viewController>
......
...@@ -16,6 +16,7 @@ import SwiftEventBus ...@@ -16,6 +16,7 @@ import SwiftEventBus
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 @IBOutlet weak var submitButton: UIButton!
19 + @IBOutlet weak var submitButtonHeight: NSLayoutConstraint!
19 20
20 public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = [] 21 public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
21 public var smCoupons:Array<swiftApi.CouponItemModel> = [] 22 public var smCoupons:Array<swiftApi.CouponItemModel> = []
...@@ -58,6 +59,7 @@ import SwiftEventBus ...@@ -58,6 +59,7 @@ import SwiftEventBus
58 // self.tableView.reloadData() 59 // self.tableView.reloadData()
59 // Reload the SM Coupons section only 60 // Reload the SM Coupons section only
60 self.tableView.reloadSections(IndexSet(integer: 1), with: .automatic) 61 self.tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
62 + self.handleSubmitButtonVisible()
61 63
62 if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) { 64 if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) {
63 self.emptyView.isHidden = false 65 self.emptyView.isHidden = false
...@@ -118,6 +120,7 @@ import SwiftEventBus ...@@ -118,6 +120,7 @@ import SwiftEventBus
118 self.unifiedCoupons = swiftApi().getUnifiedCouponList() 120 self.unifiedCoupons = swiftApi().getUnifiedCouponList()
119 self.smCoupons = swiftApi().getSMCouponList() 121 self.smCoupons = swiftApi().getSMCouponList()
120 self.tableView.reloadData() 122 self.tableView.reloadData()
123 + self.handleSubmitButtonVisible()
121 124
122 if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) { 125 if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) {
123 self.emptyView.isHidden = false 126 self.emptyView.isHidden = false
...@@ -200,6 +203,19 @@ import SwiftEventBus ...@@ -200,6 +203,19 @@ import SwiftEventBus
200 } 203 }
201 } 204 }
202 205
206 + func handleSubmitButtonVisible() {
207 + if (self.smCoupons.count > 0) {
208 + submitButton.isEnabled = true
209 + submitButton.isHidden = false
210 + submitButtonHeight.constant = 55
211 +
212 + } else {
213 + submitButton.isEnabled = false
214 + submitButton.isHidden = true
215 + submitButtonHeight.constant = 0
216 + }
217 + }
218 +
203 func showSuccessDialog() -> Void { 219 func showSuccessDialog() -> Void {
204 220
205 let alert = UIAlertController(title: "Δημιουργία Κουπονιού", message: "Το ενιαίο κουπόνι σου δημιουργήθηκε επιτυχώς.", preferredStyle: .alert) 221 let alert = UIAlertController(title: "Δημιουργία Κουπονιού", message: "Το ενιαίο κουπόνι σου δημιουργήθηκε επιτυχώς.", preferredStyle: .alert)
......