fixed issues with disabled state overwriting layers.
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
d8595d2815
commit
9093131f1d
@ -43,7 +43,19 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab
|
||||
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Control is disabled or not
|
||||
open var disabled: Bool = false { didSet { isEnabled = !disabled } }
|
||||
open var disabled: Bool = false { didSet { setNeedsUpdate(); isUserInteractionEnabled = !disabled } }
|
||||
|
||||
open override var state: UIControl.State {
|
||||
get {
|
||||
var state = super.state
|
||||
if disabled {
|
||||
state.insert(.disabled)
|
||||
} else {
|
||||
state.remove(.disabled)
|
||||
}
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
/// Override for isSelected to handle setNeedsUpdate() on changes
|
||||
open override var isSelected: Bool { didSet { setNeedsUpdate() } }
|
||||
@ -71,18 +83,18 @@ open class Control: UIControl, Handlerable, ViewProtocol, Resettable, UserInfoab
|
||||
}
|
||||
}
|
||||
|
||||
/// Override to deal with setNeedsUpdate()
|
||||
open override var isEnabled: Bool {
|
||||
get { !disabled }
|
||||
set {
|
||||
if disabled != !newValue {
|
||||
disabled = !newValue
|
||||
}
|
||||
isUserInteractionEnabled = isEnabled
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
// /// Override to deal with setNeedsUpdate()
|
||||
// open override var isEnabled: Bool {
|
||||
// get { !disabled }
|
||||
// set {
|
||||
// if disabled != !newValue {
|
||||
// disabled = !newValue
|
||||
// }
|
||||
// isUserInteractionEnabled = isEnabled
|
||||
// setNeedsUpdate()
|
||||
// }
|
||||
// }
|
||||
//
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -45,6 +45,8 @@ open class SelectorBase: Control, SelectorControlable {
|
||||
var state = super.state
|
||||
if showError {
|
||||
state.insert(.error)
|
||||
} else {
|
||||
state.remove(.error)
|
||||
}
|
||||
return state
|
||||
}
|
||||
|
||||
@ -33,19 +33,7 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
||||
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
|
||||
|
||||
/// Control is disabled or not
|
||||
open var disabled: Bool = false { didSet { isEnabled = !disabled } }
|
||||
|
||||
/// Override to deal with setNeedsUpdate()
|
||||
open var isEnabled: Bool {
|
||||
get { !disabled }
|
||||
set {
|
||||
if disabled != !newValue {
|
||||
disabled = !newValue
|
||||
}
|
||||
isUserInteractionEnabled = isEnabled
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
open var disabled: Bool = false { didSet { setNeedsUpdate(); isUserInteractionEnabled = !disabled } }
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
|
||||
@ -55,8 +55,8 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
||||
|
||||
open var surface: Surface = .light { didSet { setNeedsUpdate() }}
|
||||
|
||||
open var disabled: Bool = false { didSet { isEnabled = !disabled } }
|
||||
|
||||
open var disabled: Bool = false { didSet { setNeedsUpdate(); isUserInteractionEnabled = !disabled } }
|
||||
|
||||
open var userInfo = [String: Primitive]()
|
||||
|
||||
public var touchUpInsideCount: Int = 0
|
||||
@ -80,21 +80,22 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab
|
||||
}
|
||||
}
|
||||
|
||||
open override var state: UIControl.State {
|
||||
get {
|
||||
var state = super.state
|
||||
if disabled {
|
||||
state.insert(.disabled)
|
||||
} else {
|
||||
state.remove(.disabled)
|
||||
}
|
||||
return state
|
||||
}
|
||||
}
|
||||
|
||||
open var textStyle: TextStyle { .defaultStyle }
|
||||
|
||||
open var textColor: UIColor { .black }
|
||||
|
||||
open override var isEnabled: Bool {
|
||||
get { !disabled }
|
||||
set {
|
||||
if disabled != !newValue {
|
||||
disabled = !newValue
|
||||
}
|
||||
isUserInteractionEnabled = isEnabled
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
//--------------------------------------------------
|
||||
|
||||
@ -29,8 +29,8 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
||||
|
||||
open var surface: Surface = .light { didSet { setNeedsUpdate() }}
|
||||
|
||||
open var disabled: Bool = false { didSet { isEnabled = !disabled } }
|
||||
|
||||
open var disabled: Bool = false { didSet { setNeedsUpdate(); isUserInteractionEnabled = !disabled } }
|
||||
|
||||
open var attributes: [any LabelAttributeModel]? { didSet { setNeedsUpdate() }}
|
||||
|
||||
open var textStyle: TextStyle = .defaultStyle { didSet { setNeedsUpdate() }}
|
||||
@ -39,17 +39,6 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable {
|
||||
|
||||
open var userInfo = [String: Primitive]()
|
||||
|
||||
open override var isEnabled: Bool {
|
||||
get { !disabled }
|
||||
set {
|
||||
if disabled != !newValue {
|
||||
disabled = !newValue
|
||||
}
|
||||
isUserInteractionEnabled = isEnabled
|
||||
setNeedsUpdate()
|
||||
}
|
||||
}
|
||||
|
||||
override open var text: String? {
|
||||
didSet {
|
||||
attributes = nil
|
||||
|
||||
Loading…
Reference in New Issue
Block a user