correction.
This commit is contained in:
parent
d2d4e3d42c
commit
494df94d3a
@ -155,28 +155,29 @@ import UIKit
|
||||
fatalError("DigitEntryField xib has not been implemented")
|
||||
}
|
||||
|
||||
public init(numberOfDigits: Int) {
|
||||
super.init(frame: .zero)
|
||||
|
||||
public override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
setup()
|
||||
}
|
||||
|
||||
public convenience init() {
|
||||
self.init(frame: .zero)
|
||||
}
|
||||
|
||||
public convenience init(numberOfDigits: Int) {
|
||||
self.init(frame: .zero)
|
||||
|
||||
|
||||
self.numberOfDigits = numberOfDigits
|
||||
buildTextFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
||||
}
|
||||
|
||||
public init(numberOfDigits: Int, bothDelegates delegates: (UITextFieldDelegate & MFTextFieldDelegate)?) {
|
||||
super.init(bothDelegates: delegates as? (TextFieldDelegate & UITextFieldDelegate))
|
||||
|
||||
setup()
|
||||
self.numberOfDigits = numberOfDigits
|
||||
buildTextFieldsView(size: MVMCoreUISplitViewController.getDetailViewWidth())
|
||||
}
|
||||
|
||||
public init(numberOfDigits: Int, bothDelegates delegate: (UITextFieldDelegate & MFTextFieldDelegate)?, size: CGFloat) {
|
||||
public init(numberOfDigits: Int, bothDelegates delegate: (UITextFieldDelegate & MFTextFieldDelegate)?, size: CGFloat? = nil) {
|
||||
super.init(bothDelegates: delegate as? (TextFieldDelegate & UITextFieldDelegate))
|
||||
|
||||
setup()
|
||||
self.numberOfDigits = numberOfDigits
|
||||
buildTextFieldsView(size: size)
|
||||
buildTextFieldsView(size: size ?? MVMCoreUISplitViewController.getDetailViewWidth())
|
||||
}
|
||||
|
||||
open override func setupFieldContainerContent(_ container: UIView) {
|
||||
|
||||
@ -181,7 +181,7 @@ import UIKit
|
||||
|
||||
addSubview(feedbackLabel)
|
||||
|
||||
feedbackLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 0).isActive = true
|
||||
feedbackLabel.heightAnchor.constraint(greaterThanOrEqualToConstant: 15).isActive = true
|
||||
feedbackLabel.topAnchor.constraint(equalTo: fieldContainer.bottomAnchor, constant: PaddingOne).isActive = true
|
||||
feedbackLabelLeading = feedbackLabel.leadingAnchor.constraint(equalTo: layoutMarginsGuide.leadingAnchor)
|
||||
feedbackLabelLeading?.isActive = true
|
||||
@ -220,7 +220,7 @@ import UIKit
|
||||
open override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
|
||||
resizeBottomBar(size: 1)
|
||||
refreshUI(bottomBarSize: 1)
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
@ -252,17 +252,6 @@ import UIKit
|
||||
|
||||
func resizeBottomBar(size: CGFloat) {
|
||||
|
||||
// if bottomBar.frame.height == 1 {
|
||||
//
|
||||
// }
|
||||
|
||||
// let bottomBarHeight = CABasicAnimation(keyPath: "bounds.size.height")
|
||||
// bottomBarHeight.fromValue = 1
|
||||
// bottomBarHeight.toValue = 4
|
||||
// bottomBarHeight.duration = 0.1
|
||||
// bottomBarHeight.isRemovedOnCompletion = false
|
||||
// bottomBar.add(bottomBarHeight, forKey: "bottomBarHeight")
|
||||
|
||||
if let fieldBounds = fieldContainer?.bounds {
|
||||
bottomBar.frame = CGRect(x: 0, y: fieldBounds.height - size, width: fieldBounds.width, height: size)
|
||||
}
|
||||
|
||||
@ -26,33 +26,6 @@ import UIKit
|
||||
|
||||
private(set) var textField: UITextField?
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Delegate Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
/// The delegate and block for validation. Validates if the text that the user has entered is valid or not. Checked after each change if there is a delegate.
|
||||
public weak var mfTextFieldDelegate: TextFieldDelegate? {
|
||||
didSet {
|
||||
if mfTextFieldDelegate != nil && !observingForChanges {
|
||||
observingForChanges = true
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(valueChanged), name: UITextField.textDidChangeNotification, object: textField)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(endInputing), name: UITextField.textDidEndEditingNotification, object: textField)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(startEditing), name: UITextField.textDidBeginEditingNotification, object: textField)
|
||||
} else if mfTextFieldDelegate == nil && observingForChanges {
|
||||
observingForChanges = false
|
||||
NotificationCenter.default.removeObserver(self, name: UITextField.textDidChangeNotification, object: textField)
|
||||
NotificationCenter.default.removeObserver(self, name: UITextField.textDidEndEditingNotification, object: textField)
|
||||
NotificationCenter.default.removeObserver(self, name: UITextField.textDidBeginEditingNotification, object: textField)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If you're using a MFViewController, you must set this to it
|
||||
public weak var uiTextFieldDelegate: UITextFieldDelegate? {
|
||||
get { return textField?.delegate }
|
||||
set { textField?.delegate = newValue }
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Properties
|
||||
//--------------------------------------------------
|
||||
@ -94,6 +67,33 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Delegate Properties
|
||||
//--------------------------------------------------
|
||||
|
||||
/// The delegate and block for validation. Validates if the text that the user has entered is valid or not. Checked after each change if there is a delegate.
|
||||
public weak var mfTextFieldDelegate: TextFieldDelegate? {
|
||||
didSet {
|
||||
if mfTextFieldDelegate != nil && !observingForChanges {
|
||||
observingForChanges = true
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(valueChanged), name: UITextField.textDidChangeNotification, object: textField)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(endInputing), name: UITextField.textDidEndEditingNotification, object: textField)
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(startEditing), name: UITextField.textDidBeginEditingNotification, object: textField)
|
||||
} else if mfTextFieldDelegate == nil && observingForChanges {
|
||||
observingForChanges = false
|
||||
NotificationCenter.default.removeObserver(self, name: UITextField.textDidChangeNotification, object: textField)
|
||||
NotificationCenter.default.removeObserver(self, name: UITextField.textDidEndEditingNotification, object: textField)
|
||||
NotificationCenter.default.removeObserver(self, name: UITextField.textDidBeginEditingNotification, object: textField)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// If you're using a MFViewController, you must set this to it
|
||||
public weak var uiTextFieldDelegate: UITextFieldDelegate? {
|
||||
get { return textField?.delegate }
|
||||
set { textField?.delegate = newValue }
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Constraints
|
||||
//--------------------------------------------------
|
||||
@ -109,7 +109,6 @@ import UIKit
|
||||
setupView()
|
||||
}
|
||||
|
||||
/// Basic initializer.
|
||||
public convenience init() {
|
||||
self.init(frame: .zero)
|
||||
}
|
||||
@ -120,9 +119,9 @@ import UIKit
|
||||
}
|
||||
|
||||
/// - parameter bothDelegates: Sets both MF/UI Text Field Delegates.
|
||||
public init(bothDelegates: (UITextFieldDelegate & TextFieldDelegate)?) {
|
||||
super.init(frame: .zero)
|
||||
setupView()
|
||||
public convenience init(bothDelegates: (UITextFieldDelegate & TextFieldDelegate)?) {
|
||||
self.init(frame: .zero)
|
||||
|
||||
setBothTextDelegates(bothDelegates)
|
||||
}
|
||||
|
||||
@ -174,7 +173,7 @@ import UIKit
|
||||
|
||||
open func clearError() {
|
||||
|
||||
// feedback = nil
|
||||
feedback = nil
|
||||
textField?.accessibilityValue = nil
|
||||
}
|
||||
|
||||
@ -192,7 +191,7 @@ import UIKit
|
||||
}
|
||||
|
||||
@objc func dismissTextFieldResponder(_ sender: Any?) {
|
||||
originalAppearance()
|
||||
|
||||
textField?.resignFirstResponder()
|
||||
}
|
||||
|
||||
@ -200,7 +199,7 @@ import UIKit
|
||||
// MARK: - Observing for change
|
||||
//--------------------------------------------------
|
||||
|
||||
func valueChanged() {
|
||||
@objc func valueChanged() {
|
||||
|
||||
if !showErrorMessage {
|
||||
feedback = ""
|
||||
@ -224,19 +223,19 @@ import UIKit
|
||||
}
|
||||
}
|
||||
|
||||
func endInputing() {
|
||||
@objc func endInputing() {
|
||||
|
||||
if isValid {
|
||||
clearError()
|
||||
bottomBar.backgroundColor = UIColor.black.cgColor
|
||||
|
||||
} else if let errMessage = errorMessage {
|
||||
feedback = errMessage
|
||||
}
|
||||
}
|
||||
|
||||
func startEditing() {
|
||||
@objc func startEditing() {
|
||||
|
||||
errorAppearance(showError: true)
|
||||
textField?.becomeFirstResponder()
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user