From be29a5dfbcd5ee5a740340c53149c37d7613b81b Mon Sep 17 00:00:00 2001 From: Kevin G Christiano Date: Mon, 20 Apr 2020 09:59:02 -0400 Subject: [PATCH] removed unneded optional wrapper --- MVMCoreUI/Atomic/Atoms/Views/Toggle.swift | 36 +++++++++++------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift index cf272129..75e9675a 100644 --- a/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift +++ b/MVMCoreUI/Atomic/Atoms/Views/Toggle.swift @@ -25,13 +25,13 @@ public typealias ActionBlockConfirmation = () -> (Bool) //-------------------------------------------------- /// Holds the on and off colors for the container. - public var containerTintColor: (on: UIColor, off: UIColor)? = (on: .mvmGreen, off: .mvmBlack) + public var containerTintColor: (on: UIColor, off: UIColor) = (on: .mvmGreen, off: .mvmBlack) /// Holds the on and off colors for the knob. - public var knobTintColor: (on: UIColor, off: UIColor)? = (on: .mvmWhite, off: .mvmWhite) + public var knobTintColor: (on: UIColor, off: UIColor) = (on: .mvmWhite, off: .mvmWhite) /// Holds the on and off colors for the disabled state.. - public var disabledTintColor: (container: UIColor, knob: UIColor)? = (container: .mvmCoolGray3, knob: .mvmWhite) + public var disabledTintColor: (container: UIColor, knob: UIColor) = (container: .mvmCoolGray3, knob: .mvmWhite) /// Set this flag to false if you do not want to animate state changes. public var isAnimated = true @@ -62,8 +62,8 @@ public typealias ActionBlockConfirmation = () -> (Bool) didSet { isUserInteractionEnabled = isEnabled changeStateNoAnimation(isEnabled ? isOn : false) - backgroundColor = isEnabled ? (isOn ? containerTintColor?.on : containerTintColor?.off) : disabledTintColor?.container - knobView.backgroundColor = isEnabled ? (isOn ? knobTintColor?.on : knobTintColor?.off) : disabledTintColor?.knob + backgroundColor = isEnabled ? (isOn ? containerTintColor.on : containerTintColor.off) : disabledTintColor.container + knobView.backgroundColor = isEnabled ? (isOn ? knobTintColor.on : knobTintColor.off) : disabledTintColor.knob } } @@ -80,12 +80,12 @@ public typealias ActionBlockConfirmation = () -> (Bool) if isAnimated { UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: { if self.isOn { - self.knobView.backgroundColor = self.knobTintColor?.on - self.backgroundColor = self.containerTintColor?.on + self.knobView.backgroundColor = self.knobTintColor.on + self.backgroundColor = self.containerTintColor.on } else { - self.knobView.backgroundColor = self.knobTintColor?.off - self.backgroundColor = self.containerTintColor?.off + self.knobView.backgroundColor = self.knobTintColor.off + self.backgroundColor = self.containerTintColor.off } }, completion: nil) @@ -96,8 +96,8 @@ public typealias ActionBlockConfirmation = () -> (Bool) }, completion: nil) } else { - backgroundColor = isOn ? containerTintColor?.on : containerTintColor?.off - knobView.backgroundColor = isOn ? knobTintColor?.on : knobTintColor?.off + backgroundColor = isOn ? containerTintColor.on : containerTintColor.off + knobView.backgroundColor = isOn ? knobTintColor.on : knobTintColor.off self.constrainKnob() } @@ -206,7 +206,7 @@ public typealias ActionBlockConfirmation = () -> (Bool) widthConstraint?.isActive = true layer.cornerRadius = Self.containerSize.height / 2.0 - backgroundColor = containerTintColor?.off + backgroundColor = containerTintColor.off addSubview(knobView) @@ -226,8 +226,8 @@ public typealias ActionBlockConfirmation = () -> (Bool) public override func reset() { super.reset() - backgroundColor = containerTintColor?.off - knobView.backgroundColor = knobTintColor?.off + backgroundColor = containerTintColor.off + knobView.backgroundColor = knobTintColor.off isAnimated = true isOn = false constrainKnob() @@ -348,10 +348,10 @@ public typealias ActionBlockConfirmation = () -> (Bool) FormValidator.setupValidation(for: model, delegate: delegateObject?.formHolderDelegate) - containerTintColor?.on = model.onTintColor.uiColor - containerTintColor?.off = model.offTintColor.uiColor - knobTintColor?.on = model.onKnobTintColor.uiColor - knobTintColor?.off = model.offKnobTintColor.uiColor + containerTintColor.on = model.onTintColor.uiColor + containerTintColor.off = model.offTintColor.uiColor + knobTintColor.on = model.onKnobTintColor.uiColor + knobTintColor.off = model.offKnobTintColor.uiColor changeStateNoAnimation(model.state) isAnimated = model.animated isEnabled = model.enabled