Showing
3 changed files
with
184 additions
and
0 deletions
| ... | @@ -33,6 +33,8 @@ | ... | @@ -33,6 +33,8 @@ |
| 33 | A07936762885E9CC00064122 /* UIColorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07936752885E9CC00064122 /* UIColorExtensions.swift */; }; | 33 | A07936762885E9CC00064122 /* UIColorExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = A07936752885E9CC00064122 /* UIColorExtensions.swift */; }; |
| 34 | A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */; }; | 34 | A079367C2885F2F500064122 /* AnalysisHeaderViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */; }; |
| 35 | A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */; }; | 35 | A079367E2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */; }; |
| 36 | + A080CFD628D170A20045A315 /* MapsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A080CFD428D170A20045A315 /* MapsViewController.swift */; }; | ||
| 37 | + A080CFD728D170A20045A315 /* MapsViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = A080CFD528D170A20045A315 /* MapsViewController.xib */; }; | ||
| 36 | A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */; }; | 38 | A09DBCAE2888BA8100DD50B0 /* SharingHistoryViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */; }; |
| 37 | E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; }; | 39 | E6A77853282933340045BBA8 /* SwiftWarplyFramework.docc in Sources */ = {isa = PBXBuildFile; fileRef = E6A77852282933340045BBA8 /* SwiftWarplyFramework.docc */; }; |
| 38 | E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; | 40 | E6A77854282933340045BBA8 /* SwiftWarplyFramework.h in Headers */ = {isa = PBXBuildFile; fileRef = E6A77851282933340045BBA8 /* SwiftWarplyFramework.h */; settings = {ATTRIBUTES = (Public, ); }; }; |
| ... | @@ -187,6 +189,8 @@ | ... | @@ -187,6 +189,8 @@ |
| 187 | A07936752885E9CC00064122 /* UIColorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtensions.swift; sourceTree = "<group>"; }; | 189 | A07936752885E9CC00064122 /* UIColorExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIColorExtensions.swift; sourceTree = "<group>"; }; |
| 188 | A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderViewCell.swift; sourceTree = "<group>"; }; | 190 | A079367B2885F2F500064122 /* AnalysisHeaderViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderViewCell.swift; sourceTree = "<group>"; }; |
| 189 | A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderMessageViewCell.swift; sourceTree = "<group>"; }; | 191 | A079367D2885F60A00064122 /* AnalysisHeaderMessageViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AnalysisHeaderMessageViewCell.swift; sourceTree = "<group>"; }; |
| 192 | + A080CFD428D170A20045A315 /* MapsViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MapsViewController.swift; sourceTree = "<group>"; }; | ||
| 193 | + A080CFD528D170A20045A315 /* MapsViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MapsViewController.xib; sourceTree = "<group>"; }; | ||
| 190 | A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharingHistoryViewController.swift; sourceTree = "<group>"; }; | 194 | A09DBCAD2888BA8100DD50B0 /* SharingHistoryViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SharingHistoryViewController.swift; sourceTree = "<group>"; }; |
| 191 | A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; }; | 195 | A9B7BE01A4E812DE49866EF8 /* Pods-SwiftWarplyFramework.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.debug.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.debug.xcconfig"; sourceTree = "<group>"; }; |
| 192 | B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; }; | 196 | B9EB8A451EF0C5AD75094EEE /* Pods-SwiftWarplyFramework.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SwiftWarplyFramework.release.xcconfig"; path = "Target Support Files/Pods-SwiftWarplyFramework/Pods-SwiftWarplyFramework.release.xcconfig"; sourceTree = "<group>"; }; |
| ... | @@ -400,6 +404,13 @@ | ... | @@ -400,6 +404,13 @@ |
| 400 | name = cells; | 404 | name = cells; |
| 401 | sourceTree = "<group>"; | 405 | sourceTree = "<group>"; |
| 402 | }; | 406 | }; |
| 407 | + A080CFD828D17F7A0045A315 /* controls */ = { | ||
| 408 | + isa = PBXGroup; | ||
| 409 | + children = ( | ||
| 410 | + ); | ||
| 411 | + name = controls; | ||
| 412 | + sourceTree = "<group>"; | ||
| 413 | + }; | ||
| 403 | C049E0423E2B72D796B777A3 /* Pods */ = { | 414 | C049E0423E2B72D796B777A3 /* Pods */ = { |
| 404 | isa = PBXGroup; | 415 | isa = PBXGroup; |
| 405 | children = ( | 416 | children = ( |
| ... | @@ -433,9 +444,12 @@ | ... | @@ -433,9 +444,12 @@ |
| 433 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */, | 444 | 1E108A9728A3FA9B0008B8E7 /* Info.plist */, |
| 434 | 1E108A8B28A3F8FF0008B8E7 /* Resources */, | 445 | 1E108A8B28A3F8FF0008B8E7 /* Resources */, |
| 435 | A02F34042882B6E60086465F /* TelcoViewController.swift */, | 446 | A02F34042882B6E60086465F /* TelcoViewController.swift */, |
| 447 | + A080CFD828D17F7A0045A315 /* controls */, | ||
| 436 | A07936712885E65C00064122 /* models */, | 448 | A07936712885E65C00064122 /* models */, |
| 437 | A079366A2885CDDC00064122 /* analysis */, | 449 | A079366A2885CDDC00064122 /* analysis */, |
| 438 | A07936742885E96A00064122 /* utilities */, | 450 | A07936742885E96A00064122 /* utilities */, |
| 451 | + A080CFD428D170A20045A315 /* MapsViewController.swift */, | ||
| 452 | + A080CFD528D170A20045A315 /* MapsViewController.xib */, | ||
| 439 | E6A7785E282933E40045BBA8 /* CouponsViewController.swift */, | 453 | E6A7785E282933E40045BBA8 /* CouponsViewController.swift */, |
| 440 | 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */, | 454 | 1EA1AF092835346A008998AA /* CouponsTableViewCell.swift */, |
| 441 | E6A7785D282933E40045BBA8 /* CouponViewController.swift */, | 455 | E6A7785D282933E40045BBA8 /* CouponViewController.swift */, |
| ... | @@ -814,6 +828,7 @@ | ... | @@ -814,6 +828,7 @@ |
| 814 | E6A778E5282933E60045BBA8 /* Main.storyboard in Resources */, | 828 | E6A778E5282933E60045BBA8 /* Main.storyboard in Resources */, |
| 815 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */, | 829 | 1E108A9628A3F9280008B8E7 /* pf_square_sans_pro_bold.ttf in Resources */, |
| 816 | 1E108A9228A3F9280008B8E7 /* pf_square_sans_pro_regular.ttf in Resources */, | 830 | 1E108A9228A3F9280008B8E7 /* pf_square_sans_pro_regular.ttf in Resources */, |
| 831 | + A080CFD728D170A20045A315 /* MapsViewController.xib in Resources */, | ||
| 817 | E6A778EA282933E60045BBA8 /* WLNativeVideoTableViewCell.xib in Resources */, | 832 | E6A778EA282933E60045BBA8 /* WLNativeVideoTableViewCell.xib in Resources */, |
| 818 | 1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */, | 833 | 1E108A9528A3F9280008B8E7 /* pf_square_sans_pro_bold_italic.ttf in Resources */, |
| 819 | E6A7790A282933E60045BBA8 /* warp_white_close_button.png in Resources */, | 834 | E6A7790A282933E60045BBA8 /* warp_white_close_button.png in Resources */, |
| ... | @@ -925,6 +940,7 @@ | ... | @@ -925,6 +940,7 @@ |
| 925 | E6A7794A282933E70045BBA8 /* FMDatabaseAdditions.m in Sources */, | 940 | E6A7794A282933E70045BBA8 /* FMDatabaseAdditions.m in Sources */, |
| 926 | E6A77903282933E60045BBA8 /* WLAPSItem.m in Sources */, | 941 | E6A77903282933E60045BBA8 /* WLAPSItem.m in Sources */, |
| 927 | E6A7790B282933E60045BBA8 /* WLPushManager.m in Sources */, | 942 | E6A7790B282933E60045BBA8 /* WLPushManager.m in Sources */, |
| 943 | + A080CFD628D170A20045A315 /* MapsViewController.swift 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 */, |
| 930 | E6A77936282933E70045BBA8 /* AFAutoPurgingImageCache.m in Sources */, | 946 | E6A77936282933E70045BBA8 /* AFAutoPurgingImageCache.m in Sources */, | ... | ... |
| 1 | +// | ||
| 2 | +// MapsViewController.swift | ||
| 3 | +// SwiftWarplyFramework | ||
| 4 | +// | ||
| 5 | +// Created by Βασιλης Σκουρας on 14/9/22. | ||
| 6 | +// | ||
| 7 | + | ||
| 8 | +import UIKit | ||
| 9 | +import MapKit | ||
| 10 | + | ||
| 11 | +class MapsViewController: UIViewController, MKMapViewDelegate { | ||
| 12 | + | ||
| 13 | + // ui | ||
| 14 | + @IBOutlet private var mapView: MKMapView! | ||
| 15 | + | ||
| 16 | + @IBOutlet private var titleView: UILabel! | ||
| 17 | + @IBOutlet private var nameImageView: UIImageView! | ||
| 18 | + @IBOutlet private var nameView: UILabel! | ||
| 19 | + @IBOutlet private var hoursView: UILabel! | ||
| 20 | + @IBOutlet private var phoneView: UILabel! | ||
| 21 | + @IBOutlet private var addressView: UILabel! | ||
| 22 | + @IBOutlet private var directionsButton: UIButton! | ||
| 23 | + @IBOutlet private var infoTopConstraint: NSLayoutConstraint! | ||
| 24 | + | ||
| 25 | + // public | ||
| 26 | + public var couponSet: swiftApi.CouponSetItemModel? | ||
| 27 | + var merchantsArray:Array<swiftApi.MerchantModel> = [] | ||
| 28 | + | ||
| 29 | + // | ||
| 30 | + var loading: Bool = false | ||
| 31 | + let initialLocation = CLLocation(latitude: 38.0689416, longitude: 19.9906012) // greece | ||
| 32 | + | ||
| 33 | + // | ||
| 34 | + override func viewDidLoad() { | ||
| 35 | + super.viewDidLoad() | ||
| 36 | + | ||
| 37 | + self.hidesBottomBarWhenPushed = true | ||
| 38 | + | ||
| 39 | + self.infoTopConstraint.constant = 0 | ||
| 40 | + | ||
| 41 | + setBackButton("ic_close") | ||
| 42 | + //setNavigationTitle(ccms?._titleOffer ?? "") | ||
| 43 | + | ||
| 44 | + mapView.delegate = self | ||
| 45 | + mapView.centerToLocation(initialLocation) | ||
| 46 | + | ||
| 47 | + //directionsButton.titleLabel?.font = UIFont(name: "PFSquareSansPro-Medium", size: 16) | ||
| 48 | + directionsButton.setTitle("Οδηγίες", for: .normal) | ||
| 49 | + directionsButton.setTitleColor(.white, for: .normal) | ||
| 50 | + directionsButton.backgroundColor = UIColor(red: 0.47, green: 0.75, blue: 0.08, alpha: 1.00) | ||
| 51 | + directionsButton.layer.cornerRadius = 12.0 | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + // mvp | ||
| 55 | + @objc func load() { | ||
| 56 | + | ||
| 57 | + if (loading) { | ||
| 58 | + return; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + showLoading() | ||
| 62 | + | ||
| 63 | + // TODO: adapt params | ||
| 64 | + let merchantUuid: String = couponSet!.merchant_uuid! | ||
| 65 | + swiftApi().getMultilingualMerchantsAsync([], false, 0.0, [], "", 0, [merchantUuid], getMerchantsCallback) | ||
| 66 | + showContent() | ||
| 67 | + } | ||
| 68 | + | ||
| 69 | + func getMerchantsCallback (_ merchantsData: Array<swiftApi.MerchantModel>?) -> Void { | ||
| 70 | + if (merchantsData != nil) { | ||
| 71 | + DispatchQueue.main.async { | ||
| 72 | + self.merchantsArray = merchantsData! | ||
| 73 | + self.loadMapPins() | ||
| 74 | + } | ||
| 75 | + | ||
| 76 | + return | ||
| 77 | + } | ||
| 78 | + } | ||
| 79 | + | ||
| 80 | + private func showLoading() { | ||
| 81 | + | ||
| 82 | + loading = true | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + private func showError() { | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + private func showContent() { | ||
| 89 | + | ||
| 90 | + loading = false | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + // private | ||
| 94 | + @IBAction func closeButtomAction(_ sender: Any) { | ||
| 95 | + hidePinDetailsView() | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + private func loadMapPins() { | ||
| 99 | + for item in merchantsArray { | ||
| 100 | + let pin = MKPointAnnotation() | ||
| 101 | + pin.coordinate = CLLocationCoordinate2D(latitude: item._latitude, longitude: item._longitude) | ||
| 102 | + mapView.addAnnotation(pin) | ||
| 103 | + } | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + private func loadPinDetailsView() { | ||
| 107 | + self.titleView.text = "INTERSPORT" | ||
| 108 | + self.nameImageView.image = UIImage(named: "intersport") | ||
| 109 | + self.nameView.text = "Intersport Χαλάνδρι" | ||
| 110 | + self.hoursView.text = "Δευτέρα - Τετάρτη" | ||
| 111 | + self.phoneView.text = "210-6230453" | ||
| 112 | + self.addressView.text = "ΕΘΝΙΚΗΣ ΑΝΤΙΣΤΑΣΕΩΝ 4 41" | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + private func showPinDetailsView() { | ||
| 116 | + self.infoTopConstraint.constant = -320 | ||
| 117 | + UIView.animate(withDuration: 2.0) { | ||
| 118 | + self.view.layoutIfNeeded() | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + private func hidePinDetailsView() { | ||
| 123 | + self.infoTopConstraint.constant = 0 | ||
| 124 | + UIView.animate(withDuration: 2.0) { | ||
| 125 | + self.view.layoutIfNeeded() | ||
| 126 | + } | ||
| 127 | + } | ||
| 128 | + | ||
| 129 | + // map view delegate | ||
| 130 | + func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? { | ||
| 131 | + guard !(annotation is MKUserLocation) else { | ||
| 132 | + return nil | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + var annotationView = mapView.dequeueReusableAnnotationView(withIdentifier: "warply_custom") | ||
| 136 | + if (annotationView == nil) { | ||
| 137 | + annotationView = MKAnnotationView(annotation: annotation, reuseIdentifier: "warply_custom") | ||
| 138 | + annotationView?.canShowCallout = false | ||
| 139 | + } else { | ||
| 140 | + annotationView?.annotation = annotation | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + // TODO: add custom pin image? | ||
| 144 | + annotationView?.image = UIImage(named: "custom") | ||
| 145 | + | ||
| 146 | + return annotationView | ||
| 147 | + } | ||
| 148 | + | ||
| 149 | + func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) { | ||
| 150 | + loadPinDetailsView() | ||
| 151 | + showPinDetailsView() | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + func mapView(_ mapView: MKMapView, didDeselect view: MKAnnotationView) { | ||
| 155 | + hidePinDetailsView() | ||
| 156 | + } | ||
| 157 | +} | ||
| 158 | + | ||
| 159 | +private extension MKMapView { | ||
| 160 | + | ||
| 161 | + func centerToLocation(_ location: CLLocation, regionRadius: CLLocationDistance = 1000) { | ||
| 162 | + let coordinateRegion = MKCoordinateRegion( | ||
| 163 | + center: location.coordinate, | ||
| 164 | + latitudinalMeters: regionRadius, | ||
| 165 | + longitudinalMeters: regionRadius) | ||
| 166 | + setRegion(coordinateRegion, animated: true) | ||
| 167 | + } | ||
| 168 | +} |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment