Skip to content

Commit

Permalink
FIX: Disabled auto corretion
Browse files Browse the repository at this point in the history
Signed-off-by: ParsaKargari <[email protected]>
  • Loading branch information
ParsaKargari committed Feb 7, 2024
1 parent cc0f06c commit 5c45ebf
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 45 deletions.
Binary file added .DS_Store
Binary file not shown.
Binary file modified Rethread/.DS_Store
Binary file not shown.
18 changes: 9 additions & 9 deletions Rethread/Rethread.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,20 @@
path = Models;
sourceTree = "<group>";
};
7C9AA2D12B0EC3BC00EF6F36 /* Extensions */ = {
7C9AA2D42B0ECADF00EF6F36 /* Styles */ = {
isa = PBXGroup;
children = (
9868A7DD2B1FAE780063D9BA /* ButtonStyles.swift */,
98A1838B2B38D32A001E324A /* ColorPalette.swift */,
);
path = Extensions;
path = Styles;
sourceTree = "<group>";
};
7C9AA2D42B0ECADF00EF6F36 /* Styles */ = {
980DACBB2B71E7110008B88A /* Extensions */ = {
isa = PBXGroup;
children = (
9868A7DD2B1FAE780063D9BA /* ButtonStyles.swift */,
98A1838B2B38D32A001E324A /* ColorPalette.swift */,
);
path = Styles;
path = Extensions;
sourceTree = "<group>";
};
983286A82B05698E00851B19 = {
Expand Down Expand Up @@ -186,8 +186,8 @@
isa = PBXGroup;
children = (
983D40FA2B68D13E00905D4E /* Info.plist */,
7C9AA2D12B0EC3BC00EF6F36 /* Extensions */,
7C9AA2D42B0ECADF00EF6F36 /* Styles */,
980DACBB2B71E7110008B88A /* Extensions */,
9897C7712B3E6BF600EDE9D9 /* Components */,
98F525CC2B46A8E900CCAD78 /* VideoPlayer */,
7C9AA2CC2B0EC02600EF6F36 /* Models */,
Expand Down Expand Up @@ -639,7 +639,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = techstart.Rethread;
PRODUCT_BUNDLE_IDENTIFIER = techstart.Rethread2;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
Expand Down Expand Up @@ -673,7 +673,7 @@
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = techstart.Rethread;
PRODUCT_BUNDLE_IDENTIFIER = techstart.Rethread2;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
Expand Down
3 changes: 3 additions & 0 deletions Rethread/Rethread/Views/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ struct MainView: View {
struct CustomTextField: View {
var placeholder: String
@Binding var text: String
var disableAutocorrection: Bool = false

var body: some View {
TextField(placeholder, text: $text)
.disableAutocorrection(disableAutocorrection)
.autocapitalization(disableAutocorrection ? .none : .sentences)
.foregroundColor(Color.primaryTextColor)
.padding()
.overlay(RoundedRectangle(cornerRadius: 8).stroke(Color.gray, lineWidth: 1))
Expand Down
10 changes: 5 additions & 5 deletions Rethread/Rethread/Views/SignUpView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct SignUpView: View {
.padding(.leading, 25)
.padding(.top, 20)

CustomTextField(placeholder: "First Name", text: $formData.firstName)
CustomTextField(placeholder: "First Name", text: $formData.firstName, disableAutocorrection: true)
.padding(.leading, 25)
.padding(.top, 9)
}
Expand All @@ -96,7 +96,7 @@ struct SignUpView: View {
.padding(.trailing, 25)
.padding(.top, 20)

CustomTextField(placeholder: "Last Name", text: $formData.lastName)
CustomTextField(placeholder: "Last Name", text: $formData.lastName, disableAutocorrection: true)
.padding(.trailing, 25)
.padding(.top, 9)
}
Expand All @@ -107,7 +107,7 @@ struct SignUpView: View {
.padding(.horizontal, 25)
.padding(.top, 20)

CustomTextField(placeholder: "Email", text: $formData.email)
CustomTextField(placeholder: "Email", text: $formData.email, disableAutocorrection: true)
.padding(.horizontal, 25)
.padding(.top, 9)
HStack {
Expand Down Expand Up @@ -162,7 +162,7 @@ struct SignUpView: View {
.padding(.horizontal, 25)
.padding(.top, 20)

CustomTextField(placeholder: "Phone Number", text: $formData.phoneNumber)
CustomTextField(placeholder: "Phone Number", text: $formData.phoneNumber, disableAutocorrection: true)
.padding(.horizontal, 25)
.padding(.top, 9)

Expand Down Expand Up @@ -197,7 +197,7 @@ struct SignUpView: View {
.padding(.horizontal, 25)
.padding(.top, 20)

CustomTextField(placeholder: "Postal Code", text: $formData.postalCode)
CustomTextField(placeholder: "Postal Code", text: $formData.postalCode, disableAutocorrection: true)
.padding(.horizontal, 25)
.padding(.top, 9)

Expand Down
64 changes: 33 additions & 31 deletions Rethread/Rethread/Views/VerificationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ struct VerificationView: View {
var formData: SignUpFormData?
@Environment(\.dismiss) private var dismiss
@EnvironmentObject var viewModel: AuthViewModel
@State private var isLoading = false

// OTP Info
@State var otpFields: [String] = Array(repeating: "", count: 6)
Expand Down Expand Up @@ -53,42 +54,43 @@ struct VerificationView: View {

// Bottom content, including the sign-in button
VStack (spacing: 16) {
Button("Verify") {
// Handle sign in
if isSignIn {
// Sign in
print("Sign in")
} else {
// Confirm OTP. If successful, create user.
let otpCode = otpFields.joined()
print("Confirm OTP: \(otpCode)")
Task {
do {
// MARK: Log USER IN
// Create user
try await viewModel.createUser(formData: formData!)
dismiss()
} catch {
print("DEBUG: Error verifying user: \(error.localizedDescription)")
if isLoading {
ProgressView()
} else {
Button("Verify") {
// Handle sign in
isLoading = true
if isSignIn {
// MARK: SIGN IN OTP
} else {
// MARK: SIGN UP OTP
let otpCode = otpFields.joined()
Task {
do {
try await viewModel.createUser(formData: formData!)
dismiss()
} catch {
print("DEBUG: Error verifying user: \(error.localizedDescription)")
}
}
}
}
}
.buttonStyle(PrimaryButtonStyle(width: 300, isDisabled: checkStates()))
.disabled(checkStates())
Button(action: {
if let phoneNumber = formData?.phoneNumber {
Task {

.buttonStyle(PrimaryButtonStyle(width: 300, isDisabled: checkStates() || isLoading))
.disabled(checkStates() || isLoading)

Button(action: {
if let phoneNumber = formData?.phoneNumber {
Task {
// MARK: REQUEST NEW CODE
}
}
}) {
Text("Request new code")
.foregroundColor(Color.primaryColor)
.fontWeight(.semibold)
.underline() // Underlined text
}
}) {
Text("Request new code")
.foregroundColor(Color.primaryColor)
.fontWeight(.semibold)
.underline() // Underlined text
}
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom) // Aligns buttons to the bottom
Expand Down

0 comments on commit 5c45ebf

Please sign in to comment.