Sign-in screen
The old way138 lines
// Custom SignInView.swift — excerpt struct SignInView: View { @State private var email = "" @State private var password = "" @State private var emailError: String? @State private var passwordError: String? @FocusState private var focused: Field? var body: some View { ScrollView { VStack(spacing: 24) { Text("Sign in") .font(.largeTitle.bold()) // email field + border + error label VStack(alignment: .leading) { TextField("Email", text: $email) .textContentType(.emailAddress) .padding() .background(Color(.secondarySystemFill)) .clipShape(RoundedRectangle(cornerRadius: 10)) if let emailError { Text(emailError).foregroundStyle(.red) } } // secure field + reveal toggle + errors // primary button style, disabled state Button("Forgot password?") { } HStack { Divider(); Text("or"); Divider() } // Apple + Google custom buttons HStack { Text("Don't have an account?") Button("Sign up") { } } }.padding() } .onChange(of: email) { validateEmail() } } func validateEmail() { /* … */ } // + dark mode colors, macOS spacing, a11y labels… }
The Foundation way13 lines
DFSignInBlock( configuration: .init( socialProviders: [ .apple { await auth.signInWithApple() }, .google { await auth.signInWithGoogle() } ], onSubmit: { email, password in await auth.signIn(email: email, password: password) }, onForgotPassword: { path.append(.reset) }, onSignUp: { path.append(.signUp) } ) ) // Validation, density, theme, macOS cursor — included.