DigitEntryField was not showing errors
This commit is contained in:
parent
c27ffb8056
commit
9a62ae6987
@ -38,29 +38,6 @@ import UIKit
|
|||||||
// Default dimensions of the DigitBox
|
// Default dimensions of the DigitBox
|
||||||
static let size: CGSize = CGSize(width: 39, height: 44)
|
static let size: CGSize = CGSize(width: 39, height: 44)
|
||||||
|
|
||||||
//--------------------------------------------------
|
|
||||||
// MARK: - Computed Properties
|
|
||||||
//--------------------------------------------------
|
|
||||||
|
|
||||||
public override var showError: Bool {
|
|
||||||
get { super.showError }
|
|
||||||
set (error) {
|
|
||||||
DispatchQueue.main.async { [weak self] in
|
|
||||||
guard let self = self else { return }
|
|
||||||
|
|
||||||
self.borderStrokeColor = error ? .mvmOrange : .mvmCoolGray3
|
|
||||||
|
|
||||||
let barHeight: CGFloat = self.showError ? 4 : 1
|
|
||||||
self.bottomBar?.frame = CGRect(x: 0, y: self.bounds.height - barHeight, width: self.bounds.width, height: barHeight)
|
|
||||||
self.bottomBar?.backgroundColor = self.showError ? UIColor.mvmOrange.cgColor : UIColor.mvmBlack.cgColor
|
|
||||||
|
|
||||||
self.setNeedsDisplay()
|
|
||||||
self.layoutIfNeeded()
|
|
||||||
}
|
|
||||||
super.showError = error
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Delegate
|
// MARK: - Delegate
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -105,7 +105,7 @@ import UIKit
|
|||||||
super.isLocked = locked
|
super.isLocked = locked
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override var placeholder: String? {
|
public override var placeholder: String? {
|
||||||
get {
|
get {
|
||||||
var string = ""
|
var string = ""
|
||||||
@ -311,7 +311,6 @@ import UIKit
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|
||||||
@objc override func startEditing() {
|
@objc override func startEditing() {
|
||||||
|
|
||||||
selectedDigitBox?.isSelected = true
|
selectedDigitBox?.isSelected = true
|
||||||
selectedDigitBox?.digitField.becomeFirstResponder()
|
selectedDigitBox?.digitField.becomeFirstResponder()
|
||||||
}
|
}
|
||||||
@ -328,7 +327,6 @@ import UIKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc public override func dismissFieldInput(_ sender: Any?) {
|
@objc public override func dismissFieldInput(_ sender: Any?) {
|
||||||
|
|
||||||
digitBoxes.forEach {
|
digitBoxes.forEach {
|
||||||
if $0.isSelected {
|
if $0.isSelected {
|
||||||
$0.digitField.resignFirstResponder()
|
$0.digitField.resignFirstResponder()
|
||||||
@ -398,7 +396,6 @@ extension DigitEntryField {
|
|||||||
digitEntryModel?.text = text
|
digitEntryModel?.text = text
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -411,9 +408,9 @@ extension DigitEntryField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc public func textFieldDidBeginEditing(_ textField: UITextField) {
|
@objc public func textFieldDidBeginEditing(_ textField: UITextField) {
|
||||||
|
|
||||||
digitBoxes.forEach {
|
digitBoxes.forEach {
|
||||||
if $0.digitField === textField {
|
if $0.digitField === textField {
|
||||||
|
startEditing()
|
||||||
selectedDigitBox = $0
|
selectedDigitBox = $0
|
||||||
$0.isSelected = true
|
$0.isSelected = true
|
||||||
return
|
return
|
||||||
@ -429,15 +426,15 @@ extension DigitEntryField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc public func textFieldDidEndEditing(_ textField: UITextField) {
|
@objc public func textFieldDidEndEditing(_ textField: UITextField) {
|
||||||
|
|
||||||
// There should only be one digitBox to deselect.
|
// There should only be one digitBox to deselect.
|
||||||
selectedDigitBox?.isSelected = false
|
selectedDigitBox?.isSelected = false
|
||||||
selectedDigitBox = nil
|
selectedDigitBox = nil
|
||||||
|
|
||||||
if !switchFieldsAutomatically && validateWhenDoneEditing {
|
if !switchFieldsAutomatically && validateWhenDoneEditing {
|
||||||
validateText()
|
validateText()
|
||||||
|
endInputing()
|
||||||
}
|
}
|
||||||
|
|
||||||
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
proprietorTextDelegate?.textFieldDidEndEditing?(textField)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user