Skip to content

Commit

Permalink
Optional paddings (#1436)
Browse files Browse the repository at this point in the history
* Bump Snaphot and update some APIs

* Declare padding argument as an optional

* Changelog
  • Loading branch information
OdNairy authored Mar 30, 2023
1 parent 78de424 commit 6f98e27
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 70 deletions.
6 changes: 3 additions & 3 deletions mapbox-maps-ios/.depsvalidator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ dependencies:
# - name: MapboxCoreMaps
# variations:
# Package.swift: mapbox-core-maps-ios
- name: MapboxCommon
variations:
Package.swift: mapbox-common-ios
# - name: MapboxCommon
# variations:
# Package.swift: mapbox-common-ios
- name: Turf
variations:
Package.swift: turf-swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
"version": "1.9.0"
}
},
{
"package": "MapboxCommon",
"repositoryURL": "https://github.com/mapbox/mapbox-common-ios.git",
"state": {
"branch": null,
"revision": "185d791e7478cc5da7cc2b4756ecd0d0bd387eac",
"version": "23.4.0-beta.1"
}
},
{
"package": "Turf",
"repositoryURL": "https://github.com/mapbox/turf-swift.git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ class PointAnnotationClusteringExample: UIViewController, ExampleProtocol {
}
}
}
if let layer = queriedFeatures.first?.layer {
print("Selected a cluster in layer named: \(layer)")
if let layers = queriedFeatures.first?.layers {
print("Selected a cluster in layers: \(layers)")
}
case .failure(let error):
print("An error occurred: \(error.localizedDescription). Please try another cluster.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ private final class SettingsViewController: UIViewController, UITableViewDataSou
MapDebugOptionSetting(debugOption: .depthBuffer, displayTitle: "Show depth buffer"),
MapDebugOptionSetting(debugOption: .overdraw, displayTitle: "Debug overdraw"),
MapDebugOptionSetting(debugOption: .parseStatus, displayTitle: "Show tile coordinate"),
MapDebugOptionSetting(debugOption: .renderCache, displayTitle: "Render Cache"),
MapDebugOptionSetting(debugOption: .stencilClip, displayTitle: "Show stencil buffer"),
MapDebugOptionSetting(debugOption: .tileBorders, displayTitle: "Debug tile clipping"),
MapDebugOptionSetting(debugOption: .timestamps, displayTitle: "Show tile loaded time"),
Expand Down
5 changes: 3 additions & 2 deletions mapbox-maps-ios/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,12 @@ Mapbox welcomes participation and contributions from everyone.
* Bump MapboxCoreMaps to 10.12.0-rc.1 and MapboxCommon to 23.4.0-rc.1.
* Change annotation end-of-drag delay to 0.125 to minimize lagging.
* Different data types are now used for `querySourceFeatures` and `queryRenderedFeatures`: `QueriedSourceFeature` and `QueriedRenderedFeature`. `QueriedRenderedFeature` has a new field `layer` which contains the queried feature's layer id.
* Remove deprecated `queryRenderedFeatures()` methods. Use `queryRenderedFeatures(with:options:completion:)` instead.
* Remove deprecated `queryFeatureExtension()` method. Use `getGeoJsonClusterLeaves()`/`getGeoJsonClusterChildren()`/`getGeoJsonClusterExpansionZoom()` instead.
* Remove deprecated `queryRenderedFeatures()` methods. Use `queryRenderedFeatures(with:options:completion:)` instead.
* Remove deprecated `queryFeatureExtension()` method. Use `getGeoJsonClusterLeaves()`/`getGeoJsonClusterChildren()`/`getGeoJsonClusterExpansionZoom()` instead.
* Add the `MapboxMap.resetFeatureState` method.
* Add `callback` argument to the `MapboxMap` methods `getFeatureState`, `setFeatureState`, `removeFeatureState`.
* Return `cancelable` from the `MapboxMap` methods : `getFeatureState`, `setFeatureState`, `removeFeatureState`, `querySourceFeatures`, `getGeoJsonClusterLeaves`, `getGeoJsonClusterChildren`, `getGeoJsonClusterExpansionZoom`.
* The `CameraOptions/padding` field is now optional.

## 10.12.0-beta.1 - February 22, 2023

Expand Down
9 changes: 0 additions & 9 deletions mapbox-maps-ios/Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
"version": "1.9.0"
}
},
{
"package": "MapboxCommon",
"repositoryURL": "https://github.com/mapbox/mapbox-common-ios.git",
"state": {
"branch": null,
"revision": "185d791e7478cc5da7cc2b4756ecd0d0bd387eac",
"version": "23.4.0-beta.1"
}
},
{
"package": "Turf",
"repositoryURL": "https://github.com/mapbox/turf-swift.git",
Expand Down
12 changes: 9 additions & 3 deletions mapbox-maps-ios/Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

import PackageDescription

let coreVersion = "11.0.0-SNAPSHOT.0309T1900Z.7483222"
let coreChecksum = "93391bb880c23ea9bc2861733e2c73c1bd5e5cc008bf5b404781401f20e6d8e8"
let coreVersion = "11.0.0-SNAPSHOT.0322T1320Z.ae46035"
let coreChecksum = "5eee9732f78a9cec9b85cc83eeac8db440bb161a04aff879bbe52607567cc8f5"
let commonVersion = "23.5.0-SNAPSHOT.0321T1613Z.cc81dc2"
let commonChecksum = "34e96f7c3b1eeab4c9257d3fdd91a2b353defa6a7c17099c0dd848b3fcb5c468"
let releaseFolder: String = "snapshots"

let package = Package(
Expand All @@ -18,7 +20,6 @@ let package = Package(
),
],
dependencies: [
.package(name: "MapboxCommon", url: "https://github.com/mapbox/mapbox-common-ios.git", .exact("23.4.0-beta.1")),
.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 All @@ -28,6 +29,11 @@ let package = Package(
url: "https://api.mapbox.com/downloads/v2/mobile-maps-core-internal/\(releaseFolder)/ios/packages/\(coreVersion)/MapboxCoreMaps.xcframework-dynamic.zip",
checksum: coreChecksum
),
.binaryTarget(
name: "MapboxCommon",
url: "https://api.mapbox.com/downloads/v2/mapbox-common/\(releaseFolder)/ios/packages/\(commonVersion)/MapboxCommon.zip",
checksum: commonChecksum
),
.target(
name: "MapboxMaps",
dependencies: ["MapboxCoreMaps", "Turf", "MapboxCommon"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import MapboxCoreMaps

internal protocol DelegatingMapClientDelegate: AnyObject {
func scheduleRepaint()
func scheduleTask(forTask task: @escaping Task)
func getMetalView(for metalDevice: MTLDevice?) -> MTKView?
}

Expand All @@ -14,10 +13,6 @@ internal final class DelegatingMapClient: MapClient, MBMMetalViewProvider {
delegate?.scheduleRepaint()
}

internal func scheduleTask(forTask task: @escaping Task) {
delegate?.scheduleTask(forTask: task)
}

internal func getMetalView(for metalDevice: MTLDevice?) -> MTKView? {
return delegate?.getMetalView(for: metalDevice)
}
Expand Down
4 changes: 0 additions & 4 deletions mapbox-maps-ios/Sources/MapboxMaps/Foundation/MapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -708,10 +708,6 @@ extension MapView: DelegatingMapClientDelegate {
needsDisplayRefresh = true
}

internal func scheduleTask(forTask task: @escaping Task) {
fatalError("scheduleTask is not supported")
}

internal func getMetalView(for metalDevice: MTLDevice?) -> MTKView? {
let minSize = CGRect(x: 0, y: 0, width: 1, height: 1)
let metalView = dependencyProvider.makeMetalView(frame: minSize.union(bounds), device: metalDevice)
Expand Down
4 changes: 2 additions & 2 deletions mapbox-maps-ios/Sources/MapboxMaps/Foundation/MapboxMap.swift
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,13 @@ public final class MapboxMap: MapboxMapProtocol {
/// - pitch: The new pitch to be used by the camera.
/// - Returns: A `CameraOptions` that fits the provided constraints
public func camera(for coordinates: [CLLocationCoordinate2D],
padding: UIEdgeInsets,
padding: UIEdgeInsets?,
bearing: Double?,
pitch: Double?) -> CameraOptions {
return CameraOptions(
__map.cameraForCoordinates(
forCoordinates: coordinates.map(\.location),
padding: padding.toMBXEdgeInsetsValue(),
padding: padding?.toMBXEdgeInsetsValue(),
bearing: bearing?.NSNumber,
pitch: pitch?.NSNumber))
}
Expand Down
6 changes: 3 additions & 3 deletions mapbox-maps-ios/Sources/MapboxMaps/Snapshot/Snapshotter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ internal protocol MapSnapshotterProtocol: StyleManagerProtocol, ObservableProtoc

func cameraForCoordinates(forCoordinates
coordinates: [CLLocation],
padding: EdgeInsets,
padding: EdgeInsets?,
bearing: NSNumber?,
pitch: NSNumber?) -> MapboxCoreMaps.CameraOptions

Expand Down Expand Up @@ -289,12 +289,12 @@ public class Snapshotter {
/// - pitch: The new pitch to be used by the camera.
/// - Returns: A `CameraOptions` that fits the provided constraints
public func camera(for coordinates: [CLLocationCoordinate2D],
padding: UIEdgeInsets,
padding: UIEdgeInsets?,
bearing: Double?,
pitch: Double?) -> CameraOptions {
return CameraOptions(mapSnapshotter.cameraForCoordinates(
forCoordinates: coordinates.map(\.location),
padding: padding.toMBXEdgeInsetsValue(),
padding: padding?.toMBXEdgeInsetsValue(),
bearing: bearing?.NSNumber,
pitch: pitch?.NSNumber))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ final class AnnotationOrchestratorImplTests: XCTestCase {
state: "feature-state"
)

qrfCompletions(.success([QueriedRenderedFeature(__queriedFeature: feature, layer: "layer")]))
qrfCompletions(.success([QueriedRenderedFeature(__queriedFeature: feature, layers: ["layer"])]))

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,6 @@ final class DelegatingMapClientTests: XCTestCase {
XCTAssertEqual(delegate.scheduleRepaintStub.invocations.count, 1)
}

func testScheduleTaskForwardsToDelegate() {
var invoked = false

delegatingMapClient.scheduleTask {
invoked = true
}
delegate.scheduleTaskStub.invocations.first?.parameters()

XCTAssertEqual(delegate.scheduleTaskStub.invocations.count, 1)
XCTAssertTrue(invoked)
}

func testGetMetalViewForwardsToDelegate() {
let expectedDevice = MTLCreateSystemDefaultDevice()
let expectedView = MTKView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ final class MockDelegatingMapClientDelegate: DelegatingMapClientDelegate {
scheduleRepaintStub.call()
}

let scheduleTaskStub = Stub<Task, Void>()
func scheduleTask(forTask task: @escaping Task) {
scheduleTaskStub.call(with: task)
}

let getMetalViewStub = Stub<MTLDevice?, MTKView?>(defaultReturnValue: nil)
func getMetalView(for metalDevice: MTLDevice?) -> MTKView? {
return getMetalViewStub.call(with: metalDevice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ final class MockMapClient: MapClient, MBMMetalViewProvider {
func scheduleRepaint() {
}

func scheduleTask(forTask task: @escaping Task) {
}

let getMetalViewStub = Stub<MTLDevice?, MTKView?>(defaultReturnValue: nil)
func getMetalView(for metalDevice: MTLDevice?) -> MTKView? {
getMetalViewStub.call(with: metalDevice)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ final class MockMapSnapshotter: MockStyleManager, MapSnapshotterProtocol {

struct CameraForCoordinatesParams: Equatable {
var coordinates: [CLLocation]
var padding: EdgeInsets
var padding: EdgeInsets?
var bearing: NSNumber?
var pitch: NSNumber?
}

var cameraForCoordinatesStub = Stub<CameraForCoordinatesParams, MapboxCoreMaps.CameraOptions>(defaultReturnValue: .init(.random()))
func cameraForCoordinates(forCoordinates coordinates: [CLLocation], padding: EdgeInsets, bearing: NSNumber?, pitch: NSNumber?) -> MapboxCoreMaps.CameraOptions {
func cameraForCoordinates(forCoordinates coordinates: [CLLocation], padding: EdgeInsets?, bearing: NSNumber?, pitch: NSNumber?) -> MapboxCoreMaps.CameraOptions {
cameraForCoordinatesStub.call(with: CameraForCoordinatesParams(coordinates: coordinates, padding: padding, bearing: bearing, pitch: pitch))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ final class SnapshotterTests: XCTestCase {
let mockParameters = mockMapSnapshotter.cameraForCoordinatesStub.invocations[0].parameters

XCTAssertEqual(mockParameters.coordinates.map(\.coordinate), coordinates)
XCTAssertEqual(mockParameters.padding.toUIEdgeInsetsValue(), padding.toUIEdgeInsetsValue())
XCTAssertEqual(mockParameters.padding?.toUIEdgeInsetsValue(), padding.toUIEdgeInsetsValue())
XCTAssertEqual(mockParameters.bearing, bearing.NSNumber)
XCTAssertEqual(mockParameters.pitch, pitch.NSNumber)
XCTAssertEqual(returnedOptions, cameraOptions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ Var LocationIndicatorLayer.visibility has declared type change from MapboxMaps.V
Var RasterLayer.visibility has declared type change from MapboxMaps.Value<MapboxMaps.Visibility>? to MapboxMaps.Visibility
Var SkyLayer.visibility has declared type change from MapboxMaps.Value<MapboxMaps.Visibility>? to MapboxMaps.Visibility
Var SymbolLayer.visibility has declared type change from MapboxMaps.Value<MapboxMaps.Visibility>? to MapboxMaps.Visibility

// Make Padding argument optional
Func MapboxMap.camera(for:padding:bearing:pitch:) has parameter 1 type change from UIKit.UIEdgeInsets to UIKit.UIEdgeInsets?
Func Snapshotter.camera(for:padding:bearing:pitch:) has parameter 1 type change from UIKit.UIEdgeInsets to UIKit.UIEdgeInsets?
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ else
exit 1
fi

../download-dependency.sh mapbox-common "$COMMON_ARTIFACT" "$COMMON_VERSION" releases
../download-dependency.sh mapbox-common "$COMMON_ARTIFACT" "$COMMON_VERSION" snapshots
../download-dependency.sh mobile-maps-core-internal "$CORE_ARTIFACT" "$CORE_VERSION" snapshots
../build-dependency.sh Turf 'https://github.com/mapbox/turf-swift.git' "$TURF_VERSION" "$LINK_TYPE"

Expand Down
4 changes: 2 additions & 2 deletions mapbox-maps-ios/scripts/release/packager/versions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"MapboxCoreMaps": "11.0.0-SNAPSHOT.0309T1900Z.7483222",
"MapboxCommon": "23.4.0-beta.1",
"MapboxCoreMaps": "11.0.0-SNAPSHOT.0322T1320Z.ae46035",
"MapboxCommon": "23.5.0-SNAPSHOT.0321T1613Z.cc81dc2",
"Turf": "v2.6.1"
}

0 comments on commit 6f98e27

Please sign in to comment.