Add login background to tvOS
This commit is contained in:
parent
be66d1008e
commit
270b0802c9
|
@ -25,6 +25,7 @@ final class UserSignInViewModel: ViewModel {
|
||||||
|
|
||||||
init(server: SwiftfinStore.State.Server) {
|
init(server: SwiftfinStore.State.Server) {
|
||||||
self.server = server
|
self.server = server
|
||||||
|
JellyfinAPIAPI.basePath = server.currentURI
|
||||||
}
|
}
|
||||||
|
|
||||||
var alertTitle: String {
|
var alertTitle: String {
|
||||||
|
@ -58,7 +59,6 @@ final class UserSignInViewModel: ViewModel {
|
||||||
|
|
||||||
func loadUsers() {
|
func loadUsers() {
|
||||||
self.isLoadingUsers = true
|
self.isLoadingUsers = true
|
||||||
JellyfinAPIAPI.basePath = server.currentURI
|
|
||||||
UserAPI.getPublicUsers()
|
UserAPI.getPublicUsers()
|
||||||
.sink(receiveCompletion: { completion in
|
.sink(receiveCompletion: { completion in
|
||||||
self.handleAPIRequestError(displayMessage: L10n.unableToConnectServer, completion: completion)
|
self.handleAPIRequestError(displayMessage: L10n.unableToConnectServer, completion: completion)
|
||||||
|
@ -76,4 +76,9 @@ final class UserSignInViewModel: ViewModel {
|
||||||
quality: 90).URLString
|
quality: 90).URLString
|
||||||
return URL(string: urlString)
|
return URL(string: urlString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getSplashscreenUrl() -> URL? {
|
||||||
|
let urlString = ImageAPI.getSplashscreenWithRequestBuilder().URLString
|
||||||
|
return URL(string: urlString)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,39 +19,44 @@ struct UserSignInView: View {
|
||||||
private var password: String = ""
|
private var password: String = ""
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
Form {
|
ZStack {
|
||||||
|
ImageView(viewModel.getSplashscreenUrl())
|
||||||
|
.ignoresSafeArea()
|
||||||
|
Color.black.opacity(0.9)
|
||||||
|
.ignoresSafeArea()
|
||||||
|
Form {
|
||||||
|
Section {
|
||||||
|
TextField(L10n.username, text: $username)
|
||||||
|
.disableAutocorrection(true)
|
||||||
|
.autocapitalization(.none)
|
||||||
|
|
||||||
Section {
|
SecureField(L10n.password, text: $password)
|
||||||
TextField(L10n.username, text: $username)
|
.disableAutocorrection(true)
|
||||||
.disableAutocorrection(true)
|
.autocapitalization(.none)
|
||||||
.autocapitalization(.none)
|
|
||||||
|
|
||||||
SecureField(L10n.password, text: $password)
|
Button {
|
||||||
.disableAutocorrection(true)
|
viewModel.login(username: username, password: password)
|
||||||
.autocapitalization(.none)
|
} label: {
|
||||||
|
HStack {
|
||||||
Button {
|
L10n.connect.text
|
||||||
viewModel.login(username: username, password: password)
|
Spacer()
|
||||||
} label: {
|
if viewModel.isLoading {
|
||||||
HStack {
|
ProgressView()
|
||||||
L10n.connect.text
|
}
|
||||||
Spacer()
|
|
||||||
if viewModel.isLoading {
|
|
||||||
ProgressView()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
.disabled(viewModel.isLoading || username.isEmpty)
|
||||||
.disabled(viewModel.isLoading || username.isEmpty)
|
|
||||||
|
|
||||||
} header: {
|
} header: {
|
||||||
L10n.signInToServer(viewModel.server.name).text
|
L10n.signInToServer(viewModel.server.name).text
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
.alert(item: $viewModel.errorMessage) { _ in
|
||||||
|
Alert(title: Text(viewModel.alertTitle),
|
||||||
|
message: Text(viewModel.errorMessage?.message ?? L10n.unknownError),
|
||||||
|
dismissButton: .cancel())
|
||||||
|
}
|
||||||
|
.navigationTitle(L10n.signIn)
|
||||||
}
|
}
|
||||||
.alert(item: $viewModel.errorMessage) { _ in
|
|
||||||
Alert(title: Text(viewModel.alertTitle),
|
|
||||||
message: Text(viewModel.errorMessage?.message ?? L10n.unknownError),
|
|
||||||
dismissButton: .cancel())
|
|
||||||
}
|
|
||||||
.navigationTitle(L10n.signIn)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue