import SwiftUI struct LoginView: View { @EnvironmentObject var authViewModel: AuthViewModel @State private var email = "" @State private var password = "" @State private var showRegister = false var body: some View { NavigationStack { VStack(spacing: 24) { Spacer() VStack(spacing: 8) { Image(systemName: "bell.badge.fill") .font(.system(size: 60)) .foregroundStyle(.red) Text("Mayday") .font(.largeTitle.bold()) Text("login_subtitle") .font(.subheadline) .foregroundStyle(.secondary) } VStack(spacing: 16) { TextField("Email", text: $email) .textFieldStyle(.roundedBorder) .textContentType(.emailAddress) .keyboardType(.emailAddress) .autocorrectionDisabled() .textInputAutocapitalization(.never) SecureField("password", text: $password) .textFieldStyle(.roundedBorder) .textContentType(.password) } if let error = authViewModel.error { Text(error) .foregroundStyle(.red) .font(.footnote) .multilineTextAlignment(.center) } Button { Task { await authViewModel.login(email: email, password: password) } } label: { if authViewModel.isLoading { ProgressView() .frame(maxWidth: .infinity) } else { Text("login_button") .frame(maxWidth: .infinity) } } .buttonStyle(.borderedProminent) .disabled(email.isEmpty || password.isEmpty || authViewModel.isLoading) Button("login_no_account") { showRegister = true } .font(.footnote) #if DEBUG Button { Task { await authViewModel.enterPreviewMode() } } label: { Label("demo_mode", systemImage: "play.circle.fill") .font(.footnote) .foregroundStyle(.secondary) } .padding(.top, 8) #endif Spacer() } .padding() .navigationDestination(isPresented: $showRegister) { RegisterView() } } } }