Skip to content

Commit dbe88ea

Browse files
committed
Add refactoring previews.
1 parent 1f1f7c0 commit dbe88ea

File tree

7 files changed

+55
-31
lines changed

7 files changed

+55
-31
lines changed

Shared/Samples/Download vector tiles to local cache/DownloadVectorTilesToLocalCacheView.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -290,19 +290,6 @@ private extension DownloadVectorTilesToLocalCacheView {
290290
}
291291
}
292292

293-
private extension MapViewProxy {
294-
/// Creates an envelope from the given rectangle.
295-
/// - Parameter viewRect: The rectangle to create an envelope of.
296-
/// - Returns: An envelope of the given rectangle.
297-
func envelope(fromViewRect viewRect: CGRect) -> Envelope? {
298-
guard let min = location(fromScreenPoint: CGPoint(x: viewRect.minX, y: viewRect.minY)),
299-
let max = location(fromScreenPoint: CGPoint(x: viewRect.maxX, y: viewRect.maxY)) else {
300-
return nil
301-
}
302-
return Envelope(min: min, max: max)
303-
}
304-
}
305-
306293
private extension Envelope {
307294
/// Expands the envelope by a given factor.
308295
func expanded(by factor: Double) -> Envelope {
@@ -311,3 +298,9 @@ private extension Envelope {
311298
return builder.toGeometry()
312299
}
313300
}
301+
302+
#Preview {
303+
NavigationView {
304+
DownloadVectorTilesToLocalCacheView()
305+
}
306+
}

Shared/Samples/Generate offline map/GenerateOfflineMapView.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,19 +242,6 @@ private extension GenerateOfflineMapView {
242242
}
243243
}
244244

245-
private extension MapViewProxy {
246-
/// Creates an envelope from the given rectangle.
247-
/// - Parameter viewRect: The rectangle to create an envelope of.
248-
/// - Returns: An envelope of the given rectangle.
249-
func envelope(fromViewRect viewRect: CGRect) -> Envelope? {
250-
guard let min = location(fromScreenPoint: CGPoint(x: viewRect.minX, y: viewRect.minY)),
251-
let max = location(fromScreenPoint: CGPoint(x: viewRect.maxX, y: viewRect.maxY)) else {
252-
return nil
253-
}
254-
return Envelope(min: min, max: max)
255-
}
256-
}
257-
258245
private extension Envelope {
259246
/// Expands the envelope by a given factor.
260247
func expanded(by factor: Double) -> Envelope {
@@ -263,3 +250,9 @@ private extension Envelope {
263250
return builder.toGeometry()
264251
}
265252
}
253+
254+
#Preview {
255+
NavigationView {
256+
GenerateOfflineMapView()
257+
}
258+
}

Shared/Samples/Navigate route/NavigateRouteView.swift

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ private extension NavigateRouteView {
154154
autoPanMode = .off
155155

156156
// Creates the graphics for each stop.
157-
let stopGraphics = stops.map {
157+
let stopGraphics = Self.stops.map {
158158
Graphic(
159159
geometry: $0.geometry,
160160
symbol: SimpleMarkerSymbol(style: .diamond, color: .orange, size: 20)
@@ -183,7 +183,7 @@ private extension NavigateRouteView {
183183
parameters.outputSpatialReference = .wgs84
184184

185185
// Sets the stops on the parameters.
186-
parameters.setStops(stops)
186+
parameters.setStops(Self.stops)
187187

188188
// Solves the route based on the parameters.
189189
routeResult = try await routeTask.solveRoute(using: parameters)
@@ -323,7 +323,9 @@ private extension NavigateRouteView {
323323
isResettingRoute = false
324324
}
325325
}
326-
326+
}
327+
328+
private extension NavigateRouteView.Model {
327329
/// The stops for this sample.
328330
static var stops: [Stop] {
329331
let one = Stop(point: Point(x: -117.160386727, y: 32.706608, spatialReference: .wgs84))
@@ -348,3 +350,9 @@ private extension URL {
348350
URL(string: "http://sampleserver7.arcgisonline.com/server/rest/services/NetworkAnalysis/SanDiego/NAServer/Route")!
349351
}
350352
}
353+
354+
#Preview {
355+
NavigationView {
356+
NavigateRouteView()
357+
}
358+
}

Shared/Samples/Set min and max scale/SetMinAndMaxScaleView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,7 @@ struct SetMinAndMaxScaleView: View {
3434
MapView(map: map)
3535
}
3636
}
37+
38+
#Preview {
39+
SetMinAndMaxScaleView()
40+
}

Shared/Samples/Show device location/ShowDeviceLocationView.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ private extension ShowDeviceLocationView {
123123
}
124124

125125
private extension LocationDisplay.AutoPanMode {
126-
static var allCases: [LocationDisplay.AutoPanMode] { [.off, .recenter, .navigation, .compassNavigation] }
127-
128126
/// A human-readable label for each auto-pan mode.
129127
var label: String {
130128
switch self {
@@ -147,3 +145,9 @@ private extension LocationDisplay.AutoPanMode {
147145
}
148146
}
149147
}
148+
149+
#Preview {
150+
NavigationView {
151+
ShowDeviceLocationView()
152+
}
153+
}

Shared/Samples/Show result of spatial operations/ShowResultOfSpatialOperationsView.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,15 @@ private extension Geometry {
167167
)
168168
}
169169
}
170+
171+
#if DEBUG
172+
private extension ShowResultOfSpatialOperationsView.Model {
173+
typealias SpatialOperation = ShowResultOfSpatialOperationsView.SpatialOperation
174+
}
175+
176+
#Preview {
177+
NavigationView {
178+
ShowResultOfSpatialOperationsView()
179+
}
180+
}
181+
#endif

Shared/Samples/Show result of spatial relationships/ShowResultOfSpatialRelationshipsView.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,3 +272,13 @@ private extension Graphic {
272272
return Graphic(geometry: point, symbol: markerSymbol)
273273
}
274274
}
275+
276+
#if DEBUG
277+
private extension ShowResultOfSpatialRelationshipsView.Model {
278+
typealias Relationship = ShowResultOfSpatialRelationshipsView.Relationship
279+
}
280+
281+
#Preview {
282+
ShowResultOfSpatialRelationshipsView()
283+
}
284+
#endif

0 commit comments

Comments
 (0)