From 863eeff742fd8b0af9f0e08f2df33d502d1f4807 Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Thu, 23 Feb 2017 11:53:00 -0700 Subject: [PATCH 1/8] Add attribution button --- Dimens.swift | 13 +++++++++ Localizable.strings | 9 ++++++ ios-sdk.xcodeproj/project.pbxproj | 32 +++++++++++++++++++++ src/MapViewController.swift | 48 ++++++++++++++++++++++++++++--- 4 files changed, 98 insertions(+), 4 deletions(-) create mode 100644 Dimens.swift create mode 100644 Localizable.strings diff --git a/Dimens.swift b/Dimens.swift new file mode 100644 index 0000000..11e2232 --- /dev/null +++ b/Dimens.swift @@ -0,0 +1,13 @@ +// +// Dimens.swift +// ios-sdk +// +// Created by Sarah Lensing on 2/24/17. +// Copyright © 2017 Mapzen. All rights reserved. +// + +import UIKit + +open class Dimens { + open static let defaultPadding : CGFloat = 10.0 +} diff --git a/Localizable.strings b/Localizable.strings new file mode 100644 index 0000000..dc5452f --- /dev/null +++ b/Localizable.strings @@ -0,0 +1,9 @@ +/* + Localizable.strings + ios-sdk + + Created by Sarah Lensing on 2/24/17. + Copyright © 2017 Mapzen. All rights reserved. +*/ + +"attribution" = "Powered by Mapzen"; diff --git a/ios-sdk.xcodeproj/project.pbxproj b/ios-sdk.xcodeproj/project.pbxproj index d44aa32..2fabdd7 100644 --- a/ios-sdk.xcodeproj/project.pbxproj +++ b/ios-sdk.xcodeproj/project.pbxproj @@ -9,6 +9,8 @@ /* Begin PBXBuildFile section */ 7D2FB7671E6103D500CB82CF /* DictionaryExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FB7661E6103D500CB82CF /* DictionaryExtensions.swift */; }; 7D2FB7691E64E66B00CB82CF /* DictionaryExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */; }; + 7D7DAE161E60AF9400FFCA6F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */; }; + 7D7DAE1B1E60B01800FFCA6F /* Dimens.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */; }; 7DF0AA2E1E5520ED00B0406E /* TestTGMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */; }; AC586709D7E7D4C22AA9474D /* Pods_ios_sdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B3EC60450343448FA4E699 /* Pods_ios_sdk.framework */; }; C8F52AC1BCE46BB17E1CE0A5 /* Pods_ios_sdkTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A3EA87256F2EA6D0C43260A /* Pods_ios_sdkTests.framework */; }; @@ -75,6 +77,8 @@ 5A3EA87256F2EA6D0C43260A /* Pods_ios_sdkTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios_sdkTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 7D2FB7661E6103D500CB82CF /* DictionaryExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensions.swift; sourceTree = ""; }; 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensionsTests.swift; sourceTree = ""; }; + 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; + 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dimens.swift; sourceTree = ""; }; 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestTGMapViewController.swift; sourceTree = ""; }; 92C35E8790FB3255237B1E77 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 99B3EC60450343448FA4E699 /* Pods_ios_sdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios_sdk.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -138,6 +142,31 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 7D7DAE171E60AFEE00FFCA6F /* resources */ = { + isa = PBXGroup; + children = ( + 7D7DAE191E60B00400FFCA6F /* dimens */, + 7D7DAE181E60AFFE00FFCA6F /* strings */, + ); + name = resources; + sourceTree = ""; + }; + 7D7DAE181E60AFFE00FFCA6F /* strings */ = { + isa = PBXGroup; + children = ( + 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */, + ); + name = strings; + sourceTree = ""; + }; + 7D7DAE191E60B00400FFCA6F /* dimens */ = { + isa = PBXGroup; + children = ( + 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */, + ); + name = dimens; + sourceTree = ""; + }; 8E4E4B43C1B764470EBBDBBA /* Pods */ = { isa = PBXGroup; children = ( @@ -184,6 +213,7 @@ DB7A33CB1C8F8E8B009CC743 = { isa = PBXGroup; children = ( + 7D7DAE171E60AFEE00FFCA6F /* resources */, DB366BDC1DF8BE090045C15F /* images */, DB3192671D351E4200272990 /* tangram */, DBC84EA51C985B6D00EE80D8 /* src */, @@ -370,6 +400,7 @@ DB366BDF1DF8BE090045C15F /* ic_find_me_normal@2x.png in Resources */, DB7A33DD1C8F8E8B009CC743 /* Main.storyboard in Resources */, DB6A3F7D1DFF4EA300FBE6B6 /* ic_find_me_normal@3x.png in Resources */, + 7D7DAE161E60AF9400FFCA6F /* Localizable.strings in Resources */, DBC869AF1D3666B300DDC4FE /* building-grid.gif in Resources */, DB6A3F7E1DFF4EA300FBE6B6 /* ic_find_me_pressed.png in Resources */, DBF5221D1DFB4752009D8F1E /* ic_find_me_pressed@2x.png in Resources */, @@ -490,6 +521,7 @@ DB22E59E1DA473CA004264E0 /* RouteDirectionCell.swift in Sources */, DB5B31511DE4A173005EB816 /* LocationManager.swift in Sources */, DBC869921D3663C700DDC4FE /* PeliasMapkitExtensions.swift in Sources */, + 7D7DAE1B1E60B01800FFCA6F /* Dimens.swift in Sources */, DB188EEE1E290D310054DEFD /* MapzenRoutingController.swift in Sources */, DB70FEA91DE3425800249509 /* MapViewController.swift in Sources */, DB22E59A1DA45D73004264E0 /* RoutingSearchVC.swift in Sources */, diff --git a/src/MapViewController.swift b/src/MapViewController.swift index 4b3fe8b..94a5bfb 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -68,6 +68,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { //Error Domains for NSError Appeasement open static let MapzenGeneralErrorDomain = "MapzenGeneralErrorDomain" + private static let mapzenRights = "https://mapzen.com/rights/" open var tgViewController: TGMapViewController = TGMapViewController() var currentLocationGem: TGMapMarkerId? @@ -143,6 +144,14 @@ open class MapViewController: UIViewController, LocationManagerDelegate { public typealias OnSceneLoaded = (String) -> () fileprivate var onSceneLoadedClosure : OnSceneLoaded? = nil + open var mapView : GLKView { + return tgViewController.view as! GLKView + } + + open var tabBarHeight : CGFloat { + return self.tabBarController?.tabBar.frame.height ?? 0 + } + init(){ super.init(nibName: nil, bundle: nil) defer { @@ -396,16 +405,18 @@ open class MapViewController: UIViewController, LocationManagerDelegate { override open func viewDidLoad() { super.viewDidLoad() LocationManager.sharedManager.delegate = self - - self.view.addSubview(tgViewController.view) - + + setupTgControllerView() + setupAttribution() + tgViewController.gestureDelegate = self tgViewController.mapViewDelegate = self } override open func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { super.viewWillTransition(to: size, with: coordinator) - tgViewController.viewWillTransition(to: size, with:coordinator) + let adjustedSize = CGSize(width: size.width, height: size.height-tabBarHeight) + tgViewController.viewWillTransition(to: adjustedSize, with:coordinator) } override open func viewWillAppear(_ animated: Bool) { @@ -480,6 +491,34 @@ open class MapViewController: UIViewController, LocationManagerDelegate { allSceneUpdates.append(TGSceneUpdate(path: "global.sdk_mapzen_api_key", value: "'\(apiKey)'")) return allSceneUpdates } + + //MARK: - private + + private func setupTgControllerView() { + tgViewController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height-tabBarHeight) + self.view.addSubview(tgViewController.view) + } + + private func setupAttribution() { + let attributionBtn = UIButton() + attributionBtn.setTitle(NSLocalizedString("attribution", comment: "Mapzen Attribution"), for: .normal) + attributionBtn.setTitleColor(.darkGray, for: .normal) + attributionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) + attributionBtn.addTarget(self, action: #selector(openMapzenTerms), for: .touchUpInside) + attributionBtn.sizeToFit() + attributionBtn.translatesAutoresizingMaskIntoConstraints = false + self.view.addSubview(attributionBtn) + + let horizontalConstraint = attributionBtn.leftAnchor.constraint(equalTo: mapView.leftAnchor, constant: Dimens.defaultPadding) + let verticalConstraint = attributionBtn.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -Dimens.defaultPadding) + NSLayoutConstraint.activate([horizontalConstraint, verticalConstraint]) + } + + @objc private func openMapzenTerms() { + let url = URL(string: MapViewController.mapzenRights) + if url == nil { return } + UIApplication.shared.openURL(url!) + } } extension MapViewController : TGMapViewDelegate, TGRecognizerDelegate { @@ -579,5 +618,6 @@ extension MapViewController : TGMapViewDelegate, TGRecognizerDelegate { open func mapView(_ view: TGMapViewController, recognizer: UIGestureRecognizer, didRecognizeShoveGesture displacement: CGPoint) { shoveDelegate?.mapController(self, didShoveMap: displacement) } + } From 7b8239f5e20aba9796cc91b70a6ef85222c1ee11 Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Fri, 24 Feb 2017 11:36:44 -0700 Subject: [PATCH 2/8] Fix find me button positioning --- Dimens.swift | 1 + src/MapViewController.swift | 11 +++-------- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/Dimens.swift b/Dimens.swift index 11e2232..a7582b7 100644 --- a/Dimens.swift +++ b/Dimens.swift @@ -10,4 +10,5 @@ import UIKit open class Dimens { open static let defaultPadding : CGFloat = 10.0 + open static let squareMapBtnSize : CGFloat = 48.0 } diff --git a/src/MapViewController.swift b/src/MapViewController.swift index 94a5bfb..37d54b2 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -418,14 +418,6 @@ open class MapViewController: UIViewController, LocationManagerDelegate { let adjustedSize = CGSize(width: size.width, height: size.height-tabBarHeight) tgViewController.viewWillTransition(to: adjustedSize, with:coordinator) } - - override open func viewWillAppear(_ animated: Bool) { - super.viewWillAppear(animated) - let viewRect = view.bounds - findMeButton.frame = CGRect(x: viewRect.width - 60.0, y: viewRect.height - 100.0, width: CGFloat(48), height: CGFloat(48)) - view.addSubview(findMeButton) - findMeButton.sizeToFit() - } func createFindMeButton() -> UIButton { let findMeButton = UIButton(type: UIButtonType.custom) @@ -438,6 +430,9 @@ open class MapViewController: UIViewController, LocationManagerDelegate { findMeButton.setBackgroundImage(UIImage(named: "ic_find_me_pressed"), for: [.selected]) findMeButton.backgroundColor = UIColor.white findMeButton.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin] + let viewRect = mapView.bounds + findMeButton.frame = CGRect(x: viewRect.width - Dimens.squareMapBtnSize - Dimens.defaultPadding, y: viewRect.height - Dimens.squareMapBtnSize - Dimens.defaultPadding, width: Dimens.squareMapBtnSize, height: Dimens.squareMapBtnSize) + mapView.addSubview(findMeButton) return findMeButton } From 10991e4e55a886ee951a01708210d65d7232e0aa Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Fri, 24 Feb 2017 11:37:48 -0700 Subject: [PATCH 3/8] Add attribution to mapView for consistency --- src/MapViewController.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MapViewController.swift b/src/MapViewController.swift index 37d54b2..7139f89 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -502,7 +502,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { attributionBtn.addTarget(self, action: #selector(openMapzenTerms), for: .touchUpInside) attributionBtn.sizeToFit() attributionBtn.translatesAutoresizingMaskIntoConstraints = false - self.view.addSubview(attributionBtn) + mapView.addSubview(attributionBtn) let horizontalConstraint = attributionBtn.leftAnchor.constraint(equalTo: mapView.leftAnchor, constant: Dimens.defaultPadding) let verticalConstraint = attributionBtn.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -Dimens.defaultPadding) From 7e0549cebfd91b38daef05f936f957d8d2b62db1 Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Fri, 24 Feb 2017 13:07:35 -0700 Subject: [PATCH 4/8] Add attribution test --- ios-sdk.xcodeproj/project.pbxproj | 8 ++++++ ios-sdkTests/MapViewControllerTests.swift | 12 ++++++++- ios-sdkTests/TestApplication.swift | 20 ++++++++++++++ src/ApplicationExtensions.swift | 15 +++++++++++ src/MapViewController.swift | 33 ++++++++++++----------- 5 files changed, 71 insertions(+), 17 deletions(-) create mode 100644 ios-sdkTests/TestApplication.swift create mode 100644 src/ApplicationExtensions.swift diff --git a/ios-sdk.xcodeproj/project.pbxproj b/ios-sdk.xcodeproj/project.pbxproj index 2fabdd7..1c68724 100644 --- a/ios-sdk.xcodeproj/project.pbxproj +++ b/ios-sdk.xcodeproj/project.pbxproj @@ -11,6 +11,8 @@ 7D2FB7691E64E66B00CB82CF /* DictionaryExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */; }; 7D7DAE161E60AF9400FFCA6F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */; }; 7D7DAE1B1E60B01800FFCA6F /* Dimens.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */; }; + 7D7DAE1D1E60C5C900FFCA6F /* TestApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1C1E60C5C900FFCA6F /* TestApplication.swift */; }; + 7D7DAE211E60EEA300FFCA6F /* ApplicationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE201E60EEA300FFCA6F /* ApplicationExtensions.swift */; }; 7DF0AA2E1E5520ED00B0406E /* TestTGMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */; }; AC586709D7E7D4C22AA9474D /* Pods_ios_sdk.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 99B3EC60450343448FA4E699 /* Pods_ios_sdk.framework */; }; C8F52AC1BCE46BB17E1CE0A5 /* Pods_ios_sdkTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A3EA87256F2EA6D0C43260A /* Pods_ios_sdkTests.framework */; }; @@ -79,6 +81,8 @@ 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensionsTests.swift; sourceTree = ""; }; 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dimens.swift; sourceTree = ""; }; + 7D7DAE1C1E60C5C900FFCA6F /* TestApplication.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestApplication.swift; sourceTree = ""; }; + 7D7DAE201E60EEA300FFCA6F /* ApplicationExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationExtensions.swift; sourceTree = ""; }; 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestTGMapViewController.swift; sourceTree = ""; }; 92C35E8790FB3255237B1E77 /* Pods.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 99B3EC60450343448FA4E699 /* Pods_ios_sdk.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_ios_sdk.framework; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -262,6 +266,7 @@ DB188EEB1E28492A0054DEFD /* MapzenManagerTests.swift */, 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */, 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */, + 7D7DAE1C1E60C5C900FFCA6F /* TestApplication.swift */, ); path = "ios-sdkTests"; sourceTree = ""; @@ -276,6 +281,7 @@ DB188EE91E2846600054DEFD /* MapzenManager.swift */, DB188EED1E290D310054DEFD /* MapzenRoutingController.swift */, 7D2FB7661E6103D500CB82CF /* DictionaryExtensions.swift */, + 7D7DAE201E60EEA300FFCA6F /* ApplicationExtensions.swift */, ); path = src; sourceTree = ""; @@ -516,6 +522,7 @@ files = ( DBFB759F1E2046D100CF6173 /* TangramExtensions.swift in Sources */, DBFB759D1E20345500CF6173 /* SearchPinsViewController.swift in Sources */, + 7D7DAE211E60EEA300FFCA6F /* ApplicationExtensions.swift in Sources */, DB188EEA1E2846600054DEFD /* MapzenManager.swift in Sources */, DBF441AE1D351B0A007DEE95 /* TangramVC.swift in Sources */, DB22E59E1DA473CA004264E0 /* RouteDirectionCell.swift in Sources */, @@ -538,6 +545,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 7D7DAE1D1E60C5C900FFCA6F /* TestApplication.swift in Sources */, 7DF0AA2E1E5520ED00B0406E /* TestTGMapViewController.swift in Sources */, DB188EEC1E28492A0054DEFD /* MapzenManagerTests.swift in Sources */, DBCBC5BF1E0AE1CF0045B345 /* MapViewControllerTests.swift in Sources */, diff --git a/ios-sdkTests/MapViewControllerTests.swift b/ios-sdkTests/MapViewControllerTests.swift index 7b63e1c..c494164 100644 --- a/ios-sdkTests/MapViewControllerTests.swift +++ b/ios-sdkTests/MapViewControllerTests.swift @@ -12,7 +12,6 @@ import TangramMap import CoreLocation class TestMapViewController: MapViewController { - func lastSetPointValue() -> TGGeoPoint? { return lastSetPoint } @@ -559,6 +558,17 @@ class MapViewControllerTests: XCTestCase { controller.mapView(tgViewController, didSelectMarker: nil, atScreenPosition: CGPoint()) XCTAssertFalse(delegate.markerPicked) } + + func testAttributionOpensRights() { + let testApplication = TestApplication() + controller.application = testApplication + controller.viewDidLoad() + let actions = controller.attributionBtn.actions(forTarget: controller, forControlEvent: .touchUpInside) + let selectorStr = actions?.first + controller.perform(NSSelectorFromString(selectorStr!)) + XCTAssertEqual(testApplication.urlToOpen?.absoluteString, "https://mapzen.com/rights/") + } + } class TestPanDelegate : MapPanGestureDelegate { diff --git a/ios-sdkTests/TestApplication.swift b/ios-sdkTests/TestApplication.swift new file mode 100644 index 0000000..2fb796c --- /dev/null +++ b/ios-sdkTests/TestApplication.swift @@ -0,0 +1,20 @@ +// +// TestApplication.swift +// ios-sdk +// +// Created by Sarah Lensing on 2/24/17. +// Copyright © 2017 Mapzen. All rights reserved. +// + +import UIKit +@testable import ios_sdk + +class TestApplication: ApplicationProtocol { + + open var urlToOpen : URL? + + func openURL(_ url: URL) -> Bool { + urlToOpen = url + return false + } +} diff --git a/src/ApplicationExtensions.swift b/src/ApplicationExtensions.swift new file mode 100644 index 0000000..8e964bd --- /dev/null +++ b/src/ApplicationExtensions.swift @@ -0,0 +1,15 @@ +// +// ApplicationExtensions.swift +// ios-sdk +// +// Created by Sarah Lensing on 2/24/17. +// Copyright © 2017 Mapzen. All rights reserved. +// + +import UIKit + +protocol ApplicationProtocol { + func openURL(_ url: URL) -> Bool +} + +extension UIApplication: ApplicationProtocol {} diff --git a/src/MapViewController.swift b/src/MapViewController.swift index 7139f89..a990480 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -70,6 +70,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { open static let MapzenGeneralErrorDomain = "MapzenGeneralErrorDomain" private static let mapzenRights = "https://mapzen.com/rights/" + var application : ApplicationProtocol = UIApplication.shared open var tgViewController: TGMapViewController = TGMapViewController() var currentLocationGem: TGMapMarkerId? var lastSetPoint: TGGeoPoint? @@ -78,6 +79,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { open var shouldFollowCurrentLocation = false open var findMeButton = UIButton(type: .custom) open var currentAnnotations: [PeliasMapkitAnnotation : TGMapMarkerId] = Dictionary() + open var attributionBtn = UIButton() open var cameraType: TGCameraType { set { @@ -475,18 +477,6 @@ open class MapViewController: UIViewController, LocationManagerDelegate { return } - private func updatesWithApiKeyUpdate(_ sceneUpdates: [TGSceneUpdate]) throws -> [TGSceneUpdate] { - guard let apiKey = MapzenManager.sharedManager.apiKey else { - throw NSError(domain: MapViewController.MapzenGeneralErrorDomain, - code: MZError.apiKeyNotSet.rawValue, - userInfo: nil) - } - var allSceneUpdates = [TGSceneUpdate]() - allSceneUpdates.append(contentsOf: sceneUpdates) - allSceneUpdates.append(TGSceneUpdate(path: "global.sdk_mapzen_api_key", value: "'\(apiKey)'")) - return allSceneUpdates - } - //MARK: - private private func setupTgControllerView() { @@ -495,7 +485,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { } private func setupAttribution() { - let attributionBtn = UIButton() + attributionBtn = UIButton() attributionBtn.setTitle(NSLocalizedString("attribution", comment: "Mapzen Attribution"), for: .normal) attributionBtn.setTitleColor(.darkGray, for: .normal) attributionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) @@ -510,9 +500,20 @@ open class MapViewController: UIViewController, LocationManagerDelegate { } @objc private func openMapzenTerms() { - let url = URL(string: MapViewController.mapzenRights) - if url == nil { return } - UIApplication.shared.openURL(url!) + guard let url = URL(string: MapViewController.mapzenRights) else { return } + let _ = application.openURL(url) + } + + private func updatesWithApiKeyUpdate(_ sceneUpdates: [TGSceneUpdate]) throws -> [TGSceneUpdate] { + guard let apiKey = MapzenManager.sharedManager.apiKey else { + throw NSError(domain: MapViewController.MapzenGeneralErrorDomain, + code: MZError.apiKeyNotSet.rawValue, + userInfo: nil) + } + var allSceneUpdates = [TGSceneUpdate]() + allSceneUpdates.append(contentsOf: sceneUpdates) + allSceneUpdates.append(TGSceneUpdate(path: "global.sdk_mapzen_api_key", value: "'\(apiKey)'")) + return allSceneUpdates } } From 852d01aae616ef3af99aa98b1e0e18ec7c2e8d02 Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Tue, 28 Feb 2017 15:54:27 -0500 Subject: [PATCH 5/8] Update Dimensions file --- Dimens.swift | 14 -------------- Dimensions.swift | 17 +++++++++++++++++ ios-sdk.xcodeproj/project.pbxproj | 8 ++++---- src/MapViewController.swift | 6 +++--- 4 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 Dimens.swift create mode 100644 Dimensions.swift diff --git a/Dimens.swift b/Dimens.swift deleted file mode 100644 index a7582b7..0000000 --- a/Dimens.swift +++ /dev/null @@ -1,14 +0,0 @@ -// -// Dimens.swift -// ios-sdk -// -// Created by Sarah Lensing on 2/24/17. -// Copyright © 2017 Mapzen. All rights reserved. -// - -import UIKit - -open class Dimens { - open static let defaultPadding : CGFloat = 10.0 - open static let squareMapBtnSize : CGFloat = 48.0 -} diff --git a/Dimensions.swift b/Dimensions.swift new file mode 100644 index 0000000..11d88f1 --- /dev/null +++ b/Dimensions.swift @@ -0,0 +1,17 @@ +// +// Dimensions.swift +// ios-sdk +// +// Created by Sarah Lensing on 2/24/17. +// Copyright © 2017 Mapzen. All rights reserved. +// + +import CoreGraphics + +// Holds constant values for UI element properties such as padding and width/height +public class Dimensions { + // Default padding used for map UI elements + public static let defaultPadding : CGFloat = 10.0 + // Size of all square map buttons such as the "find me" button + public static let squareMapBtnSize : CGFloat = 48.0 +} diff --git a/ios-sdk.xcodeproj/project.pbxproj b/ios-sdk.xcodeproj/project.pbxproj index 1c68724..10349e0 100644 --- a/ios-sdk.xcodeproj/project.pbxproj +++ b/ios-sdk.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 7D2FB7671E6103D500CB82CF /* DictionaryExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FB7661E6103D500CB82CF /* DictionaryExtensions.swift */; }; 7D2FB7691E64E66B00CB82CF /* DictionaryExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */; }; 7D7DAE161E60AF9400FFCA6F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */; }; - 7D7DAE1B1E60B01800FFCA6F /* Dimens.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */; }; + 7D7DAE1B1E60B01800FFCA6F /* Dimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1A1E60B01800FFCA6F /* Dimensions.swift */; }; 7D7DAE1D1E60C5C900FFCA6F /* TestApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1C1E60C5C900FFCA6F /* TestApplication.swift */; }; 7D7DAE211E60EEA300FFCA6F /* ApplicationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE201E60EEA300FFCA6F /* ApplicationExtensions.swift */; }; 7DF0AA2E1E5520ED00B0406E /* TestTGMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */; }; @@ -80,7 +80,7 @@ 7D2FB7661E6103D500CB82CF /* DictionaryExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensions.swift; sourceTree = ""; }; 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensionsTests.swift; sourceTree = ""; }; 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; - 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dimens.swift; sourceTree = ""; }; + 7D7DAE1A1E60B01800FFCA6F /* Dimensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dimensions.swift; sourceTree = ""; }; 7D7DAE1C1E60C5C900FFCA6F /* TestApplication.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestApplication.swift; sourceTree = ""; }; 7D7DAE201E60EEA300FFCA6F /* ApplicationExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationExtensions.swift; sourceTree = ""; }; 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestTGMapViewController.swift; sourceTree = ""; }; @@ -166,7 +166,7 @@ 7D7DAE191E60B00400FFCA6F /* dimens */ = { isa = PBXGroup; children = ( - 7D7DAE1A1E60B01800FFCA6F /* Dimens.swift */, + 7D7DAE1A1E60B01800FFCA6F /* Dimensions.swift */, ); name = dimens; sourceTree = ""; @@ -528,7 +528,7 @@ DB22E59E1DA473CA004264E0 /* RouteDirectionCell.swift in Sources */, DB5B31511DE4A173005EB816 /* LocationManager.swift in Sources */, DBC869921D3663C700DDC4FE /* PeliasMapkitExtensions.swift in Sources */, - 7D7DAE1B1E60B01800FFCA6F /* Dimens.swift in Sources */, + 7D7DAE1B1E60B01800FFCA6F /* Dimensions.swift in Sources */, DB188EEE1E290D310054DEFD /* MapzenRoutingController.swift in Sources */, DB70FEA91DE3425800249509 /* MapViewController.swift in Sources */, DB22E59A1DA45D73004264E0 /* RoutingSearchVC.swift in Sources */, diff --git a/src/MapViewController.swift b/src/MapViewController.swift index a990480..e162081 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -433,7 +433,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { findMeButton.backgroundColor = UIColor.white findMeButton.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin] let viewRect = mapView.bounds - findMeButton.frame = CGRect(x: viewRect.width - Dimens.squareMapBtnSize - Dimens.defaultPadding, y: viewRect.height - Dimens.squareMapBtnSize - Dimens.defaultPadding, width: Dimens.squareMapBtnSize, height: Dimens.squareMapBtnSize) + findMeButton.frame = CGRect(x: viewRect.width - Dimensions.squareMapBtnSize - Dimensions.defaultPadding, y: viewRect.height - Dimensions.squareMapBtnSize - Dimensions.defaultPadding, width: Dimensions.squareMapBtnSize, height: Dimensions.squareMapBtnSize) mapView.addSubview(findMeButton) return findMeButton } @@ -494,8 +494,8 @@ open class MapViewController: UIViewController, LocationManagerDelegate { attributionBtn.translatesAutoresizingMaskIntoConstraints = false mapView.addSubview(attributionBtn) - let horizontalConstraint = attributionBtn.leftAnchor.constraint(equalTo: mapView.leftAnchor, constant: Dimens.defaultPadding) - let verticalConstraint = attributionBtn.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -Dimens.defaultPadding) + let horizontalConstraint = attributionBtn.leftAnchor.constraint(equalTo: mapView.leftAnchor, constant: Dimensions.defaultPadding) + let verticalConstraint = attributionBtn.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -Dimensions.defaultPadding) NSLayoutConstraint.activate([horizontalConstraint, verticalConstraint]) } From 18b277c186a45fd50d40001e13e8c5fc6524a62e Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Tue, 28 Feb 2017 23:47:41 -0500 Subject: [PATCH 6/8] Update map subview constraints --- ios-sdkTests/MapViewControllerTests.swift | 5 +- src/MapViewController.swift | 83 ++++++++++++++--------- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/ios-sdkTests/MapViewControllerTests.swift b/ios-sdkTests/MapViewControllerTests.swift index c494164..9dfd50c 100644 --- a/ios-sdkTests/MapViewControllerTests.swift +++ b/ios-sdkTests/MapViewControllerTests.swift @@ -31,11 +31,13 @@ class MockHTTPHandler: TGHttpHandler { class MapViewControllerTests: XCTestCase { + let testApplication = TestApplication() var controller = TestMapViewController() var tgViewController = TestTGMapViewController() let mockLocation = CLLocation(latitude: 0.0, longitude: 0.0) // Null Island! override func setUp() { + controller = TestMapViewController(applicationProtocol: testApplication) controller.tgViewController = tgViewController let mockHTTP = MockHTTPHandler() controller.tgViewController.httpHandler = mockHTTP @@ -232,6 +234,7 @@ class MapViewControllerTests: XCTestCase { } func testFindMeButtonInitialState() { + controller.viewDidLoad() //Test Initial State XCTAssertTrue(controller.findMeButton.isHidden) XCTAssertFalse(controller.findMeButton.isEnabled) @@ -560,8 +563,6 @@ class MapViewControllerTests: XCTestCase { } func testAttributionOpensRights() { - let testApplication = TestApplication() - controller.application = testApplication controller.viewDidLoad() let actions = controller.attributionBtn.actions(forTarget: controller, forControlEvent: .touchUpInside) let selectorStr = actions?.first diff --git a/src/MapViewController.swift b/src/MapViewController.swift index e162081..6d661cc 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -70,7 +70,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { open static let MapzenGeneralErrorDomain = "MapzenGeneralErrorDomain" private static let mapzenRights = "https://mapzen.com/rights/" - var application : ApplicationProtocol = UIApplication.shared + let application : ApplicationProtocol open var tgViewController: TGMapViewController = TGMapViewController() var currentLocationGem: TGMapMarkerId? var lastSetPoint: TGGeoPoint? @@ -146,26 +146,32 @@ open class MapViewController: UIViewController, LocationManagerDelegate { public typealias OnSceneLoaded = (String) -> () fileprivate var onSceneLoadedClosure : OnSceneLoaded? = nil - open var mapView : GLKView { - return tgViewController.view as! GLKView + init() { + application = UIApplication.shared + super.init(nibName: nil, bundle: nil) } - open var tabBarHeight : CGFloat { - return self.tabBarController?.tabBar.frame.height ?? 0 + required public init?(coder aDecoder: NSCoder) { + application = UIApplication.shared + super.init(coder: aDecoder) } - - init(){ + + public override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + application = UIApplication.shared + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + init(applicationProtocol: ApplicationProtocol) { + application = applicationProtocol super.init(nibName: nil, bundle: nil) - defer { - findMeButton = createFindMeButton() - } } - required public init?(coder aDecoder: NSCoder) { - super.init(coder: aDecoder) - defer { - findMeButton = createFindMeButton() - } + open var mapView : GLKView { + return tgViewController.view as! GLKView + } + + open var tabBarHeight : CGFloat { + return self.tabBarController?.tabBar.frame.height ?? 0 } open func animate(toPosition position: TGGeoPoint, withDuration seconds: Float) { @@ -410,6 +416,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { setupTgControllerView() setupAttribution() + setupFindMeButton() tgViewController.gestureDelegate = self tgViewController.mapViewDelegate = self @@ -421,23 +428,6 @@ open class MapViewController: UIViewController, LocationManagerDelegate { tgViewController.viewWillTransition(to: adjustedSize, with:coordinator) } - func createFindMeButton() -> UIButton { - let findMeButton = UIButton(type: UIButtonType.custom) - findMeButton.addTarget(self, action: #selector(MapViewController.defaultFindMeAction(_:touchEvent:)), for: .touchUpInside) - findMeButton.isEnabled = false - findMeButton.isHidden = true - findMeButton.adjustsImageWhenHighlighted = false - findMeButton.setBackgroundImage(UIImage(named: "ic_find_me_normal"), for: UIControlState()) - //TODO: This should also have .Highlighted as well .Selected , but something about the @3x assets and UIButton is misbehaving; might need bug opened with Apple. - findMeButton.setBackgroundImage(UIImage(named: "ic_find_me_pressed"), for: [.selected]) - findMeButton.backgroundColor = UIColor.white - findMeButton.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin] - let viewRect = mapView.bounds - findMeButton.frame = CGRect(x: viewRect.width - Dimensions.squareMapBtnSize - Dimensions.defaultPadding, y: viewRect.height - Dimensions.squareMapBtnSize - Dimensions.defaultPadding, width: Dimensions.squareMapBtnSize, height: Dimensions.squareMapBtnSize) - mapView.addSubview(findMeButton) - return findMeButton - } - //MARK: - LocationManagerDelegate open func locationDidUpdate(_ location: CLLocation) { @@ -480,8 +470,14 @@ open class MapViewController: UIViewController, LocationManagerDelegate { //MARK: - private private func setupTgControllerView() { - tgViewController.view.frame = CGRect(x: 0, y: 0, width: self.view.bounds.width, height: self.view.bounds.height-tabBarHeight) + tgViewController.view.translatesAutoresizingMaskIntoConstraints = false self.view.addSubview(tgViewController.view) + + let leftConstraint = tgViewController.view.leftAnchor.constraint(equalTo: view.leftAnchor) + let rightConstraint = tgViewController.view.rightAnchor.constraint(equalTo: view.rightAnchor) + let topConstraint = tgViewController.view.topAnchor.constraint(equalTo: view.topAnchor) + let bottomConstraint = tgViewController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor, constant: -tabBarHeight) + NSLayoutConstraint.activate([leftConstraint, rightConstraint, topConstraint, bottomConstraint]) } private func setupAttribution() { @@ -499,6 +495,27 @@ open class MapViewController: UIViewController, LocationManagerDelegate { NSLayoutConstraint.activate([horizontalConstraint, verticalConstraint]) } + private func setupFindMeButton() { + findMeButton = UIButton(type: UIButtonType.custom) + findMeButton.addTarget(self, action: #selector(MapViewController.defaultFindMeAction(_:touchEvent:)), for: .touchUpInside) + findMeButton.isEnabled = false + findMeButton.isHidden = true + findMeButton.adjustsImageWhenHighlighted = false + findMeButton.setBackgroundImage(UIImage(named: "ic_find_me_normal"), for: UIControlState()) + //TODO: This should also have .Highlighted as well .Selected , but something about the @3x assets and UIButton is misbehaving; might need bug opened with Apple. + findMeButton.setBackgroundImage(UIImage(named: "ic_find_me_pressed"), for: [.selected]) + findMeButton.backgroundColor = UIColor.white + //findMeButton.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin] + findMeButton.translatesAutoresizingMaskIntoConstraints = false + mapView.addSubview(findMeButton) + + let horizontalConstraint = findMeButton.rightAnchor.constraint(equalTo: mapView.rightAnchor, constant: -Dimensions.defaultPadding) + let verticalConstraint = findMeButton.bottomAnchor.constraint(equalTo: mapView.bottomAnchor, constant: -Dimensions.defaultPadding) + let widthConstraint = findMeButton.widthAnchor.constraint(equalToConstant: Dimensions.squareMapBtnSize) + let heightConstraint = findMeButton.widthAnchor.constraint(equalToConstant: Dimensions.squareMapBtnSize) + NSLayoutConstraint.activate([horizontalConstraint, verticalConstraint, widthConstraint, heightConstraint]) + } + @objc private func openMapzenTerms() { guard let url = URL(string: MapViewController.mapzenRights) else { return } let _ = application.openURL(url) From 8c92df633202f6528fd5217841619d4371593664 Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Wed, 1 Mar 2017 16:35:23 -0500 Subject: [PATCH 7/8] Remove strings file for now --- Localizable.strings | 9 ------ ios-sdk.xcodeproj/project.pbxproj | 32 ++++--------------- src/MapViewController.swift | 2 +- .../dimensions/Dimensions.swift | 0 4 files changed, 8 insertions(+), 35 deletions(-) delete mode 100644 Localizable.strings rename Dimensions.swift => src/dimensions/Dimensions.swift (100%) diff --git a/Localizable.strings b/Localizable.strings deleted file mode 100644 index dc5452f..0000000 --- a/Localizable.strings +++ /dev/null @@ -1,9 +0,0 @@ -/* - Localizable.strings - ios-sdk - - Created by Sarah Lensing on 2/24/17. - Copyright © 2017 Mapzen. All rights reserved. -*/ - -"attribution" = "Powered by Mapzen"; diff --git a/ios-sdk.xcodeproj/project.pbxproj b/ios-sdk.xcodeproj/project.pbxproj index 10349e0..cf77066 100644 --- a/ios-sdk.xcodeproj/project.pbxproj +++ b/ios-sdk.xcodeproj/project.pbxproj @@ -10,7 +10,7 @@ 7D2FB7671E6103D500CB82CF /* DictionaryExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FB7661E6103D500CB82CF /* DictionaryExtensions.swift */; }; 7D2FB7691E64E66B00CB82CF /* DictionaryExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */; }; 7D7DAE161E60AF9400FFCA6F /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */; }; - 7D7DAE1B1E60B01800FFCA6F /* Dimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1A1E60B01800FFCA6F /* Dimensions.swift */; }; + 7D7847251E6775EA000D56CA /* Dimensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7847241E6775EA000D56CA /* Dimensions.swift */; }; 7D7DAE1D1E60C5C900FFCA6F /* TestApplication.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE1C1E60C5C900FFCA6F /* TestApplication.swift */; }; 7D7DAE211E60EEA300FFCA6F /* ApplicationExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7D7DAE201E60EEA300FFCA6F /* ApplicationExtensions.swift */; }; 7DF0AA2E1E5520ED00B0406E /* TestTGMapViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */; }; @@ -80,7 +80,7 @@ 7D2FB7661E6103D500CB82CF /* DictionaryExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensions.swift; sourceTree = ""; }; 7D2FB7681E64E66B00CB82CF /* DictionaryExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DictionaryExtensionsTests.swift; sourceTree = ""; }; 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; path = Localizable.strings; sourceTree = ""; }; - 7D7DAE1A1E60B01800FFCA6F /* Dimensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dimensions.swift; sourceTree = ""; }; + 7D7847241E6775EA000D56CA /* Dimensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Dimensions.swift; sourceTree = ""; }; 7D7DAE1C1E60C5C900FFCA6F /* TestApplication.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestApplication.swift; sourceTree = ""; }; 7D7DAE201E60EEA300FFCA6F /* ApplicationExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ApplicationExtensions.swift; sourceTree = ""; }; 7DF0AA2D1E5520ED00B0406E /* TestTGMapViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestTGMapViewController.swift; sourceTree = ""; }; @@ -146,29 +146,12 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ - 7D7DAE171E60AFEE00FFCA6F /* resources */ = { + 7D7847231E6775EA000D56CA /* dimensions */ = { isa = PBXGroup; children = ( - 7D7DAE191E60B00400FFCA6F /* dimens */, - 7D7DAE181E60AFFE00FFCA6F /* strings */, + 7D7847241E6775EA000D56CA /* Dimensions.swift */, ); - name = resources; - sourceTree = ""; - }; - 7D7DAE181E60AFFE00FFCA6F /* strings */ = { - isa = PBXGroup; - children = ( - 7D7DAE151E60AF9400FFCA6F /* Localizable.strings */, - ); - name = strings; - sourceTree = ""; - }; - 7D7DAE191E60B00400FFCA6F /* dimens */ = { - isa = PBXGroup; - children = ( - 7D7DAE1A1E60B01800FFCA6F /* Dimensions.swift */, - ); - name = dimens; + path = dimensions; sourceTree = ""; }; 8E4E4B43C1B764470EBBDBBA /* Pods */ = { @@ -217,7 +200,6 @@ DB7A33CB1C8F8E8B009CC743 = { isa = PBXGroup; children = ( - 7D7DAE171E60AFEE00FFCA6F /* resources */, DB366BDC1DF8BE090045C15F /* images */, DB3192671D351E4200272990 /* tangram */, DBC84EA51C985B6D00EE80D8 /* src */, @@ -274,6 +256,7 @@ DBC84EA51C985B6D00EE80D8 /* src */ = { isa = PBXGroup; children = ( + 7D7847231E6775EA000D56CA /* dimensions */, DBC869911D3663C700DDC4FE /* PeliasMapkitExtensions.swift */, DB70FEA81DE3425800249509 /* MapViewController.swift */, DB5B31501DE4A173005EB816 /* LocationManager.swift */, @@ -406,7 +389,6 @@ DB366BDF1DF8BE090045C15F /* ic_find_me_normal@2x.png in Resources */, DB7A33DD1C8F8E8B009CC743 /* Main.storyboard in Resources */, DB6A3F7D1DFF4EA300FBE6B6 /* ic_find_me_normal@3x.png in Resources */, - 7D7DAE161E60AF9400FFCA6F /* Localizable.strings in Resources */, DBC869AF1D3666B300DDC4FE /* building-grid.gif in Resources */, DB6A3F7E1DFF4EA300FBE6B6 /* ic_find_me_pressed.png in Resources */, DBF5221D1DFB4752009D8F1E /* ic_find_me_pressed@2x.png in Resources */, @@ -523,12 +505,12 @@ DBFB759F1E2046D100CF6173 /* TangramExtensions.swift in Sources */, DBFB759D1E20345500CF6173 /* SearchPinsViewController.swift in Sources */, 7D7DAE211E60EEA300FFCA6F /* ApplicationExtensions.swift in Sources */, + 7D7847251E6775EA000D56CA /* Dimensions.swift in Sources */, DB188EEA1E2846600054DEFD /* MapzenManager.swift in Sources */, DBF441AE1D351B0A007DEE95 /* TangramVC.swift in Sources */, DB22E59E1DA473CA004264E0 /* RouteDirectionCell.swift in Sources */, DB5B31511DE4A173005EB816 /* LocationManager.swift in Sources */, DBC869921D3663C700DDC4FE /* PeliasMapkitExtensions.swift in Sources */, - 7D7DAE1B1E60B01800FFCA6F /* Dimensions.swift in Sources */, DB188EEE1E290D310054DEFD /* MapzenRoutingController.swift in Sources */, DB70FEA91DE3425800249509 /* MapViewController.swift in Sources */, DB22E59A1DA45D73004264E0 /* RoutingSearchVC.swift in Sources */, diff --git a/src/MapViewController.swift b/src/MapViewController.swift index 6d661cc..4dbe242 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -482,7 +482,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { private func setupAttribution() { attributionBtn = UIButton() - attributionBtn.setTitle(NSLocalizedString("attribution", comment: "Mapzen Attribution"), for: .normal) + attributionBtn.setTitle("Powered by Mapzen", for: .normal) attributionBtn.setTitleColor(.darkGray, for: .normal) attributionBtn.titleLabel?.font = UIFont.systemFont(ofSize: 14) attributionBtn.addTarget(self, action: #selector(openMapzenTerms), for: .touchUpInside) diff --git a/Dimensions.swift b/src/dimensions/Dimensions.swift similarity index 100% rename from Dimensions.swift rename to src/dimensions/Dimensions.swift From 6ee219ffcfbc577189e5357d3604ef20c191d628 Mon Sep 17 00:00:00 2001 From: Sarah Lensing Date: Wed, 1 Mar 2017 17:18:14 -0500 Subject: [PATCH 8/8] Change setup method scope to internal --- ios-sdkTests/MapViewControllerTests.swift | 2 +- src/MapViewController.swift | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ios-sdkTests/MapViewControllerTests.swift b/ios-sdkTests/MapViewControllerTests.swift index 9dfd50c..abb3350 100644 --- a/ios-sdkTests/MapViewControllerTests.swift +++ b/ios-sdkTests/MapViewControllerTests.swift @@ -234,7 +234,7 @@ class MapViewControllerTests: XCTestCase { } func testFindMeButtonInitialState() { - controller.viewDidLoad() + controller.setupFindMeButton() //Test Initial State XCTAssertTrue(controller.findMeButton.isHidden) XCTAssertFalse(controller.findMeButton.isEnabled) diff --git a/src/MapViewController.swift b/src/MapViewController.swift index 4dbe242..3a7d23b 100644 --- a/src/MapViewController.swift +++ b/src/MapViewController.swift @@ -495,7 +495,7 @@ open class MapViewController: UIViewController, LocationManagerDelegate { NSLayoutConstraint.activate([horizontalConstraint, verticalConstraint]) } - private func setupFindMeButton() { + func setupFindMeButton() { findMeButton = UIButton(type: UIButtonType.custom) findMeButton.addTarget(self, action: #selector(MapViewController.defaultFindMeAction(_:touchEvent:)), for: .touchUpInside) findMeButton.isEnabled = false