Skip to content

Commit ad561ea

Browse files
committed
Updated version to latest
1 parent d3d0ec8 commit ad561ea

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

Sources/MapLibreSwiftUI/MapViewCoordinator.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,21 @@ public class MapViewCoordinator: NSObject {
3232
}
3333

3434
// MARK: - Coordinator API - Camera + Manipulation
35-
35+
36+
/// Update the camera based on the MapViewCamera binding change.
37+
///
38+
/// - Parameters:
39+
/// - mapView: This is the camera updating protocol representation of the MLNMapView. This allows mockable testing for camera related MLNMapView functionality.
40+
/// - camera: The new camera from the binding.
41+
/// - animated: Whether to animate.
3642
func updateCamera(mapView: MLNMapViewCameraUpdating, camera: MapViewCamera, animated: Bool) {
3743
guard camera != snapshotCamera else {
3844
// No action - camera has not changed.
3945
return
4046
}
4147

4248
switch camera.state {
43-
case .coordinate(let coordinate):
49+
case .centered(onCoordinate: let coordinate):
4450
mapView.userTrackingMode = .none
4551
mapView.setCenter(coordinate,
4652
zoomLevel: camera.zoom,

Sources/MapLibreSwiftUI/Models/MapCamera/CameraState.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import MapLibre
55
public enum CameraState: Hashable {
66

77
/// Centered on a coordinate
8-
case coordinate(onCenter: CLLocationCoordinate2D)
8+
case centered(onCoordinate: CLLocationCoordinate2D)
99

1010
/// Follow the user's location using the MapView's internal camera.
1111
///
@@ -36,8 +36,8 @@ extension CameraState: CustomDebugStringConvertible {
3636
public var debugDescription: String {
3737
switch self {
3838

39-
case .coordinate(onCenter: let onCenter):
40-
return "CameraState.coordinate(onCenter: \(onCenter)"
39+
case .centered(onCoordinate: let onCoordinate):
40+
return "CameraState.centered(onCoordinate: \(onCoordinate)"
4141
case .trackingUserLocation:
4242
return "CameraState.trackingUserLocation"
4343
case .trackingUserLocationWithHeading:

Sources/MapLibreSwiftUI/Models/MapCamera/MapViewCamera.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public struct MapViewCamera: Hashable {
3131
///
3232
/// - Returns: The constructed MapViewCamera.
3333
public static func `default`() -> MapViewCamera {
34-
return MapViewCamera(state: .coordinate(onCenter: Defaults.coordinate),
34+
return MapViewCamera(state: .centered(onCoordinate: Defaults.coordinate),
3535
zoom: Defaults.zoom,
3636
pitch: Defaults.pitch,
3737
direction: Defaults.direction,
@@ -52,7 +52,7 @@ public struct MapViewCamera: Hashable {
5252
direction: CLLocationDirection = Defaults.direction,
5353
reason: CameraChangeReason? = nil) -> MapViewCamera {
5454

55-
return MapViewCamera(state: .coordinate(onCenter: coordinate),
55+
return MapViewCamera(state: .centered(onCoordinate: coordinate),
5656
zoom: zoom,
5757
pitch: pitch,
5858
direction: direction,

Tests/MapLibreSwiftUITests/Models/MapCamera/CameraStateTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ final class CameraStateTests: XCTestCase {
66

77
func testCenterCameraState() {
88
let expectedCoordinate = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
9-
let state: CameraState = .coordinate(onCenter: expectedCoordinate)
10-
XCTAssertEqual(state, .coordinate(onCenter: CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)))
11-
XCTAssertEqual(String(describing: state), "CameraState.coordinate(onCenter: CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)")
9+
let state: CameraState = .centered(onCoordinate: expectedCoordinate)
10+
XCTAssertEqual(state, .centered(onCoordinate: CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)))
11+
XCTAssertEqual(String(describing: state), "CameraState.centered(onCoordinate: CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)")
1212
}
1313

1414
func testTrackingUserLocation() {

Tests/MapLibreSwiftUITests/Models/MapCamera/MapViewCameraTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class MapViewCameraTests: XCTestCase {
1111

1212
let camera = MapViewCamera.center(expectedCoordinate, zoom: 12, pitch: pitch, direction: direction)
1313

14-
XCTAssertEqual(camera.state, .coordinate(onCenter: expectedCoordinate))
14+
XCTAssertEqual(camera.state, .centered(onCoordinate: expectedCoordinate))
1515
XCTAssertEqual(camera.zoom, 12)
1616
XCTAssertEqual(camera.pitch, pitch)
1717
XCTAssertEqual(camera.direction, direction)

0 commit comments

Comments
 (0)