import SwiftUI struct LoginView: View { @Environment(AuthSession.self) private var auth @State private var email = "" @State private var password = "" var body: some View { VStack(spacing: 24) { Spacer() Image(systemName: "pawprint.fill") .font(.system(size: 80)) .foregroundStyle(Color.accentColor) VStack(spacing: 6) { Text("Ban Yaro Go") .font(.largeTitle.bold()) Text("Melde dich mit deinem banyaro-Account an.") .font(.callout) .foregroundStyle(.secondary) .multilineTextAlignment(.center) } VStack(spacing: 12) { TextField("E-Mail", text: $email) .textContentType(.emailAddress) .keyboardType(.emailAddress) .textInputAutocapitalization(.never) .autocorrectionDisabled() .padding() .background(.background.secondary, in: RoundedRectangle(cornerRadius: 12)) SecureField("Passwort", text: $password) .textContentType(.password) .padding() .background(.background.secondary, in: RoundedRectangle(cornerRadius: 12)) } if let error = auth.errorMessage { Text(error) .font(.footnote) .foregroundStyle(.red) .multilineTextAlignment(.center) } Button { Task { await auth.login( email: email.trimmingCharacters(in: .whitespacesAndNewlines), password: password ) } } label: { Group { if auth.isLoggingIn { ProgressView().tint(.white) } else { Text("Login").bold() } } .frame(maxWidth: .infinity, minHeight: 50) } .background(Color.accentColor, in: RoundedRectangle(cornerRadius: 12)) .foregroundStyle(.white) .disabled(auth.isLoggingIn || email.isEmpty || password.isEmpty) registrationHint Spacer() } .padding(.horizontal, 28) } private var registrationHint: some View { VStack(spacing: 6) { Text("Noch kein Account?") .font(.footnote) .foregroundStyle(.secondary) if let url = URL(string: "https://banyaro.app/#settings?tab=register") { Link(destination: url) { HStack(spacing: 6) { Text("Kostenlos bei banyaro.app registrieren") .font(.footnote.bold()) Image(systemName: "arrow.up.right.square") .font(.caption) } .foregroundStyle(Color.accentColor) } } } } } #Preview { LoginView() .environment(AuthSession()) }