[tvOS] Change password to be a SecureField and autosubmit on password comple… (#1090)
Some checks are pending
Build 🔨 / Build 🔨 (Swiftfin tvOS) (push) Waiting to run
Build 🔨 / Build 🔨 (Swiftfin) (push) Waiting to run

* Change password to be a SecureField and autosubmit on password completion

* Fix SelectUser Button

* Respond to comments and remove unnecessary changes

* Make FocusField a private enum
This commit is contained in:
Peter McNeil 2024-10-06 09:24:28 +01:00 committed by GitHub
parent ddd651ea3f
commit 5d59d57871
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 16 deletions

2
.gitignore vendored
View File

@ -98,3 +98,5 @@ iOSInjectionProject/
ehthumbs.db
Thumbs.db
Shared/Generated/Strings.swift
.idea

View File

@ -44,7 +44,6 @@ class SelectUserViewModel: ViewModel, Eventful, Stateful {
var events: AnyPublisher<Event, Never> {
eventSubject
.receive(on: RunLoop.main)
.eraseToAnyPublisher()
}

View File

@ -17,6 +17,11 @@ import SwiftUI
struct UserSignInView: View {
private enum FocusField: Hashable {
case username
case password
}
@Default(.accentColor)
private var accentColor
@ -24,7 +29,7 @@ struct UserSignInView: View {
private var router: UserSignInCoordinator.Router
@FocusState
private var focusedTextField: Int?
private var focusedTextField: FocusField?
@State
private var duplicateUser: UserState? = nil
@ -52,17 +57,16 @@ struct UserSignInView: View {
TextField(L10n.username, text: $username)
.autocorrectionDisabled()
.textInputAutocapitalization(.never)
.focused($focusedTextField, equals: 0)
.onSubmit {
focusedTextField = 1
}
.focused($focusedTextField, equals: .username)
TextField(L10n.password, text: $password) {
focusedTextField = nil
}
.autocorrectionDisabled()
.textInputAutocapitalization(.never)
.focused($focusedTextField, equals: 1)
SecureField(L10n.password, text: $password)
.focused($focusedTextField, equals: .password)
.onSubmit {
guard username.isNotEmpty else {
return
}
viewModel.send(.signIn(username: username, password: password, policy: .none))
}
} header: {
Text(L10n.signInToServer(viewModel.server.name))
}
@ -74,8 +78,6 @@ struct UserSignInView: View {
.foregroundStyle(.red, .red.opacity(0.2))
} else {
Button(L10n.signIn) {
focusedTextField = nil
viewModel.send(.signIn(username: username, password: password, policy: .none))
}
.disabled(username.isEmpty)
@ -123,7 +125,7 @@ struct UserSignInView: View {
) {
username = user.name ?? ""
password = ""
focusedTextField = 1
focusedTextField = .password
}
}
}
@ -177,7 +179,7 @@ struct UserSignInView: View {
}
}
.onFirstAppear {
focusedTextField = 0
focusedTextField = .username
viewModel.send(.getPublicData)
}
.alert(