Manos Chorianopoulos

add CouponsVC empty text

......@@ -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>
......
......@@ -12,6 +12,9 @@ import SwiftEventBus
@objc public class CouponsViewController: 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 coupons:Array<swiftApi.CouponItemModel> = []
......@@ -34,6 +37,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) {
......@@ -43,6 +48,14 @@ import SwiftEventBus
self.coupons = swiftApi().getCouponList()
self.tableView.reloadData()
if (self.coupons.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()
}
......@@ -64,6 +77,14 @@ import SwiftEventBus
DispatchQueue.main.async {
SwiftEventBus.post("coupons_fetched")
self.tableView.reloadData()
if (self.coupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
}
}
} else {
self.coupons = []
......
......@@ -162,14 +162,35 @@
<outlet property="delegate" destination="UpJ-ey-hJ5" id="lXT-i0-gPS"/>
</connections>
</tableView>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="pdh-2h-vVS">
<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="xtj-PD-xx6">
<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="height" id="CMi-78-cNv"/>
<constraint firstAttribute="trailing" secondItem="xtj-PD-xx6" secondAttribute="trailing" id="Y5v-ib-fY7"/>
<constraint firstItem="xtj-PD-xx6" firstAttribute="leading" secondItem="pdh-2h-vVS" secondAttribute="leading" id="i0h-zC-keQ"/>
<constraint firstItem="xtj-PD-xx6" firstAttribute="top" secondItem="pdh-2h-vVS" secondAttribute="top" constant="30" id="lR8-Ro-Dx1"/>
</constraints>
</view>
</subviews>
<color key="backgroundColor" red="0.94901960784313721" green="0.94901960784313721" blue="0.95294117647058818" alpha="1" colorSpace="calibratedRGB"/>
<constraints>
<constraint firstItem="pdh-2h-vVS" firstAttribute="top" secondItem="FoX-v7-tak" secondAttribute="top" id="7Sy-Ik-hSl"/>
<constraint firstItem="KhH-tg-FBN" firstAttribute="top" secondItem="FoX-v7-tak" secondAttribute="top" constant="2" id="DSl-zy-v7y"/>
<constraint firstAttribute="bottom" secondItem="KhH-tg-FBN" secondAttribute="bottom" id="Dk8-ID-x8T"/>
<constraint firstItem="5rB-1e-ygb" firstAttribute="top" secondItem="FoX-v7-tak" secondAttribute="top" id="R4t-dF-JMv"/>
<constraint firstItem="5rB-1e-ygb" firstAttribute="leading" secondItem="FoX-v7-tak" secondAttribute="leading" id="Yyu-T7-XaB"/>
<constraint firstAttribute="trailing" secondItem="pdh-2h-vVS" secondAttribute="trailing" constant="20" id="b5E-7L-rab"/>
<constraint firstAttribute="trailing" secondItem="5rB-1e-ygb" secondAttribute="trailing" id="h1f-x6-eGo"/>
<constraint firstItem="pdh-2h-vVS" firstAttribute="leading" secondItem="FoX-v7-tak" secondAttribute="leading" constant="20" id="kkR-L1-aiu"/>
<constraint firstAttribute="bottom" secondItem="5rB-1e-ygb" secondAttribute="bottom" id="mFa-RR-qQj"/>
<constraint firstItem="KhH-tg-FBN" firstAttribute="leading" secondItem="FoX-v7-tak" secondAttribute="leading" id="oXI-zv-0nB"/>
<constraint firstAttribute="trailing" secondItem="KhH-tg-FBN" secondAttribute="trailing" id="tAn-PH-mZ8"/>
......@@ -193,6 +214,9 @@
<navigationItem key="navigationItem" id="mr8-UG-4rX"/>
<connections>
<outlet property="backgroundImage" destination="5rB-1e-ygb" id="Nxt-Pj-vLK"/>
<outlet property="emptyLabel" destination="xtj-PD-xx6" id="9JM-Kf-e0g"/>
<outlet property="emptyView" destination="pdh-2h-vVS" id="E7E-54-sSD"/>
<outlet property="emptyViewHeight" destination="CMi-78-cNv" id="IqX-OJ-1Pb"/>
<outlet property="tableView" destination="KhH-tg-FBN" id="EJH-sF-YPj"/>
</connections>
</viewController>
......