Skip to content

Commit da13c3f

Browse files
committed
Add done button to dismiss sheet
1 parent ef4bd03 commit da13c3f

File tree

1 file changed

+34
-19
lines changed

1 file changed

+34
-19
lines changed

Shared/Samples/Add dynamic entity layer/AddDynamicEntityLayerView.SettingsView.swift

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,33 +19,48 @@ extension AddDynamicEntityLayerView {
1919
/// The view model for the sample.
2020
@EnvironmentObject private var model: Model
2121

22+
/// The action to dismiss the settings sheet.
23+
@Environment(\.dismiss) private var dismiss: DismissAction
24+
2225
var body: some View {
23-
List {
24-
Section("Track display properties") {
25-
Toggle("Track Lines", isOn: $model.showsTrackLine)
26-
Toggle("Previous Observations", isOn: $model.showsPreviousObservations)
27-
}
28-
29-
Section("Observations") {
30-
VStack {
26+
NavigationView {
27+
List {
28+
Section("Track display properties") {
29+
Toggle("Track Lines", isOn: $model.showsTrackLine)
30+
Toggle("Previous Observations", isOn: $model.showsPreviousObservations)
31+
}
32+
33+
Section("Observations") {
34+
VStack {
35+
HStack {
36+
Text("Observations per track")
37+
Spacer()
38+
Text(model.maximumObservations.formatted())
39+
.foregroundColor(.secondary)
40+
}
41+
Slider(value: $model.maximumObservations, in: model.maxObservationRange, step: 1)
42+
}
3143
HStack {
32-
Text("Observations per track")
3344
Spacer()
34-
Text(model.maximumObservations.formatted())
35-
.foregroundColor(.secondary)
45+
Button("Purge All Observations") {
46+
Task {
47+
try? await model.streamService.purgeAll()
48+
}
49+
}
50+
Spacer()
3651
}
37-
Slider(value: $model.maximumObservations, in: model.maxObservationRange, step: 1)
3852
}
39-
HStack {
40-
Spacer()
41-
Button("Purge All Observations") {
42-
Task {
43-
try? await model.streamService.purgeAll()
44-
}
53+
}
54+
.navigationTitle("Dynamic Entity Settings")
55+
.navigationBarTitleDisplayMode(.inline)
56+
.toolbar {
57+
ToolbarItem(placement: .confirmationAction) {
58+
Button("Done") {
59+
dismiss()
4560
}
46-
Spacer()
4761
}
4862
}
63+
.navigationViewStyle(.stack)
4964
}
5065
}
5166
}

0 commit comments

Comments
 (0)