[ad_1]
I’m creating an OTP Verification Web page which is having a OTPDigitField() inside one VSTack as a baby View.
THe OTP Verification web page (father or mother)has an API Name . Upon failure of which the digit fields ought to flip pink and the pink error textual content ought to show below otps.
My query is initally the showError is not going to be true and the error textual content will present up . How can I passs the values from apicall to little one view efficiently?
An instance might be :
MobileVerification.swift :
View {
VStack {
//Different View Components
OTPDigitField { code, standing in
if SubmitClicked && apiCallStstatus() {
errorStatus(true)
} else {
errorStatus(false)
}
}
}
}
OTPDigitField.swift
var handler: (String(Bool) -> Void) -> Void
@State non-public var showError: Bool = false // Right here initally its false inflicting error to look in inital loading itself
View {
//code for digits subject
//code for error
.hidden(showError)
func validate() {
handler(digits) { success in
if success && !code.isEmpty {
showError = true
}
}
}
}
[ad_2]
