Manos Chorianopoulos

add SeeShopWebsite popup at MapVC

...@@ -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>0</integer> 10 + <integer>1</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>1</integer> 10 + <integer>0</integer>
11 </dict> 11 </dict>
12 </dict> 12 </dict>
13 </dict> 13 </dict>
......
...@@ -173,50 +173,50 @@ import AVFoundation ...@@ -173,50 +173,50 @@ import AVFoundation
173 // } 173 // }
174 174
175 mapButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18) 175 mapButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
176 - // mapButton.setTitle("Δες τα καταστήματα", for: .normal) 176 + mapButton.setTitle("Δες τα καταστήματα", for: .normal)
177 mapButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal) 177 mapButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal)
178 mapButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00) 178 mapButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
179 mapButton.layer.cornerRadius = 8.0 179 mapButton.layer.cornerRadius = 8.0
180 - // mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44) 180 + mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
181 - // mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) 181 + mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
182 182
183 - mapButton.isHidden = true 183 + // mapButton.isHidden = true
184 - mapButtonHeight.constant = 0 184 + // mapButtonHeight.constant = 0
185 - mapButtonTopSpace.constant = 0 185 + // mapButtonTopSpace.constant = 0
186 186
187 - let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList() 187 + // let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
188 188
189 - for merchant in merchantList { 189 + // for merchant in merchantList {
190 - if (merchant._uuid == couponSetData?.merchant_uuid) { 190 + // if (merchant._uuid == couponSetData?.merchant_uuid) {
191 - if (merchant._show_map == true) { 191 + // if (merchant._show_map == true) {
192 - mapButton.setTitle("Δες τα καταστήματα", for: .normal) 192 + // mapButton.setTitle("Δες τα καταστήματα", for: .normal)
193 - mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44) 193 + // mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
194 - mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) 194 + // mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
195 - mapButton.isHidden = false 195 + // mapButton.isHidden = false
196 - mapBtnVisible = true 196 + // mapBtnVisible = true
197 - eshopBtnVisible = false 197 + // eshopBtnVisible = false
198 - mapButtonHeight.constant = 44 198 + // mapButtonHeight.constant = 44
199 - mapButtonTopSpace.constant = 10 199 + // mapButtonTopSpace.constant = 10
200 - } else if (merchant._eshop == true) { 200 + // } else if (merchant._eshop == true) {
201 - mapButton.setTitle("Δες το eshop", for: .normal) 201 + // mapButton.setTitle("Δες το eshop", for: .normal)
202 - mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44) 202 + // mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
203 - mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16) 203 + // mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
204 - mapButton.isHidden = false 204 + // mapButton.isHidden = false
205 - mapBtnVisible = false 205 + // mapBtnVisible = false
206 - eshopBtnVisible = true 206 + // eshopBtnVisible = true
207 - mapButtonHeight.constant = 44 207 + // mapButtonHeight.constant = 44
208 - mapButtonTopSpace.constant = 10 208 + // mapButtonTopSpace.constant = 10
209 - } else { 209 + // } else {
210 - mapButton.isHidden = true 210 + // mapButton.isHidden = true
211 - mapBtnVisible = false 211 + // mapBtnVisible = false
212 - eshopBtnVisible = false 212 + // eshopBtnVisible = false
213 - mapButtonHeight.constant = 0 213 + // mapButtonHeight.constant = 0
214 - mapButtonTopSpace.constant = 0 214 + // mapButtonTopSpace.constant = 0
215 - } 215 + // }
216 - eshopWebsite = merchant._website 216 + // eshopWebsite = merchant._website
217 - break; 217 + // break;
218 - } 218 + // }
219 - } 219 + // }
220 220
221 // Fix width for ipad 221 // Fix width for ipad
222 // if UIDevice.current.userInterfaceIdiom == .pad { 222 // if UIDevice.current.userInterfaceIdiom == .pad {
...@@ -389,28 +389,28 @@ import AVFoundation ...@@ -389,28 +389,28 @@ import AVFoundation
389 vc.couponSet = coupon?.couponset_data 389 vc.couponSet = coupon?.couponset_data
390 self.navigationController?.pushViewController(vc, animated: true) 390 self.navigationController?.pushViewController(vc, animated: true)
391 391
392 - if (mapBtnVisible == true) { 392 + // if (mapBtnVisible == true) {
393 - swiftApi().logTrackersEvent("click", "SeeShops") 393 + // swiftApi().logTrackersEvent("click", "SeeShops")
394 394
395 - let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self)) 395 + // let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
396 - vc.couponSet = coupon?.couponset_data 396 + // vc.couponSet = coupon?.couponset_data
397 - self.navigationController?.pushViewController(vc, animated: true) 397 + // self.navigationController?.pushViewController(vc, animated: true)
398 398
399 - } else if (eshopBtnVisible == true) { 399 + // } else if (eshopBtnVisible == true) {
400 - if (eshopWebsite != "") { 400 + // if (eshopWebsite != "") {
401 - guard let websiteUrl = URL(string: eshopWebsite) else { 401 + // guard let websiteUrl = URL(string: eshopWebsite) else {
402 - print("Error creating URL") 402 + // print("Error creating URL")
403 - return 403 + // return
404 - } 404 + // }
405 405
406 - // check if link can be opened. 406 + // // check if link can be opened.
407 - guard UIApplication.shared.canOpenURL(websiteUrl) else { 407 + // guard UIApplication.shared.canOpenURL(websiteUrl) else {
408 - return 408 + // return
409 - } 409 + // }
410 410
411 - swiftApi().logTrackersEvent("click", "SeeShopWebsite") 411 + // swiftApi().logTrackersEvent("click", "SeeShopWebsite")
412 - UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil) 412 + // UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
413 - } 413 + // }
414 - } 414 + // }
415 } 415 }
416 } 416 }
......
...@@ -133,11 +133,72 @@ import MapKit ...@@ -133,11 +133,72 @@ import MapKit
133 133
134 self.merchantsArray = merchantsData ?? [] 134 self.merchantsArray = merchantsData ?? []
135 self.loadMapPins() 135 self.loadMapPins()
136 +
137 + let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
138 + if (filteredMerchants.count == 0) {
139 + self.showDialog("Καταστήματα συνεργάτη", "Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.")
140 + }
136 } 141 }
137 142
138 return 143 return
139 } 144 }
140 } 145 }
146 +
147 + func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
148 +
149 + let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
150 +
151 + let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
152 + switch action.style{
153 + case .default:
154 + self.navigationController?.popViewController(animated: true)
155 + self.dismiss(animated: true, completion: {})
156 +
157 + case .cancel:
158 + print("cancel")
159 +
160 + case .destructive:
161 + print("destructive")
162 +
163 + }
164 + })
165 + // cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
166 + alert.addAction(cancelButton)
167 +
168 + alert.addAction(UIAlertAction(title: "Δες το eshop", style: .default, handler: { action in
169 + switch action.style{
170 + case .default:
171 + if (self.merchantsArray.count > 0) {
172 + for item in self.merchantsArray {
173 + let eshopWebsite = item._website
174 + if (eshopWebsite != "") {
175 + guard let websiteUrl = URL(string: eshopWebsite) else {
176 + print("Error creating URL")
177 + return
178 + }
179 +
180 + // check if link can be opened.
181 + guard UIApplication.shared.canOpenURL(websiteUrl) else {
182 + return
183 + }
184 +
185 + swiftApi().logTrackersEvent("click", "SeeShopWebsite")
186 + UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
187 + break;
188 + }
189 + }
190 + }
191 +
192 + case .cancel:
193 + print("cancel")
194 +
195 + case .destructive:
196 + print("destructive")
197 +
198 + }
199 + }))
200 + self.present(alert, animated: true, completion: nil)
201 + }
141 202
142 private func showLoading() { 203 private func showLoading() {
143 204
......