Made small improvements like dismissing the keyboard. Tapping the Contacts tab causes the app to crash.

This commit is contained in:
Isaac Greene 2022-06-10 23:55:34 -04:00
parent b77ef882e8
commit 5c4d4f8059
21 changed files with 174 additions and 36 deletions

View file

@ -11,12 +11,20 @@ import SwiftUI
// human-readable without aid, as long as
// the reader has a basic understanding of
// Swift and/or SwiftUI.
let username = "admin"
let password = "123"
struct DocsView: View {
@State var pass: String = ""
@State var user: String = ""
enum Field: Hashable {
case username
case password
}
@State private var pass: String = ""
@State private var user: String = ""
@FocusState private var focusedField: Field?
var body: some View {
NavigationView {
List {
@ -36,14 +44,22 @@ struct DocsView: View {
}
Section(header: Text("App Information")) {
NavigationLink("Software License", destination: LicenseView())
Text("Version: 1.0.0")
Text("Version: Release Candidate (1.0.0)")
Text("Release date: 2022-06-10")
Text("Start date: 2022-03-25")
Link("Built with SwiftUI \(Image(systemName: "swift"))", destination: URL(string: "https://developer.apple.com/xcode/swiftui")!)
}
Section(header: Text("Login")) {
SecureField("Username", text: $user)
.keyboardType(.alphabet)
.textContentType(.username)
.submitLabel(.next)
.focused($focusedField, equals: .username)
SecureField("Password", text: $pass)
.keyboardType(.numbersAndPunctuation)
.textContentType(.password)
.submitLabel(.done)
.focused($focusedField, equals: .password)
if (pass == password && user == username) {
NavigationLink("Contacts", destination: SecretView())
}
@ -51,6 +67,14 @@ struct DocsView: View {
}
.navigationTitle("Docs")
}
.onSubmit {
switch focusedField {
case .username:
focusedField = .password
default:
()
}
}
}
}