Manos Chorianopoulos

add submitButton at UnifiedCouponsViewController

......@@ -4863,6 +4863,20 @@
<outlet property="delegate" destination="3uV-Le-crf" id="3Mq-HR-Udb"/>
</connections>
</tableView>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Qz6-OH-kIb">
<rect key="frame" x="20" y="763" width="374" height="55"/>
<constraints>
<constraint firstAttribute="height" constant="55" id="Jgw-dF-afS"/>
</constraints>
<fontDescription key="fontDescription" name="PeridotPE-SBold" family="Peridot PE" pointSize="16"/>
<inset key="imageEdgeInsets" minX="0.0" minY="0.0" maxX="2.2250738585072014e-308" maxY="0.0"/>
<state key="normal" title="Συνδύασε τις προσφορές σε ένα κουπόνι">
<color key="titleColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</state>
<connections>
<action selector="submitButtonAction:" destination="3uV-Le-crf" eventType="touchUpInside" id="RhR-Dq-X8G"/>
</connections>
</button>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U5I-GH-geX">
<rect key="frame" x="20" y="0.0" width="374" height="0.0"/>
<subviews>
......@@ -4888,13 +4902,16 @@
<constraint firstAttribute="bottom" secondItem="YVv-xm-y2W" secondAttribute="bottom" id="2Sd-z8-rwY"/>
<constraint firstAttribute="trailing" secondItem="YVv-xm-y2W" secondAttribute="trailing" id="38N-7Z-jr0"/>
<constraint firstItem="YVv-xm-y2W" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" id="93P-If-3rc"/>
<constraint firstItem="Qz6-OH-kIb" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" constant="20" id="9EW-pJ-DQx"/>
<constraint firstAttribute="bottom" secondItem="QKV-Lk-E2a" secondAttribute="bottom" id="IeT-AJ-BlK"/>
<constraint firstAttribute="trailing" secondItem="Qz6-OH-kIb" secondAttribute="trailing" constant="20" id="MxK-Uo-07g"/>
<constraint firstItem="QKV-Lk-E2a" firstAttribute="top" secondItem="BQW-dX-NwZ" secondAttribute="top" id="TRn-cU-wHn"/>
<constraint firstItem="U5I-GH-geX" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" constant="20" id="U9E-ku-HqF"/>
<constraint firstItem="YVv-xm-y2W" firstAttribute="top" secondItem="BQW-dX-NwZ" secondAttribute="top" constant="2" id="XeB-29-8xb"/>
<constraint firstItem="QKV-Lk-E2a" firstAttribute="leading" secondItem="BQW-dX-NwZ" secondAttribute="leading" id="ZP8-kd-9RI"/>
<constraint firstAttribute="trailing" secondItem="U5I-GH-geX" secondAttribute="trailing" constant="20" id="ex6-de-ech"/>
<constraint firstAttribute="trailing" secondItem="QKV-Lk-E2a" secondAttribute="trailing" id="tzT-5O-w7Q"/>
<constraint firstAttribute="bottom" secondItem="Qz6-OH-kIb" secondAttribute="bottom" constant="30" id="vyB-w0-TFK"/>
</constraints>
<variation key="default">
<mask key="subviews">
......@@ -4917,6 +4934,7 @@
<outlet property="emptyLabel" destination="VW1-eq-kSh" id="Lva-nM-uXu"/>
<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="tableView" destination="YVv-xm-y2W" id="kle-or-Ckg"/>
</connections>
</viewController>
......
......@@ -15,6 +15,7 @@ import SwiftEventBus
@IBOutlet weak var emptyView: UIView!
@IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabel: UILabel!
@IBOutlet weak var submitButton: UIButton!
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
public var smCoupons:Array<swiftApi.CouponItemModel> = []
......@@ -76,10 +77,28 @@ import SwiftEventBus
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
// tableView.contentInset.top = 30
// TODO: Change
tableView.contentInset.bottom = 115
emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!"
submitButton.setTitle("Συνδύασε τις προσφορές σε ένα κουπόνι", for: .normal)
submitButton.setTitleColor(.white, for: .normal)
submitButton.layer.cornerRadius = 16.0
// submitButton.backgroundColor = UIColor(red: 0.05, green: 0.65, blue: 0.00, alpha: 1.00)
submitButton.backgroundColor = UIColor(rgb: 0x9D9D9C)
submitButton.isEnabled = false
// submitButton.frame = CGRect(x: 0.0, y: 0.0, width: submitButton.intrinsicContentSize.width, height: 50)
// submitButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 25, bottom: 0, right: 25)
// Fix width for ipad
if UIDevice.current.userInterfaceIdiom == .pad {
// iPad
submitButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 18)
// submitButton.widthAnchor.constraint(equalToConstant: 250).isActive = true
} else {
// not iPad (iPhone, mac, tv, carPlay, unspecified)
submitButton.titleLabel?.font = UIFont(name: "PeridotPE-SBold", size: 16)
// submitButton.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.6).isActive = true
}
}
public override func viewWillAppear(_ animated: Bool) {
......@@ -117,6 +136,8 @@ import SwiftEventBus
smCouponsSelected = []
}
handleSubmitButtonUI()
// Reload the SM Coupons section only
tableView.reloadSections(IndexSet(integer: 1), with: .automatic)
}
......@@ -147,6 +168,27 @@ import SwiftEventBus
tableView.reloadRows(at: [indexPath], with: .automatic) // Reload the specific row
}
}
handleSubmitButtonUI()
}
func handleSubmitButtonUI() {
if (self.smCouponsSelected.count > 0) {
submitButton.backgroundColor = UIColor(rgb: 0x0EA600)
submitButton.isEnabled = true
} else {
submitButton.backgroundColor = UIColor(rgb: 0x9D9D9C)
submitButton.isEnabled = false
}
}
// MARK: - Actions
@IBAction func submitButtonAction(_ sender: Any) {
// let smCouponsString = self.smCouponsSelected.map { $0.coupon ?? "" }.joined(separator: ",")
// swiftApi().logTrackersEvent("click", ("UnifySMCoupons:" + (smCouponsString)))
// TODO: Add action
}
}
......