Merge branch 'mbruce/bugfixes' into 'develop'
refactored var to track internal error See merge request BPHV_MIPS/vds_ios!166
This commit is contained in:
commit
8f320a9363
@ -154,13 +154,13 @@ open class EntryFieldBase: Control, Changeable, FormFieldable {
|
||||
open var showError: Bool = false { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Whether or not to show the internal error
|
||||
internal var showInternalError: Bool = false { didSet { setNeedsUpdate() } }
|
||||
open internal(set) var hasInternalError: Bool = false { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Override UIControl state to add the .error state if showError is true.
|
||||
open override var state: UIControl.State {
|
||||
get {
|
||||
var state = super.state
|
||||
if showError || showInternalError {
|
||||
if showError || hasInternalError {
|
||||
state.insert(.error)
|
||||
}
|
||||
return state
|
||||
@ -380,7 +380,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldable {
|
||||
}
|
||||
|
||||
open func updateErrorLabel(){
|
||||
if showError, showInternalError, let errorText, let internalErrorText {
|
||||
if showError, hasInternalError, let errorText, let internalErrorText {
|
||||
errorLabel.text = [internalErrorText, errorText].joined(separator: "\n")
|
||||
errorLabel.surface = surface
|
||||
errorLabel.isEnabled = isEnabled
|
||||
@ -398,7 +398,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldable {
|
||||
icon.color = VDSColor.paletteBlack
|
||||
icon.surface = surface
|
||||
icon.isHidden = !isEnabled
|
||||
} else if showInternalError, let internalErrorText {
|
||||
} else if hasInternalError, let internalErrorText {
|
||||
errorLabel.text = internalErrorText
|
||||
errorLabel.surface = surface
|
||||
errorLabel.isEnabled = isEnabled
|
||||
|
||||
@ -247,16 +247,16 @@ open class TextArea: EntryFieldBase {
|
||||
let countStr = (count > maxLength ?? 0) ? ("-" + "\(count-(maxLength ?? 0))") : "\(count)"
|
||||
if let maxLength, maxLength > 0 {
|
||||
if count > maxLength {
|
||||
showInternalError = true
|
||||
hasInternalError = true
|
||||
internalErrorText = "You have exceeded the character limit."
|
||||
return countStr
|
||||
} else {
|
||||
showInternalError = false
|
||||
hasInternalError = false
|
||||
internalErrorText = nil
|
||||
return ("\(countStr)" + "/" + "\(maxLength)")
|
||||
}
|
||||
} else {
|
||||
showInternalError = false
|
||||
hasInternalError = false
|
||||
internalErrorText = nil
|
||||
return nil
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user