mirror of
https://github.com/jellyfin/Swiftfin.git
synced 2024-11-27 08:10:23 +00:00
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) {
|
||||
self.server = server
|
||||
JellyfinAPIAPI.basePath = server.currentURI
|
||||
}
|
||||
|
||||
var alertTitle: String {
|
||||
@ -58,7 +59,6 @@ final class UserSignInViewModel: ViewModel {
|
||||
|
||||
func loadUsers() {
|
||||
self.isLoadingUsers = true
|
||||
JellyfinAPIAPI.basePath = server.currentURI
|
||||
UserAPI.getPublicUsers()
|
||||
.sink(receiveCompletion: { completion in
|
||||
self.handleAPIRequestError(displayMessage: L10n.unableToConnectServer, completion: completion)
|
||||
@ -76,4 +76,9 @@ final class UserSignInViewModel: ViewModel {
|
||||
quality: 90).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 = ""
|
||||
|
||||
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 {
|
||||
TextField(L10n.username, text: $username)
|
||||
.disableAutocorrection(true)
|
||||
.autocapitalization(.none)
|
||||
SecureField(L10n.password, text: $password)
|
||||
.disableAutocorrection(true)
|
||||
.autocapitalization(.none)
|
||||
|
||||
SecureField(L10n.password, text: $password)
|
||||
.disableAutocorrection(true)
|
||||
.autocapitalization(.none)
|
||||
|
||||
Button {
|
||||
viewModel.login(username: username, password: password)
|
||||
} label: {
|
||||
HStack {
|
||||
L10n.connect.text
|
||||
Spacer()
|
||||
if viewModel.isLoading {
|
||||
ProgressView()
|
||||
Button {
|
||||
viewModel.login(username: username, password: password)
|
||||
} label: {
|
||||
HStack {
|
||||
L10n.connect.text
|
||||
Spacer()
|
||||
if viewModel.isLoading {
|
||||
ProgressView()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.disabled(viewModel.isLoading || username.isEmpty)
|
||||
.disabled(viewModel.isLoading || username.isEmpty)
|
||||
|
||||
} header: {
|
||||
L10n.signInToServer(viewModel.server.name).text
|
||||
} header: {
|
||||
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
Block a user