Manos Chorianopoulos

add eshopWebsite button at couponBarcodeVC

...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key> 7 <key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
8 <dict> 8 <dict>
9 <key>orderHint</key> 9 <key>orderHint</key>
10 - <integer>0</integer> 10 + <integer>1</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -39,12 +39,18 @@ import AVFoundation ...@@ -39,12 +39,18 @@ import AVFoundation
39 @IBOutlet weak var border2TopSpace: NSLayoutConstraint! 39 @IBOutlet weak var border2TopSpace: NSLayoutConstraint!
40 @IBOutlet weak var mapButton: UIButton! 40 @IBOutlet weak var mapButton: UIButton!
41 @IBOutlet weak var topBorderLine: UIImageView! 41 @IBOutlet weak var topBorderLine: UIImageView!
42 + @IBOutlet weak var mapButtonHeight: NSLayoutConstraint!
43 + @IBOutlet weak var mapButtonTopSpace: NSLayoutConstraint!
42 44
43 let uiscreen: CGRect = UIScreen.main.bounds 45 let uiscreen: CGRect = UIScreen.main.bounds
44 46
45 var termsVisible: Bool = false; 47 var termsVisible: Bool = false;
46 var barcodeVisible: Bool = false; 48 var barcodeVisible: Bool = false;
47 49
50 + var mapBtnVisible: Bool = false;
51 + var eshopBtnVisible: Bool = false;
52 + var eshopWebsite: String = "";
53 +
48 public var coupon: swiftApi.CouponItemModel? 54 public var coupon: swiftApi.CouponItemModel?
49 public var isFromWallet: Bool? = false 55 public var isFromWallet: Bool? = false
50 56
...@@ -136,12 +142,51 @@ import AVFoundation ...@@ -136,12 +142,51 @@ import AVFoundation
136 // } 142 // }
137 143
138 mapButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18) 144 mapButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
139 - mapButton.setTitle("Δες τα καταστήματα", for: .normal) 145 + // mapButton.setTitle("Δες τα καταστήματα", for: .normal)
140 mapButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal) 146 mapButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal)
141 mapButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00) 147 mapButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
142 mapButton.layer.cornerRadius = 8.0 148 mapButton.layer.cornerRadius = 8.0
149 + // mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
150 + // mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
151 +
152 + mapButton.isHidden = true
153 + mapButtonHeight.constant = 0
154 + mapButtonTopSpace.constant = 0
155 +
156 + let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
157 +
158 + for merchant in merchantList {
159 + if (merchant._uuid == couponSetData?.merchant_uuid) {
160 + if (merchant._show_map == true) {
161 + mapButton.setTitle("Δες τα καταστήματα", for: .normal)
143 mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44) 162 mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
144 mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) 163 mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
164 + mapButton.isHidden = false
165 + mapBtnVisible = true
166 + eshopBtnVisible = false
167 + mapButtonHeight.constant = 44
168 + mapButtonTopSpace.constant = 10
169 + } else if (merchant._eshop == true) {
170 + mapButton.setTitle("Δες το eshop", for: .normal)
171 + mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
172 + mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
173 + mapButton.isHidden = false
174 + mapBtnVisible = false
175 + eshopBtnVisible = true
176 + mapButtonHeight.constant = 44
177 + mapButtonTopSpace.constant = 10
178 + } else {
179 + mapButton.isHidden = true
180 + mapBtnVisible = false
181 + eshopBtnVisible = false
182 + mapButtonHeight.constant = 0
183 + mapButtonTopSpace.constant = 0
184 + }
185 + eshopWebsite = merchant._website
186 + break;
187 + }
188 + }
189 +
145 // Fix width for ipad 190 // Fix width for ipad
146 // if UIDevice.current.userInterfaceIdiom == .pad { 191 // if UIDevice.current.userInterfaceIdiom == .pad {
147 // // iPad 192 // // iPad
...@@ -311,5 +356,29 @@ import AVFoundation ...@@ -311,5 +356,29 @@ import AVFoundation
311 let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self)) 356 let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
312 vc.couponSet = coupon?.couponset_data 357 vc.couponSet = coupon?.couponset_data
313 self.navigationController?.pushViewController(vc, animated: true) 358 self.navigationController?.pushViewController(vc, animated: true)
359 +
360 + if (mapBtnVisible == true) {
361 + swiftApi().logTrackersEvent("click", "SeeShops")
362 +
363 + let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
364 + vc.couponSet = coupon?.couponset_data
365 + self.navigationController?.pushViewController(vc, animated: true)
366 +
367 + } else if (eshopBtnVisible == true) {
368 + if (eshopWebsite != "") {
369 + guard let websiteUrl = URL(string: eshopWebsite) else {
370 + print("Error creating URL")
371 + return
372 + }
373 +
374 + // check if link can be opened.
375 + guard UIApplication.shared.canOpenURL(websiteUrl) else {
376 + return
377 + }
378 +
379 + swiftApi().logTrackersEvent("click", "SeeShopWebsite")
380 + UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
381 + }
382 + }
314 } 383 }
315 } 384 }
......
...@@ -1626,6 +1626,8 @@ ...@@ -1626,6 +1626,8 @@
1626 <outlet property="expirationLabel" destination="UhC-Lj-tfN" id="9Hj-I1-nJa"/> 1626 <outlet property="expirationLabel" destination="UhC-Lj-tfN" id="9Hj-I1-nJa"/>
1627 <outlet property="mainView" destination="P3Q-nP-aSj" id="pZK-pk-db5"/> 1627 <outlet property="mainView" destination="P3Q-nP-aSj" id="pZK-pk-db5"/>
1628 <outlet property="mapButton" destination="W5f-1T-iW6" id="2IL-QE-TdM"/> 1628 <outlet property="mapButton" destination="W5f-1T-iW6" id="2IL-QE-TdM"/>
1629 + <outlet property="mapButtonHeight" destination="3pq-y5-f66" id="oFZ-P9-dUD"/>
1630 + <outlet property="mapButtonTopSpace" destination="Rbe-XQ-CIj" id="Mpv-Gg-awa"/>
1629 <outlet property="nameLabel" destination="Xz4-EE-EzJ" id="zTY-n5-36h"/> 1631 <outlet property="nameLabel" destination="Xz4-EE-EzJ" id="zTY-n5-36h"/>
1630 <outlet property="redeemButton" destination="8cR-Rc-YMJ" id="atB-0m-8ff"/> 1632 <outlet property="redeemButton" destination="8cR-Rc-YMJ" id="atB-0m-8ff"/>
1631 <outlet property="scrollContentView" destination="1ec-eH-fkX" id="IZE-ie-TUA"/> 1633 <outlet property="scrollContentView" destination="1ec-eH-fkX" id="IZE-ie-TUA"/>
......
...@@ -5252,6 +5252,8 @@ public class swiftApi { ...@@ -5252,6 +5252,8 @@ public class swiftApi {
5252 private var distance: Int? 5252 private var distance: Int?
5253 private var default_shown: Bool? 5253 private var default_shown: Bool?
5254 private var hidden: Bool? 5254 private var hidden: Bool?
5255 + private var show_map: Bool?
5256 + private var eshop: Bool?
5255 // private var working_hours: [String: Any]? 5257 // private var working_hours: [String: Any]?
5256 // private var tags: [[String: Any]]? 5258 // private var tags: [[String: Any]]?
5257 // private var product: [String: Any]? 5259 // private var product: [String: Any]?
...@@ -5294,6 +5296,8 @@ public class swiftApi { ...@@ -5294,6 +5296,8 @@ public class swiftApi {
5294 self.distance = 0 5296 self.distance = 0
5295 self.default_shown = false 5297 self.default_shown = false
5296 self.hidden = false 5298 self.hidden = false
5299 + self.show_map = false
5300 + self.eshop = false
5297 // self.working_hours = [String: Any]() 5301 // self.working_hours = [String: Any]()
5298 // self.tags = [[String: Any]]() 5302 // self.tags = [[String: Any]]()
5299 // self.product = [String: Any]() 5303 // self.product = [String: Any]()
...@@ -5340,6 +5344,13 @@ public class swiftApi { ...@@ -5340,6 +5344,13 @@ public class swiftApi {
5340 // self.working_hours = dictionary["working_hours"] as? [String: Any]? ?? [String: Any]() 5344 // self.working_hours = dictionary["working_hours"] as? [String: Any]? ?? [String: Any]()
5341 // self.tags = dictionary["tags"] as? [[String: Any]]? ?? [[String: Any]]() 5345 // self.tags = dictionary["tags"] as? [[String: Any]]? ?? [[String: Any]]()
5342 // self.product = dictionary["product"] as? [String: Any]? ?? [String: Any]() 5346 // self.product = dictionary["product"] as? [String: Any]? ?? [String: Any]()
5347 + if let extra_fields = dictionary["extra_fields"] as? [String: Any] {
5348 + self.show_map = extra_fields["show_map"] as? Bool? ?? false
5349 + self.eshop = extra_fields["eshop"] as? Bool? ?? false
5350 + } else {
5351 + self.show_map = false
5352 + self.eshop = false
5353 + }
5343 } 5354 }
5344 5355
5345 public var _address: String { 5356 public var _address: String {
...@@ -5675,6 +5686,24 @@ public class swiftApi { ...@@ -5675,6 +5686,24 @@ public class swiftApi {
5675 } 5686 }
5676 } 5687 }
5677 5688
5689 + public var _show_map: Bool {
5690 + get { // getter
5691 + return self.show_map ?? false
5692 + }
5693 + set(newValue) { //setter
5694 + self.show_map = newValue
5695 + }
5696 + }
5697 +
5698 + public var _eshop: Bool {
5699 + get { // getter
5700 + return self.eshop ?? false
5701 + }
5702 + set(newValue) { //setter
5703 + self.eshop = newValue
5704 + }
5705 + }
5706 +
5678 // public var _working_hours: [String: Any] { 5707 // public var _working_hours: [String: Any] {
5679 // get { // getter 5708 // get { // getter
5680 // return self.working_hours ?? [String: Any]() 5709 // return self.working_hours ?? [String: Any]()
......