Manos Chorianopoulos

add SeeShopWebsite popup at MapVC

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -173,50 +173,50 @@ import AVFoundation
// }
mapButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18)
// mapButton.setTitle("Δες τα καταστήματα", for: .normal)
mapButton.setTitle("Δες τα καταστήματα", for: .normal)
mapButton.setTitleColor(UIColor(red: 0.31, green: 0.62, blue: 0.18, alpha: 1.00), for: .normal)
mapButton.backgroundColor = UIColor(red: 0.90, green: 0.90, blue: 0.90, alpha: 1.00)
mapButton.layer.cornerRadius = 8.0
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
mapButton.isHidden = true
mapButtonHeight.constant = 0
mapButtonTopSpace.constant = 0
// mapButton.isHidden = true
// mapButtonHeight.constant = 0
// mapButtonTopSpace.constant = 0
let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
// let merchantList:Array<swiftApi.MerchantModel> = swiftApi().getMerchantList()
for merchant in merchantList {
if (merchant._uuid == couponSetData?.merchant_uuid) {
if (merchant._show_map == true) {
mapButton.setTitle("Δες τα καταστήματα", for: .normal)
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
mapButton.isHidden = false
mapBtnVisible = true
eshopBtnVisible = false
mapButtonHeight.constant = 44
mapButtonTopSpace.constant = 10
} else if (merchant._eshop == true) {
mapButton.setTitle("Δες το eshop", for: .normal)
mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
mapButton.isHidden = false
mapBtnVisible = false
eshopBtnVisible = true
mapButtonHeight.constant = 44
mapButtonTopSpace.constant = 10
} else {
mapButton.isHidden = true
mapBtnVisible = false
eshopBtnVisible = false
mapButtonHeight.constant = 0
mapButtonTopSpace.constant = 0
}
eshopWebsite = merchant._website
break;
}
}
// for merchant in merchantList {
// if (merchant._uuid == couponSetData?.merchant_uuid) {
// if (merchant._show_map == true) {
// mapButton.setTitle("Δες τα καταστήματα", for: .normal)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
// mapButton.isHidden = false
// mapBtnVisible = true
// eshopBtnVisible = false
// mapButtonHeight.constant = 44
// mapButtonTopSpace.constant = 10
// } else if (merchant._eshop == true) {
// mapButton.setTitle("Δες το eshop", for: .normal)
// mapButton.frame = CGRect(x: 0.0, y: 0.0, width: mapButton.intrinsicContentSize.width, height: 44)
// mapButton.contentEdgeInsets = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
// mapButton.isHidden = false
// mapBtnVisible = false
// eshopBtnVisible = true
// mapButtonHeight.constant = 44
// mapButtonTopSpace.constant = 10
// } else {
// mapButton.isHidden = true
// mapBtnVisible = false
// eshopBtnVisible = false
// mapButtonHeight.constant = 0
// mapButtonTopSpace.constant = 0
// }
// eshopWebsite = merchant._website
// break;
// }
// }
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
......@@ -389,28 +389,28 @@ import AVFoundation
vc.couponSet = coupon?.couponset_data
self.navigationController?.pushViewController(vc, animated: true)
if (mapBtnVisible == true) {
swiftApi().logTrackersEvent("click", "SeeShops")
// if (mapBtnVisible == true) {
// swiftApi().logTrackersEvent("click", "SeeShops")
let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
vc.couponSet = coupon?.couponset_data
self.navigationController?.pushViewController(vc, animated: true)
// let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
// vc.couponSet = coupon?.couponset_data
// self.navigationController?.pushViewController(vc, animated: true)
} else if (eshopBtnVisible == true) {
if (eshopWebsite != "") {
guard let websiteUrl = URL(string: eshopWebsite) else {
print("Error creating URL")
return
}
// } else if (eshopBtnVisible == true) {
// if (eshopWebsite != "") {
// guard let websiteUrl = URL(string: eshopWebsite) else {
// print("Error creating URL")
// return
// }
// check if link can be opened.
guard UIApplication.shared.canOpenURL(websiteUrl) else {
return
}
// // check if link can be opened.
// guard UIApplication.shared.canOpenURL(websiteUrl) else {
// return
// }
swiftApi().logTrackersEvent("click", "SeeShopWebsite")
UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
}
}
// swiftApi().logTrackersEvent("click", "SeeShopWebsite")
// UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
// }
// }
}
}
......
......@@ -133,11 +133,72 @@ import MapKit
self.merchantsArray = merchantsData ?? []
self.loadMapPins()
let filteredMerchants = self.merchantsArray.filter({ return (($0._latitude != 0.0) && ($0._longitude != 0.0)) })
if (filteredMerchants.count == 0) {
self.showDialog("Καταστήματα συνεργάτη", "Ο συνεργάτης διαθέτει μόνο ηλεκτρονικό κατάστημα για ηλεκτρονικές παραγγελίες.")
}
}
return
}
}
func showDialog(_ alertTitle: String, _ alertSubTitle: String) -> Void {
let alert = UIAlertController(title: alertTitle, message: alertSubTitle, preferredStyle: .alert)
let cancelButton = UIAlertAction(title: "Άκυρο", style: .default, handler: { action in
switch action.style{
case .default:
self.navigationController?.popViewController(animated: true)
self.dismiss(animated: true, completion: {})
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
})
// cancelButton.setValue(UIColor(rgb: 0xFC5757), forKey: "titleTextColor")
alert.addAction(cancelButton)
alert.addAction(UIAlertAction(title: "Δες το eshop", style: .default, handler: { action in
switch action.style{
case .default:
if (self.merchantsArray.count > 0) {
for item in self.merchantsArray {
let eshopWebsite = item._website
if (eshopWebsite != "") {
guard let websiteUrl = URL(string: eshopWebsite) else {
print("Error creating URL")
return
}
// check if link can be opened.
guard UIApplication.shared.canOpenURL(websiteUrl) else {
return
}
swiftApi().logTrackersEvent("click", "SeeShopWebsite")
UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
break;
}
}
}
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}
}))
self.present(alert, animated: true, completion: nil)
}
private func showLoading() {
......