- Add email/username login support - Android: Update LoginScreen with email keyboard type - iOS: Update LoginView with email keyboard support - Refactor iOS password reset screens to use native SwiftUI components - Convert ForgotPasswordView to use Form with Sections - Convert VerifyResetCodeView to use Form with Sections - Convert ResetPasswordView to use Form with Sections - Use Label components for error/success messages - Add navigation titles and improve iOS-native appearance 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
171 lines
6.3 KiB
Swift
171 lines
6.3 KiB
Swift
import SwiftUI
|
|
|
|
struct VerifyResetCodeView: View {
|
|
@ObservedObject var viewModel: PasswordResetViewModel
|
|
@FocusState private var isCodeFocused: Bool
|
|
@Environment(\.dismiss) var dismiss
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
Form {
|
|
// Header Section
|
|
Section {
|
|
VStack(spacing: 12) {
|
|
Image(systemName: "envelope.badge.fill")
|
|
.font(.system(size: 60))
|
|
.foregroundStyle(.blue.gradient)
|
|
.padding(.vertical)
|
|
|
|
Text("Check Your Email")
|
|
.font(.title2)
|
|
.fontWeight(.bold)
|
|
|
|
Text("We sent a 6-digit code to")
|
|
.font(.subheadline)
|
|
.foregroundColor(.secondary)
|
|
|
|
Text(viewModel.email)
|
|
.font(.subheadline)
|
|
.fontWeight(.semibold)
|
|
.foregroundColor(.primary)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.vertical)
|
|
}
|
|
.listRowBackground(Color.clear)
|
|
|
|
// Info Section
|
|
Section {
|
|
Label {
|
|
Text("Code expires in 15 minutes")
|
|
.fontWeight(.semibold)
|
|
} icon: {
|
|
Image(systemName: "clock.fill")
|
|
.foregroundColor(.orange)
|
|
}
|
|
}
|
|
|
|
// Code Input Section
|
|
Section {
|
|
TextField("000000", text: $viewModel.code)
|
|
.font(.system(size: 32, weight: .semibold, design: .rounded))
|
|
.multilineTextAlignment(.center)
|
|
.keyboardType(.numberPad)
|
|
.focused($isCodeFocused)
|
|
.onChange(of: viewModel.code) { _, newValue in
|
|
// Limit to 6 digits
|
|
if newValue.count > 6 {
|
|
viewModel.code = String(newValue.prefix(6))
|
|
}
|
|
// Only allow numbers
|
|
viewModel.code = newValue.filter { $0.isNumber }
|
|
viewModel.clearError()
|
|
}
|
|
} header: {
|
|
Text("Verification Code")
|
|
} footer: {
|
|
Text("Enter the 6-digit code from your email")
|
|
}
|
|
|
|
// Error/Success Messages
|
|
if let errorMessage = viewModel.errorMessage {
|
|
Section {
|
|
Label {
|
|
Text(errorMessage)
|
|
.foregroundColor(.red)
|
|
} icon: {
|
|
Image(systemName: "exclamationmark.triangle.fill")
|
|
.foregroundColor(.red)
|
|
}
|
|
}
|
|
}
|
|
|
|
if let successMessage = viewModel.successMessage {
|
|
Section {
|
|
Label {
|
|
Text(successMessage)
|
|
.foregroundColor(.green)
|
|
} icon: {
|
|
Image(systemName: "checkmark.circle.fill")
|
|
.foregroundColor(.green)
|
|
}
|
|
}
|
|
}
|
|
|
|
// Verify Button
|
|
Section {
|
|
Button(action: {
|
|
viewModel.verifyResetCode()
|
|
}) {
|
|
HStack {
|
|
Spacer()
|
|
if viewModel.isLoading {
|
|
ProgressView()
|
|
} else {
|
|
Label("Verify Code", systemImage: "checkmark.shield.fill")
|
|
.fontWeight(.semibold)
|
|
}
|
|
Spacer()
|
|
}
|
|
}
|
|
.disabled(viewModel.code.count != 6 || viewModel.isLoading)
|
|
}
|
|
|
|
// Help Section
|
|
Section {
|
|
VStack(spacing: 12) {
|
|
Text("Didn't receive the code?")
|
|
.font(.subheadline)
|
|
.foregroundColor(.secondary)
|
|
|
|
Button(action: {
|
|
// Clear code and go back to request new one
|
|
viewModel.code = ""
|
|
viewModel.clearError()
|
|
viewModel.currentStep = .requestCode
|
|
}) {
|
|
Text("Send New Code")
|
|
.font(.subheadline)
|
|
.fontWeight(.semibold)
|
|
}
|
|
|
|
Text("Check your spam folder if you don't see it")
|
|
.font(.caption)
|
|
.foregroundColor(.secondary)
|
|
.multilineTextAlignment(.center)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
}
|
|
.listRowBackground(Color.clear)
|
|
}
|
|
.navigationTitle("Verify Code")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.navigationBarBackButtonHidden(true)
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarLeading) {
|
|
Button(action: {
|
|
viewModel.moveToPreviousStep()
|
|
}) {
|
|
HStack(spacing: 4) {
|
|
Image(systemName: "chevron.left")
|
|
.font(.system(size: 16))
|
|
Text("Back")
|
|
.font(.subheadline)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
isCodeFocused = true
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
let vm = PasswordResetViewModel()
|
|
vm.email = "test@example.com"
|
|
vm.currentStep = .verifyCode
|
|
return VerifyResetCodeView(viewModel: vm)
|
|
}
|