1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import SwiftUI
/// Half-sheet for picking a story's location from the review stage.
struct StoryLocationSheet: View {
@Environment(\.dismiss) private var dismiss
@Binding var resolvedLocation: (h3: String, name: String, address: [String: AnyCodable]?)?
let photoLocationResult: NominatimResult?
let onSelectLocation: (NominatimResult) -> Void
var body: some View {
NavigationStack {
Form {
Section {
LocationPickerRows(
resolvedLocation: $resolvedLocation,
photoLocationResult: photoLocationResult,
onSelectLocation: { result in
onSelectLocation(result)
dismiss()
}
)
}
}
.navigationTitle("Location")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") { dismiss() }
}
}
}
.presentationDetents([.medium, .large])
}
}
/// Half-sheet for choosing a story's self-applied content labels.
struct StoryContentLabelSheet: View {
@Environment(\.dismiss) private var dismiss
@Binding var selectedLabels: Set<String>
var body: some View {
NavigationStack {
Form {
ContentLabelPicker(selectedLabels: $selectedLabels, initiallyExpanded: true)
}
.navigationTitle("Content warning")
.navigationBarTitleDisplayMode(.inline)
.toolbar {
ToolbarItem(placement: .confirmationAction) {
Button("Done") { dismiss() }
}
}
}
.presentationDetents([.medium])
}
}
#Preview("Location") {
@Previewable @State var location: (h3: String, name: String, address: [String: AnyCodable]?)?
Color.black
.sheet(isPresented: .constant(true)) {
StoryLocationSheet(resolvedLocation: $location, photoLocationResult: nil) { _ in }
}
.previewEnvironments()
.grainPreview()
}
#Preview("Labels") {
@Previewable @State var labels: Set = ["nudity"]
Color.black
.sheet(isPresented: .constant(true)) {
StoryContentLabelSheet(selectedLabels: $labels)
}
.previewEnvironments()
.grainPreview()
}