-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathExampleView.swift
More file actions
65 lines (58 loc) · 1.74 KB
/
Copy pathExampleView.swift
File metadata and controls
65 lines (58 loc) · 1.74 KB
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
import SwiftUI
import TextFieldAlert
struct ExampleView: View {
@StateObject private var viewModel = ExampleViewModel()
var body: some View {
VStack {
Spacer()
Spacer()
Button {
viewModel.presentSignInAlert()
} label: {
Text("Sign in")
}
Spacer()
Spacer()
Text("Mail: \(viewModel.mail)")
Text("Password: \(viewModel.password)")
Spacer()
}
.textFieldAlert(
title: "Sign in",
message: "Enter the following information.",
textFields: [
.init(
text: $viewModel.mail,
placeholder: "Email address (cannot be empty)",
autocapitalizationType: .none,
keyboardType: .emailAddress
),
.init(
text: $viewModel.password,
placeholder: "Password (5 characters or more)",
isSecureTextEntry: true,
autocapitalizationType: .none
)
],
actions: [
.init(
title: "Cancel",
style: .cancel
),
.init(
title: "OK",
isEnabled: viewModel.isValid,
closure: { _ in
viewModel.signIn()
}
)
],
isPresented: $viewModel.isPresented
)
}
}
struct ExampleViewPreviews: PreviewProvider {
static var previews: some View {
ExampleView()
}
}