Manos Chorianopoulos

add eshopWebsite button at couponBarcodeVC

......@@ -7,7 +7,7 @@
<key>Pods-SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
<integer>0</integer>
</dict>
</dict>
</dict>
......
......@@ -7,7 +7,7 @@
<key>SwiftWarplyFramework.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>
......
......@@ -39,12 +39,18 @@ import AVFoundation
@IBOutlet weak var border2TopSpace: NSLayoutConstraint!
@IBOutlet weak var mapButton: UIButton!
@IBOutlet weak var topBorderLine: UIImageView!
@IBOutlet weak var mapButtonHeight: NSLayoutConstraint!
@IBOutlet weak var mapButtonTopSpace: NSLayoutConstraint!
let uiscreen: CGRect = UIScreen.main.bounds
var termsVisible: Bool = false;
var barcodeVisible: Bool = false;
var mapBtnVisible: Bool = false;
var eshopBtnVisible: Bool = false;
var eshopWebsite: String = "";
public var coupon: swiftApi.CouponItemModel?
public var isFromWallet: Bool? = false
......@@ -136,12 +142,51 @@ 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.isHidden = true
mapButtonHeight.constant = 0
mapButtonTopSpace.constant = 0
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;
}
}
// Fix width for ipad
// if UIDevice.current.userInterfaceIdiom == .pad {
// // iPad
......@@ -311,5 +356,29 @@ import AVFoundation
let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self))
vc.couponSet = coupon?.couponset_data
self.navigationController?.pushViewController(vc, animated: true)
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)
} 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
}
swiftApi().logTrackersEvent("click", "SeeShopWebsite")
UIApplication.shared.open(websiteUrl, options: [:], completionHandler: nil)
}
}
}
}
......
......@@ -1626,6 +1626,8 @@
<outlet property="expirationLabel" destination="UhC-Lj-tfN" id="9Hj-I1-nJa"/>
<outlet property="mainView" destination="P3Q-nP-aSj" id="pZK-pk-db5"/>
<outlet property="mapButton" destination="W5f-1T-iW6" id="2IL-QE-TdM"/>
<outlet property="mapButtonHeight" destination="3pq-y5-f66" id="oFZ-P9-dUD"/>
<outlet property="mapButtonTopSpace" destination="Rbe-XQ-CIj" id="Mpv-Gg-awa"/>
<outlet property="nameLabel" destination="Xz4-EE-EzJ" id="zTY-n5-36h"/>
<outlet property="redeemButton" destination="8cR-Rc-YMJ" id="atB-0m-8ff"/>
<outlet property="scrollContentView" destination="1ec-eH-fkX" id="IZE-ie-TUA"/>
......
......@@ -5252,6 +5252,8 @@ public class swiftApi {
private var distance: Int?
private var default_shown: Bool?
private var hidden: Bool?
private var show_map: Bool?
private var eshop: Bool?
// private var working_hours: [String: Any]?
// private var tags: [[String: Any]]?
// private var product: [String: Any]?
......@@ -5294,6 +5296,8 @@ public class swiftApi {
self.distance = 0
self.default_shown = false
self.hidden = false
self.show_map = false
self.eshop = false
// self.working_hours = [String: Any]()
// self.tags = [[String: Any]]()
// self.product = [String: Any]()
......@@ -5340,6 +5344,13 @@ public class swiftApi {
// self.working_hours = dictionary["working_hours"] as? [String: Any]? ?? [String: Any]()
// self.tags = dictionary["tags"] as? [[String: Any]]? ?? [[String: Any]]()
// self.product = dictionary["product"] as? [String: Any]? ?? [String: Any]()
if let extra_fields = dictionary["extra_fields"] as? [String: Any] {
self.show_map = extra_fields["show_map"] as? Bool? ?? false
self.eshop = extra_fields["eshop"] as? Bool? ?? false
} else {
self.show_map = false
self.eshop = false
}
}
public var _address: String {
......@@ -5675,6 +5686,24 @@ public class swiftApi {
}
}
public var _show_map: Bool {
get { // getter
return self.show_map ?? false
}
set(newValue) { //setter
self.show_map = newValue
}
}
public var _eshop: Bool {
get { // getter
return self.eshop ?? false
}
set(newValue) { //setter
self.eshop = newValue
}
}
// public var _working_hours: [String: Any] {
// get { // getter
// return self.working_hours ?? [String: Any]()
......