Skip to content

Commit dfc7526

Browse files
run swiftformat
1 parent 004ce94 commit dfc7526

File tree

6 files changed

+68
-56
lines changed

6 files changed

+68
-56
lines changed

Sources/MapLibreSwiftUI/Extensions/MapLibre/MLNMapViewCameraUpdating.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ protocol MLNMapViewCameraUpdating: AnyObject {
1313
direction: CLLocationDirection,
1414
animated: Bool)
1515
func setZoomLevel(_ zoomLevel: Double, animated: Bool)
16-
func setVisibleCoordinateBounds(_ bounds: MLNCoordinateBounds, edgePadding: UIEdgeInsets, animated: Bool, completionHandler: (() -> Void)?)
16+
func setVisibleCoordinateBounds(
17+
_ bounds: MLNCoordinateBounds,
18+
edgePadding: UIEdgeInsets,
19+
animated: Bool,
20+
completionHandler: (() -> Void)?
21+
)
1722
}
1823

1924
extension MLNMapView: MLNMapViewCameraUpdating {

Sources/MapLibreSwiftUI/MapViewCoordinator.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public class MapViewCoordinator: NSObject {
6363
case .trackingUserLocationWithCourse:
6464
mapView.userTrackingMode = .followWithCourse
6565
mapView.setZoomLevel(camera.zoom, animated: false)
66-
case let .rect(boundingBox, padding):
67-
mapView.setVisibleCoordinateBounds(boundingBox,
68-
edgePadding: padding,
69-
animated: animated,
70-
completionHandler: nil)
66+
case let .rect(boundingBox, padding):
67+
mapView.setVisibleCoordinateBounds(boundingBox,
68+
edgePadding: padding,
69+
animated: animated,
70+
completionHandler: nil)
7171
case .showcase:
7272
// TODO: Need a method these/or to finalize a goal here.
7373
break

Sources/MapLibreSwiftUI/Models/MapCamera/CameraState.swift

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ public enum CameraState: Hashable {
2525
case trackingUserLocationWithCourse
2626

2727
/// Centered on a bounding box/rectangle.
28-
case rect(boundingBox: MLNCoordinateBounds, edgePadding: UIEdgeInsets = .init(top: 20, left: 20, bottom: 20, right: 20))
28+
case rect(
29+
boundingBox: MLNCoordinateBounds,
30+
edgePadding: UIEdgeInsets = .init(top: 20, left: 20, bottom: 20, right: 20)
31+
)
2932

3033
/// Showcasing GeoJSON, Polygons, etc.
3134
case showcase(shapeCollection: MLNShapeCollection)
@@ -42,32 +45,30 @@ extension CameraState: CustomDebugStringConvertible {
4245
"CameraState.trackingUserLocationWithHeading"
4346
case .trackingUserLocationWithCourse:
4447
"CameraState.trackingUserLocationWithCourse"
45-
case .rect(boundingBox: let boundingBox, _):
46-
"CameraState.rect(northeast: \(boundingBox.ne), southwest: \(boundingBox.sw))"
47-
case .showcase(shapeCollection: let shapeCollection):
48+
case let .rect(boundingBox: boundingBox, _):
49+
"CameraState.rect(northeast: \(boundingBox.ne), southwest: \(boundingBox.sw))"
50+
case let .showcase(shapeCollection: shapeCollection):
4851
"CameraState.showcase(shapeCollection: \(shapeCollection))"
4952
}
5053
}
5154
}
5255

5356
extension MLNCoordinateBounds: Equatable, Hashable {
54-
55-
public func hash(into hasher: inout Hasher) {
56-
hasher.combine(self.ne)
57-
hasher.combine(self.sw)
58-
}
59-
60-
public static func == (lhs: MLNCoordinateBounds, rhs: MLNCoordinateBounds) -> Bool {
61-
return lhs.ne == rhs.ne && lhs.sw == rhs.sw
62-
}
57+
public func hash(into hasher: inout Hasher) {
58+
hasher.combine(ne)
59+
hasher.combine(sw)
60+
}
61+
62+
public static func == (lhs: MLNCoordinateBounds, rhs: MLNCoordinateBounds) -> Bool {
63+
lhs.ne == rhs.ne && lhs.sw == rhs.sw
64+
}
6365
}
6466

6567
extension UIEdgeInsets: Hashable {
66-
67-
public func hash(into hasher: inout Hasher) {
68-
hasher.combine(self.left)
69-
hasher.combine(self.right)
70-
hasher.combine(self.top)
71-
hasher.combine(self.bottom)
72-
}
68+
public func hash(into hasher: inout Hasher) {
69+
hasher.combine(left)
70+
hasher.combine(right)
71+
hasher.combine(top)
72+
hasher.combine(bottom)
73+
}
7374
}

Sources/MapLibreSwiftUI/Models/MapCamera/MapViewCamera.swift

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,19 +117,22 @@ public struct MapViewCamera: Hashable {
117117
direction: Defaults.direction,
118118
lastReasonForChange: .programmatic)
119119
}
120-
121-
/// Positions the camera to show a specific region in the MapView.
122-
///
123-
/// - Parameters:
124-
/// - box: Set the desired bounding box. This is a one time event and the user can manipulate by moving the map.
125-
/// - edgePadding: Set the edge insets that should be applied before positioning the map.
126-
/// - Returns: The MapViewCamera representing the scenario
127-
public static func boundingBox(_ box: MLNCoordinateBounds, edgePadding: UIEdgeInsets = .init(top: 20, left: 20, bottom: 20, right: 20)) -> MapViewCamera {
128-
// zoom, pitch & direction are ignored.
129-
return MapViewCamera(state: .rect(boundingBox: box, edgePadding: edgePadding),
130-
zoom: 1,
131-
pitch: Defaults.pitch,
132-
direction: Defaults.direction,
133-
lastReasonForChange: .programmatic)
134-
}
120+
121+
/// Positions the camera to show a specific region in the MapView.
122+
///
123+
/// - Parameters:
124+
/// - box: Set the desired bounding box. This is a one time event and the user can manipulate by moving the map.
125+
/// - edgePadding: Set the edge insets that should be applied before positioning the map.
126+
/// - Returns: The MapViewCamera representing the scenario
127+
public static func boundingBox(
128+
_ box: MLNCoordinateBounds,
129+
edgePadding: UIEdgeInsets = .init(top: 20, left: 20, bottom: 20, right: 20)
130+
) -> MapViewCamera {
131+
// zoom, pitch & direction are ignored.
132+
MapViewCamera(state: .rect(boundingBox: box, edgePadding: edgePadding),
133+
zoom: 1,
134+
pitch: Defaults.pitch,
135+
direction: Defaults.direction,
136+
lastReasonForChange: .programmatic)
137+
}
135138
}

