Skip to content

Instantly share code, notes, and snippets.

@azamsharp
Created March 4, 2020 14:33
Show Gist options
  • Save azamsharp/092e3f89b42aeda92d6a9f671e90da0a to your computer and use it in GitHub Desktop.
Save azamsharp/092e3f89b42aeda92d6a9f671e90da0a to your computer and use it in GitHub Desktop.
struct ContentView: View {
@ObservedObject private var registrationVM = RegistrationViewModel()
var body: some View {
NavigationView {
Form {
VStack(spacing: 10) {
TextField("First name", text: $registrationVM.firstname.bound)
.textFieldStyle(RoundedBorderTextFieldStyle())
TextField("Last name", text: $registrationVM.lastname.bound)
.textFieldStyle(RoundedBorderTextFieldStyle())
TextField("Username", text: $registrationVM.username.bound)
.textFieldStyle(RoundedBorderTextFieldStyle())
SecureField("Password", text: $registrationVM.password.bound)
.textFieldStyle(RoundedBorderTextFieldStyle())
Button("Register") {
self.registrationVM.validate()
}.padding(10)
.background(Color.blue)
.cornerRadius(6)
.foregroundColor(Color.white)
BrokenRulesView(brokenRules: registrationVM.brokenRules)
}
}
.navigationBarTitle("Registration")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment