Manos Chorianopoulos

fix CouponsViewController empty view accessibility

......@@ -17,6 +17,7 @@ import SwiftEventBus
@IBOutlet weak var emptyLabel: UILabel!
public var coupons:Array<swiftApi.CouponItemModel> = []
var showEmptyView: Bool = false;
public override func viewDidLoad() {
super.viewDidLoad()
......@@ -84,11 +85,13 @@ import SwiftEventBus
// MARK: - Functions
func handleEmptyView() {
if (self.coupons.count == 0) {
self.emptyView.isHidden = false
self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
// self.emptyView.isHidden = false
// self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height
self.showEmptyView = true
} else {
self.emptyView.isHidden = true
self.emptyViewHeight.constant = 0
// self.emptyView.isHidden = true
// self.emptyViewHeight.constant = 0
self.showEmptyView = false
}
}
......@@ -122,43 +125,72 @@ import SwiftEventBus
extension CouponsViewController: UITableViewDelegate, UITableViewDataSource{
public func numberOfSections(in tableView: UITableView) -> Int {
return 1
return 2
}
public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return self.coupons.count
if (section == 0) {
return self.coupons.count
} else if (section == 1) {
if (self.showEmptyView == true) {
return 1
} else {
return 0
}
} else {
return 0
}
}
public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 130.0 + 8.0
if (indexPath.section == 0) {
return 130.0 + 8.0
} else if (indexPath.section == 1) {
if (self.showEmptyView == true) {
return UITableView.automaticDimension
} else {
return 0.0
}
} else {
return 0.0
}
// return UITableViewAutomaticDimension
}
public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: coupons[indexPath.row])
return cell
if (indexPath.section == 0) {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell
cell.configureCell(coupon: coupons[indexPath.row])
return cell
} else {
let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsEmptyViewTableViewCellId", for: indexPath) as! CouponsEmptyViewTableViewCell
return cell
}
}
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if (indexPath.section == 0) {
// SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row])
// Logs
let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
swiftApi().logTrackersEvent("click", ("Coupon:" + (couponSetData?.name ?? "")))
// SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row])
// Logs
let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data
print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? ""))
print("Coupon Name clicked: " + (couponSetData?.name ?? ""))
print("Coupon Description clicked: " + (couponSetData?.short_description ?? ""))
print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? ""))
swiftApi().logTrackersEvent("click", ("Coupon:" + (couponSetData?.name ?? "")))
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
vc.coupon = coupons[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self))
let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController
vc.coupon = coupons[indexPath.row]
self.navigationController?.pushViewController(vc, animated: true)
} else if (indexPath.section == 1) {
// Do nothing
}
}
}
......
......@@ -158,17 +158,17 @@
</connections>
</tableViewCell>
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" indentationWidth="0.0" reuseIdentifier="CouponsEmptyViewTableViewCellId" id="Q8g-pg-5xK" customClass="CouponsEmptyViewTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target">
<rect key="frame" x="0.0" y="114.5" width="414" height="44"/>
<rect key="frame" x="0.0" y="114.5" width="414" height="18.5"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Q8g-pg-5xK" id="JYq-d6-s3q">
<rect key="frame" x="0.0" y="0.0" width="414" height="44"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="18.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="z9z-j6-tcA">
<rect key="frame" x="20" y="21.5" width="374" height="0.0"/>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z9z-j6-tcA">
<rect key="frame" x="0.0" y="0.0" width="414" height="18.5"/>
<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="c0T-sg-38i">
<rect key="frame" x="20" y="0.0" width="38.5" height="18.5"/>
<rect key="frame" x="20" y="0.0" 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"/>
......@@ -184,6 +184,12 @@
</view>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="z9z-j6-tcA" firstAttribute="leading" secondItem="JYq-d6-s3q" secondAttribute="leading" id="53J-AG-7CH"/>
<constraint firstAttribute="bottom" secondItem="z9z-j6-tcA" secondAttribute="bottom" id="Ztu-bS-fcn"/>
<constraint firstItem="z9z-j6-tcA" firstAttribute="top" secondItem="JYq-d6-s3q" secondAttribute="top" id="Zwf-CZ-Fdw"/>
<constraint firstAttribute="trailing" secondItem="z9z-j6-tcA" secondAttribute="trailing" id="vBa-MC-bSw"/>
</constraints>
</tableViewCellContentView>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<connections>
......@@ -232,6 +238,7 @@
<variation key="default">
<mask key="subviews">
<exclude reference="5rB-1e-ygb"/>
<exclude reference="pdh-2h-vVS"/>
</mask>
</variation>
</view>
......@@ -4505,6 +4512,7 @@
<outlet property="dotRight" destination="lSo-ay-XsD" id="E2j-PC-Gb3"/>
<outlet property="dotRightHeight" destination="HV6-Q8-2aO" id="U9Z-Sh-b8t"/>
<outlet property="dotRightWidth" destination="15e-YJ-Pxi" id="ti6-L4-Nec"/>
<outlet property="historyButton" destination="nmF-FM-3Dl" id="ePm-nD-CZR"/>
<outlet property="historyButtonImage" destination="Dhs-5p-kfA" id="cek-Li-bJt"/>
<outlet property="sectionTitleLabel" destination="2hO-dB-t2z" id="lsu-hO-JQE"/>
</connections>
......