Manos Chorianopoulos

handle SubmitButton visibility at UnifiedCouponsViewController

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -4934,6 +4934,7 @@
<outlet property="emptyView" destination="U5I-GH-geX" id="lhU-3z-yKl"/>
<outlet property="emptyViewHeight" destination="Ooe-1Z-EJ8" id="SRF-jF-7to"/>
<outlet property="submitButton" destination="Qz6-OH-kIb" id="9Dq-GE-NMA"/>
<outlet property="submitButtonHeight" destination="Jgw-dF-afS" id="Jrt-eo-KbP"/>
<outlet property="tableView" destination="YVv-xm-y2W" id="kle-or-Ckg"/>
</connections>
</viewController>
......
......@@ -16,6 +16,7 @@ import SwiftEventBus
@IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var submitButton: UIButton!
@IBOutlet weak var submitButtonHeight: NSLayoutConstraint!
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
public var smCoupons:Array<swiftApi.CouponItemModel> = []
......@@ -58,6 +59,7 @@ import SwiftEventBus
// self.tableView.reloadData()
// Reload the SM Coupons section only
self.tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
self.handleSubmitButtonVisible()
if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) {
self.emptyView.isHidden = false
......@@ -118,6 +120,7 @@ import SwiftEventBus
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.smCoupons = swiftApi().getSMCouponList()
self.tableView.reloadData()
self.handleSubmitButtonVisible()
if (self.unifiedCoupons.count == 0 && self.smCoupons.count == 0) {
self.emptyView.isHidden = false
......@@ -200,6 +203,19 @@ import SwiftEventBus
}
}
func handleSubmitButtonVisible() {
if (self.smCoupons.count > 0) {
submitButton.isEnabled = true
submitButton.isHidden = false
submitButtonHeight.constant = 55
} else {
submitButton.isEnabled = false
submitButton.isHidden = true
submitButtonHeight.constant = 0
}
}
func showSuccessDialog() -> Void {
let alert = UIAlertController(title: "Δημιουργία Κουπονιού", message: "Το ενιαίο κουπόνι σου δημιουργήθηκε επιτυχώς.", preferredStyle: .alert)
......