88
99import UIKit
1010
11- protocol DPOTPViewDelegate {
11+ public protocol DPOTPViewDelegate {
1212 func dpOTPViewAddText( _ text: String , at position: Int )
1313 func dpOTPViewRemoveText( _ text: String , at position: Int )
1414 func dpOTPViewChangePositionAt( _ position: Int )
1515 func dpOTPViewBecomeFirstResponder( )
1616 func dpOTPViewResignFirstResponder( )
1717}
1818
19- @IBDesignable class DPOTPView : UIView {
19+ @IBDesignable public final class DPOTPView : UIView {
2020
2121 /** The number of textField that will be put in the DPOTPView */
22- @IBInspectable var count : Int = 4
22+ @IBInspectable public var count : Int = 4
2323
2424 /** Spaceing between textField in the DPOTPView */
25- @IBInspectable var spacing : CGFloat = 8
25+ @IBInspectable public var spacing : CGFloat = 8
2626
2727 /** Text color for the textField */
28- @IBInspectable var textColorTextField : UIColor = UIColor . black
28+ @IBInspectable public var textColorTextField : UIColor = UIColor . black
2929
3030 /** Text font for the textField */
31- @IBInspectable var fontTextField : UIFont = UIFont . systemFont ( ofSize: 25 )
31+ @IBInspectable public var fontTextField : UIFont = UIFont . systemFont ( ofSize: 25 )
3232
3333 /** Placeholder */
34- @IBInspectable var placeholder : String = " "
34+ @IBInspectable public var placeholder : String = " "
3535
3636 /** Placeholder text color for the textField */
37- @IBInspectable var placeholderTextColor : UIColor = UIColor . gray
37+ @IBInspectable public var placeholderTextColor : UIColor = UIColor . gray
3838
3939 /** Circle textField */
40- @IBInspectable var isCircleTextField : Bool = false
40+ @IBInspectable public var isCircleTextField : Bool = false
4141
4242 /** Allow only Bottom Line for the TextField */
43- @IBInspectable var isBottomLineTextField : Bool = false
43+ @IBInspectable public var isBottomLineTextField : Bool = false
4444
4545 /** Background color for the textField */
46- @IBInspectable var backGroundColorTextField : UIColor = UIColor . clear
46+ @IBInspectable public var backGroundColorTextField : UIColor = UIColor . clear
4747
4848 /** Border color for the TextField */
49- @IBInspectable var borderColorTextField : UIColor ?
49+ @IBInspectable public var borderColorTextField : UIColor ?
5050
5151 /** Border color for the TextField */
52- @IBInspectable var selectedBorderColorTextField : UIColor ?
52+ @IBInspectable public var selectedBorderColorTextField : UIColor ?
5353
5454 /** Border width for the TextField */
55- @IBInspectable var borderWidthTextField : CGFloat = 0.0
55+ @IBInspectable public var borderWidthTextField : CGFloat = 0.0
5656
5757 /** Border width for the TextField */
58- @IBInspectable var selectedBorderWidthTextField : CGFloat = 0.0
58+ @IBInspectable public var selectedBorderWidthTextField : CGFloat = 0.0
5959
6060 /** Corner radius for the TextField */
61- @IBInspectable var cornerRadiusTextField : CGFloat = 0.0
61+ @IBInspectable public var cornerRadiusTextField : CGFloat = 0.0
6262
6363 /** Tint/cursor color for the TextField */
64- @IBInspectable var tintColorTextField : UIColor = UIColor . systemBlue
64+ @IBInspectable public var tintColorTextField : UIColor = UIColor . systemBlue
6565
6666 /** Shadow Radius for the TextField */
67- @IBInspectable var shadowRadiusTextField : CGFloat = 0.0
67+ @IBInspectable public var shadowRadiusTextField : CGFloat = 0.0
6868
6969 /** Shadow Opacity for the TextField */
70- @IBInspectable var shadowOpacityTextField : Float = 0.0
70+ @IBInspectable public var shadowOpacityTextField : Float = 0.0
7171
7272 /** Shadow Offset Size for the TextField */
73- @IBInspectable var shadowOffsetSizeTextField : CGSize = . zero
73+ @IBInspectable public var shadowOffsetSizeTextField : CGSize = . zero
7474
7575 /** Shadow color for the TextField */
76- @IBInspectable var shadowColorTextField : UIColor ?
76+ @IBInspectable public var shadowColorTextField : UIColor ?
7777
7878 /** Dismiss keyboard with enter last character*/
79- @IBInspectable var dismissOnLastEntry : Bool = false
79+ @IBInspectable public var dismissOnLastEntry : Bool = false
8080
8181 /** Secure Text Entry*/
82- @IBInspectable var isSecureTextEntry : Bool = false
82+ @IBInspectable public var isSecureTextEntry : Bool = false
8383
8484 /** Hide cursor*/
85- @IBInspectable var isCursorHidden : Bool = false
85+ @IBInspectable public var isCursorHidden : Bool = false
8686
8787 /** Dark keyboard*/
88- @IBInspectable var isDarkKeyboard : Bool = false
88+ @IBInspectable public var isDarkKeyboard : Bool = false
8989
90- var textEdgeInsets : UIEdgeInsets ?
91- var editingTextEdgeInsets : UIEdgeInsets ?
90+ public var textEdgeInsets : UIEdgeInsets ?
91+ public var editingTextEdgeInsets : UIEdgeInsets ?
9292
93- var dpOTPViewDelegate : DPOTPViewDelegate ?
94- var keyboardType : UIKeyboardType = UIKeyboardType . asciiCapableNumberPad
93+ public var dpOTPViewDelegate : DPOTPViewDelegate ?
94+ public var keyboardType : UIKeyboardType = UIKeyboardType . asciiCapableNumberPad
9595
96- var text : String ? {
96+ public var text : String ? {
9797 get {
9898 var str = " "
9999 arrTextFields. forEach { str. append ( $0. text ?? " " ) }
@@ -113,22 +113,22 @@ protocol DPOTPViewDelegate {
113113 fileprivate var arrTextFields : [ OTPBackTextField ] = [ ]
114114 /** Override coder init, for IB/XIB compatibility */
115115 #if !TARGET_INTERFACE_BUILDER
116- required init ? ( coder aDecoder: NSCoder ) {
116+ public required init ? ( coder aDecoder: NSCoder ) {
117117 super. init ( coder: aDecoder)
118118 }
119119
120120 /** Override common init, for manual allocation */
121- override init ( frame: CGRect ) {
121+ public override init ( frame: CGRect ) {
122122 super. init ( frame: frame)
123123 }
124124
125- override func layoutSubviews( ) {
125+ public override func layoutSubviews( ) {
126126 super. layoutSubviews ( )
127127 self . initialization ( )
128128 }
129129 #endif
130130
131- override func prepareForInterfaceBuilder( ) {
131+ public override func prepareForInterfaceBuilder( ) {
132132 super. prepareForInterfaceBuilder ( )
133133 initialization ( )
134134 }
@@ -208,7 +208,7 @@ protocol DPOTPViewDelegate {
208208// }
209209
210210
211- override func becomeFirstResponder( ) -> Bool {
211+ public override func becomeFirstResponder( ) -> Bool {
212212 if isCursorHidden {
213213 for i in 0 ..< arrTextFields. count {
214214 if arrTextFields [ i] . text? . count == 0 {
@@ -226,7 +226,7 @@ protocol DPOTPViewDelegate {
226226 return super. becomeFirstResponder ( )
227227 }
228228
229- override func resignFirstResponder( ) -> Bool {
229+ public override func resignFirstResponder( ) -> Bool {
230230 arrTextFields. forEach { ( textField) in
231231 _ = textField. resignFirstResponder ( )
232232 }
@@ -251,11 +251,11 @@ protocol DPOTPViewDelegate {
251251
252252extension DPOTPView : UITextFieldDelegate , OTPBackTextFieldDelegate {
253253
254- func textFieldDidBeginEditing( _ textField: UITextField ) {
254+ public func textFieldDidBeginEditing( _ textField: UITextField ) {
255255 dpOTPViewDelegate? . dpOTPViewChangePositionAt ( textField. tag/ 1000 - 1 )
256256 }
257257
258- func textField( _ textField: UITextField , shouldChangeCharactersIn range: NSRange , replacementString string: String ) -> Bool {
258+ public func textField( _ textField: UITextField , shouldChangeCharactersIn range: NSRange , replacementString string: String ) -> Bool {
259259 if string. trimmingCharacters ( in: CharacterSet . whitespaces) . count != 0 {
260260 textField. text = string
261261 if textField. tag < count*1000 {
0 commit comments