mirror of
https://github.com/jellyfin/Swiftfin.git
synced 2024-11-23 05:59:51 +00:00
[tvOS] Change password to be a SecureField and autosubmit on password comple… (#1090)
* 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:
parent
ddd651ea3f
commit
5d59d57871
2
.gitignore
vendored
2
.gitignore
vendored
@ -98,3 +98,5 @@ iOSInjectionProject/
|
|||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
Shared/Generated/Strings.swift
|
Shared/Generated/Strings.swift
|
||||||
|
|
||||||
|
.idea
|
||||||
|
@ -44,7 +44,6 @@ class SelectUserViewModel: ViewModel, Eventful, Stateful {
|
|||||||
|
|
||||||
var events: AnyPublisher<Event, Never> {
|
var events: AnyPublisher<Event, Never> {
|
||||||
eventSubject
|
eventSubject
|
||||||
.receive(on: RunLoop.main)
|
|
||||||
.eraseToAnyPublisher()
|
.eraseToAnyPublisher()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@ import SwiftUI
|
|||||||
|
|
||||||
struct UserSignInView: View {
|
struct UserSignInView: View {
|
||||||
|
|
||||||
|
private enum FocusField: Hashable {
|
||||||
|
case username
|
||||||
|
case password
|
||||||
|
}
|
||||||
|
|
||||||
@Default(.accentColor)
|
@Default(.accentColor)
|
||||||
private var accentColor
|
private var accentColor
|
||||||
|
|
||||||
@ -24,7 +29,7 @@ struct UserSignInView: View {
|
|||||||
private var router: UserSignInCoordinator.Router
|
private var router: UserSignInCoordinator.Router
|
||||||
|
|
||||||
@FocusState
|
@FocusState
|
||||||
private var focusedTextField: Int?
|
private var focusedTextField: FocusField?
|
||||||
|
|
||||||
@State
|
@State
|
||||||
private var duplicateUser: UserState? = nil
|
private var duplicateUser: UserState? = nil
|
||||||
@ -52,17 +57,16 @@ struct UserSignInView: View {
|
|||||||
TextField(L10n.username, text: $username)
|
TextField(L10n.username, text: $username)
|
||||||
.autocorrectionDisabled()
|
.autocorrectionDisabled()
|
||||||
.textInputAutocapitalization(.never)
|
.textInputAutocapitalization(.never)
|
||||||
.focused($focusedTextField, equals: 0)
|
.focused($focusedTextField, equals: .username)
|
||||||
.onSubmit {
|
|
||||||
focusedTextField = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
TextField(L10n.password, text: $password) {
|
SecureField(L10n.password, text: $password)
|
||||||
focusedTextField = nil
|
.focused($focusedTextField, equals: .password)
|
||||||
}
|
.onSubmit {
|
||||||
.autocorrectionDisabled()
|
guard username.isNotEmpty else {
|
||||||
.textInputAutocapitalization(.never)
|
return
|
||||||
.focused($focusedTextField, equals: 1)
|
}
|
||||||
|
viewModel.send(.signIn(username: username, password: password, policy: .none))
|
||||||
|
}
|
||||||
} header: {
|
} header: {
|
||||||
Text(L10n.signInToServer(viewModel.server.name))
|
Text(L10n.signInToServer(viewModel.server.name))
|
||||||
}
|
}
|
||||||
@ -74,8 +78,6 @@ struct UserSignInView: View {
|
|||||||
.foregroundStyle(.red, .red.opacity(0.2))
|
.foregroundStyle(.red, .red.opacity(0.2))
|
||||||
} else {
|
} else {
|
||||||
Button(L10n.signIn) {
|
Button(L10n.signIn) {
|
||||||
focusedTextField = nil
|
|
||||||
|
|
||||||
viewModel.send(.signIn(username: username, password: password, policy: .none))
|
viewModel.send(.signIn(username: username, password: password, policy: .none))
|
||||||
}
|
}
|
||||||
.disabled(username.isEmpty)
|
.disabled(username.isEmpty)
|
||||||
@ -123,7 +125,7 @@ struct UserSignInView: View {
|
|||||||
) {
|
) {
|
||||||
username = user.name ?? ""
|
username = user.name ?? ""
|
||||||
password = ""
|
password = ""
|
||||||
focusedTextField = 1
|
focusedTextField = .password
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -177,7 +179,7 @@ struct UserSignInView: View {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onFirstAppear {
|
.onFirstAppear {
|
||||||
focusedTextField = 0
|
focusedTextField = .username
|
||||||
viewModel.send(.getPublicData)
|
viewModel.send(.getPublicData)
|
||||||
}
|
}
|
||||||
.alert(
|
.alert(
|
||||||
|
Loading…
Reference in New Issue
Block a user