fixed bug in toggle being out of sync with isSelected
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
edcaadf274
commit
bd96705b4e
@ -130,7 +130,15 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable {
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var isOn: Bool = false { didSet { didChange() }}
|
open var isOn: Bool {
|
||||||
|
get { isSelected }
|
||||||
|
set {
|
||||||
|
if isSelected != newValue {
|
||||||
|
isSelected = newValue
|
||||||
|
}
|
||||||
|
didChange()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
open var isAnimated: Bool = true { didSet { didChange() }}
|
open var isAnimated: Bool = true { didSet { didChange() }}
|
||||||
|
|
||||||
@ -292,7 +300,6 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable {
|
|||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
label.reset()
|
label.reset()
|
||||||
isSelected = false
|
|
||||||
isOn = false
|
isOn = false
|
||||||
|
|
||||||
isAnimated = true
|
isAnimated = true
|
||||||
@ -313,7 +320,6 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable {
|
|||||||
/// This will toggle the state of the Toggle and execute the actionBlock if provided.
|
/// This will toggle the state of the Toggle and execute the actionBlock if provided.
|
||||||
open func toggle() {
|
open func toggle() {
|
||||||
isOn.toggle()
|
isOn.toggle()
|
||||||
isSelected = isOn
|
|
||||||
sendActions(for: .valueChanged)
|
sendActions(for: .valueChanged)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user