Showing
5 changed files
with
68 additions
and
11 deletions
No preview for this file type
| ... | @@ -22,7 +22,11 @@ import AVFoundation | ... | @@ -22,7 +22,11 @@ import AVFoundation |
| 22 | @IBOutlet weak var merchantDescrTextView: UnselectableTappableTextView! | 22 | @IBOutlet weak var merchantDescrTextView: UnselectableTappableTextView! |
| 23 | @IBOutlet weak var merchantDescrTextViewHeight: NSLayoutConstraint! | 23 | @IBOutlet weak var merchantDescrTextViewHeight: NSLayoutConstraint! |
| 24 | @IBOutlet weak var merchantDescrTextViewTopSpace: NSLayoutConstraint! | 24 | @IBOutlet weak var merchantDescrTextViewTopSpace: NSLayoutConstraint! |
| 25 | + @IBOutlet weak var couponCodeLabel: UILabel! | ||
| 26 | + @IBOutlet weak var couponCodeLabelHeight: NSLayoutConstraint! | ||
| 25 | @IBOutlet weak var couponView: UIView! | 27 | @IBOutlet weak var couponView: UIView! |
| 28 | + @IBOutlet weak var couponViewTopSpace: NSLayoutConstraint! | ||
| 29 | + @IBOutlet weak var couponViewHeight: NSLayoutConstraint! | ||
| 26 | @IBOutlet weak var couponNumberLabel: CopyableLabel! | 30 | @IBOutlet weak var couponNumberLabel: CopyableLabel! |
| 27 | @IBOutlet weak var barcodeImage: UIImageView! | 31 | @IBOutlet weak var barcodeImage: UIImageView! |
| 28 | @IBOutlet weak var barcodeImageHeight: NSLayoutConstraint! | 32 | @IBOutlet weak var barcodeImageHeight: NSLayoutConstraint! |
| ... | @@ -59,6 +63,7 @@ import AVFoundation | ... | @@ -59,6 +63,7 @@ import AVFoundation |
| 59 | 63 | ||
| 60 | public var coupon: swiftApi.CouponItemModel? | 64 | public var coupon: swiftApi.CouponItemModel? |
| 61 | public var isFromWallet: Bool? = false | 65 | public var isFromWallet: Bool? = false |
| 66 | + public var isMarket: Bool? = false | ||
| 62 | 67 | ||
| 63 | public override func viewDidLoad() { | 68 | public override func viewDidLoad() { |
| 64 | super.viewDidLoad() | 69 | super.viewDidLoad() |
| ... | @@ -95,17 +100,31 @@ import AVFoundation | ... | @@ -95,17 +100,31 @@ import AVFoundation |
| 95 | // topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR) | 100 | // topBorderLine.heightAnchor.constraint(equalTo: topBorderLine.widthAnchor, multiplier: 1/aspectR) |
| 96 | // ]) | 101 | // ]) |
| 97 | 102 | ||
| 98 | - // COUPONSET: desc, img_preview, name, terms | 103 | + // COUPONSET: description, img_preview, name, terms |
| 99 | // COUPON: coupon, expiration, discount, status | 104 | // COUPON: coupon, expiration, discount, status |
| 100 | 105 | ||
| 106 | + // OLD COUPON KEYS: coupon, expiration, discount, status | ||
| 107 | + // NEW COUPON KEYS (from couponset): inner_text, merchant_uuid | ||
| 108 | + // MISSING KEYS (from couponset): img_preview, name, short_description, terms | ||
| 109 | + | ||
| 101 | let couponSetData: swiftApi.CouponSetItemModel? = coupon?.couponset_data | 110 | let couponSetData: swiftApi.CouponSetItemModel? = coupon?.couponset_data |
| 102 | 111 | ||
| 112 | + if (isMarket == true) { | ||
| 113 | + couponImage.load(link: coupon?.image ?? "", placeholder: UIImage(), cache: URLCache()) | ||
| 114 | + } else { | ||
| 103 | couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | 115 | couponImage.load(link: couponSetData?.img_preview ?? "", placeholder: UIImage(), cache: URLCache()) |
| 116 | + } | ||
| 117 | + | ||
| 104 | couponImage.contentMode = .scaleAspectFill | 118 | couponImage.contentMode = .scaleAspectFill |
| 105 | couponImageHeight.constant = 255 //230 // 253 // self.uiscreen.height * 0.25 | 119 | couponImageHeight.constant = 255 //230 // 253 // self.uiscreen.height * 0.25 |
| 106 | 120 | ||
| 121 | + if (isMarket == true) { | ||
| 122 | + nameLabel.text = coupon?.name ?? "" | ||
| 123 | + discriptionLabel.text = coupon?.short_description ?? "" | ||
| 124 | + } else { | ||
| 107 | nameLabel.text = couponSetData?.name ?? "" | 125 | nameLabel.text = couponSetData?.name ?? "" |
| 108 | discriptionLabel.text = couponSetData?.short_description ?? "" | 126 | discriptionLabel.text = couponSetData?.short_description ?? "" |
| 127 | + } | ||
| 109 | 128 | ||
| 110 | merchantDescrTextView.text = "" | 129 | merchantDescrTextView.text = "" |
| 111 | merchantDescrTextViewTopSpace.constant = CGFloat(0) | 130 | merchantDescrTextViewTopSpace.constant = CGFloat(0) |
| ... | @@ -114,9 +133,15 @@ import AVFoundation | ... | @@ -114,9 +133,15 @@ import AVFoundation |
| 114 | couponCodeLabelTopSpace.constant = CGFloat(35) | 133 | couponCodeLabelTopSpace.constant = CGFloat(35) |
| 115 | 134 | ||
| 116 | let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() | 135 | let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() |
| 136 | + var merchantUuid: String = "" | ||
| 137 | + if (isMarket == true) { | ||
| 138 | + merchantUuid = coupon?.merchant_uuid ?? "" | ||
| 139 | + } else { | ||
| 140 | + merchantUuid = couponSetData?.merchant_uuid ?? "" | ||
| 141 | + } | ||
| 117 | 142 | ||
| 118 | for merchant in merchantList { | 143 | for merchant in merchantList { |
| 119 | - if (merchant._uuid == couponSetData?.merchant_uuid) { | 144 | + if (merchant._uuid == merchantUuid) { |
| 120 | let htmlMerchDescrText = merchant._body | 145 | let htmlMerchDescrText = merchant._body |
| 121 | 146 | ||
| 122 | if (htmlMerchDescrText != "") { | 147 | if (htmlMerchDescrText != "") { |
| ... | @@ -146,6 +171,25 @@ import AVFoundation | ... | @@ -146,6 +171,25 @@ import AVFoundation |
| 146 | couponNumberLabel.text = coupon?.coupon ?? "" | 171 | couponNumberLabel.text = coupon?.coupon ?? "" |
| 147 | couponView.frame = CGRect(x: 0.0, y: 0.0, width: couponView.intrinsicContentSize.width, height: 55) | 172 | couponView.frame = CGRect(x: 0.0, y: 0.0, width: couponView.intrinsicContentSize.width, height: 55) |
| 148 | 173 | ||
| 174 | + if (isMarket == true) { | ||
| 175 | + couponCodeLabel.isHidden = true | ||
| 176 | + couponCodeLabelHeight.constant = CGFloat(0) | ||
| 177 | + couponCodeLabelTopSpace.constant = CGFloat(0) | ||
| 178 | + | ||
| 179 | + couponView.isHidden = true | ||
| 180 | + couponViewHeight.constant = CGFloat(0) | ||
| 181 | + couponViewTopSpace.constant = CGFloat(0) | ||
| 182 | + | ||
| 183 | + } else { | ||
| 184 | + couponCodeLabel.isHidden = false | ||
| 185 | + couponCodeLabelHeight.constant = CGFloat(20) | ||
| 186 | + couponCodeLabelTopSpace.constant = CGFloat(35) | ||
| 187 | + | ||
| 188 | + couponView.isHidden = true | ||
| 189 | + couponViewHeight.constant = CGFloat(55) | ||
| 190 | + couponViewTopSpace.constant = CGFloat(20) | ||
| 191 | + } | ||
| 192 | + | ||
| 149 | let barcodeString = constructBarcode() ?? "" | 193 | let barcodeString = constructBarcode() ?? "" |
| 150 | barcodeLabel.text = barcodeString | 194 | barcodeLabel.text = barcodeString |
| 151 | 195 | ||
| ... | @@ -283,7 +327,13 @@ import AVFoundation | ... | @@ -283,7 +327,13 @@ import AVFoundation |
| 283 | termsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5); | 327 | termsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5); |
| 284 | termsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8) | 328 | termsButton.imageView?.layer.transform = CATransform3DMakeScale(0.8, 0.8, 0.8) |
| 285 | 329 | ||
| 286 | - let htmlText = couponSetData?.terms ?? "" | 330 | + var htmlText = "" |
| 331 | + if (isMarket == true) { | ||
| 332 | + htmlText = coupon?.terms ?? "" | ||
| 333 | + } else { | ||
| 334 | + htmlText = couponSetData?.terms ?? "" | ||
| 335 | + } | ||
| 336 | + | ||
| 287 | termsTextView.attributedText = htmlText.htmlToAttributedString | 337 | termsTextView.attributedText = htmlText.htmlToAttributedString |
| 288 | termsTextView.font = UIFont(name: "PeridotPE-Regular", size: 14) | 338 | termsTextView.font = UIFont(name: "PeridotPE-Regular", size: 14) |
| 289 | termsTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00) | 339 | termsTextView.textColor = UIColor(red: 0.13, green: 0.13, blue: 0.13, alpha: 1.00) |
| ... | @@ -297,7 +347,9 @@ import AVFoundation | ... | @@ -297,7 +347,9 @@ import AVFoundation |
| 297 | 347 | ||
| 298 | // Uncomment if Barcode Section is active again | 348 | // Uncomment if Barcode Section is active again |
| 299 | // toggleTerms() | 349 | // toggleTerms() |
| 350 | + if (isMarket == false) { | ||
| 300 | toggleBarcode() | 351 | toggleBarcode() |
| 352 | + } | ||
| 301 | 353 | ||
| 302 | // Logs | 354 | // Logs |
| 303 | print("Coupon: " + (coupon?.coupon ?? "")) | 355 | print("Coupon: " + (coupon?.coupon ?? "")) | ... | ... |
This diff is collapsed. Click to expand it.
| ... | @@ -181,18 +181,19 @@ extension UnifiedCouponBarcodeViewController: UITableViewDelegate, UITableViewDa | ... | @@ -181,18 +181,19 @@ extension UnifiedCouponBarcodeViewController: UITableViewDelegate, UITableViewDa |
| 181 | // SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row]) | 181 | // SwiftEventBus.post("couponBarcodePressed", sender: coupons[indexPath.row]) |
| 182 | 182 | ||
| 183 | // Logs | 183 | // Logs |
| 184 | -// let couponSetData: swiftApi.CouponSetItemModel? = coupons[indexPath.row].couponset_data | 184 | +// let couponSetData: swiftApi.CouponSetItemModel? = self.coupon?._coupons[indexPath.row].couponset_data |
| 185 | -// print("Coupon clicked: " + (coupons[indexPath.row].coupon ?? "")) | 185 | +// print("Coupon clicked: " + (self.coupon?._coupons[indexPath.row].coupon ?? "")) |
| 186 | // print("Coupon Name clicked: " + (couponSetData?.name ?? "")) | 186 | // print("Coupon Name clicked: " + (couponSetData?.name ?? "")) |
| 187 | // print("Coupon Description clicked: " + (couponSetData?.short_description ?? "")) | 187 | // print("Coupon Description clicked: " + (couponSetData?.short_description ?? "")) |
| 188 | -// print("Coupon Expiration clicked: " + (coupons[indexPath.row].expiration ?? "")) | 188 | +// print("Coupon Expiration clicked: " + (self.coupon?._coupons[indexPath.row].expiration ?? "")) |
| 189 | 189 | ||
| 190 | -// swiftApi().logTrackersEvent("click", ("Coupon:" + (couponSetData?.name ?? ""))) | 190 | + swiftApi().logTrackersEvent("click", ("Coupon:" + (self.coupon?._coupons[indexPath.row].name ?? ""))) |
| 191 | 191 | ||
| 192 | -// let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) | 192 | + let storyboard = UIStoryboard(name: "Main", bundle: Bundle(for: MyEmptyClass.self)) |
| 193 | -// let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController | 193 | + let vc = storyboard.instantiateViewController(withIdentifier: "CouponBarcodeViewController") as! SwiftWarplyFramework.CouponBarcodeViewController |
| 194 | -// vc.coupon = self.coupon?._coupons[indexPath.row] | 194 | + vc.coupon = self.coupon?._coupons[indexPath.row] |
| 195 | -// self.navigationController?.pushViewController(vc, animated: true) | 195 | + vc.isMarket = true |
| 196 | + self.navigationController?.pushViewController(vc, animated: true) | ||
| 196 | } | 197 | } |
| 197 | 198 | ||
| 198 | public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | 199 | public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { | ... | ... |
| ... | @@ -610,6 +610,8 @@ public class swiftApi { | ... | @@ -610,6 +610,8 @@ public class swiftApi { |
| 610 | // Market Coupon | 610 | // Market Coupon |
| 611 | public let inner_text: String? | 611 | public let inner_text: String? |
| 612 | public let merchant_uuid: String? | 612 | public let merchant_uuid: String? |
| 613 | + public let short_description: String? | ||
| 614 | + public let terms: String? | ||
| 613 | 615 | ||
| 614 | 616 | ||
| 615 | public init(dictionary: [String: Any]) { | 617 | public init(dictionary: [String: Any]) { |
| ... | @@ -626,6 +628,8 @@ public class swiftApi { | ... | @@ -626,6 +628,8 @@ public class swiftApi { |
| 626 | // Market Coupon | 628 | // Market Coupon |
| 627 | self.inner_text = dictionary["inner_text"] as? String? ?? "" | 629 | self.inner_text = dictionary["inner_text"] as? String? ?? "" |
| 628 | self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? "" | 630 | self.merchant_uuid = dictionary["merchant_uuid"] as? String? ?? "" |
| 631 | + self.short_description = dictionary["short_description"] as? String? ?? "" | ||
| 632 | + self.terms = dictionary["terms"] as? String? ?? "" | ||
| 629 | 633 | ||
| 630 | if let couponSetData = dictionary["couponset_data"] as? [String: Any]? ?? ["":""] { | 634 | if let couponSetData = dictionary["couponset_data"] as? [String: Any]? ?? ["":""] { |
| 631 | 635 | ... | ... |
-
Please register or login to post a comment