Closed kosakoytim closed 4 years ago
There is a way in which you can do this, although it's a little ugly.
The didChangeCallback gives you the pin that has been entered so far, this can be stored on the presenting layer (ViewController). You can then set the error styling, call clearPin() and follow it up by pasting the partial (or complete) pin using the pastePin method.
The pasting will have to be delayed by a small offset in order for the view to have time to render itself before the pin is copied (hence ugly 😅).
pinView.didChangeCallback = { pin in
self.tempPinStore = pin
print("The entered pin is \(pin)")
}
// toggle error state
pinView.textColor = .red
pinView.activeBorderLineColor = .red
pinView.borderLineColor = .red
pinView.becomeFirstResponderAtIndex = tempPinStore.count
clearPin()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.pinView.pastePin(pin: self.tempPinStore)
}
Thanks for sharing your use-case, will try and improve on the way this is handled. Do let me know if this resolves your problem.
I actually tried a similar method earlier, but got an error because i didn't add a delay for the rendering. This will solve for now, thanks!
@kosakoytim I have added a completionHandler for the clearPin method in the latest release.
I have a case where i need to change my PIN style text color, underline color when the PIN input is invalid. I can't seem to do this without calling
pin.clearPin()
which will reload the view and clear all the input. Is there another way to do this? Thanks