OTPFieldView icon indicating copy to clipboard operation
OTPFieldView copied to clipboard

SwiftUI Implementation

Open elai950 opened this issue 3 years ago • 1 comments

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
        }
    }
}

elai950 avatar Dec 27 '20 19:12 elai950

Same happen with me . When i click on OTP field no keyboard open. Looks like not consider as textField.

ParagDevac avatar Jan 31 '22 14:01 ParagDevac