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() } }
|
open var showError: Bool = false { didSet { setNeedsUpdate() } }
|
||||||
|
|
||||||
/// Whether or not to show the internal error
|
/// 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.
|
/// Override UIControl state to add the .error state if showError is true.
|
||||||
open override var state: UIControl.State {
|
open override var state: UIControl.State {
|
||||||
get {
|
get {
|
||||||
var state = super.state
|
var state = super.state
|
||||||
if showError || showInternalError {
|
if showError || hasInternalError {
|
||||||
state.insert(.error)
|
state.insert(.error)
|
||||||
}
|
}
|
||||||
return state
|
return state
|
||||||
@ -380,7 +380,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
open func updateErrorLabel(){
|
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.text = [internalErrorText, errorText].joined(separator: "\n")
|
||||||
errorLabel.surface = surface
|
errorLabel.surface = surface
|
||||||
errorLabel.isEnabled = isEnabled
|
errorLabel.isEnabled = isEnabled
|
||||||
@ -398,7 +398,7 @@ open class EntryFieldBase: Control, Changeable, FormFieldable {
|
|||||||
icon.color = VDSColor.paletteBlack
|
icon.color = VDSColor.paletteBlack
|
||||||
icon.surface = surface
|
icon.surface = surface
|
||||||
icon.isHidden = !isEnabled
|
icon.isHidden = !isEnabled
|
||||||
} else if showInternalError, let internalErrorText {
|
} else if hasInternalError, let internalErrorText {
|
||||||
errorLabel.text = internalErrorText
|
errorLabel.text = internalErrorText
|
||||||
errorLabel.surface = surface
|
errorLabel.surface = surface
|
||||||
errorLabel.isEnabled = isEnabled
|
errorLabel.isEnabled = isEnabled
|
||||||
|
|||||||
@ -247,16 +247,16 @@ open class TextArea: EntryFieldBase {
|
|||||||
let countStr = (count > maxLength ?? 0) ? ("-" + "\(count-(maxLength ?? 0))") : "\(count)"
|
let countStr = (count > maxLength ?? 0) ? ("-" + "\(count-(maxLength ?? 0))") : "\(count)"
|
||||||
if let maxLength, maxLength > 0 {
|
if let maxLength, maxLength > 0 {
|
||||||
if count > maxLength {
|
if count > maxLength {
|
||||||
showInternalError = true
|
hasInternalError = true
|
||||||
internalErrorText = "You have exceeded the character limit."
|
internalErrorText = "You have exceeded the character limit."
|
||||||
return countStr
|
return countStr
|
||||||
} else {
|
} else {
|
||||||
showInternalError = false
|
hasInternalError = false
|
||||||
internalErrorText = nil
|
internalErrorText = nil
|
||||||
return ("\(countStr)" + "/" + "\(maxLength)")
|
return ("\(countStr)" + "/" + "\(maxLength)")
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
showInternalError = false
|
hasInternalError = false
|
||||||
internalErrorText = nil
|
internalErrorText = nil
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user