From 28b3760a9b45fd74758debe64409a7beb7951fc2 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Mon, 10 Apr 2023 15:43:09 -0700 Subject: [PATCH 01/18] Compass with viewpoint --- Examples/Examples/CompassExampleView.swift | 36 +++++-------------- .../Components/Compass/Compass.swift | 27 +++++++------- 2 files changed, 21 insertions(+), 42 deletions(-) diff --git a/Examples/Examples/CompassExampleView.swift b/Examples/Examples/CompassExampleView.swift index d92a3480c..44bfbfbbe 100644 --- a/Examples/Examples/CompassExampleView.swift +++ b/Examples/Examples/CompassExampleView.swift @@ -19,17 +19,17 @@ import SwiftUI struct CompassExampleView: View { /// A scenario represents a type of environment a compass may be used in. enum Scenario: String { - case map case scene + case viewpoint } /// The active scenario. - @State private var scenario = Scenario.map + @State private var scenario = Scenario.viewpoint var body: some View { Group { switch scenario { - case .map: + case .viewpoint: MapWithViewpoint() case .scene: SceneWithCameraController() @@ -39,9 +39,9 @@ struct CompassExampleView: View { ToolbarItem(placement: .navigationBarTrailing) { Menu(scenario.rawValue.capitalized) { Button { - scenario = .map + scenario = .viewpoint } label: { - Label("Map", systemImage: "map.fill") + Text("Viewpoint") } Button { @@ -72,17 +72,8 @@ struct MapWithViewpoint: View { MapView(map: map, viewpoint: viewpoint) .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } .overlay(alignment: .topTrailing) { - Compass(viewpoint: $viewpoint) { - guard let viewpoint else { return } - Task { - // Animate the map view to zero when the compass is tapped. - await proxy.setViewpoint( - viewpoint.withRotation(0), - duration: 0.25 - ) - } - } - .padding() + Compass(viewpoint: $viewpoint, geoViewProxy: proxy) + .padding() } } } @@ -108,18 +99,7 @@ struct SceneWithCameraController: View { heading = newCamera.heading.rounded() } .overlay(alignment: .topTrailing) { - Compass(viewpointRotation: $heading) { - // Animate the scene view when the compass is tapped. - Task { - await cameraController.moveCamera( - distanceDelta: .zero, - headingDelta: heading > 180 ? 360 - heading : -heading, - pitchDelta: .zero, - duration: 0.3 - ) - } - } - .padding() + Compass(viewpointRotation: $heading) } } } diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 544b5466b..90b3b88fd 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -20,8 +20,8 @@ public struct Compass: View { /// The opacity of the compass. @State private var opacity: Double = .zero - /// An action to perform when the compass is tapped. - private let action: (() -> Void)? + /// <#Description#> + private var geoViewProxy: GeoViewProxy? /// A Boolean value indicating whether the compass should automatically /// hide/show itself when the heading is `0`. @@ -44,13 +44,13 @@ public struct Compass: View { /// direction toward true East, etc.). /// - Parameters: /// - heading: The heading of the compass. - /// - action: An action to perform when the compass is tapped. + /// - geoViewProxy: <#Description#> public init( heading: Binding, - action: (() -> Void)? = nil + geoViewProxy: GeoViewProxy? = nil ) { _heading = heading - self.action = action + self.geoViewProxy = geoViewProxy } public var body: some View { @@ -72,8 +72,8 @@ public struct Compass: View { } } .onTapGesture { - if let action { - action() + if let mapViewProxy = geoViewProxy as? MapViewProxy { + Task { await mapViewProxy.setViewpointRotation(0) } } else { heading = .zero } @@ -90,27 +90,26 @@ public extension Compass { /// - Parameters: /// - viewpointRotation: The viewpoint rotation whose value determines the /// heading of the compass. - /// - action: An action to perform when the compass is tapped. + /// - geoViewProxy: <#Description#> init( viewpointRotation: Binding, - action: (() -> Void)? = nil + geoViewProxy: GeoViewProxy? = nil ) { let heading = Binding(get: { viewpointRotation.wrappedValue.isZero ? .zero : 360 - viewpointRotation.wrappedValue }, set: { newHeading in viewpointRotation.wrappedValue = newHeading.isZero ? .zero : 360 - newHeading }) - self.init(heading: heading, action: action) + self.init(heading: heading, geoViewProxy: geoViewProxy) } /// Creates a compass with a binding to an optional viewpoint. /// - Parameters: /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - action: An action to perform when the compass is tapped. - /// when the viewpoint's rotation is 0 degrees. + /// - geoViewProxy: <#Description#> init( viewpoint: Binding, - action: (() -> Void)? = nil + geoViewProxy: GeoViewProxy? = nil ) { let viewpointRotation = Binding { viewpoint.wrappedValue?.rotation ?? .nan @@ -122,7 +121,7 @@ public extension Compass { rotation: newViewpointRotation ) } - self.init(viewpointRotation: viewpointRotation, action: action) + self.init(viewpointRotation: viewpointRotation, geoViewProxy: geoViewProxy) } /// Define a custom size for the compass. From 572fc0129e11556eb8eb1665827db04ae7ef9d34 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Mon, 10 Apr 2023 18:01:03 -0700 Subject: [PATCH 02/18] Update doc, sample --- Examples/Examples/CompassExampleView.swift | 85 ++----------------- .../Components/Compass/Compass.swift | 24 +++--- 2 files changed, 20 insertions(+), 89 deletions(-) diff --git a/Examples/Examples/CompassExampleView.swift b/Examples/Examples/CompassExampleView.swift index 44bfbfbbe..7f092a0fd 100644 --- a/Examples/Examples/CompassExampleView.swift +++ b/Examples/Examples/CompassExampleView.swift @@ -15,101 +15,32 @@ import ArcGIS import ArcGISToolkit import SwiftUI -/// An example demonstrating how to use a compass in three different environments. -struct CompassExampleView: View { - /// A scenario represents a type of environment a compass may be used in. - enum Scenario: String { - case scene - case viewpoint - } - - /// The active scenario. - @State private var scenario = Scenario.viewpoint - - var body: some View { - Group { - switch scenario { - case .viewpoint: - MapWithViewpoint() - case .scene: - SceneWithCameraController() - } - } - .toolbar { - ToolbarItem(placement: .navigationBarTrailing) { - Menu(scenario.rawValue.capitalized) { - Button { - scenario = .viewpoint - } label: { - Text("Viewpoint") - } - - Button { - scenario = .scene - } label: { - Label("Scene", systemImage: "globe.americas.fill") - } - } - } - } - } -} - /// An example demonstrating how to use a compass with a map view. -struct MapWithViewpoint: View { +struct CompassExampleView: View { /// The `Map` displayed in the `MapView`. @State private var map = Map(basemapStyle: .arcGISImagery) /// Allows for communication between the Compass and MapView or SceneView. - @State private var viewpoint: Viewpoint? = Viewpoint( - center: .esriRedlands, - scale: 10_000, - rotation: -45 - ) + @State private var viewpoint: Viewpoint? = .esriRedlands var body: some View { MapViewReader { proxy in MapView(map: map, viewpoint: viewpoint) .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } .overlay(alignment: .topTrailing) { - Compass(viewpoint: $viewpoint, geoViewProxy: proxy) + Compass(viewpoint: $viewpoint, mapViewProxy: proxy) .padding() } } } } -/// An example demonstrating how to use a compass with a scene view and camera controller. -struct SceneWithCameraController: View { - /// The data model containing the `Scene` displayed in the `SceneView`. - @State private var scene = Scene(basemapStyle: .arcGISImagery) - - /// The current heading as reported by the scene view. - @State private var heading = Double.zero - - /// The orbit location camera controller used by the scene view. - private let cameraController = OrbitLocationCameraController( - target: .esriRedlands, - distance: 10_000 - ) - - var body: some View { - SceneView(scene: scene, cameraController: cameraController) - .onCameraChanged { newCamera in - heading = newCamera.heading.rounded() - } - .overlay(alignment: .topTrailing) { - Compass(viewpointRotation: $heading) - } - } -} - -private extension Point { - static var esriRedlands: Point { +private extension Viewpoint { + static var esriRedlands: Viewpoint { .init( - x: -117.19494, - y: 34.05723, - spatialReference: .wgs84 + center: .init(x: -117.19494, y: 34.05723, spatialReference: .wgs84), + scale: 10_000, + rotation: -45 ) } } diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 90b3b88fd..124656246 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -20,8 +20,8 @@ public struct Compass: View { /// The opacity of the compass. @State private var opacity: Double = .zero - /// <#Description#> - private var geoViewProxy: GeoViewProxy? + /// Provides access to viewpoint animation. + private var mapViewProxy: MapViewProxy? /// A Boolean value indicating whether the compass should automatically /// hide/show itself when the heading is `0`. @@ -44,13 +44,13 @@ public struct Compass: View { /// direction toward true East, etc.). /// - Parameters: /// - heading: The heading of the compass. - /// - geoViewProxy: <#Description#> + /// - mapViewProxy: Provides access to viewpoint animation. public init( heading: Binding, - geoViewProxy: GeoViewProxy? = nil + mapViewProxy: MapViewProxy? = nil ) { _heading = heading - self.geoViewProxy = geoViewProxy + self.mapViewProxy = mapViewProxy } public var body: some View { @@ -72,7 +72,7 @@ public struct Compass: View { } } .onTapGesture { - if let mapViewProxy = geoViewProxy as? MapViewProxy { + if let mapViewProxy { Task { await mapViewProxy.setViewpointRotation(0) } } else { heading = .zero @@ -90,26 +90,26 @@ public extension Compass { /// - Parameters: /// - viewpointRotation: The viewpoint rotation whose value determines the /// heading of the compass. - /// - geoViewProxy: <#Description#> + /// - mapViewProxy: Provides access to viewpoint animation. init( viewpointRotation: Binding, - geoViewProxy: GeoViewProxy? = nil + mapViewProxy: MapViewProxy? = nil ) { let heading = Binding(get: { viewpointRotation.wrappedValue.isZero ? .zero : 360 - viewpointRotation.wrappedValue }, set: { newHeading in viewpointRotation.wrappedValue = newHeading.isZero ? .zero : 360 - newHeading }) - self.init(heading: heading, geoViewProxy: geoViewProxy) + self.init(heading: heading, mapViewProxy: mapViewProxy) } /// Creates a compass with a binding to an optional viewpoint. /// - Parameters: /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - geoViewProxy: <#Description#> + /// - mapViewProxy: Provides access to viewpoint animation. init( viewpoint: Binding, - geoViewProxy: GeoViewProxy? = nil + mapViewProxy: MapViewProxy? = nil ) { let viewpointRotation = Binding { viewpoint.wrappedValue?.rotation ?? .nan @@ -121,7 +121,7 @@ public extension Compass { rotation: newViewpointRotation ) } - self.init(viewpointRotation: viewpointRotation, geoViewProxy: geoViewProxy) + self.init(viewpointRotation: viewpointRotation, mapViewProxy: mapViewProxy) } /// Define a custom size for the compass. From 0f5ae9ecdb73ca4d69e8bc291add2528bbef97f5 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Tue, 11 Apr 2023 13:50:32 -0700 Subject: [PATCH 03/18] Update README.md --- Documentation/Compass/README.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index 4956d70a5..96fe4106d 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -24,8 +24,8 @@ Compass: /// direction toward true East, etc.). /// - Parameters: /// - heading: The heading of the compass. - /// - action: An action to perform when the compass is tapped. - public init(heading: Binding, action: (() -> Void)? = nil) + /// - mapViewProxy: Provides access to viewpoint animation. + public init(heading: Binding, mapViewProxy: MapViewProxy? = nil) ``` ```swift @@ -35,16 +35,16 @@ Compass: /// - Parameters: /// - viewpointRotation: The viewpoint rotation whose value determines the /// heading of the compass. - /// - action: An action to perform when the compass is tapped. - public init(viewpointRotation: Binding, action: (() -> Void)? = nil) + /// - mapViewProxy: Provides access to viewpoint animation. + public init(viewpointRotation: Binding, mapViewProxy: MapViewProxy? = nil) ``` ```swift /// Creates a compass with a binding to an optional viewpoint. /// - Parameters: /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - action: An action to perform when the compass is tapped. - public init(viewpoint: Binding, action: (() -> Void)? = nil) + /// - mapViewProxy: Provides access to viewpoint animation. + public init(viewpoint: Binding, mapViewProxy: MapViewProxy? = nil) ``` `Compass` has the following modifiers: @@ -63,7 +63,7 @@ When the compass is tapped, the map orients back to north (zero bearing). ### Basic usage for displaying a `Compass`. ```swift -@StateObject var map = Map(basemapStyle: .arcGISImagery) +@State private var map = Map(basemapStyle: .arcGISImagery) /// Allows for communication between the Compass and MapView or SceneView. @State private var viewpoint: Viewpoint? = Viewpoint( @@ -73,12 +73,14 @@ When the compass is tapped, the map orients back to north (zero bearing). ) var body: some View { - MapView(map: map, viewpoint: viewpoint) - .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } - .overlay(alignment: .topTrailing) { - Compass(viewpoint: $viewpoint) - .padding() - } + MapViewReader { proxy in + MapView(map: map, viewpoint: viewpoint) + .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } + .overlay(alignment: .topTrailing) { + Compass(viewpoint: $viewpoint, mapViewProxy: proxy) + .padding() + } + } } ``` From bee39901b118ff5c258a66711c7d2d6fcaa77f48 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 09:47:01 -0700 Subject: [PATCH 04/18] Update proxy doc to match that proposed in #300 --- Documentation/Compass/README.md | 6 +++--- Sources/ArcGISToolkit/Components/Compass/Compass.swift | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index 96fe4106d..69b62775f 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -24,7 +24,7 @@ Compass: /// direction toward true East, etc.). /// - Parameters: /// - heading: The heading of the compass. - /// - mapViewProxy: Provides access to viewpoint animation. + /// - mapViewProxy: The proxy to provide access to map view operations. public init(heading: Binding, mapViewProxy: MapViewProxy? = nil) ``` @@ -35,7 +35,7 @@ Compass: /// - Parameters: /// - viewpointRotation: The viewpoint rotation whose value determines the /// heading of the compass. - /// - mapViewProxy: Provides access to viewpoint animation. + /// - mapViewProxy: The proxy to provide access to map view operations. public init(viewpointRotation: Binding, mapViewProxy: MapViewProxy? = nil) ``` @@ -43,7 +43,7 @@ Compass: /// Creates a compass with a binding to an optional viewpoint. /// - Parameters: /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - mapViewProxy: Provides access to viewpoint animation. + /// - mapViewProxy: The proxy to provide access to map view operations. public init(viewpoint: Binding, mapViewProxy: MapViewProxy? = nil) ``` diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 124656246..577a0ff56 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -20,7 +20,7 @@ public struct Compass: View { /// The opacity of the compass. @State private var opacity: Double = .zero - /// Provides access to viewpoint animation. + /// The proxy to provide access to map view operations. private var mapViewProxy: MapViewProxy? /// A Boolean value indicating whether the compass should automatically @@ -44,7 +44,7 @@ public struct Compass: View { /// direction toward true East, etc.). /// - Parameters: /// - heading: The heading of the compass. - /// - mapViewProxy: Provides access to viewpoint animation. + /// - mapViewProxy: The proxy to provide access to map view operations. public init( heading: Binding, mapViewProxy: MapViewProxy? = nil @@ -90,7 +90,7 @@ public extension Compass { /// - Parameters: /// - viewpointRotation: The viewpoint rotation whose value determines the /// heading of the compass. - /// - mapViewProxy: Provides access to viewpoint animation. + /// - mapViewProxy: The proxy to provide access to map view operations. init( viewpointRotation: Binding, mapViewProxy: MapViewProxy? = nil @@ -106,7 +106,7 @@ public extension Compass { /// Creates a compass with a binding to an optional viewpoint. /// - Parameters: /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - mapViewProxy: Provides access to viewpoint animation. + /// - mapViewProxy: The proxy to provide access to map view operations. init( viewpoint: Binding, mapViewProxy: MapViewProxy? = nil From 9aa5e5231531b03ae25fb443258573db574d06aa Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 15:16:40 -0700 Subject: [PATCH 05/18] Update API --- Examples/Examples/CompassExampleView.swift | 2 +- .../Components/Compass/Compass.swift | 86 +++++++++---------- 2 files changed, 42 insertions(+), 46 deletions(-) diff --git a/Examples/Examples/CompassExampleView.swift b/Examples/Examples/CompassExampleView.swift index 7f092a0fd..99e2af733 100644 --- a/Examples/Examples/CompassExampleView.swift +++ b/Examples/Examples/CompassExampleView.swift @@ -28,7 +28,7 @@ struct CompassExampleView: View { MapView(map: map, viewpoint: viewpoint) .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } .overlay(alignment: .topTrailing) { - Compass(viewpoint: $viewpoint, mapViewProxy: proxy) + Compass(viewpoint: viewpoint, mapViewProxy: proxy) .padding() } } diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 577a0ff56..fc5402ec9 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -20,36 +20,30 @@ public struct Compass: View { /// The opacity of the compass. @State private var opacity: Double = .zero - /// The proxy to provide access to map view operations. - private var mapViewProxy: MapViewProxy? - /// A Boolean value indicating whether the compass should automatically /// hide/show itself when the heading is `0`. private var autoHide: Bool = true - /// A Boolean value indicating whether the compass should hide based on the - /// current heading and whether the compass automatically hides. - var shouldHide: Bool { - (heading.isZero || heading.isNaN) && autoHide - } + /// The heading of the compass in degrees. + private var heading: Double + + /// The proxy to provide access to map view operations. + private var mapViewProxy: MapViewProxy /// The width and height of the compass. private var size: CGFloat = 44 - /// The heading of the compass in degrees. - @Binding private var heading: Double - /// Creates a compass with a binding to a heading based on compass /// directions (0° indicates a direction toward true North, 90° indicates a /// direction toward true East, etc.). /// - Parameters: /// - heading: The heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init( - heading: Binding, - mapViewProxy: MapViewProxy? = nil + init( + heading: Double, + mapViewProxy: MapViewProxy ) { - _heading = heading + self.heading = heading self.mapViewProxy = mapViewProxy } @@ -63,26 +57,33 @@ public struct Compass: View { .aspectRatio(1, contentMode: .fit) .opacity(opacity) .frame(width: size, height: size) - .onAppear { opacity = shouldHide ? 0 : 1 } - .onChange(of: heading) { _ in - let newOpacity: Double = shouldHide ? .zero : 1 + .onAppear { opacity = shouldHide(forHeading: heading) ? 0 : 1 } + .onChange(of: heading) { newHeading in + let newOpacity: Double = shouldHide(forHeading: newHeading) ? .zero : 1 guard opacity != newOpacity else { return } - withAnimation(.default.delay(shouldHide ? 0.25 : 0)) { + withAnimation(.default.delay(shouldHide(forHeading: newHeading) ? 0.25 : 0)) { opacity = newOpacity } } .onTapGesture { - if let mapViewProxy { - Task { await mapViewProxy.setViewpointRotation(0) } - } else { - heading = .zero - } + Task { await mapViewProxy.setViewpointRotation(0) } } .accessibilityLabel("Compass, heading \(Int(heading.rounded())) degrees \(CompassDirection(heading).rawValue)") } } } +extension Compass { + /// Returns a Boolean value indicating whether the compass should hide based on the + /// provided heading and whether the compass has been configured to automatically hide. + /// - Parameter heading: The heading used to determine if the compass should hide. + /// - Returns: `true` if the compass should hide, `false` otherwise. + func shouldHide(forHeading heading: Double) -> Bool { + print(heading) + return (heading.rounded(.up) == 360 || heading.rounded(.down) == 0 || heading.isNaN) && autoHide + } +} + public extension Compass { /// Creates a compass with a binding to a viewpoint rotation (0° indicates /// a direction toward true North, 90° indicates a direction toward true @@ -92,15 +93,17 @@ public extension Compass { /// heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. init( - viewpointRotation: Binding, - mapViewProxy: MapViewProxy? = nil + viewpointRotation: Double?, + mapViewProxy: MapViewProxy ) { - let heading = Binding(get: { - viewpointRotation.wrappedValue.isZero ? .zero : 360 - viewpointRotation.wrappedValue - }, set: { newHeading in - viewpointRotation.wrappedValue = newHeading.isZero ? .zero : 360 - newHeading - }) - self.init(heading: heading, mapViewProxy: mapViewProxy) + if let viewpointRotation { + self.init( + heading: viewpointRotation.isZero ? .zero : 360 - viewpointRotation, + mapViewProxy: mapViewProxy + ) + } else { + self.init(heading: .nan, mapViewProxy: mapViewProxy) + } } /// Creates a compass with a binding to an optional viewpoint. @@ -108,20 +111,13 @@ public extension Compass { /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. init( - viewpoint: Binding, - mapViewProxy: MapViewProxy? = nil + viewpoint: Viewpoint?, + mapViewProxy: MapViewProxy ) { - let viewpointRotation = Binding { - viewpoint.wrappedValue?.rotation ?? .nan - } set: { newViewpointRotation in - guard let oldViewpoint = viewpoint.wrappedValue else { return } - viewpoint.wrappedValue = Viewpoint( - center: oldViewpoint.targetGeometry.extent.center, - scale: oldViewpoint.targetScale, - rotation: newViewpointRotation - ) - } - self.init(viewpointRotation: viewpointRotation, mapViewProxy: mapViewProxy) + self.init( + viewpointRotation: viewpoint?.rotation ?? .nan, + mapViewProxy: mapViewProxy + ) } /// Define a custom size for the compass. From 188ef21ec08c539834360c527186ae4ba2ac960c Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 15:19:02 -0700 Subject: [PATCH 06/18] Update Compass.swift --- Sources/ArcGISToolkit/Components/Compass/Compass.swift | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index fc5402ec9..9723d2ad6 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -79,8 +79,7 @@ extension Compass { /// - Parameter heading: The heading used to determine if the compass should hide. /// - Returns: `true` if the compass should hide, `false` otherwise. func shouldHide(forHeading heading: Double) -> Bool { - print(heading) - return (heading.rounded(.up) == 360 || heading.rounded(.down) == 0 || heading.isNaN) && autoHide + (heading.rounded(.up) == 360 || heading.rounded(.down) == 0 || heading.isNaN) && autoHide } } From c0825f5c6c33f276f1eed437ac41e8b0a10e8c9d Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 15:23:40 -0700 Subject: [PATCH 07/18] Update Compass.swift --- Sources/ArcGISToolkit/Components/Compass/Compass.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 9723d2ad6..79a8baf41 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -79,7 +79,7 @@ extension Compass { /// - Parameter heading: The heading used to determine if the compass should hide. /// - Returns: `true` if the compass should hide, `false` otherwise. func shouldHide(forHeading heading: Double) -> Bool { - (heading.rounded(.up) == 360 || heading.rounded(.down) == 0 || heading.isNaN) && autoHide + (heading.isZero || heading.isNaN) && autoHide } } From f3bf7eb3723a96f3880c3aa61ebccd6fd2b9d088 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 15:54:22 -0700 Subject: [PATCH 08/18] Update api, tests, readme --- Documentation/Compass/README.md | 22 +---- .../Components/Compass/Compass.swift | 12 +-- Tests/ArcGISToolkitTests/CompassTests.swift | 91 ++++++------------- 3 files changed, 34 insertions(+), 91 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index 69b62775f..a7d1f10e4 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -18,23 +18,12 @@ Compass: `Compass` has the following initializers: -```swift - /// Creates a compass with a binding to a heading based on compass - /// directions (0° indicates a direction toward true North, 90° indicates a - /// direction toward true East, etc.). - /// - Parameters: - /// - heading: The heading of the compass. - /// - mapViewProxy: The proxy to provide access to map view operations. - public init(heading: Binding, mapViewProxy: MapViewProxy? = nil) -``` - ```swift /// Creates a compass with a binding to a viewpoint rotation (0° indicates /// a direction toward true North, 90° indicates a direction toward true /// West, etc.). /// - Parameters: - /// - viewpointRotation: The viewpoint rotation whose value determines the - /// heading of the compass. + /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. public init(viewpointRotation: Binding, mapViewProxy: MapViewProxy? = nil) ``` @@ -65,19 +54,14 @@ When the compass is tapped, the map orients back to north (zero bearing). ```swift @State private var map = Map(basemapStyle: .arcGISImagery) -/// Allows for communication between the Compass and MapView or SceneView. -@State private var viewpoint: Viewpoint? = Viewpoint( - center: Point(x: -117.19494, y: 34.05723, spatialReference: .wgs84), - scale: 10_000, - rotation: -45 -) +@State private var viewpoint: Viewpoint? var body: some View { MapViewReader { proxy in MapView(map: map, viewpoint: viewpoint) .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } .overlay(alignment: .topTrailing) { - Compass(viewpoint: $viewpoint, mapViewProxy: proxy) + Compass(viewpoint: viewpoint, mapViewProxy: proxy) .padding() } } diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 79a8baf41..22db34933 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -14,8 +14,7 @@ import ArcGIS import SwiftUI -/// A `Compass` (alias North arrow) shows where north is in a `MapView` or -/// `SceneView`. +/// A `Compass` (alias North arrow) shows where north is in a `MapView` or `SceneView`. public struct Compass: View { /// The opacity of the compass. @State private var opacity: Double = .zero @@ -28,7 +27,7 @@ public struct Compass: View { private var heading: Double /// The proxy to provide access to map view operations. - private var mapViewProxy: MapViewProxy + private var mapViewProxy: MapViewProxy? /// The width and height of the compass. private var size: CGFloat = 44 @@ -41,7 +40,7 @@ public struct Compass: View { /// - mapViewProxy: The proxy to provide access to map view operations. init( heading: Double, - mapViewProxy: MapViewProxy + mapViewProxy: MapViewProxy? = nil ) { self.heading = heading self.mapViewProxy = mapViewProxy @@ -66,7 +65,7 @@ public struct Compass: View { } } .onTapGesture { - Task { await mapViewProxy.setViewpointRotation(0) } + Task { await mapViewProxy?.setViewpointRotation(0) } } .accessibilityLabel("Compass, heading \(Int(heading.rounded())) degrees \(CompassDirection(heading).rawValue)") } @@ -88,8 +87,7 @@ public extension Compass { /// a direction toward true North, 90° indicates a direction toward true /// West, etc.). /// - Parameters: - /// - viewpointRotation: The viewpoint rotation whose value determines the - /// heading of the compass. + /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. init( viewpointRotation: Double?, diff --git a/Tests/ArcGISToolkitTests/CompassTests.swift b/Tests/ArcGISToolkitTests/CompassTests.swift index 23f831ff8..df0f69802 100644 --- a/Tests/ArcGISToolkitTests/CompassTests.swift +++ b/Tests/ArcGISToolkitTests/CompassTests.swift @@ -17,76 +17,37 @@ import XCTest @testable import ArcGISToolkit final class CompassTests: XCTestCase { - /// Verifies that the compass accurately indicates when the compass should be hidden when - /// `autoHide` is `false`. + /// Verifies that the compass accurately indicates it shouldn't be hidden when `autoHideDisabled` + /// is applied. func testHiddenWithAutoHideOff() { - let initialValue = 0.0 - let finalValue = 90.0 - var _viewpoint: Viewpoint? = makeViewpoint(rotation: initialValue) - let viewpoint = Binding(get: { _viewpoint }, set: { _viewpoint = $0 }) - let compass = Compass(viewpoint: viewpoint) + let compass1Heading = Double.zero + let compass1 = Compass(heading: compass1Heading) .autoHideDisabled() as! Compass - XCTAssertFalse(compass.shouldHide) - _viewpoint = makeViewpoint(rotation: finalValue) - XCTAssertFalse(compass.shouldHide) - } - - /// Verifies that the compass accurately indicates when the compass should be hidden when - /// `autoHide` is `true` (which is the default). - func testHiddenWithAutoHideOn() { - let initialValue = 0.0 - let finalValue = 90.0 - var _viewpoint: Viewpoint? = makeViewpoint(rotation: initialValue) - let viewpoint = Binding(get: { _viewpoint }, set: { _viewpoint = $0 }) - let compass = Compass(viewpoint: viewpoint) - XCTAssertTrue(compass.shouldHide) - _viewpoint = makeViewpoint(rotation: finalValue) - XCTAssertFalse(compass.shouldHide) - } - - /// Verifies that the compass correctly initializes when given a `nil` viewpoint. - func testInit() { - let compass = Compass(viewpoint: .constant(nil)) - XCTAssertTrue(compass.shouldHide) - } - - /// Verifies that the compass correctly initializes when given a `nil` viewpoint, and `autoHide` is - /// `false`. - func testAutomaticallyHidesNoAutoHide() { - let compass = Compass(viewpoint: .constant(nil)) + XCTAssertFalse(compass1.shouldHide(forHeading: compass1Heading)) + + let compass2Heading = 45.0 + let compass2 = Compass(heading: compass2Heading) .autoHideDisabled() as! Compass - XCTAssertFalse(compass.shouldHide) - } - - /// Verifies that the compass correctly initializes when given only a viewpoint. - func testInitWithViewpoint() { - let compass = Compass(viewpoint: .constant(makeViewpoint(rotation: .zero))) - XCTAssertTrue(compass.shouldHide) - } - - /// Verifies that the compass correctly initializes when given only a viewpoint. - func testInitWithViewpointAndAutoHide() { - let compass = Compass(viewpoint: .constant(makeViewpoint(rotation: .zero))) + XCTAssertFalse(compass2.shouldHide(forHeading: compass2Heading)) + + let compass3Heading = Double.nan + let compass3 = Compass(heading: compass3Heading) .autoHideDisabled() as! Compass - XCTAssertFalse(compass.shouldHide) - } -} - -extension CompassTests { - /// An arbitrary point to use for testing. - var point: Point { - Point(x: -117.19494, y: 34.05723, spatialReference: .wgs84) - } - - /// An arbitrary scale to use for testing. - var scale: Double { - 10_000.00 + XCTAssertFalse(compass3.shouldHide(forHeading: compass3Heading)) } - /// Builds viewpoints to use for tests. - /// - Parameter rotation: The rotation to use for the resulting viewpoint. - /// - Returns: A viewpoint object for tests. - func makeViewpoint(rotation: Double) -> Viewpoint { - return Viewpoint(center: point, scale: scale, rotation: rotation) + /// Verifies that the compass accurately indicates when it should be hidden. + func testHiddenWithAutoHideOn() { + let compass1Heading: Double = .zero + let compass1 = Compass(heading: compass1Heading) + XCTAssertTrue(compass1.shouldHide(forHeading: compass1Heading)) + + let compass2Heading = 45.0 + let compass2 = Compass(heading: compass2Heading) + XCTAssertFalse(compass2.shouldHide(forHeading: compass2Heading)) + + let compass3Heading = Double.nan + let compass3 = Compass(heading: compass3Heading) + XCTAssertTrue(compass3.shouldHide(forHeading: compass3Heading)) } } From 648d82e66738812a22b28e2e17c9f4fb293648d9 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 15:59:37 -0700 Subject: [PATCH 09/18] Update README.md --- Documentation/Compass/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index a7d1f10e4..e57d23826 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -25,7 +25,7 @@ Compass: /// - Parameters: /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpointRotation: Binding, mapViewProxy: MapViewProxy? = nil) + public init(viewpointRotation: Double?, mapViewProxy: MapViewProxy? = nil) ``` ```swift @@ -33,7 +33,7 @@ Compass: /// - Parameters: /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpoint: Binding, mapViewProxy: MapViewProxy? = nil) + public init(viewpoint: Viewpoint?, mapViewProxy: MapViewProxy? = nil) ``` `Compass` has the following modifiers: From 3c7eb9c9f29727ff698e410dff0ed8b168b71ebf Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 16:01:29 -0700 Subject: [PATCH 10/18] Alphabetize --- Documentation/Compass/README.md | 16 +++++------ .../Components/Compass/Compass.swift | 28 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index e57d23826..99e8d6c61 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -19,21 +19,21 @@ Compass: `Compass` has the following initializers: ```swift - /// Creates a compass with a binding to a viewpoint rotation (0° indicates - /// a direction toward true North, 90° indicates a direction toward true - /// West, etc.). + /// Creates a compass with a binding to an optional viewpoint. /// - Parameters: - /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. + /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpointRotation: Double?, mapViewProxy: MapViewProxy? = nil) + public init(viewpoint: Viewpoint?, mapViewProxy: MapViewProxy? = nil) ``` ```swift - /// Creates a compass with a binding to an optional viewpoint. + /// Creates a compass with a binding to a viewpoint rotation (0° indicates + /// a direction toward true North, 90° indicates a direction toward true + /// West, etc.). /// - Parameters: - /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. + /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpoint: Viewpoint?, mapViewProxy: MapViewProxy? = nil) + public init(viewpointRotation: Double?, mapViewProxy: MapViewProxy? = nil) ``` `Compass` has the following modifiers: diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 22db34933..b9db2487b 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -83,6 +83,20 @@ extension Compass { } public extension Compass { + /// Creates a compass with a binding to an optional viewpoint. + /// - Parameters: + /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. + /// - mapViewProxy: The proxy to provide access to map view operations. + init( + viewpoint: Viewpoint?, + mapViewProxy: MapViewProxy + ) { + self.init( + viewpointRotation: viewpoint?.rotation ?? .nan, + mapViewProxy: mapViewProxy + ) + } + /// Creates a compass with a binding to a viewpoint rotation (0° indicates /// a direction toward true North, 90° indicates a direction toward true /// West, etc.). @@ -103,20 +117,6 @@ public extension Compass { } } - /// Creates a compass with a binding to an optional viewpoint. - /// - Parameters: - /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - mapViewProxy: The proxy to provide access to map view operations. - init( - viewpoint: Viewpoint?, - mapViewProxy: MapViewProxy - ) { - self.init( - viewpointRotation: viewpoint?.rotation ?? .nan, - mapViewProxy: mapViewProxy - ) - } - /// Define a custom size for the compass. /// - Parameter size: The width and height of the compass. func compassSize(size: CGFloat) -> Self { From 1301522f4ae18127ef4841e7c2aa122bf07c4518 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Wed, 12 Apr 2023 16:05:05 -0700 Subject: [PATCH 11/18] Update README.md --- Documentation/Compass/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index 99e8d6c61..f3817f907 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -23,7 +23,7 @@ Compass: /// - Parameters: /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpoint: Viewpoint?, mapViewProxy: MapViewProxy? = nil) + public init(viewpoint: Viewpoint?, mapViewProxy: MapViewProxy) ``` ```swift @@ -33,7 +33,7 @@ Compass: /// - Parameters: /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpointRotation: Double?, mapViewProxy: MapViewProxy? = nil) + public init(viewpointRotation: Double?, mapViewProxy: MapViewProxy) ``` `Compass` has the following modifiers: From 158732c4c808cecf22a3fb7d6c9beced9dd55563 Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Thu, 13 Apr 2023 09:26:26 -0700 Subject: [PATCH 12/18] Update Sources/ArcGISToolkit/Components/Compass/Compass.swift Co-authored-by: Mark Dostal --- Sources/ArcGISToolkit/Components/Compass/Compass.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index b9db2487b..03be01b6d 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -14,7 +14,7 @@ import ArcGIS import SwiftUI -/// A `Compass` (alias North arrow) shows where north is in a `MapView` or `SceneView`. +/// A `Compass` (alias North arrow) shows where north is in a `MapView`. public struct Compass: View { /// The opacity of the compass. @State private var opacity: Double = .zero From d7d62db5bf891162449479bb7c88edb4c98c9a3d Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Thu, 13 Apr 2023 12:08:23 -0700 Subject: [PATCH 13/18] Update Sources/ArcGISToolkit/Components/Compass/Compass.swift Co-authored-by: Philip Ridgeway --- Sources/ArcGISToolkit/Components/Compass/Compass.swift | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 03be01b6d..73ea65da9 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -107,14 +107,13 @@ public extension Compass { viewpointRotation: Double?, mapViewProxy: MapViewProxy ) { + let heading: Double if let viewpointRotation { - self.init( - heading: viewpointRotation.isZero ? .zero : 360 - viewpointRotation, - mapViewProxy: mapViewProxy - ) + heading = viewpointRotation.isZero ? .zero : 360 - viewpointRotation } else { - self.init(heading: .nan, mapViewProxy: mapViewProxy) + heading = .nan } + self.init(heading: heading, mapViewProxy: mapViewProxy) } /// Define a custom size for the compass. From f734b6d6ae2d6af933336021add4b57caacccb4e Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Thu, 13 Apr 2023 12:15:20 -0700 Subject: [PATCH 14/18] Drop `init(viewpoint:, mapViewProxy:)`, update example --- Examples/Examples/CompassExampleView.swift | 2 +- .../Components/Compass/Compass.swift | 22 ++++--------------- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/Examples/Examples/CompassExampleView.swift b/Examples/Examples/CompassExampleView.swift index 99e2af733..f5954df67 100644 --- a/Examples/Examples/CompassExampleView.swift +++ b/Examples/Examples/CompassExampleView.swift @@ -28,7 +28,7 @@ struct CompassExampleView: View { MapView(map: map, viewpoint: viewpoint) .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } .overlay(alignment: .topTrailing) { - Compass(viewpoint: viewpoint, mapViewProxy: proxy) + Compass(rotation: viewpoint?.rotation, mapViewProxy: proxy) .padding() } } diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 73ea65da9..67d2fc006 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -83,33 +83,19 @@ extension Compass { } public extension Compass { - /// Creates a compass with a binding to an optional viewpoint. - /// - Parameters: - /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - mapViewProxy: The proxy to provide access to map view operations. - init( - viewpoint: Viewpoint?, - mapViewProxy: MapViewProxy - ) { - self.init( - viewpointRotation: viewpoint?.rotation ?? .nan, - mapViewProxy: mapViewProxy - ) - } - /// Creates a compass with a binding to a viewpoint rotation (0° indicates /// a direction toward true North, 90° indicates a direction toward true /// West, etc.). /// - Parameters: - /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. + /// - rotation: The viewpoint rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. init( - viewpointRotation: Double?, + rotation: Double?, mapViewProxy: MapViewProxy ) { let heading: Double - if let viewpointRotation { - heading = viewpointRotation.isZero ? .zero : 360 - viewpointRotation + if let rotation { + heading = rotation.isZero ? .zero : 360 - rotation } else { heading = .nan } From c5614e228d3911667acbd4d412ca492a9c62c19d Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Thu, 13 Apr 2023 12:17:10 -0700 Subject: [PATCH 15/18] Update README.md --- Documentation/Compass/README.md | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index f3817f907..bdba525c7 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -16,22 +16,14 @@ Compass: ## Key properties -`Compass` has the following initializers: - -```swift - /// Creates a compass with a binding to an optional viewpoint. - /// - Parameters: - /// - viewpoint: The viewpoint whose rotation determines the heading of the compass. - /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpoint: Viewpoint?, mapViewProxy: MapViewProxy) -``` +`Compass` has the following initializer: ```swift /// Creates a compass with a binding to a viewpoint rotation (0° indicates /// a direction toward true North, 90° indicates a direction toward true /// West, etc.). /// - Parameters: - /// - viewpointRotation: The viewpoint rotation whose value determines the heading of the compass. + /// - rotation: The rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. public init(viewpointRotation: Double?, mapViewProxy: MapViewProxy) ``` @@ -61,7 +53,7 @@ var body: some View { MapView(map: map, viewpoint: viewpoint) .onViewpointChanged(kind: .centerAndScale) { viewpoint = $0 } .overlay(alignment: .topTrailing) { - Compass(viewpoint: viewpoint, mapViewProxy: proxy) + Compass(rotation: viewpoint?.rotation, mapViewProxy: proxy) .padding() } } From bf38ee70e4a552b3deac3824d079d28129be424b Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Thu, 13 Apr 2023 12:24:38 -0700 Subject: [PATCH 16/18] Doc --- Documentation/Compass/README.md | 7 +++---- .../ArcGISToolkit/Components/Compass/Compass.swift | 12 +++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index bdba525c7..e2274b49b 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -19,13 +19,12 @@ Compass: `Compass` has the following initializer: ```swift - /// Creates a compass with a binding to a viewpoint rotation (0° indicates - /// a direction toward true North, 90° indicates a direction toward true - /// West, etc.). + /// Creates a compass with a rotation (0° indicates a direction toward true North, 90° indicates + /// a direction toward true West, etc.). /// - Parameters: /// - rotation: The rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. - public init(viewpointRotation: Double?, mapViewProxy: MapViewProxy) + public init(rotation: Double?, mapViewProxy: MapViewProxy) ``` `Compass` has the following modifiers: diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 67d2fc006..d2f40b574 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -32,9 +32,8 @@ public struct Compass: View { /// The width and height of the compass. private var size: CGFloat = 44 - /// Creates a compass with a binding to a heading based on compass - /// directions (0° indicates a direction toward true North, 90° indicates a - /// direction toward true East, etc.). + /// Creates a compass with a heading based on compass directions (0° indicates a direction + /// toward true North, 90° indicates a direction toward true East, etc.). /// - Parameters: /// - heading: The heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. @@ -83,11 +82,10 @@ extension Compass { } public extension Compass { - /// Creates a compass with a binding to a viewpoint rotation (0° indicates - /// a direction toward true North, 90° indicates a direction toward true - /// West, etc.). + /// Creates a compass with a rotation (0° indicates a direction toward true North, 90° indicates + /// a direction toward true West, etc.). /// - Parameters: - /// - rotation: The viewpoint rotation whose value determines the heading of the compass. + /// - rotation: The rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. init( rotation: Double?, From 117516938f5677206dcee5f9cb0af0448ba1731b Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Thu, 13 Apr 2023 12:50:10 -0700 Subject: [PATCH 17/18] Fix map doc --- Documentation/Compass/README.md | 4 ++-- Sources/ArcGISToolkit/Components/Compass/Compass.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index e2274b49b..c2d63c0da 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -19,8 +19,8 @@ Compass: `Compass` has the following initializer: ```swift - /// Creates a compass with a rotation (0° indicates a direction toward true North, 90° indicates - /// a direction toward true West, etc.). + /// Creates a compass with a rotation (0° indicates a map rotation towards true North, 90° + /// indicates a map rotation towards true East, etc.). /// - Parameters: /// - rotation: The rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index d2f40b574..69bf85f61 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -82,8 +82,8 @@ extension Compass { } public extension Compass { - /// Creates a compass with a rotation (0° indicates a direction toward true North, 90° indicates - /// a direction toward true West, etc.). + /// Creates a compass with a rotation (0° indicates a map rotation towards true North, 90° + /// indicates a map rotation towards true East, etc.). /// - Parameters: /// - rotation: The rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. From d9be3ebaceff2b161be4d35cd5ace758009504aa Mon Sep 17 00:00:00 2001 From: David Feinzimer Date: Thu, 13 Apr 2023 12:56:50 -0700 Subject: [PATCH 18/18] Doc --- Documentation/Compass/README.md | 4 ++-- Sources/ArcGISToolkit/Components/Compass/Compass.swift | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Documentation/Compass/README.md b/Documentation/Compass/README.md index c2d63c0da..e2274b49b 100644 --- a/Documentation/Compass/README.md +++ b/Documentation/Compass/README.md @@ -19,8 +19,8 @@ Compass: `Compass` has the following initializer: ```swift - /// Creates a compass with a rotation (0° indicates a map rotation towards true North, 90° - /// indicates a map rotation towards true East, etc.). + /// Creates a compass with a rotation (0° indicates a direction toward true North, 90° indicates + /// a direction toward true West, etc.). /// - Parameters: /// - rotation: The rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations. diff --git a/Sources/ArcGISToolkit/Components/Compass/Compass.swift b/Sources/ArcGISToolkit/Components/Compass/Compass.swift index 69bf85f61..d2f40b574 100644 --- a/Sources/ArcGISToolkit/Components/Compass/Compass.swift +++ b/Sources/ArcGISToolkit/Components/Compass/Compass.swift @@ -82,8 +82,8 @@ extension Compass { } public extension Compass { - /// Creates a compass with a rotation (0° indicates a map rotation towards true North, 90° - /// indicates a map rotation towards true East, etc.). + /// Creates a compass with a rotation (0° indicates a direction toward true North, 90° indicates + /// a direction toward true West, etc.). /// - Parameters: /// - rotation: The rotation whose value determines the heading of the compass. /// - mapViewProxy: The proxy to provide access to map view operations.