Tests/MapLibreSwiftUITests/Models/MapCamera/CameraStateTests.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ final class CameraStateTests: XCTestCase {
3434
func testRect() {
3535
let northeast = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
3636
let southwest = CLLocationCoordinate2D(latitude: 34.5, longitude: 45.6)
37-
38-
let state: CameraState = .rect(boundingBox: .init(sw: southwest, ne: northeast))
39-
XCTAssertEqual(state, .rect(boundingBox: .init(sw: southwest, ne: northeast)))
37+
38+
let state: CameraState = .rect(boundingBox: .init(sw: southwest, ne: northeast))
39+
XCTAssertEqual(state, .rect(boundingBox: .init(sw: southwest, ne: northeast)))
4040

4141
XCTAssertEqual(
4242
String(describing: state),

Tests/MapLibreSwiftUITests/Models/MapCamera/MapViewCameraTests.swift

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,18 +45,21 @@ final class MapViewCameraTests: XCTestCase {
4545
XCTAssertEqual(camera.pitch, .free)
4646
XCTAssertEqual(camera.direction, 0)
4747
}
48-
49-
func testBoundingBox() {
50-
let southwest = CLLocationCoordinate2D(latitude: 24.6056011, longitude: 46.67369842529297)
51-
let northeast = CLLocationCoordinate2D(latitude: 24.6993808, longitude: 46.7709285)
52-
let bounds = MLNCoordinateBounds(sw: southwest, ne: northeast)
53-
let camera = MapViewCamera.boundingBox(bounds)
54-
55-
XCTAssertEqual(camera.state, .rect(boundingBox: bounds, edgePadding: .init(top: 20, left: 20, bottom: 20, right: 20)))
56-
XCTAssertEqual(camera.zoom, 1)
57-
XCTAssertEqual(camera.pitch, .free)
58-
XCTAssertEqual(camera.direction, 0)
59-
}
48+
49+
func testBoundingBox() {
50+
let southwest = CLLocationCoordinate2D(latitude: 24.6056011, longitude: 46.67369842529297)
51+
let northeast = CLLocationCoordinate2D(latitude: 24.6993808, longitude: 46.7709285)
52+
let bounds = MLNCoordinateBounds(sw: southwest, ne: northeast)
53+
let camera = MapViewCamera.boundingBox(bounds)
54+
55+
XCTAssertEqual(
56+
camera.state,
57+
.rect(boundingBox: bounds, edgePadding: .init(top: 20, left: 20, bottom: 20, right: 20))
58+
)
59+
XCTAssertEqual(camera.zoom, 1)
60+
XCTAssertEqual(camera.pitch, .free)
61+
XCTAssertEqual(camera.direction, 0)
62+
}
6063

6164
// TODO: Add additional camera tests once behaviors are added (e.g. rect)
6265
}

0 commit comments

Comments
 (0)