Skip to content

Commit 2c8672c

Browse files
committed
Add navigation bar back button
1 parent 9341c4a commit 2c8672c

File tree

2 files changed

+58
-54
lines changed

2 files changed

+58
-54
lines changed

Shared/Samples/Augment reality to show hidden infrastructure/AugmentRealityToShowHiddenInfrastructureView.swift

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,14 @@ struct AugmentRealityToShowHiddenInfrastructureView: View {
104104
.disabled(!geometryEditorCanUndo && !canDelete)
105105
Spacer()
106106

107-
NavigationLink {
108-
ARPipesSceneView(model: model.sceneModel)
109-
} label: {
110-
Image(systemName: "camera")
107+
NavigationStack {
108+
NavigationLink {
109+
ARPipesSceneView(model: model.sceneModel)
110+
} label: {
111+
Image(systemName: "camera")
112+
}
113+
.disabled(geometryEditorCanUndo || !canDelete)
111114
}
112-
.disabled(geometryEditorCanUndo || !canDelete)
113115
Spacer()
114116

115117
Button("Done", systemImage: "checkmark") {

Shared/Samples/Search for web map/SearchForWebMapView.swift

Lines changed: 51 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -29,63 +29,65 @@ struct SearchForWebMapView: View {
2929
@State private var error: Error?
3030

3131
var body: some View {
32-
ScrollView {
33-
LazyVStack {
34-
ForEach(model.portalItems, id: \.id) { item in
35-
NavigationLink {
36-
SafeMapView(map: Map(item: item))
37-
.navigationTitle(item.title)
38-
} label: {
39-
PortalItemRowView(item: item)
40-
}
41-
.buttonStyle(.plain)
42-
.task {
43-
// Load the next results when the last item is reached.
44-
guard item.id == model.portalItems.last?.id else { return }
45-
46-
resultsAreLoading = true
47-
defer { resultsAreLoading = false }
48-
49-
do {
50-
try await model.findNextItems()
51-
} catch {
52-
self.error = error
32+
NavigationStack {
33+
ScrollView {
34+
LazyVStack {
35+
ForEach(model.portalItems, id: \.id) { item in
36+
NavigationLink {
37+
SafeMapView(map: Map(item: item))
38+
.navigationTitle(item.title)
39+
} label: {
40+
PortalItemRowView(item: item)
41+
}
42+
.buttonStyle(.plain)
43+
.task {
44+
// Load the next results when the last item is reached.
45+
guard item.id == model.portalItems.last?.id else { return }
46+
47+
resultsAreLoading = true
48+
defer { resultsAreLoading = false }
49+
50+
do {
51+
try await model.findNextItems()
52+
} catch {
53+
self.error = error
54+
}
5355
}
5456
}
55-
}
56-
57-
if resultsAreLoading {
58-
ProgressView()
57+
58+
if resultsAreLoading {
59+
ProgressView()
60+
.padding()
61+
} else if !query.isEmpty && model.portalItems.isEmpty {
62+
VStack {
63+
Text("No Results")
64+
.font(.headline)
65+
Text("Check spelling or try a new search.")
66+
.font(.footnote)
67+
}
5968
.padding()
60-
} else if !query.isEmpty && model.portalItems.isEmpty {
61-
VStack {
62-
Text("No Results")
63-
.font(.headline)
64-
Text("Check spelling or try a new search.")
65-
.font(.footnote)
6669
}
67-
.padding()
6870
}
6971
}
70-
}
71-
.background(Color(.secondarySystemBackground))
72-
.searchable(
73-
text: $query,
74-
placement: .navigationBarDrawer(displayMode: .always),
75-
prompt: "Web Maps"
76-
)
77-
.task(id: query) {
78-
// Load new results when the query changes.
79-
resultsAreLoading = true
80-
defer { resultsAreLoading = false }
81-
82-
do {
83-
try await model.findItems(for: query)
84-
} catch {
85-
self.error = error
72+
.background(Color(.secondarySystemBackground))
73+
.searchable(
74+
text: $query,
75+
placement: .navigationBarDrawer(displayMode: .always),
76+
prompt: "Web Maps"
77+
)
78+
.task(id: query) {
79+
// Load new results when the query changes.
80+
resultsAreLoading = true
81+
defer { resultsAreLoading = false }
82+
83+
do {
84+
try await model.findItems(for: query)
85+
} catch {
86+
self.error = error
87+
}
8688
}
89+
.errorAlert(presentingError: $error)
8790
}
88-
.errorAlert(presentingError: $error)
8991
}
9092
}
9193

0 commit comments

Comments
 (0)