-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path04-07-2021.swift
107 lines (89 loc) · 2.4 KB
/
04-07-2021.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
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
//
// 04-07-2021.swift
// SwiftUI Miami Challenges
//
import SwiftUI
struct Item: Identifiable {
let id = UUID()
let title: String
}
struct FooterView: View {
var body: some View {
Button(action: {
print("")
}) {
HStack {
Spacer()
Image(systemName: "plus.circle.fill")
.font(.largeTitle)
.foregroundColor(.blue)
.padding(.vertical, 16)
Spacer()
}
}
}
}
struct EntryCell: View {
@State private var text = ""
var onTap: () -> Void
var body: some View {
VStack(alignment: .leading) {
HStack {
Image(systemName: "phone.circle.fill")
.font(.title)
Text("Phone".uppercased())
.font(.subheadline)
Spacer()
Button(action: onTap) {
Image(systemName: "xmark.circle.fill")
.font(.title2)
}
}
HStack {
Text("Call")
.font(.body)
TextField("Placeholder", text: $text)
.font(.body)
}
}
.padding(.vertical)
}
}
struct VerticalView: View {
var items = [Item(title: "Hey"),Item(title: "Ciao"),Item(title: "Something in Castellano"),Item(title: "Bonjour")]
var body: some View {
NavigationView {
List {
Section(footer: FooterView()) {
ForEach(items) { item in
EntryCell {
guard let index = items.firstIndex(where: {
$0.id == item.id
}) else { return }
}
}
}
}
.listStyle(InsetGroupedListStyle())
.navigationTitle("New Shortcut")
}
}
}
struct VerticalViewPreview: PreviewProvider {
static var previews: some View {
VerticalView()
}
}
/*
var body: some View {
NavigationView {
List(items) { item in
Section(footer: Text("Bottom Text")) {
Text(item.title)
}
}
.navigationTitle("New Shortcut")
}
}
}
*/