Showing
2 changed files
with
58 additions
and
3 deletions
... | @@ -20,6 +20,7 @@ import UIKit | ... | @@ -20,6 +20,7 @@ import UIKit |
20 | @IBOutlet weak var expirationRedImage: UIImageView! | 20 | @IBOutlet weak var expirationRedImage: UIImageView! |
21 | @IBOutlet weak var expirationRedLabel: UILabel! | 21 | @IBOutlet weak var expirationRedLabel: UILabel! |
22 | 22 | ||
23 | + let smCouponsetsList = swiftApi().getCouponSetsDealsList() | ||
23 | 24 | ||
24 | // Variables for the view, image, and button | 25 | // Variables for the view, image, and button |
25 | var selectView: UIView! | 26 | var selectView: UIView! |
... | @@ -199,6 +200,14 @@ import UIKit | ... | @@ -199,6 +200,14 @@ import UIKit |
199 | // COUPON: coupon, expiration, discount, status | 200 | // COUPON: coupon, expiration, discount, status |
200 | // MERCHANT: _img_preview,_admin_name | 201 | // MERCHANT: _img_preview,_admin_name |
201 | 202 | ||
203 | + var couponSetData: swiftApi.CouponSetItemModel? | ||
204 | + for item in smCouponsetsList { | ||
205 | + if (item.uuid == coupon.couponset_uuid) { | ||
206 | + couponSetData = item | ||
207 | + break; | ||
208 | + } | ||
209 | + } | ||
210 | + | ||
202 | // // Add shadow | 211 | // // Add shadow |
203 | contentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor | 212 | contentView.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor |
204 | contentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) | 213 | contentView.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) |
... | @@ -306,12 +315,14 @@ import UIKit | ... | @@ -306,12 +315,14 @@ import UIKit |
306 | for merchant in merchantList { | 315 | for merchant in merchantList { |
307 | if (merchant._uuid == coupon.merchant_uuid) { | 316 | if (merchant._uuid == coupon.merchant_uuid) { |
308 | // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | 317 | // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) |
309 | - self.postImageURL = merchant._img_preview | 318 | +// self.postImageURL = merchant._img_preview |
310 | nameLabel.text = merchant._admin_name | 319 | nameLabel.text = merchant._admin_name |
311 | break; | 320 | break; |
312 | } | 321 | } |
313 | } | 322 | } |
314 | 323 | ||
324 | + self.postImageURL = couponSetData?.img_preview | ||
325 | + | ||
315 | // let priceFloat = Float(round(100 * (Float(coupon.discount ?? "0.0") ?? 0.0 )) / 100) | 326 | // let priceFloat = Float(round(100 * (Float(coupon.discount ?? "0.0") ?? 0.0 )) / 100) |
316 | // var priceString = "0" | 327 | // var priceString = "0" |
317 | // priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) | 328 | // priceString = String(format: "%.2f", priceFloat).replacingOccurrences(of: ".", with: ",", options: .literal, range: nil) |
... | @@ -325,6 +336,50 @@ import UIKit | ... | @@ -325,6 +336,50 @@ import UIKit |
325 | 336 | ||
326 | } | 337 | } |
327 | 338 | ||
339 | + func configureCell(coupon: swiftApi.CouponItemModel, isSMCoupon: Bool) { | ||
340 | +// COUPONSET: desc, img_preview, name, terms, merchant_uuid, discount_type, final_price | ||
341 | +// COUPON: coupon, expiration, discount, status | ||
342 | +// MERCHANT: _img_preview,_admin_name | ||
343 | + | ||
344 | + // Add shadow | ||
345 | + self.layer.shadowColor = UIColor(red: 0.00, green: 0.00, blue: 0.00, alpha: 0.2).cgColor | ||
346 | + self.layer.shadowOffset = CGSize(width: 0.0, height: 1.0) | ||
347 | + self.layer.shadowOpacity = 1.0 | ||
348 | + self.layer.shadowRadius = 1.0 | ||
349 | + | ||
350 | + let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() | ||
351 | + | ||
352 | + let couponSetData: swiftApi.CouponSetItemModel? = coupon.couponset_data | ||
353 | + | ||
354 | + nameLabel.text = "" | ||
355 | + | ||
356 | + // for merchant in merchantList { | ||
357 | + // // if (merchant._uuid == couponSetData?.merchant_uuid) { | ||
358 | + // if (merchant._uuid == coupon.merchant_uuid) { | ||
359 | + // // couponImage.load(link: merchant._img_preview, placeholder: UIImage(), cache: URLCache()) | ||
360 | + // self.postImageURL = merchant._img_preview | ||
361 | + // nameLabel.text = merchant._admin_name | ||
362 | + // break; | ||
363 | + // } | ||
364 | + // } | ||
365 | + | ||
366 | + let merchantDetails: swiftApi.MerchantModel? = coupon.merchant_details | ||
367 | + self.postImageURL = couponSetData?.img_preview | ||
368 | + nameLabel.text = merchantDetails?._admin_name | ||
369 | + | ||
370 | +// couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | ||
371 | +// nameLabel.text = couponSetData?.name ?? "" | ||
372 | + let discount = couponSetData?.discount_type == "value" ? ((coupon.discount ?? "") + "€") | ||
373 | + : couponSetData?.discount_type == "percentage" ? ((coupon.discount ?? "") + "%") | ||
374 | + : couponSetData?.discount_type == "plus_one" ? "1+1" | ||
375 | + : ((coupon.discount ?? "") + "€") | ||
376 | + dicountLabel.text = discount | ||
377 | + // let htmlText = couponSetData?.inner_text ?? "" | ||
378 | + // discriptionLabel.text = htmlText.htmlToString | ||
379 | + discriptionLabel.text = couponSetData?.inner_text ?? "" | ||
380 | + expirationLabel.text = "Ισχύει έως "+(coupon.expiration ?? "") | ||
381 | + } | ||
382 | + | ||
328 | // Configure the cell with visibility of the selectView, a selected state, and select Button Action | 383 | // Configure the cell with visibility of the selectView, a selected state, and select Button Action |
329 | func showSelectButton(isSelectViewVisible: Bool, isSelected: Bool, buttonAction: @escaping () -> Void) { | 384 | func showSelectButton(isSelectViewVisible: Bool, isSelected: Bool, buttonAction: @escaping () -> Void) { |
330 | self.isSelectViewVisible = isSelectViewVisible | 385 | self.isSelectViewVisible = isSelectViewVisible | ... | ... |
... | @@ -37,7 +37,7 @@ import SwiftEventBus | ... | @@ -37,7 +37,7 @@ import SwiftEventBus |
37 | 37 | ||
38 | DispatchQueue.main.async { | 38 | DispatchQueue.main.async { |
39 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() | 39 | self.unifiedCoupons = swiftApi().getUnifiedCouponList() |
40 | - // self.tableView.reloadData() | 40 | +// self.tableView.reloadData() |
41 | // Reload the Unified Coupons section only | 41 | // Reload the Unified Coupons section only |
42 | self.tableView.reloadSections(IndexSet(integer: 0), with: .automatic) | 42 | self.tableView.reloadSections(IndexSet(integer: 0), with: .automatic) |
43 | 43 | ||
... | @@ -307,7 +307,7 @@ extension UnifiedCouponsViewController: UITableViewDelegate, UITableViewDataSour | ... | @@ -307,7 +307,7 @@ extension UnifiedCouponsViewController: UITableViewDelegate, UITableViewDataSour |
307 | let isCouponSelected = self.smCouponsSelected.contains { $0.coupon == currentCoupon.coupon } | 307 | let isCouponSelected = self.smCouponsSelected.contains { $0.coupon == currentCoupon.coupon } |
308 | 308 | ||
309 | let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell | 309 | let cell = tableView.dequeueReusableCell(withIdentifier: "CouponsTableViewCellId", for: indexPath) as! CouponsTableViewCell |
310 | - cell.configureCell(coupon: smCoupons[indexPath.row]) | 310 | + cell.configureCell(coupon: smCoupons[indexPath.row], isSMCoupon: true) |
311 | cell.showSelectButton(isSelectViewVisible: true, isSelected: isCouponSelected) { | 311 | cell.showSelectButton(isSelectViewVisible: true, isSelected: isCouponSelected) { |
312 | self.handleSelectCouponAction(indexPath: indexPath) | 312 | self.handleSelectCouponAction(indexPath: indexPath) |
313 | } | 313 | } | ... | ... |
-
Please register or login to post a comment