fixed bug for disabled
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
eaae15658e
commit
529be82f36
@ -101,10 +101,10 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
|||||||
// MARK: - Static Properties
|
// MARK: - Static Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// Sizes are from InVision design specs.
|
// Sizes are from InVision design specs.
|
||||||
public static var toggleSize = CGSize(width: 52, height: 24)
|
public static var toggleSize = CGSize(width: 51, height: 31)
|
||||||
open class func getToggleScaledSize() -> CGSize { return Self.toggleSize }
|
open class func getToggleScaledSize() -> CGSize { return Self.toggleSize }
|
||||||
|
|
||||||
public static var knobSize = CGSize(width: 20, height: 20)
|
public static var knobSize = CGSize(width: 28, height: 28)
|
||||||
open class func getKnobScaledSize() -> CGSize { return Self.knobSize }
|
open class func getKnobScaledSize() -> CGSize { return Self.knobSize }
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -407,18 +407,8 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
|||||||
setAccessibilityHint(!viewModel.disabled)
|
setAccessibilityHint(!viewModel.disabled)
|
||||||
setAccessibilityValue(viewModel.on)
|
setAccessibilityValue(viewModel.on)
|
||||||
|
|
||||||
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: {
|
//private func
|
||||||
if viewModel.on {
|
func constrainKnob(){
|
||||||
self.knobView.backgroundColor = self.knobTintColor.on
|
|
||||||
self.toggleView.backgroundColor = self.containerTintColor.on
|
|
||||||
|
|
||||||
} else {
|
|
||||||
self.knobView.backgroundColor = self.knobTintColor.off
|
|
||||||
self.toggleView.backgroundColor = self.containerTintColor.off
|
|
||||||
}
|
|
||||||
}, completion: nil)
|
|
||||||
|
|
||||||
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: {
|
|
||||||
self.knobLeadingConstraint?.isActive = false
|
self.knobLeadingConstraint?.isActive = false
|
||||||
self.knobTrailingConstraint?.isActive = false
|
self.knobTrailingConstraint?.isActive = false
|
||||||
if viewModel.on {
|
if viewModel.on {
|
||||||
@ -432,7 +422,28 @@ public class DefaultToggleModel: DefaultLabelModel, VDSToggleModel {
|
|||||||
self.knobLeadingConstraint?.isActive = true
|
self.knobLeadingConstraint?.isActive = true
|
||||||
self.knobWidthConstraint?.constant = Self.getKnobScaledSize().width
|
self.knobWidthConstraint?.constant = Self.getKnobScaledSize().width
|
||||||
self.layoutIfNeeded()
|
self.layoutIfNeeded()
|
||||||
}, completion: nil)
|
}
|
||||||
|
|
||||||
|
if viewModel.disabled {
|
||||||
|
toggleView.backgroundColor = isEnabled ? isOn ? containerTintColor.on : containerTintColor.off : disabledTintColor.container
|
||||||
|
knobView.backgroundColor = isEnabled ? isOn ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob
|
||||||
|
constrainKnob()
|
||||||
|
} else {
|
||||||
|
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: {
|
||||||
|
if viewModel.on {
|
||||||
|
self.knobView.backgroundColor = self.knobTintColor.on
|
||||||
|
self.toggleView.backgroundColor = self.containerTintColor.on
|
||||||
|
|
||||||
|
} else {
|
||||||
|
self.knobView.backgroundColor = self.knobTintColor.off
|
||||||
|
self.toggleView.backgroundColor = self.containerTintColor.off
|
||||||
|
}
|
||||||
|
}, completion: nil)
|
||||||
|
|
||||||
|
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: {
|
||||||
|
constrainKnob()
|
||||||
|
}, completion: nil)
|
||||||
|
}
|
||||||
|
|
||||||
backgroundColor = viewModel.surface == .dark ? VDSColor.backgroundPrimaryDark : .clear
|
backgroundColor = viewModel.surface == .dark ? VDSColor.backgroundPrimaryDark : .clear
|
||||||
isUserInteractionEnabled = !viewModel.disabled
|
isUserInteractionEnabled = !viewModel.disabled
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user