Merge branch 'main' into quickconnect

This commit is contained in:
David Ullmer 2022-07-12 19:57:01 +02:00 committed by GitHub
commit b8a0af5b28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 40 additions and 27 deletions

View File

@ -22,6 +22,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 {
@ -54,7 +55,6 @@ final class UserSignInViewModel: ViewModel {
} }
func loadUsers() { func loadUsers() {
JellyfinAPIAPI.basePath = server.currentURI
UserAPI.getPublicUsers() UserAPI.getPublicUsers()
.trackActivity(loading) .trackActivity(loading)
.sink(receiveCompletion: { completion in .sink(receiveCompletion: { completion in
@ -72,4 +72,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)
}
} }

View File

@ -19,39 +19,47 @@ 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()
Section { Color.black
TextField(L10n.username, text: $username) .opacity(0.9)
.disableAutocorrection(true) .ignoresSafeArea()
.autocapitalization(.none)
SecureField(L10n.password, text: $password) Form {
.disableAutocorrection(true) Section {
.autocapitalization(.none) TextField(L10n.username, text: $username)
.disableAutocorrection(true)
.autocapitalization(.none)
Button { SecureField(L10n.password, text: $password)
viewModel.login(username: username, password: password) .disableAutocorrection(true)
} label: { .autocapitalization(.none)
HStack {
L10n.connect.text Button {
Spacer() viewModel.login(username: username, password: password)
if viewModel.isLoading { } label: {
ProgressView() HStack {
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)
} }
} }