-
Notifications
You must be signed in to change notification settings - Fork 25
Sign up view #69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Sign up view #69
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. File not needed on PR |
||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>SwiftUIBasics.xcscheme_^#shared#^_</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ import SwiftUI | |
struct SwiftUIBasicsApp: App { | ||
var body: some Scene { | ||
WindowGroup { | ||
ContentView() | ||
SignUpView() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not required for testing view |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// | ||
// CatsView.swift | ||
// SwiftUIBasics | ||
// | ||
// Created by Gustavo Ali Gómez Trejo on 15/12/23. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct CatsView: View { | ||
var body: some View { | ||
List { | ||
ForEach((1..<20)){ _ in | ||
|
||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview { | ||
CatsView() | ||
} | ||
Comment on lines
+10
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file should be skiped on PR |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// | ||
// CatsView.swift | ||
// SwiftUIBasics | ||
// | ||
// Created by Gustavo Ali Gómez Trejo on 15/12/23. | ||
// | ||
|
||
import Foundation | ||
Comment on lines
+1
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ?? |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -10,26 +10,36 @@ import Combine | |||||
|
||||||
class SignUpViewModel: ObservableObject { | ||||||
// inputs | ||||||
@Published var username: String = "" | ||||||
@Published var email: String = "" | ||||||
@Published var password: String = "" | ||||||
@Published var passwordConfirm: String = "" | ||||||
|
||||||
// outputs | ||||||
@Published var isValidUsernameLength: Bool = false | ||||||
@Published var isValidEmailLength: Bool = false | ||||||
@Published var isValidPasswordLength: Bool = false | ||||||
@Published var isValidPasswordUpperCase: Bool = false | ||||||
@Published var isValidPasswordLowerCase: Bool = false | ||||||
@Published var isValidPasswordSymbol: Bool = false | ||||||
@Published var isValidPasswordNumber: Bool = false | ||||||
@Published var isValidPasswordMatch: Bool = false | ||||||
@Published var isValid: Bool = false | ||||||
@Published var isValidPre: Bool = false | ||||||
|
||||||
|
||||||
private var cancelableSet: Set<AnyCancellable> = [] | ||||||
|
||||||
init() { | ||||||
$username | ||||||
.receive(on: RunLoop.main) | ||||||
.map { username in | ||||||
return username.count >= 4 | ||||||
.map { email in | ||||||
let pattern = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}" | ||||||
if let _ = email.range(of: pattern, options: .regularExpression) { | ||||||
return true | ||||||
} else { | ||||||
return false | ||||||
} | ||||||
} | ||||||
.assign(to: \.isValidUsernameLength, on: self) | ||||||
.assign(to: \.isValidEmailLength, on: self) | ||||||
.store(in: &cancelableSet) | ||||||
|
||||||
$password | ||||||
|
@@ -52,16 +62,59 @@ class SignUpViewModel: ObservableObject { | |||||
} | ||||||
.assign(to: \.isValidPasswordUpperCase, on: self) | ||||||
.store(in: &cancelableSet) | ||||||
|
||||||
$password | ||||||
.receive(on: RunLoop.main) | ||||||
.map { password in | ||||||
let pattern = "[a-z]" | ||||||
if let _ = password.range(of: pattern, options: .regularExpression) { | ||||||
return true | ||||||
} else { | ||||||
return false | ||||||
} | ||||||
} | ||||||
.assign(to: \.isValidPasswordLowerCase, on: self) | ||||||
.store(in: &cancelableSet) | ||||||
$password | ||||||
.receive(on: RunLoop.main) | ||||||
.map { password in | ||||||
let pattern = "[0-9]" | ||||||
if let _ = password.range(of: pattern, options: .regularExpression) { | ||||||
return true | ||||||
} else { | ||||||
return false | ||||||
} | ||||||
} | ||||||
.assign(to: \.isValidPasswordNumber, on: self) | ||||||
.store(in: &cancelableSet) | ||||||
$password | ||||||
.receive(on: RunLoop.main) | ||||||
.map { password in | ||||||
let pattern = "[!\"#$%&'()*+,-./:;<=>?@\\[\\\\\\]^_`{|}~]+" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if let _ = password.range(of: pattern, options: .regularExpression) { | ||||||
return true | ||||||
} else { | ||||||
return false | ||||||
} | ||||||
} | ||||||
.assign(to: \.isValidPasswordSymbol, on: self) | ||||||
.store(in: &cancelableSet) | ||||||
|
||||||
Publishers.CombineLatest($password, $passwordConfirm) | ||||||
.receive(on: RunLoop.main) | ||||||
.map { (password, passwordConfirm) in | ||||||
return !password.isEmpty && !passwordConfirm.isEmpty && password == passwordConfirm | ||||||
} | ||||||
.assign(to: \.isValidPasswordMatch, on: self) | ||||||
.store(in: &cancelableSet) | ||||||
|
||||||
Publishers.CombineLatest4($isValidPasswordNumber, $isValidPasswordSymbol, $isValidPasswordLowerCase, $isValidPasswordUpperCase) | ||||||
.map { (a, b, c, d) in | ||||||
return a && b && c && d | ||||||
} | ||||||
.assign(to: \.isValidPre, on: self) | ||||||
.store(in: &cancelableSet) | ||||||
|
||||||
Publishers.CombineLatest4($isValidUsernameLength, $isValidPasswordLength, $isValidPasswordUpperCase, $isValidPasswordMatch) | ||||||
Publishers.CombineLatest4($isValidEmailLength, $isValidPasswordLength, $isValidPre, $isValidPasswordMatch) | ||||||
.map { (a, b, c, d) in | ||||||
return a && b && c && d | ||||||
} | ||||||
|
@@ -80,13 +133,18 @@ struct SignUpView: View { | |||||
.bold() | ||||||
.foregroundStyle(.maryBlue) | ||||||
.padding(.bottom, 30) | ||||||
FormTextField(name: "Username", value: $vm.username) | ||||||
RequirementText(text: "A minimum of 4 characters", isValid: vm.isValidUsernameLength) | ||||||
FormTextField(name: "Email", value: $vm.email) | ||||||
.keyboardType(.emailAddress) | ||||||
.autocapitalization(.none) | ||||||
RequirementText(text: "Enter a valid Email.", isValid: vm.isValidEmailLength) | ||||||
.padding() | ||||||
FormTextField(name: "Password", value: $vm.password, isSecure: true) | ||||||
VStack { | ||||||
RequirementText(text: "A minimum of 8 characters", isValid: vm.isValidPasswordLength) | ||||||
RequirementText(text: "One uppercase letter", isValid: vm.isValidPasswordUpperCase) | ||||||
RequirementText(text: "One lowercase letter", isValid: vm.isValidPasswordLowerCase) | ||||||
RequirementText(text: "One symbol", isValid: vm.isValidPasswordSymbol) | ||||||
RequirementText(text: "One number", isValid: vm.isValidPasswordNumber) | ||||||
} | ||||||
.padding() | ||||||
FormTextField(name: "Confirm Password", value: $vm.passwordConfirm, isSecure: true) | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file not needed on PR