Created
November 17, 2022 09:02
-
-
Save wizard1066/b526f7e40e711170d5b43837fd087f6c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct PassForm: View { | |
@ObservedObject var model: PassModel | |
@State private var buttonIsDisabled = true | |
var body: some View { | |
VStack { | |
Text("Password Form") | |
.font(.headline) | |
Form { | |
TextField("field I ", text: $model.firstEntry) | |
.textFieldStyle(RoundedBorderTextFieldStyle()) | |
.lineLimit(1) | |
.multilineTextAlignment(.center) | |
.padding() | |
TextField("field II ", text: $model.secondEntry) | |
.textFieldStyle(RoundedBorderTextFieldStyle()) | |
.multilineTextAlignment(.center) | |
.padding() | |
VStack { | |
ForEach(model.validationMessages, id: \.self) { msg in | |
HStack { | |
Spacer() | |
Text(msg) | |
.foregroundColor(.red) | |
Spacer() | |
} | |
} | |
} | |
} | |
Button(action: {}) { | |
Text("Submit") | |
}.disabled(buttonIsDisabled) | |
.onReceive(model.submitAllowed) { submitAllowed in | |
self.buttonIsDisabled = !submitAllowed | |
} | |
.padding() | |
.background(RoundedRectangle(cornerRadius: 10) | |
.stroke(Color.blue, lineWidth: 1) | |
) | |
Spacer() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment