-
Notifications
You must be signed in to change notification settings - Fork 1
/
Content.swift
46 lines (42 loc) · 1.4 KB
/
Content.swift
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
import SwiftUI
struct Content: View {
@ObservedObject var places: Places
@State private var creating = false
var add: (String) -> Void
var delete: (IndexSet) -> Void
var body: some View {
List {
HStack {
Image(systemName: "plus.circle.fill")
.padding(.leading, 5)
.foregroundColor(Color("halo"))
Text(.init("Main.add"))
.padding(.leading, 2)
}
.onTapGesture {
self.creating = true
}
Section(header: Text(.init("Main.header"))) {
ForEach(places.session.items, id: \.self) { item in
NavigationLink(destination: Navigate(places: self.places, item: item)) {
Text(item.name)
}
}.onDelete(perform: delete)
}
}
.navigationBarTitle("Main.title")
.sheet(isPresented: $creating) {
Create {
self.add($0)
self.creating = false
}
}
.alert(isPresented: self.$places.error) {
Alert(title: Text("Main.alert"), message: Text(self.places.message), dismissButton:
.default(Text("Main.continue")) {
self.places.error = false
}
)
}
}
}