Showing
2 changed files
with
71 additions
and
31 deletions
... | @@ -17,6 +17,7 @@ import SwiftEventBus | ... | @@ -17,6 +17,7 @@ import SwiftEventBus |
17 | @IBOutlet weak var emptyLabel: UILabel! | 17 | @IBOutlet weak var emptyLabel: UILabel! |
18 | 18 | ||
19 | public var coupons:Array<swiftApi.CouponItemModel> = [] | 19 | public var coupons:Array<swiftApi.CouponItemModel> = [] |
20 | + var showEmptyView: Bool = false; | ||
20 | 21 | ||
21 | public override func viewDidLoad() { | 22 | public override func viewDidLoad() { |
22 | super.viewDidLoad() | 23 | super.viewDidLoad() |
... | @@ -84,11 +85,13 @@ import SwiftEventBus | ... | @@ -84,11 +85,13 @@ import SwiftEventBus |
84 | // MARK: - Functions | 85 | // MARK: - Functions |
85 | func handleEmptyView() { | 86 | func handleEmptyView() { |
86 | if (self.coupons.count == 0) { | 87 | if (self.coupons.count == 0) { |
87 | - self.emptyView.isHidden = false | 88 | + // self.emptyView.isHidden = false |
88 | - self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height | 89 | + // self.emptyViewHeight.constant = self.emptyView.intrinsicContentSize.height |
90 | + self.showEmptyView = true | ||
89 | } else { | 91 | } else { |
90 | - self.emptyView.isHidden = true | 92 | + // self.emptyView.isHidden = true |
91 | - self.emptyViewHeight.constant = 0 | 93 | + // self.emptyViewHeight.constant = 0 |
94 | + self.showEmptyView = false | ||
92 | } | 95 | } |
93 | } | 96 | } |
94 | 97 | ||
... | @@ -122,43 +125,72 @@ import SwiftEventBus | ... | @@ -122,43 +125,72 @@ import SwiftEventBus |
122 | extension CouponsViewController: UITableViewDelegate, UITableViewDataSource{ | 125 | extension CouponsViewController: UITableViewDelegate, UITableViewDataSource{ |
123 | 126 | ||
124 | public func numberOfSections(in tableView: UITableView) -> Int { | 127 | public func numberOfSections(in tableView: UITableView) -> Int { |
125 | - return 1 | 128 | + return 2 |
126 | } | 129 | } |
127 | 130 | ||
128 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { | 131 | public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { |
129 | - return self.coupons.count | 132 | + if (section == 0) { |
133 | + return self.coupons.count | ||
134 | + } else if (section == 1) { | ||
135 | + if (self.showEmptyView == true) { | ||
136 | + return 1 | ||
137 | + } else { | ||
138 | + return 0 | ||
139 | + } | ||
140 | + } else { | ||
141 | + return 0 | ||
142 | + } | ||
130 | } | 143 | } |
131 | 144 | ||
132 | public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { | 145 | public func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { |
133 | - return 130.0 + 8.0 | 146 | + if (indexPath.section == 0) { |
147 | + return 130.0 + 8.0 | ||
148 | + } else if (indexPath.section == 1) { | ||
149 | + if (self.showEmptyView == true) { | ||
150 | + return UITableView.automaticDimension | ||
151 | + } else { | ||
152 | + return 0.0 | ||
153 | + } | ||
154 | + } else { | ||
155 | + return 0.0 | ||
156 | + } | ||
134 | // return UITableViewAutomaticDimension | 157 | // return UITableViewAutomaticDimension |
135 | } | 158 | } |
136 | 159 | ||
137 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { | 160 | public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { |
138 | - let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell | 161 | + if (indexPath.section == 0) { |
139 | - | 162 | + let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell |
140 | - cell.configureCell(coupon: coupons[indexPath.row]) | 163 | + |
141 | - | 164 | + cell.configureCell(coupon: coupons[indexPath.row]) |
142 | - return cell | 165 | + |
166 | + return cell | ||
167 | + } else { | ||
168 | + let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsEmptyViewTableViewCellId", for: indexPath) as! CouponsEmptyViewTableViewCell | ||
169 | + return cell | ||
170 | + } | ||
143 | } | 171 | } |
144 | 172 | ||
145 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { | 173 | public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { |
174 | + if (indexPath.section == 0) { | ||
175 | + // SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row]) | ||
176 | + | ||
177 | + // Logs | ||
178 | + let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data | ||
179 | + print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? "")) | ||
180 | + print("Coupon Name clicked: " + (couponSetData?.name ?? "")) | ||
181 | + print("Coupon Description clicked: " + (couponSetData?.short_description ?? "")) | ||
182 | + print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? "")) | ||
183 | + | ||
184 | + swiftApi().logTrackersEvent("click", ("Coupon:" + (couponSetData?.name ?? ""))) | ||
146 | 185 | ||
147 | - // SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row]) | 186 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
148 | - | 187 | + let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController |
149 | - // Logs | 188 | + vc.coupon = coupons[indexPath.row] |
150 | - let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data | 189 | + self.navigationController?.pushViewController(vc, animated: true) |
151 | - print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? "")) | ||
152 | - print("Coupon Name clicked: " + (couponSetData?.name ?? "")) | ||
153 | - print("Coupon Description clicked: " + (couponSetData?.short_description ?? "")) | ||
154 | - print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? "")) | ||
155 | - | ||
156 | - swiftApi().logTrackersEvent("click", ("Coupon:" + (couponSetData?.name ?? ""))) | ||
157 | 190 | ||
158 | - let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 191 | + } else if (indexPath.section == 1) { |
159 | - let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController | 192 | + // Do nothing |
160 | - vc.coupon = coupons[indexPath.row] | 193 | + } |
161 | - self.navigationController?.pushViewController(vc, animated: true) | ||
162 | } | 194 | } |
163 | 195 | ||
164 | } | 196 | } | ... | ... |
... | @@ -158,17 +158,17 @@ | ... | @@ -158,17 +158,17 @@ |
158 | </connections> | 158 | </connections> |
159 | </tableViewCell> | 159 | </tableViewCell> |
160 | <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" indentationWidth="0.0" reuseIdentifier="CouponsEmptyViewTableViewCellId" id="Q8g-pg-5xK" customClass="CouponsEmptyViewTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target"> | 160 | <tableViewCell clipsSubviews="YES" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" selectionStyle="none" indentationWidth="0.0" reuseIdentifier="CouponsEmptyViewTableViewCellId" id="Q8g-pg-5xK" customClass="CouponsEmptyViewTableViewCell" customModule="SwiftWarplyFramework" customModuleProvider="target"> |
161 | - <rect key="frame" x="0.0" y="114.5" width="414" height="44"/> | 161 | + <rect key="frame" x="0.0" y="114.5" width="414" height="18.5"/> |
162 | <autoresizingMask key="autoresizingMask"/> | 162 | <autoresizingMask key="autoresizingMask"/> |
163 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Q8g-pg-5xK" id="JYq-d6-s3q"> | 163 | <tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" preservesSuperviewLayoutMargins="YES" insetsLayoutMarginsFromSafeArea="NO" tableViewCell="Q8g-pg-5xK" id="JYq-d6-s3q"> |
164 | - <rect key="frame" x="0.0" y="0.0" width="414" height="44"/> | 164 | + <rect key="frame" x="0.0" y="0.0" width="414" height="18.5"/> |
165 | <autoresizingMask key="autoresizingMask"/> | 165 | <autoresizingMask key="autoresizingMask"/> |
166 | <subviews> | 166 | <subviews> |
167 | - <view contentMode="scaleToFill" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="z9z-j6-tcA"> | 167 | + <view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="z9z-j6-tcA"> |
168 | - <rect key="frame" x="20" y="21.5" width="374" height="0.0"/> | 168 | + <rect key="frame" x="0.0" y="0.0" width="414" height="18.5"/> |
169 | <subviews> | 169 | <subviews> |
170 | <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"> | 170 | <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"> |
171 | - <rect key="frame" x="20" y="0.0" width="38.5" height="18.5"/> | 171 | + <rect key="frame" x="20" y="0.0" width="374" height="18.5"/> |
172 | <fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="15"/> | 172 | <fontDescription key="fontDescription" name="PeridotPE-Regular" family="Peridot PE" pointSize="15"/> |
173 | <color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/> | 173 | <color key="textColor" red="0.12941176469999999" green="0.12941176469999999" blue="0.12941176469999999" alpha="1" colorSpace="calibratedRGB"/> |
174 | <nil key="highlightedColor"/> | 174 | <nil key="highlightedColor"/> |
... | @@ -184,6 +184,12 @@ | ... | @@ -184,6 +184,12 @@ |
184 | </view> | 184 | </view> |
185 | </subviews> | 185 | </subviews> |
186 | <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | 186 | <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> |
187 | + <constraints> | ||
188 | + <constraint firstItem="z9z-j6-tcA" firstAttribute="leading" secondItem="JYq-d6-s3q" secondAttribute="leading" id="53J-AG-7CH"/> | ||
189 | + <constraint firstAttribute="bottom" secondItem="z9z-j6-tcA" secondAttribute="bottom" id="Ztu-bS-fcn"/> | ||
190 | + <constraint firstItem="z9z-j6-tcA" firstAttribute="top" secondItem="JYq-d6-s3q" secondAttribute="top" id="Zwf-CZ-Fdw"/> | ||
191 | + <constraint firstAttribute="trailing" secondItem="z9z-j6-tcA" secondAttribute="trailing" id="vBa-MC-bSw"/> | ||
192 | + </constraints> | ||
187 | </tableViewCellContentView> | 193 | </tableViewCellContentView> |
188 | <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> | 194 | <color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/> |
189 | <connections> | 195 | <connections> |
... | @@ -232,6 +238,7 @@ | ... | @@ -232,6 +238,7 @@ |
232 | <variation key="default"> | 238 | <variation key="default"> |
233 | <mask key="subviews"> | 239 | <mask key="subviews"> |
234 | <exclude reference="5rB-1e-ygb"/> | 240 | <exclude reference="5rB-1e-ygb"/> |
241 | + <exclude reference="pdh-2h-vVS"/> | ||
235 | </mask> | 242 | </mask> |
236 | </variation> | 243 | </variation> |
237 | </view> | 244 | </view> |
... | @@ -4505,6 +4512,7 @@ | ... | @@ -4505,6 +4512,7 @@ |
4505 | <outlet property="dotRight" destination="lSo-ay-XsD" id="E2j-PC-Gb3"/> | 4512 | <outlet property="dotRight" destination="lSo-ay-XsD" id="E2j-PC-Gb3"/> |
4506 | <outlet property="dotRightHeight" destination="HV6-Q8-2aO" id="U9Z-Sh-b8t"/> | 4513 | <outlet property="dotRightHeight" destination="HV6-Q8-2aO" id="U9Z-Sh-b8t"/> |
4507 | <outlet property="dotRightWidth" destination="15e-YJ-Pxi" id="ti6-L4-Nec"/> | 4514 | <outlet property="dotRightWidth" destination="15e-YJ-Pxi" id="ti6-L4-Nec"/> |
4515 | + <outlet property="historyButton" destination="nmF-FM-3Dl" id="ePm-nD-CZR"/> | ||
4508 | <outlet property="historyButtonImage" destination="Dhs-5p-kfA" id="cek-Li-bJt"/> | 4516 | <outlet property="historyButtonImage" destination="Dhs-5p-kfA" id="cek-Li-bJt"/> |
4509 | <outlet property="sectionTitleLabel" destination="2hO-dB-t2z" id="lsu-hO-JQE"/> | 4517 | <outlet property="sectionTitleLabel" destination="2hO-dB-t2z" id="lsu-hO-JQE"/> |
4510 | </connections> | 4518 | </connections> | ... | ... |
-
Please register or login to post a comment