Showing
19 changed files
with
419 additions
and
1 deletions
... | @@ -24,6 +24,10 @@ | ... | @@ -24,6 +24,10 @@ |
24 | 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; }; | 24 | 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */; }; |
25 | 1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */; }; | 25 | 1EBE97212865EE460080EFF7 /* MFYInboxTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */; }; |
26 | 1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; }; | 26 | 1EBF5F072840E13F00B8B17F /* SwiftEventBus in Frameworks */ = {isa = PBXBuildFile; productRef = 1EBF5F062840E13F00B8B17F /* SwiftEventBus */; }; |
27 | + 1ECA079128D9E3BA00D2BDE0 /* CSMButton.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */; }; | ||
28 | + 1ECA079428D9E53F00D2BDE0 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */; }; | ||
29 | + 1ECA079528D9E53F00D2BDE0 /* MapsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */; }; | ||
30 | + 1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */; }; | ||
27 | 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; }; | 31 | 7630AD9A6242D60846D6750C /* Pods_SwiftWarplyFramework.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C0D5F56DD4E5371A50AD2D87 /* Pods_SwiftWarplyFramework.framework */; }; |
28 | A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02F34042882B6E60086465F /* TelcoViewController.swift */; }; | 32 | A02F34052882B6E60086465F /* TelcoViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A02F34042882B6E60086465F /* TelcoViewController.swift */; }; |
29 | A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A04D31DD288FF670000E43B5 /* HistoryViewController.swift */; }; | 33 | A04D31DE288FF670000E43B5 /* HistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A04D31DD288FF670000E43B5 /* HistoryViewController.swift */; }; |
... | @@ -179,6 +183,10 @@ | ... | @@ -179,6 +183,10 @@ |
179 | 1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; }; | 183 | 1EB5F4C728536FD60016F36E /* StepsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StepsViewController.swift; sourceTree = "<group>"; }; |
180 | 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; }; | 184 | 1EB5F4C9285370C90016F36E /* LoyaltyAnalysisViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LoyaltyAnalysisViewController.swift; sourceTree = "<group>"; }; |
181 | 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFYInboxTableViewCell.swift; sourceTree = "<group>"; }; | 185 | 1EBE97202865EE460080EFF7 /* MFYInboxTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MFYInboxTableViewCell.swift; sourceTree = "<group>"; }; |
186 | + 1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CSMButton.swift; sourceTree = "<group>"; }; | ||
187 | + 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; }; | ||
188 | + 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapsViewController.xib; sourceTree = "<group>"; }; | ||
189 | + 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MerchantAnnotation.swift; sourceTree = "<group>"; }; | ||
182 | A02F34042882B6E60086465F /* TelcoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelcoViewController.swift; sourceTree = "<group>"; }; | 190 | A02F34042882B6E60086465F /* TelcoViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TelcoViewController.swift; sourceTree = "<group>"; }; |
183 | A04D31DD288FF670000E43B5 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = "<group>"; }; | 191 | A04D31DD288FF670000E43B5 /* HistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HistoryViewController.swift; sourceTree = "<group>"; }; |
184 | A079366D2885D07700064122 /* AnalysisChildViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisChildViewController.swift; sourceTree = "<group>"; }; | 192 | A079366D2885D07700064122 /* AnalysisChildViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisChildViewController.swift; sourceTree = "<group>"; }; |
... | @@ -430,6 +438,7 @@ | ... | @@ -430,6 +438,7 @@ |
430 | E6A77850282933340045BBA8 /* SwiftWarplyFramework */ = { | 438 | E6A77850282933340045BBA8 /* SwiftWarplyFramework */ = { |
431 | isa = PBXGroup; | 439 | isa = PBXGroup; |
432 | children = ( | 440 | children = ( |
441 | + 1ECA079028D9E3BA00D2BDE0 /* CSMButton.swift */, | ||
433 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */, | 442 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */, |
434 | 1E108A8B28A3F8FF0008B8E7 /* Resources */, | 443 | 1E108A8B28A3F8FF0008B8E7 /* Resources */, |
435 | A02F34042882B6E60086465F /* TelcoViewController.swift */, | 444 | A02F34042882B6E60086465F /* TelcoViewController.swift */, |
... | @@ -465,6 +474,9 @@ | ... | @@ -465,6 +474,9 @@ |
465 | E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */, | 474 | E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */, |
466 | E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */, | 475 | E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */, |
467 | E6A77A37282BC3530045BBA8 /* Media.xcassets */, | 476 | E6A77A37282BC3530045BBA8 /* Media.xcassets */, |
477 | + 1ECA079228D9E53F00D2BDE0 /* MapsViewController.swift */, | ||
478 | + 1ECA079628D9E66200D2BDE0 /* MerchantAnnotation.swift */, | ||
479 | + 1ECA079328D9E53F00D2BDE0 /* MapsViewController.xib */, | ||
468 | ); | 480 | ); |
469 | path = SwiftWarplyFramework; | 481 | path = SwiftWarplyFramework; |
470 | sourceTree = "<group>"; | 482 | sourceTree = "<group>"; |
... | @@ -814,6 +826,7 @@ | ... | @@ -814,6 +826,7 @@ |
814 | E6A778E5282933E60045BBA8 /* Main.storyboard in Resources */, | 826 | E6A778E5282933E60045BBA8 /* Main.storyboard in Resources */, |
815 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */, | 827 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */, |
816 | 1E108A9228A3F9280008B8E7 /* pf_square_sans_pro_regular.ttf in Resources */, | 828 | 1E108A9228A3F9280008B8E7 /* pf_square_sans_pro_regular.ttf in Resources */, |
829 | + 1ECA079528D9E53F00D2BDE0 /* MapsViewController.xib in Resources */, | ||
817 | E6A778EA282933E60045BBA8 /* WLNativeVideoTableViewCell.xib in Resources */, | 830 | E6A778EA282933E60045BBA8 /* WLNativeVideoTableViewCell.xib in Resources */, |
818 | 1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */, | 831 | 1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */, |
819 | E6A7790A282933E60045BBA8 /* warp_white_close_button.png in Resources */, | 832 | E6A7790A282933E60045BBA8 /* warp_white_close_button.png in Resources */, |
... | @@ -901,8 +914,10 @@ | ... | @@ -901,8 +914,10 @@ |
901 | E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */, | 914 | E6A77917282933E60045BBA8 /* UIViewController+WLAdditions.m in Sources */, |
902 | 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */, | 915 | 1EA2BB792865BFE8003F2AB0 /* InboxTableViewCell.swift in Sources */, |
903 | E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */, | 916 | E6A77943282933E70045BBA8 /* AFNetworkReachabilityManager.m in Sources */, |
917 | + 1ECA079428D9E53F00D2BDE0 /* MapsViewController.swift in Sources */, | ||
904 | A07936702885D95600064122 /* AnalysisItemViewCell.swift in Sources */, | 918 | A07936702885D95600064122 /* AnalysisItemViewCell.swift in Sources */, |
905 | E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */, | 919 | E6A77956282933E70045BBA8 /* GiftsViewController.swift in Sources */, |
920 | + 1ECA079728D9E66200D2BDE0 /* MerchantAnnotation.swift in Sources */, | ||
906 | E6A778F1282933E60045BBA8 /* WLNativeAdTableViewCell.m in Sources */, | 921 | E6A778F1282933E60045BBA8 /* WLNativeAdTableViewCell.m in Sources */, |
907 | E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */, | 922 | E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */, |
908 | E6A77938282933E70045BBA8 /* AFImageDownloader.m in Sources */, | 923 | E6A77938282933E70045BBA8 /* AFImageDownloader.m in Sources */, |
... | @@ -924,6 +939,7 @@ | ... | @@ -924,6 +939,7 @@ |
924 | 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */, | 939 | 1EB5F4CA285370C90016F36E /* LoyaltyAnalysisViewController.swift in Sources */, |
925 | E6A7794A282933E70045BBA8 /* FMDatabaseAdditions.m in Sources */, | 940 | E6A7794A282933E70045BBA8 /* FMDatabaseAdditions.m in Sources */, |
926 | E6A77903282933E60045BBA8 /* WLAPSItem.m in Sources */, | 941 | E6A77903282933E60045BBA8 /* WLAPSItem.m in Sources */, |
942 | + 1ECA079128D9E3BA00D2BDE0 /* CSMButton.swift in Sources */, | ||
927 | E6A7790B282933E60045BBA8 /* WLPushManager.m in Sources */, | 943 | E6A7790B282933E60045BBA8 /* WLPushManager.m in Sources */, |
928 | A079366E2885D07700064122 /* AnalysisChildViewController.swift in Sources */, | 944 | A079366E2885D07700064122 /* AnalysisChildViewController.swift in Sources */, |
929 | E6A77950282933E70045BBA8 /* FMResultSet.m in Sources */, | 945 | E6A77950282933E70045BBA8 /* FMResultSet.m in Sources */, | ... | ... |
No preview for this file type
1 | +// | ||
2 | +// CSMButton.swift | ||
3 | +// SwiftWarplyFramework | ||
4 | +// | ||
5 | +// Created by Manos Chorianopoulos on 20/9/22. | ||
6 | +// | ||
7 | + | ||
8 | +import UIKit | ||
9 | + | ||
10 | +// @IBDesignable | ||
11 | +@objc public class CSMButton: UIButton { | ||
12 | + required init?(coder aDecoder: NSCoder) { | ||
13 | + super.init(coder: aDecoder) | ||
14 | + configure() | ||
15 | + } | ||
16 | + override init(frame: CGRect = .zero) { | ||
17 | + super.init(frame: frame) | ||
18 | + configure() | ||
19 | + } | ||
20 | + | ||
21 | + public override func prepareForInterfaceBuilder() { | ||
22 | + super.prepareForInterfaceBuilder() | ||
23 | + configure() | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +private extension CSMButton { | ||
28 | + func configure() { | ||
29 | + setImage(UIImage(named: "directions"), for: .normal) | ||
30 | + titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 18) | ||
31 | + setTitleColor(.white, for: .normal) | ||
32 | + backgroundColor = UIColor(rgb: 0x79BF14) | ||
33 | + layer.cornerRadius = 12.0 | ||
34 | + | ||
35 | + imageEdgeInsets = UIEdgeInsets(top:0.0, left:0.0, bottom:0.0, right:5.0); | ||
36 | + titleEdgeInsets = UIEdgeInsets(top:0.0, left:5.0, bottom:0.0, right:0.0); | ||
37 | + } | ||
38 | +} |
... | @@ -252,6 +252,8 @@ import AVFoundation | ... | @@ -252,6 +252,8 @@ import AVFoundation |
252 | } | 252 | } |
253 | 253 | ||
254 | @IBAction func mapButtonAction(_ sender: Any) { | 254 | @IBAction func mapButtonAction(_ sender: Any) { |
255 | - // TODO: open MapVC | 255 | + let vc = SwiftWarplyFramework.MapsViewController(nibName: "MapsViewController", bundle: Bundle(for: MyEmptyClass.self)) |
256 | + vc.couponSet = coupon?.couponset_data | ||
257 | + self.navigationController?.pushViewController(vc, animated: true) | ||
256 | } | 258 | } |
257 | } | 259 | } | ... | ... |
1 | +// | ||
2 | +// MapsViewController.swift | ||
3 | +// SwiftWarplyFramework | ||
4 | +// | ||
5 | +// Created by Manos Chorianopoulos on 20/9/22. | ||
6 | +// | ||
7 | + | ||
8 | +import UIKit | ||
9 | +import MapKit | ||
10 | + | ||
11 | +@objc public class MapsViewController: UIViewController, MKMapViewDelegate { | ||
12 | + // ui | ||
13 | + @IBOutlet weak var backgroundImage: UIImageView! | ||
14 | + @IBOutlet private var mapView: MKMapView! | ||
15 | + | ||
16 | + @IBOutlet weak var closeButton: UIButton! | ||
17 | + @IBOutlet private var titleView: UILabel! | ||
18 | + @IBOutlet private var nameImageView: UIImageView! | ||
19 | + @IBOutlet private var nameView: UILabel! | ||
20 | + @IBOutlet private var hoursView: UILabel! | ||
21 | + @IBOutlet private var phoneView: UILabel! | ||
22 | + @IBOutlet private var addressView: UILabel! | ||
23 | + @IBOutlet private var directionsButton: CSMButton! | ||
24 | + @IBOutlet private var infoTopConstraint: NSLayoutConstraint! | ||
25 | + | ||
26 | + // public | ||
27 | + public var couponSet: swiftApi.CouponSetItemModel? | ||
28 | + var merchantsArray:Array<swiftApi.MerchantModel> = [] | ||
29 | + var selectedMerchant: swiftApi.MerchantModel? | ||
30 | + var annotationGroup = [MKPointAnnotation]() | ||
31 | + | ||
32 | + // | ||
33 | + var loading: Bool = false | ||
34 | + let initialLocation = CLLocation(latitude: 37.9641262, longitude: 23.7468592) // greece | ||
35 | + // | ||
36 | + public override func viewDidLoad() { | ||
37 | + super.viewDidLoad() | ||
38 | + | ||
39 | + self.hidesBottomBarWhenPushed = true | ||
40 | + | ||
41 | + self.infoTopConstraint.constant = 0 | ||
42 | + | ||
43 | + setBackButton() | ||
44 | + setNavigationTitle("Καταστήματα") | ||
45 | + | ||
46 | + backgroundImage.image = UIImage(named: "coupons_scrollview_white") | ||
47 | + | ||
48 | + mapView.delegate = self | ||
49 | + mapView.centerToLocation(initialLocation, regionRadius: 1000000) | ||
50 | + | ||
51 | + mapView.clipsToBounds = true | ||
52 | + mapView.layer.cornerRadius = 30 | ||
53 | + mapView.layer.maskedCorners = [ .layerMinXMinYCorner] // Top left corner radius | ||
54 | + | ||
55 | + | ||
56 | + closeButton.imageView?.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.5) | ||
57 | + | ||
58 | + titleView.font = UIFont(name: "PFSquareSansPro-Bold", size: 19) | ||
59 | + titleView.textColor = UIColor(rgb: 0x757575) | ||
60 | + | ||
61 | + nameView.font = UIFont(name: "PFSquareSansPro-Medium", size: 18) | ||
62 | + nameView.textColor = UIColor(rgb: 0x415564) | ||
63 | + | ||
64 | + hoursView.font = UIFont(name: "PFSquareSansPro-Regular", size: 18) | ||
65 | + hoursView.textColor = UIColor(rgb: 0xAEAEAE) | ||
66 | + | ||
67 | + hoursView.font = UIFont(name: "PFSquareSansPro-Medium", size: 18) | ||
68 | + hoursView.textColor = UIColor(rgb: 0x415564) | ||
69 | + | ||
70 | + addressView.font = UIFont(name: "PFSquareSansPro-Medium", size: 18) | ||
71 | + addressView.textColor = UIColor(rgb: 0x415564) | ||
72 | + | ||
73 | + //directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) | ||
74 | + directionsButton.setTitle("Οδηγίες", for: .normal) | ||
75 | + directionsButton.setImage(UIImage(named: "ic_directions"), for: .normal) | ||
76 | + | ||
77 | +// directionsButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 5); | ||
78 | +// directionsButton.titleEdgeInsets = UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 0); | ||
79 | +// directionsButton.sizeToFit() | ||
80 | + //directionsButton.setTitleColor(.white, for: .normal) | ||
81 | + //directionsButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00) | ||
82 | + //directionsButton.layer.cornerRadius = 12.0 | ||
83 | + | ||
84 | + load() | ||
85 | + } | ||
86 | + | ||
87 | + // mvp | ||
88 | + @objc func load() { | ||
89 | + | ||
90 | + if (loading) { | ||
91 | + return; | ||
92 | + } | ||
93 | + showLoading() | ||
94 | + | ||
95 | + if (couponSet != nil) { | ||
96 | + if let merchantUuid: String = couponSet?.merchant_uuid { | ||
97 | + swiftApi().getMultilingualMerchantsAsync([], false, 0.0, [], "", 0, [merchantUuid], getMerchantsCallback) | ||
98 | + showContent() | ||
99 | + } | ||
100 | + } | ||
101 | + | ||
102 | + } | ||
103 | + | ||
104 | + func getMerchantsCallback (_ merchantsData: Array<swiftApi.MerchantModel>?) -> Void { | ||
105 | + if (merchantsData != nil) { | ||
106 | + DispatchQueue.main.async { | ||
107 | + | ||
108 | + self.merchantsArray = merchantsData ?? [] | ||
109 | + self.loadMapPins() | ||
110 | + } | ||
111 | + | ||
112 | + return | ||
113 | + } | ||
114 | + } | ||
115 | + | ||
116 | + private func showLoading() { | ||
117 | + | ||
118 | + loading = true | ||
119 | + } | ||
120 | + | ||
121 | + private func showError() { | ||
122 | + } | ||
123 | + | ||
124 | + private func showContent() { | ||
125 | + | ||
126 | + loading = false | ||
127 | + } | ||
128 | + | ||
129 | + // private | ||
130 | + @IBAction func closeButtonAction(_ sender: Any) { | ||
131 | + print("closeButton Pressed!!!") | ||
132 | + hidePinDetailsView() | ||
133 | + | ||
134 | + let selectedAnnotations = mapView.selectedAnnotations | ||
135 | + for annotation in selectedAnnotations { | ||
136 | + mapView.deselectAnnotation(annotation, animated: false) | ||
137 | + } | ||
138 | + } | ||
139 | + | ||
140 | + @IBAction func directionsButtomAction(_ sender: Any) { | ||
141 | + | ||
142 | + guard let lon = selectedMerchant?._longitude, let lat = selectedMerchant?._latitude else { | ||
143 | + return | ||
144 | + } | ||
145 | + | ||
146 | + // guard your URL instances | ||
147 | +// guard let googleMapsUrl = URL(string: String(format: "https://www.google.com/maps/@%.6f,%.6f,6z", lat, lon)), | ||
148 | +// let appleMapsUrl = URL(string: String(format: "http://maps.apple.com/?ll=%.6f,%.6f", lat, lon)) else { | ||
149 | +// print("Error creating URLs") | ||
150 | +// return | ||
151 | +// } | ||
152 | + | ||
153 | + guard let googleMapsUrl = URL(string: "https://www.google.co.in/maps/dir/?saddr=&daddr=\(lat),\(lon)&directionsmode=driving"), | ||
154 | + let appleMapsUrl = URL(string: "http://maps.apple.com/?daddr=\(lat),\(lon)") else { | ||
155 | + print("Error creating URLs") | ||
156 | + return | ||
157 | + } | ||
158 | + | ||
159 | + // check if link can be opened with google maps. | ||
160 | + guard UIApplication.shared.canOpenURL(googleMapsUrl) else { | ||
161 | + UIApplication.shared.open(appleMapsUrl, options: [:], completionHandler: nil) | ||
162 | + return | ||
163 | + } | ||
164 | + | ||
165 | + UIApplication.shared.open(googleMapsUrl, options: [:], completionHandler: nil) | ||
166 | + | ||
167 | + } | ||
168 | + | ||
169 | + private func loadMapPins() { | ||
170 | + for item in merchantsArray { | ||
171 | + let pin = MerchantAnnotation(item) | ||
172 | + mapView.addAnnotation(pin) | ||
173 | + | ||
174 | +// self.annotationGroup.append(pin) | ||
175 | +// self.mapView.addAnnotations(self.annotationGroup) | ||
176 | +// self.mapView.showAnnotations(self.annotationGroup, animated: true) | ||
177 | + | ||
178 | +// let annotation = MKPointAnnotation() | ||
179 | +// annotation.coordinate.longitude = item._longitude | ||
180 | +// annotation.coordinate.latitude = item._latitude | ||
181 | +// annotation.title = item._admin_name //This is the line to remove the optional annotation.title? from. | ||
182 | +// annotation.subtitle = item._admin_name | ||
183 | +// self.annotationGroup.append(annotation) | ||
184 | +// self.mapView.addAnnotations(self.annotationGroup) | ||
185 | +// self.mapView.showAnnotations(self.annotationGroup, animated: true) | ||
186 | + | ||
187 | +// let annotation = MKPointAnnotation() | ||
188 | +// let centerCoordinate = CLLocationCoordinate2D(latitude: item._latitude, longitude: item._longitude) | ||
189 | +// annotation.coordinate = centerCoordinate | ||
190 | +// annotation.title = "Pass Title here" | ||
191 | +// mapView.addAnnotation(annotation) | ||
192 | + } | ||
193 | +// mapView.showAnnotations(mapView.annotations, animated: true) | ||
194 | + } | ||
195 | + | ||
196 | + private func loadPinDetailsView(_ annotation: MerchantAnnotation) { | ||
197 | + self.selectedMerchant = annotation.model | ||
198 | + | ||
199 | + self.titleView.text = self.selectedMerchant?._admin_name | ||
200 | + self.nameImageView.load(link: self.selectedMerchant?._img_preview ?? "", placeholder: UIImage(), cache: URLCache()) | ||
201 | + self.nameView.text = self.selectedMerchant?._name | ||
202 | + // TODO: Make dynamic | ||
203 | + self.hoursView.text = "" | ||
204 | + self.phoneView.text = self.selectedMerchant?._telephone | ||
205 | + self.addressView.text = self.selectedMerchant?._address | ||
206 | + } | ||
207 | + | ||
208 | + private func showPinDetailsView() { | ||
209 | + self.infoTopConstraint.constant = -320 | ||
210 | + UIView.animate(withDuration: 1.0) { | ||
211 | + self.view.layoutIfNeeded() | ||
212 | + } | ||
213 | + } | ||
214 | + | ||
215 | + private func hidePinDetailsView() { | ||
216 | + self.selectedMerchant = nil | ||
217 | + | ||
218 | + self.infoTopConstraint.constant = 0 | ||
219 | + UIView.animate(withDuration: 1.0) { | ||
220 | + self.view.layoutIfNeeded() | ||
221 | + } | ||
222 | + } | ||
223 | + | ||
224 | + // map view delegate | ||
225 | +// public func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { | ||
226 | +// | ||
227 | +//// guard !(annotation is MKUserLocation) else { | ||
228 | +//// return nil | ||
229 | +//// } | ||
230 | +// | ||
231 | +// var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom") | ||
232 | +// if (annotationView == nil) { | ||
233 | +// print("=== annotationView == nil ===") | ||
234 | +// | ||
235 | +// annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom") | ||
236 | +// annotationView?.canShowCallout = false | ||
237 | +// } else { | ||
238 | +// print("=== annotationView != nil ===") | ||
239 | +// | ||
240 | +// annotationView?.annotation = annotation | ||
241 | +// } | ||
242 | +// | ||
243 | +// // TODO: add custom pin image? | ||
244 | +// //annotationView?.image = UIImage(named: "custom") | ||
245 | +// | ||
246 | +// print("=== returned annotation ===") | ||
247 | +// print(annotation) | ||
248 | +// | ||
249 | +// return annotationView | ||
250 | +// } | ||
251 | + | ||
252 | + public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { | ||
253 | + let merchant = view.annotation as? MerchantAnnotation | ||
254 | + loadPinDetailsView(merchant!) | ||
255 | + showPinDetailsView() | ||
256 | + } | ||
257 | + | ||
258 | + public func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) { | ||
259 | + hidePinDetailsView() | ||
260 | + } | ||
261 | +} | ||
262 | + | ||
263 | +private extension MKMapView { | ||
264 | + | ||
265 | + func centerToLocation(_ location: CLLocation, regionRadius: CLLocationDistance = 1000) { | ||
266 | + let coordinateRegion = MKCoordinateRegion( | ||
267 | + center: location.coordinate, | ||
268 | + latitudinalMeters: regionRadius, | ||
269 | + longitudinalMeters: regionRadius) | ||
270 | + setRegion(coordinateRegion, animated: true) | ||
271 | + } | ||
272 | +} |
This diff is collapsed. Click to expand it.
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_address.imageset/Contents.json
0 → 100644
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_pin_location.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_pin_location-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_pin_location-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_address.imageset/ic_pin_location-1.png
0 → 100644
757 Bytes
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_address.imageset/ic_pin_location-2.png
0 → 100644
757 Bytes
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_address.imageset/ic_pin_location.png
0 → 100644
757 Bytes
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_directions.imageset/Contents.json
0 → 100644
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_pin_compass.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_pin_compass-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_pin_compass-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_directions.imageset/ic_pin_compass-1.png
0 → 100644
997 Bytes
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_directions.imageset/ic_pin_compass-2.png
0 → 100644
997 Bytes
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_directions.imageset/ic_pin_compass.png
0 → 100644
997 Bytes
1 | +{ | ||
2 | + "images" : [ | ||
3 | + { | ||
4 | + "filename" : "ic_pin_tel.png", | ||
5 | + "idiom" : "universal", | ||
6 | + "scale" : "1x" | ||
7 | + }, | ||
8 | + { | ||
9 | + "filename" : "ic_pin_tel-1.png", | ||
10 | + "idiom" : "universal", | ||
11 | + "scale" : "2x" | ||
12 | + }, | ||
13 | + { | ||
14 | + "filename" : "ic_pin_tel-2.png", | ||
15 | + "idiom" : "universal", | ||
16 | + "scale" : "3x" | ||
17 | + } | ||
18 | + ], | ||
19 | + "info" : { | ||
20 | + "author" : "xcode", | ||
21 | + "version" : 1 | ||
22 | + } | ||
23 | +} |
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_phone.imageset/ic_pin_tel-1.png
0 → 100644
657 Bytes
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_phone.imageset/ic_pin_tel-2.png
0 → 100644
657 Bytes
SwiftWarplyFramework/SwiftWarplyFramework/Media.xcassets/ic_phone.imageset/ic_pin_tel.png
0 → 100644
657 Bytes
1 | +// | ||
2 | +// MerchantAnnotation.swift | ||
3 | +// SwiftWarplyFramework | ||
4 | +// | ||
5 | +// Created by Manos Chorianopoulos on 20/9/22. | ||
6 | +// | ||
7 | + | ||
8 | +import Foundation | ||
9 | +import MapKit | ||
10 | + | ||
11 | +@objc public class MerchantAnnotation: NSObject, MKAnnotation { | ||
12 | + let model: swiftApi.MerchantModel | ||
13 | + public let coordinate: CLLocationCoordinate2D | ||
14 | + | ||
15 | + | ||
16 | + init(_ model: swiftApi.MerchantModel) { | ||
17 | + self.model = model | ||
18 | + self.coordinate = CLLocationCoordinate2D(latitude: model._latitude, longitude: model._longitude) | ||
19 | + super.init() | ||
20 | + } | ||
21 | +} |
-
Please register or login to post a comment