Manos Chorianopoulos

add UnifiedCouponsVC empty view

......@@ -3180,13 +3180,13 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="4" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jeN-eT-NTP">
<rect key="frame" x="292.5" y="25.5" width="81.5" height="14"/>
<rect key="frame" x="292.5" y="25" width="81.5" height="15"/>
<fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="12"/>
<color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="wCr-ft-C3l">
<rect key="frame" x="119" y="35.5" width="255" height="14"/>
<rect key="frame" x="119" y="34.5" width="255" height="15"/>
<fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="12"/>
<color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
......@@ -3241,16 +3241,37 @@
<outlet property="delegate" destination="3uV-Le-crf" id="3Mq-HR-Udb"/>
</connections>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="U5I-GH-geX">
<rect key="frame" x="20" y="0.0" width="374" height="0.0"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="VW1-eq-kSh">
<rect key="frame" x="0.0" y="30" width="374" height="18.5"/>
<fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="15"/>
<color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="VW1-eq-kSh" secondAttribute="trailing" id="CUA-sb-5E4"/>
<constraint firstAttribute="height" id="Ooe-1Z-EJ8"/>
<constraint firstItem="VW1-eq-kSh" firstAttribute="top" secondItem="U5I-GH-geX" secondAttribute="top" constant="30" id="WZg-A7-B3I"/>
<constraint firstItem="VW1-eq-kSh" firstAttribute="leading" secondItem="U5I-GH-geX" secondAttribute="leading" id="WjY-2G-56p"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94901960780000005" green="0.94901960780000005" blue="0.95294117649999999" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="U5I-GH-geX" firstAttribute="top" secondItem="BQW-dX-NwZ" secondAttribute="top" id="0Sl-He-idh"/>
<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 firstAttribute="bottom" secondItem="QKV-Lk-E2a" secondAttribute="bottom" id="IeT-AJ-BlK"/>
<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"/>
</constraints>
<variation key="default">
......@@ -3271,6 +3292,9 @@
</view>
<connections>
<outlet property="backgroundImage" destination="QKV-Lk-E2a" id="sWD-ra-Ek8"/>
<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="tableView" destination="YVv-xm-y2W" id="kle-or-Ckg"/>
</connections>
</viewController>
......
......@@ -12,6 +12,9 @@ import SwiftEventBus
@objc public class UnifiedCouponsViewController: UIViewController {
@IBOutlet weak var backgroundImage: UIImageView!
@IBOutlet weak var tableView: UITableView!
@IBOutlet weak var emptyView: UIView!
@IBOutlet weak var emptyViewHeight: NSLayoutConstraint!
@IBOutlet weak var emptyLabel: UILabel!
public var unifiedCoupons:Array<swiftApi.UnifiedCouponModel> = []
......@@ -25,6 +28,14 @@ import SwiftEventBus
DispatchQueue.main.async {
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.tableView.reloadData()
if (self.unifiedCoupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
}
}
......@@ -40,6 +51,8 @@ import SwiftEventBus
// tableView.layer.cornerRadius = 30
// tableView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius
tableView.contentInset.top = 30
emptyLabel.text = "Αυτήν τη στιγμή δεν έχεις κάποιο ενεργό κουπόνι. Στην ενότητα FOR YOU μπορείς να βρεις κουπόνια αποκλειστικά για σένα!"
}
public override func viewWillAppear(_ animated: Bool) {
......@@ -49,6 +62,14 @@ import SwiftEventBus
self.unifiedCoupons = swiftApi().getUnifiedCouponList()
self.tableView.reloadData()
if (self.unifiedCoupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
self.navigationController?.hideHairline()
}
......