Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import StripePaymentSheet
struct KYCInfoView: View {

/// Controls which KYC information set this form collects.
enum CollectionMode {
enum CollectionMode: Equatable {

/// Original behavior where all fields are shown and date of birth + id number are required.
case original
Expand Down Expand Up @@ -116,21 +116,12 @@ struct KYCInfoView: View {
)
}

private var isDateOfBirthIncluded: Binding<Bool> {
Binding(
get: { dateOfBirth != nil },
set: { shouldIncludeDateOfBirth in
dateOfBirth = shouldIncludeDateOfBirth ? (dateOfBirth ?? Self.today) : nil
}
)
}

private var collectedKYCLevel: KYCLevel {
switch collectionMode {
case .original, .kycLevel1StepUp:
return .level1
case .kycLevel0:
return (dateOfBirth != nil && !idNumber.isEmpty) ? .level1 : .level0
return .level0
}
}

Expand Down Expand Up @@ -183,32 +174,21 @@ struct KYCInfoView: View {
}
}

FormField(title("Social Security Number", required: collectionMode.requiresDateOfBirthAndIdNumber)) {
makeTextField(
"Enter your SSN",
text: $idNumber,
field: .idNumber,
keyboardType: .numberPad
)
}
if collectionMode != .kycLevel0 {
FormField(title("Social Security Number", required: collectionMode.requiresDateOfBirthAndIdNumber)) {
makeTextField(
"Enter your SSN",
text: $idNumber,
field: .idNumber,
keyboardType: .numberPad
)
}

FormField(title("Date of Birth", required: collectionMode.requiresDateOfBirthAndIdNumber)) {
VStack(alignment: .leading, spacing: 12) {
if collectionMode.requiresDateOfBirthAndIdNumber {
DatePicker("", selection: dateOfBirthBinding, in: ...Self.today, displayedComponents: .date)
.datePickerStyle(WheelDatePickerStyle())
.labelsHidden()
.frame(maxWidth: .infinity)
} else {
Toggle("Add date of birth now", isOn: isDateOfBirthIncluded)

if dateOfBirth != nil {
DatePicker("", selection: dateOfBirthBinding, in: ...Self.today, displayedComponents: .date)
.datePickerStyle(WheelDatePickerStyle())
.labelsHidden()
.frame(maxWidth: .infinity)
}
}
FormField(title("Date of Birth", required: collectionMode.requiresDateOfBirthAndIdNumber)) {
DatePicker("", selection: dateOfBirthBinding, in: ...Self.today, displayedComponents: .date)
.datePickerStyle(WheelDatePickerStyle())
.labelsHidden()
.frame(maxWidth: .infinity)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,13 @@ struct LogInSignUpView: View {
.safeAreaInset(edge: .bottom) {
VStack(spacing: 8) {
Button("Log In") {
isEmailFieldFocused = false
isPasswordFieldFocused = false
dismissKeyboard()
logIn()
}
.buttonStyle(PrimaryButtonStyle())

Button("Sign Up") {
isEmailFieldFocused = false
isPasswordFieldFocused = false
dismissKeyboard()
signUp()
}
.buttonStyle(PrimaryButtonStyle())
Expand All @@ -147,6 +145,11 @@ struct LogInSignUpView: View {

// MARK: - Actions

private func dismissKeyboard() {
isEmailFieldFocused = false
isPasswordFieldFocused = false
}

private func logIn() {
isLoading.wrappedValue = true
Task {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ struct RegistrationView: View {
/// Called when registration and authentication succeed.
let onCompleted: () -> Void

@State private var fullName: String = ""
@State private var phoneNumber: String = ""
@State private var country: String = "US"
@State private var errorMessage: String?
Expand All @@ -39,7 +38,6 @@ struct RegistrationView: View {

@Environment(\.isLoading) private var isLoading

@FocusState private var isFullNameFieldFocused: Bool
@FocusState private var isPhoneNumberFieldFocused: Bool
@FocusState private var isCountryFieldFocused: Bool

Expand Down Expand Up @@ -76,13 +74,6 @@ struct RegistrationView: View {
.foregroundColor(.secondary)
}

FormField("Full Name (optional)") {
TextField("Enter your full name", text: $fullName)
.textFieldStyle(RoundedBorderTextFieldStyle())
.autocapitalization(.words)
.focused($isFullNameFieldFocused)
}

FormField("Phone Number") {
TextField("Enter phone number (e.g., +12125551234)", text: $phoneNumber)
.textFieldStyle(RoundedBorderTextFieldStyle())
Expand Down Expand Up @@ -156,7 +147,7 @@ struct RegistrationView: View {
do {
try await coordinator.registerLinkUser(
email: email,
fullName: fullName.isEmpty ? nil : fullName,
fullName: nil,
phone: phoneNumber,
country: country
)
Expand Down Expand Up @@ -253,7 +244,6 @@ struct RegistrationView: View {
}

private func resetFocusState() {
isFullNameFieldFocused = false
isPhoneNumberFieldFocused = false
isCountryFieldFocused = false
}
Expand Down
Loading