From dfa2fa334356f3f655e9fb41e7ddb4e81dc9bd70 Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Wed, 8 Jan 2020 11:03:44 -0500 Subject: [PATCH] Ensure that isEnabled only triggers when false. Preventing isEnabled from changing isON. --- MVMCoreUI/Atoms/Views/Toggle.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MVMCoreUI/Atoms/Views/Toggle.swift b/MVMCoreUI/Atoms/Views/Toggle.swift index 1a2341c2..22956a98 100644 --- a/MVMCoreUI/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atoms/Views/Toggle.swift @@ -61,7 +61,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) open override var isEnabled: Bool { didSet { isUserInteractionEnabled = isEnabled - changeStateNoAnimation(isEnabled) + changeStateNoAnimation(isEnabled ? isOn : false) backgroundColor = isEnabled ? containerTintColor?.off : disabledTintColor?.container knobView.backgroundColor = isEnabled ? knobTintColor?.off : disabledTintColor?.knob } @@ -398,6 +398,10 @@ extension Toggle { if let isAnimated = dictionary["isAnimated"] as? Bool { self.isAnimated = isAnimated } + + if let isEnabled = dictionary["isEnabled"] as? Bool{//}, !isEnabled { + self.isEnabled = isEnabled + } } public class func estimatedHeight(forRow json: [AnyHashable: Any]?, delegateObject: MVMCoreUIDelegateObject?) -> CGFloat {