refactored colors
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
63d5b97de6
commit
669c2b15b5
@ -26,15 +26,46 @@ import Combine
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// Holds the on and off colors for the container.
|
private var toggleTintColor: (on: UIColor, off: UIColor) {
|
||||||
private var containerTintColor: (on: UIColor, off: UIColor) = (on: VDSColor.paletteGreen26, off: VDSColor.paletteGray44)
|
return getToggleColor(for: disabled, surface: surface)
|
||||||
|
}
|
||||||
|
|
||||||
/// Holds the on and off colors for the knob.
|
private var knobTintColor: (on: UIColor, off: UIColor) {
|
||||||
private var knobTintColor: (on: UIColor, off: UIColor) = (on: VDSColor.paletteWhite, off: VDSColor.paletteWhite)
|
return getKnobColor(for: disabled, surface: surface)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func getToggleColor(for disabled: Bool, surface: Surface) -> (on: UIColor, off: UIColor) {
|
||||||
|
if disabled {
|
||||||
|
if surface == .light {
|
||||||
|
return (on: VDSColor.interactiveDisabledOnlight, off: VDSColor.interactiveDisabledOnlight)
|
||||||
|
} else {
|
||||||
|
return (on: VDSColor.interactiveDisabledOndark, off: VDSColor.interactiveDisabledOndark)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if surface == .light {
|
||||||
|
return (on: VDSColor.paletteGreen26, off: VDSColor.elementsSecondaryOndark)
|
||||||
|
} else {
|
||||||
|
return (on: VDSColor.paletteGreen34, off: VDSColor.paletteGray44)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func getKnobColor(for disabled: Bool, surface: Surface) -> (on: UIColor, off: UIColor) {
|
||||||
|
if disabled {
|
||||||
|
if surface == .light {
|
||||||
|
return (on: VDSColor.paletteGray95, off: VDSColor.paletteGray95)
|
||||||
|
} else {
|
||||||
|
return (on: VDSColor.paletteGray44, off: VDSColor.paletteGray44)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if surface == .light {
|
||||||
|
return (on: VDSColor.elementsPrimaryOndark, off: VDSColor.elementsPrimaryOndark)
|
||||||
|
} else {
|
||||||
|
return (on: VDSColor.elementsPrimaryOndark, off: VDSColor.elementsPrimaryOndark)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Holds the on and off colors for the disabled state..
|
|
||||||
private var disabledTintColor: (container: UIColor, knob: UIColor) = (container: VDSColor.paletteGray11, knob: VDSColor.paletteWhite)
|
|
||||||
|
|
||||||
private var showTextSpacing: CGFloat {
|
private var showTextSpacing: CGFloat {
|
||||||
showText ? 12 : 0
|
showText ? 12 : 0
|
||||||
}
|
}
|
||||||
@ -210,7 +241,7 @@ import Combine
|
|||||||
toggleView.layer.cornerRadius = toggleSize.height / 2.0
|
toggleView.layer.cornerRadius = toggleSize.height / 2.0
|
||||||
knobView.layer.cornerRadius = knobSize.height / 2.0
|
knobView.layer.cornerRadius = knobSize.height / 2.0
|
||||||
|
|
||||||
toggleView.backgroundColor = containerTintColor.off
|
toggleView.backgroundColor = toggleTintColor.off
|
||||||
|
|
||||||
toggleView.addSubview(knobView)
|
toggleView.addSubview(knobView)
|
||||||
|
|
||||||
@ -251,7 +282,7 @@ import Combine
|
|||||||
public override func reset() {
|
public override func reset() {
|
||||||
super.reset()
|
super.reset()
|
||||||
|
|
||||||
toggleView.backgroundColor = containerTintColor.off
|
toggleView.backgroundColor = toggleTintColor.off
|
||||||
knobView.backgroundColor = knobTintColor.off
|
knobView.backgroundColor = knobTintColor.off
|
||||||
setAccessibilityLabel()
|
setAccessibilityLabel()
|
||||||
onChange = nil
|
onChange = nil
|
||||||
@ -356,20 +387,17 @@ import Combine
|
|||||||
self.layoutIfNeeded()
|
self.layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let toggleColor = getToggleColor(for: viewModel.disabled, surface: viewModel.surface)
|
||||||
|
let knobColor = getKnobColor(for: viewModel.disabled, surface: viewModel.surface)
|
||||||
|
|
||||||
if viewModel.disabled {
|
if viewModel.disabled {
|
||||||
toggleView.backgroundColor = enabled ? viewModel.on ? containerTintColor.on : containerTintColor.off : disabledTintColor.container
|
toggleView.backgroundColor = viewModel.on ? toggleColor.on : toggleColor.off
|
||||||
knobView.backgroundColor = enabled ? viewModel.on ? knobTintColor.on : knobTintColor.off : disabledTintColor.knob
|
knobView.backgroundColor = viewModel.on ? knobColor.on : knobColor.off
|
||||||
constrainKnob()
|
constrainKnob()
|
||||||
} else {
|
} else {
|
||||||
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: {
|
UIView.animate(withDuration: 0.2, delay: 0.0, options: .curveEaseIn, animations: {
|
||||||
if viewModel.on {
|
self.toggleView.backgroundColor = viewModel.on ? toggleColor.on : toggleColor.off
|
||||||
self.knobView.backgroundColor = self.knobTintColor.on
|
self.knobView.backgroundColor = viewModel.on ? knobColor.on : knobColor.off
|
||||||
self.toggleView.backgroundColor = self.containerTintColor.on
|
|
||||||
|
|
||||||
} else {
|
|
||||||
self.knobView.backgroundColor = self.knobTintColor.off
|
|
||||||
self.toggleView.backgroundColor = self.containerTintColor.off
|
|
||||||
}
|
|
||||||
}, completion: nil)
|
}, completion: nil)
|
||||||
|
|
||||||
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: {
|
UIView.animate(withDuration: 0.33, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 0.2, options: [], animations: {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user