OTPFieldView
OTPFieldView copied to clipboard
SwiftUI Implementation
I'm trying to implement OTPFieldView Delegation with SwiftUI but no luck. Is there anyone who successfully implemented this repo?
My test:
import SwiftUI
import OTPFieldView
struct OTP: UIViewRepresentable{
func makeUIView(context: Context) -> OTPFieldView{
let otp = OTPFieldView()
otp.fieldsCount = 6
otp.displayType = .underlinedBottom
otp.separatorSpace = 8
otp.initializeUI()
return otp
}
func updateUIView(_ uiView: OTPFieldView, context: Context){
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
internal class Coordinator: OTPFieldViewDelegate{
func shouldBecomeFirstResponderForOTP(otpTextFieldIndex index: Int) -> Bool {
return true
}
func enteredOTP(otp: String) {
print(otp)
}
func hasEnteredAllOTP(hasEnteredAll: Bool) -> Bool {
return false
}
var parent: OTP
init(_ parent: OTP){
self.parent = parent
}
}
}
Same happen with me . When i click on OTP field no keyboard open. Looks like not consider as textField.