Skip to content

Commit

Permalink
Sync/internal to public main (#1937)
Browse files Browse the repository at this point in the history
* Enable zoom during dragging gesture (#1391)

* Enable Pinch and Pan gestures work together

* Fix unit tests

* Bugfix/mapsios 538 bearing is incorrect when rotate (#1396)

* Correct PanZoomPinchBehavior drag camera options.

* Correct PanPinchBehavior drag camera options

* allow animations during longtap (#1415) (#1418)

* Mark snapshotter tile mode as deprecated (#1427)

* Prepare v10.12.0 release (#1435)

* Bump MapboxCoreMaps to 10.12.0 and MapboxCommon to 23.4.0
* Bump MapboxMaps version to 10.12.0
* Update LICENSE.md

* Pass metal view size instead of map view size as they can diverge to MapboxMap (#1437)

Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com>

* Bypass Edit Home Screen alert in iOS 16.2 test lab devices (#1438)

* Bypass Edit Home Screen alert in iOS 16.2 test lab devices

* Dismiss Edit Home Screen alert before first test

---------

Co-authored-by: Roman Gardukevich <roman.gardukevich@mapbox.com>
Co-authored-by: Ivan Persidsky <ivan.persidskii@mapbox.com>
Co-authored-by: Roman Laitarenko <roman.laitarenko@mapbox.com>
  • Loading branch information
4 people committed Mar 24, 2023
1 parent 3257f24 commit 203af16
Show file tree
Hide file tree
Showing 30 changed files with 198 additions and 199 deletions.
8 changes: 4 additions & 4 deletions Apps/Apps.xcworkspace/xcshareddata/swiftpm/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"repositoryURL": "https://github.com/mapbox/mapbox-common-ios.git",
"state": {
"branch": null,
"revision": "d38abed1cfca3843308d478450c3d8b07a797c5a",
"version": "23.4.0-rc.1"
"revision": "49f0c56ce7a113b4474e08837a1985cf1a8590b5",
"version": "23.4.0"
}
},
{
"package": "MapboxCoreMaps",
"repositoryURL": "https://github.com/mapbox/mapbox-core-maps-ios.git",
"state": {
"branch": null,
"revision": "82706a65bf7a51818d943c91f014d17588b0f65e",
"version": "10.12.0-rc.1"
"revision": "d0826b92cb5094fb26ce6f8f6a09bc4734751baf",
"version": "10.12.0"
}
},
{
Expand Down
6 changes: 6 additions & 0 deletions Apps/Examples/Examples.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
74A2313C27EDCE7F0065FB7D /* AnnotationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74A2313B27EDCE7F0065FB7D /* AnnotationView.swift */; };
74A2313E27EE1C640065FB7D /* ViewAnnotationWithPointAnnotationExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74A2313D27EE1C630065FB7D /* ViewAnnotationWithPointAnnotationExample.swift */; };
74D0803A28A13916008EB69C /* BasicLocationPulsingExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D0803928A13916008EB69C /* BasicLocationPulsingExample.swift */; };
955B69EF299AAE6700FD4A19 /* RasterColorExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955B69EE299AAE6700FD4A19 /* RasterColorExample.swift */; };
95857AC229B7A1A2005D238C /* LongTapAnimationExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = 95857AC129B7A1A2005D238C /* LongTapAnimationExample.swift */; };
A41E58342654593500D8B946 /* SwitchStylesExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41E58332654593500D8B946 /* SwitchStylesExample.swift */; };
A41E584C26555A3400D8B946 /* PointClusteringExample.swift in Sources */ = {isa = PBXBuildFile; fileRef = A41E584B26555A3400D8B946 /* PointClusteringExample.swift */; };
A41E58F4265C005300D8B946 /* blueprint_style.json in Resources */ = {isa = PBXBuildFile; fileRef = A41E58F3265C005300D8B946 /* blueprint_style.json */; };
Expand Down Expand Up @@ -226,6 +228,8 @@
74A2313D27EE1C630065FB7D /* ViewAnnotationWithPointAnnotationExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewAnnotationWithPointAnnotationExample.swift; sourceTree = "<group>"; };
74A2313F27EE243B0065FB7D /* annotations.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = annotations.json; sourceTree = "<group>"; };
74D0803928A13916008EB69C /* BasicLocationPulsingExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BasicLocationPulsingExample.swift; sourceTree = "<group>"; };
955B69EE299AAE6700FD4A19 /* RasterColorExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RasterColorExample.swift; sourceTree = "<group>"; };
95857AC129B7A1A2005D238C /* LongTapAnimationExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LongTapAnimationExample.swift; sourceTree = "<group>"; };
A41E58332654593500D8B946 /* SwitchStylesExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwitchStylesExample.swift; sourceTree = "<group>"; };
A41E584B26555A3400D8B946 /* PointClusteringExample.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PointClusteringExample.swift; sourceTree = "<group>"; };
A41E58F3265C005300D8B946 /* blueprint_style.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = blueprint_style.json; sourceTree = "<group>"; };
Expand Down Expand Up @@ -332,6 +336,7 @@
17B48066268A4E9300CF0D5E /* DistanceExpressionExample.swift */,
077E3B2B2581810600564A3E /* ExternalVectorSourceExample.swift */,
07B0715F254789D6007F2865 /* FeaturesAtPointExample.swift */,
95857AC129B7A1A2005D238C /* LongTapAnimationExample.swift */,
0C784D1026D002DC004AE7D0 /* FeatureStateExample.swift */,
077E3B8F2581966300564A3E /* FitCameraToGeometryExample.swift */,
58A28B5A2869F69B006F7D93 /* GlobeExample.swift */,
Expand Down Expand Up @@ -708,6 +713,7 @@
5812B55127C5A0E500E10063 /* CustomLocationProviderExample.swift in Sources */,
CADCF71D2584990E0065C51B /* CustomPointAnnotationExample.swift in Sources */,
17B4806B268BD91000CF0D5E /* RasterTileSourceExample.swift in Sources */,
95857AC229B7A1A2005D238C /* LongTapAnimationExample.swift in Sources */,
3A7CE98B282AB0DE00C3A0B8 /* NavigationSimulator.swift in Sources */,
CADCF7212584990E0065C51B /* PolygonAnnotationExample.swift in Sources */,
A41E58342654593500D8B946 /* SwitchStylesExample.swift in Sources */,
Expand Down
65 changes: 65 additions & 0 deletions Apps/Examples/Examples/All Examples/LongTapAnimationExample.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import MapboxMaps
import UIKit

private extension String {
static let blueMarker = "blue-marker"
}

// This examples shows how to animate camera to a long-tapped coordinate.
public class LongTapAnimationExample: UIViewController, ExampleProtocol {
internal var mapView: MapView!
private var pointAnnotationManager: PointAnnotationManager!

override public func viewDidLoad() {
super.viewDidLoad()

// Center the map over the United States.
let centerCoordinate = CLLocationCoordinate2D(latitude: 39.368279,
longitude: -97.646484)
let options = MapInitOptions(cameraOptions: CameraOptions(center: centerCoordinate, zoom: 2.4))

mapView = MapView(frame: view.bounds, mapInitOptions: options)
mapView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.addSubview(mapView)

mapView.mapboxMap.onNext(event: .mapLoaded) { _ in
self.setupExample()

// The following line is just for testing purposes.
self.finish()
}
pointAnnotationManager = mapView.annotations.makePointAnnotationManager()
}

func setupExample() {
try! mapView.mapboxMap.style.addImage(UIImage(named: "blue_marker_view")!, id: .blueMarker)
let tapGesture = UILongPressGestureRecognizer(target: self, action: #selector(longPress))
mapView.addGestureRecognizer(tapGesture)
}

@objc public func longPress(_ sender: UILongPressGestureRecognizer) {
switch sender.state {
case .began:
longPressBegan(at: sender.location(in: mapView))
default:
break
}
}

private func longPressBegan(at location: CGPoint) {
haptic()
let coordinate = mapView.mapboxMap.coordinate(for: location)

var annotation = PointAnnotation(point: Point(coordinate))
annotation.iconImage = .blueMarker
pointAnnotationManager.annotations.append(annotation)

let camera = CameraOptions(center: coordinate)
mapView.camera.ease(to: camera, duration: 0.5)
}

private func haptic() {
let impactFeedbackGenerator = UIImpactFeedbackGenerator(style: .heavy)
impactFeedbackGenerator.impactOccurred()
}
}
3 changes: 3 additions & 0 deletions Apps/Examples/Examples/Models/Examples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,9 @@ struct Examples {
Example(title: "Add an interactive clustered layer",
description: "Display an alert controller after selecting a feature.",
type: SymbolClusteringExample.self),
Example(title: "Long tap animation",
description: "Animate camera upon a long tap",
type: LongTapAnimationExample.self)
]

// Examples that show map accessibility features
Expand Down
18 changes: 17 additions & 1 deletion Apps/Examples/ExamplesUITests/ExamplesUITests.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import XCTest

final class ExamplesUITests: XCTestCase {
private var locationAuthorizationAlertMonitor: NSObjectProtocol?

override class func setUp() {
// This is the setUp() class method.
// XCTest calls it before calling the first test method.
// Set up any overall initial state here.
dismissEditHomeScreenAlert(timeout: 5)
}

override func setUpWithError() throws {
// Put setup code here. This method is called before the invocation of each test method in the class.
Expand Down Expand Up @@ -57,4 +63,14 @@ extension XCTestCase {

allowButton.tap()
}

/// Query Springboard for "Edit Home Screen" alert to dismis it.
static func dismissEditHomeScreenAlert(timeout: TimeInterval) {
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")

let editHomeScreenAlert = springboard.alerts["Edit Home Screen"]
if editHomeScreenAlert.waitForExistence(timeout: timeout) {
editHomeScreenAlert.buttons["Dismiss"].tap()
}
}
}
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Mapbox welcomes participation and contributions from everyone.

## main

## 10.12.0 - March 22, 2023

* Deprecate `Snapshotter.tileMode`.
* Bump MapboxCoreMaps to 10.12.0 and MapboxCommon to 23.4.0

## 10.12.0-rc.1 - March 8, 2023

* Correct user-agent fragment sent to events/telemetry service.
Expand Down
4 changes: 2 additions & 2 deletions LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions MapboxMaps.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |m|

maps_version = '10.12.0-rc.1'
maps_version = '10.12.0'

m.name = 'MapboxMaps'
m.version = maps_version
Expand All @@ -25,9 +25,9 @@ Pod::Spec.new do |m|
# TODO: remove after Cocoapods 1.12 is released
m.pod_target_xcconfig = { 'CODE_SIGNING_ALLOWED' => 'NO' }

m.dependency 'MapboxCoreMaps', '10.12.0-rc.1'
m.dependency 'MapboxCoreMaps', '10.12.0'
m.dependency 'MapboxMobileEvents', '1.0.10'
m.dependency 'MapboxCommon', '23.4.0-rc.1'
m.dependency 'MapboxCommon', '23.4.0'
m.dependency 'Turf', '~> 2.0'

end
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"repositoryURL": "https://github.com/mapbox/mapbox-common-ios.git",
"state": {
"branch": null,
"revision": "d38abed1cfca3843308d478450c3d8b07a797c5a",
"version": "23.4.0-rc.1"
"revision": "49f0c56ce7a113b4474e08837a1985cf1a8590b5",
"version": "23.4.0"
}
},
{
"package": "MapboxCoreMaps",
"repositoryURL": "https://github.com/mapbox/mapbox-core-maps-ios.git",
"state": {
"branch": null,
"revision": "82706a65bf7a51818d943c91f014d17588b0f65e",
"version": "10.12.0-rc.1"
"revision": "d0826b92cb5094fb26ce6f8f6a09bc4734751baf",
"version": "10.12.0"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ let package = Package(
targets: ["MapboxMaps"]),
],
dependencies: [
.package(name: "MapboxCoreMaps", url: "https://github.com/mapbox/mapbox-core-maps-ios.git", .exact("10.12.0-rc.1")),
.package(name: "MapboxCoreMaps", url: "https://github.com/mapbox/mapbox-core-maps-ios.git", .exact("10.12.0")),
// We keep MME dependency for compatibility reasons
.package(name: "MapboxMobileEvents", url: "https://github.com/mapbox/mapbox-events-ios.git", .exact("1.0.10")),
.package(name: "MapboxCommon", url: "https://github.com/mapbox/mapbox-common-ios.git", .exact("23.4.0-rc.1")),
.package(name: "MapboxCommon", url: "https://github.com/mapbox/mapbox-common-ios.git", .exact("23.4.0")),
.package(name: "Turf", url: "https://github.com/mapbox/turf-swift.git", from: "2.0.0"),
.package(name: "CocoaImageHashing", url: "https://github.com/ameingast/cocoaimagehashing", .exact("1.9.0"))
],
Expand Down
12 changes: 0 additions & 12 deletions Sources/MapboxMaps/Foundation/Enablable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,3 @@ internal protocol MutableEnablableProtocol: EnablableProtocol {
internal final class Enablable: MutableEnablableProtocol {
internal var isEnabled = true
}

internal final class CompositeEnablable: EnablableProtocol {
internal var isEnabled: Bool {
enablables.allSatisfy(\.isEnabled)
}

private let enablables: [EnablableProtocol]

internal init(enablables: [EnablableProtocol]) {
self.enablables = enablables
}
}
8 changes: 7 additions & 1 deletion Sources/MapboxMaps/Foundation/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,13 @@ open class MapView: UIView {

open override func layoutSubviews() {
super.layoutSubviews()
mapboxMap.size = bounds.size

// metal view is created by invoking `MapboxMap.createRenderer()`
// which is currently invoked in the init of the `MapboxMap`
// making metal view always available here
if let metalView = metalView {
mapboxMap.size = metalView.bounds.size
}
}

@_spi(Metrics) public var metricsReporter: MapViewMetricsReporter?
Expand Down
15 changes: 7 additions & 8 deletions Sources/MapboxMaps/Foundation/MapViewDependencyProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco
internal let mapboxObservableProvider: (ObservableProtocol) -> MapboxObservableProtocol = MapboxObservable.init

internal let cameraAnimatorsRunnerEnablable: MutableEnablableProtocol = Enablable()
private let gesturesCameraAnimatorsRunnerEnablable = Enablable()
private let mainQueue: MainQueueProtocol = MainQueueWrapper()
private let interfaceOrientationProvider: InterfaceOrientationProvider

Expand All @@ -65,10 +64,7 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco
internal func makeCameraAnimatorsRunner(mapboxMap: MapboxMapProtocol) -> CameraAnimatorsRunnerProtocol {
CameraAnimatorsRunner(
mapboxMap: mapboxMap,
enablable: CompositeEnablable(
enablables: [
cameraAnimatorsRunnerEnablable,
gesturesCameraAnimatorsRunnerEnablable]))
enablable: cameraAnimatorsRunnerEnablable)
}

internal func makeCameraAnimationsManagerImpl(cameraViewContainerView: UIView,
Expand Down Expand Up @@ -178,7 +174,9 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco
cameraAnimationsManager: cameraAnimationsManager)
}

private func makeAnyTouchGestureHandler(view: UIView) -> GestureHandler {
private func makeAnyTouchGestureHandler(
view: UIView,
cameraAnimationsManager: CameraAnimationsManagerProtocol) -> GestureHandler {
// 0.15 seconds is a sufficient delay to avoid interrupting animations
// in between a rapid succession of double tap or double touch gestures.
// It's also not so long as to feel unnatural when touching the map to
Expand All @@ -191,7 +189,7 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco
view.addGestureRecognizer(gestureRecognizer)
return AnyTouchGestureHandler(
gestureRecognizer: gestureRecognizer,
cameraAnimatorsRunnerEnablable: gesturesCameraAnimatorsRunnerEnablable)
cameraAnimationsManager: cameraAnimationsManager)
}

private func makeInterruptDecelerationGestureHandler(view: UIView,
Expand Down Expand Up @@ -234,7 +232,8 @@ internal final class MapViewDependencyProvider: MapViewDependencyProviderProtoco
singleTapGestureHandler: makeSingleTapGestureHandler(
view: view,
cameraAnimationsManager: cameraAnimationsManager),
anyTouchGestureHandler: makeAnyTouchGestureHandler(view: view),
anyTouchGestureHandler: makeAnyTouchGestureHandler(view: view,
cameraAnimationsManager: cameraAnimationsManager),
interruptDecelerationGestureHandler: makeInterruptDecelerationGestureHandler(
view: view,
cameraAnimationsManager: cameraAnimationsManager),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import UIKit

internal final class AnyTouchGestureHandler: GestureHandler {

private let cameraAnimatorsRunnerEnablable: MutableEnablableProtocol
private let cameraAnimationsManager: CameraAnimationsManagerProtocol

internal init(gestureRecognizer: UIGestureRecognizer,
cameraAnimatorsRunnerEnablable: MutableEnablableProtocol) {
self.cameraAnimatorsRunnerEnablable = cameraAnimatorsRunnerEnablable
cameraAnimationsManager: CameraAnimationsManagerProtocol) {
self.cameraAnimationsManager = cameraAnimationsManager
super.init(gestureRecognizer: gestureRecognizer)
gestureRecognizer.addTarget(self, action: #selector(handleGesture(_:)))
}

@objc private func handleGesture(_ gestureRecognizer: AnyTouchGestureRecognizer) {
switch gestureRecognizer.state {
case .began:
cameraAnimatorsRunnerEnablable.isEnabled = false
case .ended, .cancelled:
cameraAnimatorsRunnerEnablable.isEnabled = true
cameraAnimationsManager.cancelAnimations()
default:
break
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
internal final class PanPinchBehavior: PinchBehavior {
private let initialCameraState: CameraState
private let initialPinchMidpoint: CGPoint
private var currentPinchMidpoint: CGPoint
private let mapboxMap: MapboxMapProtocol

internal init(initialCameraState: CameraState,
initialPinchMidpoint: CGPoint,
mapboxMap: MapboxMapProtocol) {
self.initialCameraState = initialCameraState
self.initialPinchMidpoint = initialPinchMidpoint
internal init(initialPinchMidpoint: CGPoint, mapboxMap: MapboxMapProtocol) {
self.currentPinchMidpoint = initialPinchMidpoint
self.mapboxMap = mapboxMap
}

internal func update(pinchMidpoint: CGPoint, pinchScale: CGFloat) {
mapboxMap.performWithoutNotifying {
mapboxMap.setCamera(to: CameraOptions(
center: initialCameraState.center,
bearing: initialCameraState.bearing))
}

mapboxMap.dragStart(for: initialPinchMidpoint)
mapboxMap.dragStart(for: currentPinchMidpoint)
let dragOptions = mapboxMap.dragCameraOptions(
from: initialPinchMidpoint,
from: currentPinchMidpoint,
to: pinchMidpoint)
mapboxMap.setCamera(to: dragOptions)
mapboxMap.dragEnd()

currentPinchMidpoint = pinchMidpoint
}
}
Loading

0 comments on commit 203af16

Please sign in to comment.