updated color config

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-10-10 16:22:28 -05:00
parent 02325d0d30
commit 163c292796
10 changed files with 260 additions and 252 deletions

View File

@ -8,15 +8,7 @@
import Foundation
import UIKit
public protocol BinaryColorable{
var userTrueColor: Bool { get }
}
extension BinaryColorable where Self: Selectable {
public var userTrueColor: Bool { return selected }
}
public typealias ClassColorable = Colorable & Initable & ObjectWithable
public typealias ObjectColorable = Colorable & Initable & ObjectWithable
/// Meant to be used in a Object that implements the following interfaces for 2 possible color combinations
/// - Surfaceable (var surface: Surface)
@ -30,16 +22,31 @@ public typealias ClassColorable = Colorable & Initable & ObjectWithable
/// config.darkColor = .white
///
/// let textColor = config.getColor(model) //returns .black
open class SurfaceColorConfiguration<ModelType:Surfaceable>: ClassColorable {
final public class SurfaceColorConfiguration: ObjectColorable {
public typealias ModelType = Surfaceable
public var lightColor: UIColor = .clear
public var darkColor: UIColor = .clear
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
public func getColor(_ viewModel: any ModelType) -> UIColor {
return viewModel.surface == .light ? lightColor : darkColor
}
}
///-------------------------------------------------------------------
///MARK -- DisabledSurfaceColorable
///-------------------------------------------------------------------
public protocol DisabledSurfaceColorable: ObjectColorable {
var disabled: SurfaceColorConfiguration { get set }
var enabled: SurfaceColorConfiguration { get set }
}
extension DisabledSurfaceColorable {
public func getDisabledColor<M: Surfaceable & Disabling> (_ viewModel: M) -> UIColor {
viewModel.disabled ? disabled.getColor(viewModel) : enabled.getColor(viewModel)
}
}
/// Meant to be used in a Object that implements the following interfaces for 4 possible color combinations
/// - Disabling (var disabled: Bool)
/// - Surfaceable (var surface: Surface)
@ -48,7 +55,7 @@ open class SurfaceColorConfiguration<ModelType:Surfaceable>: ClassColorable {
/// model.surface = .dark
/// model.disabled = false
///
/// let config = DisabledSurfaceColorConfiguration<TestModel>()
/// let config = DisabledSurfaceColorConfiguration()
///
/// //disabled == false
/// config.enabled.lightColor = .black
@ -61,14 +68,40 @@ open class SurfaceColorConfiguration<ModelType:Surfaceable>: ClassColorable {
/// let textColor = config.getColor(model) //returns .white
///
///
open class DisabledSurfaceColorConfiguration<ModelType:Disabling & Surfaceable>: ClassColorable {
public var disabled = SurfaceColorConfiguration<ModelType>()
public var enabled = SurfaceColorConfiguration<ModelType>()
final public class DisabledSurfaceColorConfiguration: DisabledSurfaceColorable {
public typealias ModelType = Surfaceable & Disabling
public var disabled = SurfaceColorConfiguration()
public var enabled = SurfaceColorConfiguration()
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
return viewModel.disabled ? disabled.getColor(viewModel) : enabled.getColor(viewModel)
public func getColor(_ viewModel: any ModelType) -> UIColor {
getDisabledColor(viewModel)
}
}
///-------------------------------------------------------------------
///MARK -- BinaryColorable
///-------------------------------------------------------------------
public protocol BinaryColorable{
var userTrueColor: Bool { get }
}
extension BinaryColorable where Self: Selectable {
public var userTrueColor: Bool { return selected }
}
///-------------------------------------------------------------------
///MARK -- BinarySurfaceColorable
///-------------------------------------------------------------------
public protocol BinarySurfaceColorable: ObjectColorable {
var forTrue: SurfaceColorConfiguration { get set }
var forFalse: SurfaceColorConfiguration { get set }
}
extension BinarySurfaceColorable {
public func getBinaryColor<M: Surfaceable & BinaryColorable>(_ viewModel: M) -> UIColor {
viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel)
}
}
@ -79,7 +112,7 @@ open class DisabledSurfaceColorConfiguration<ModelType:Disabling & Surfaceable>:
/// let model = TestModel()
/// model.surface = .dark
/// model.on = true //this is read in the extension var userTrueColor
/// let config = BinarySurfaceColorConfiguration<TestModel>()
/// let config = BinarySurfaceColorConfiguration()
///
/// //True from BinaryColorable.userTrueColor
/// config.forTrue.lightColor = .black
@ -92,14 +125,30 @@ open class DisabledSurfaceColorConfiguration<ModelType:Disabling & Surfaceable>:
/// let textColor = config.getColor(model) //returns .white
///
///
open class BinarySurfaceColorConfiguration<ModelType:Surfaceable & BinaryColorable>: ClassColorable {
public var forTrue = SurfaceColorConfiguration<ModelType>()
public var forFalse = SurfaceColorConfiguration<ModelType>()
final public class BinarySurfaceColorConfiguration: BinarySurfaceColorable {
public typealias ModelType = Surfaceable & BinaryColorable
public var forTrue = SurfaceColorConfiguration()
public var forFalse = SurfaceColorConfiguration()
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
return viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel)
public func getColor(_ viewModel: any ModelType) -> UIColor {
getBinaryColor(viewModel)
}
}
///-------------------------------------------------------------------
///MARK -- BinaryDisabledSurfaceColorable
///-------------------------------------------------------------------
public protocol BinaryDisabledSurfaceColorable: ObjectColorable {
var forTrue: DisabledSurfaceColorConfiguration { get set }
var forFalse: DisabledSurfaceColorConfiguration { get set }
}
extension BinaryDisabledSurfaceColorable {
public func getBinaryColor<M: Disabling & Surfaceable & BinaryColorable>(_ viewModel: M) -> UIColor {
viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel)
}
}
@ -112,7 +161,7 @@ open class BinarySurfaceColorConfiguration<ModelType:Surfaceable & BinaryColorab
/// model.on = false
/// model.disabled = false
/// model.surface = .light
/// let config = BinaryDisabledSurfaceColorConfiguration<TestModel>()
/// let config = BinaryDisabledSurfaceColorConfiguration()
///
/// //True
/// config.forTrue.enabled.lightColor = .black
@ -129,13 +178,14 @@ open class BinarySurfaceColorConfiguration<ModelType:Surfaceable & BinaryColorab
/// let textColor = config.getColor(model)
///
///
open class BinaryDisabledSurfaceColorConfiguration<ModelType:Disabling & Surfaceable & BinaryColorable>: ClassColorable {
public var forTrue = DisabledSurfaceColorConfiguration<ModelType>()
public var forFalse = DisabledSurfaceColorConfiguration<ModelType>()
final public class BinaryDisabledSurfaceColorConfiguration: BinaryDisabledSurfaceColorable {
public typealias ModelType = Disabling & Surfaceable & BinaryColorable
public var forTrue = DisabledSurfaceColorConfiguration()
public var forFalse = DisabledSurfaceColorConfiguration()
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
return viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel)
public func getColor(_ viewModel: any ModelType) -> UIColor {
getBinaryColor(viewModel)
}
}

View File

@ -91,40 +91,40 @@ open class BadgeBase<ModelType: BadgeModel>: View<ModelType> {
// MARK: - Configuration
//--------------------------------------------------
public func backgroundColor(for fillColor: BadgeFillColor) -> UIColor {
var config: SurfaceColorConfiguration<ModelType>
var config: SurfaceColorConfiguration
switch model.fillColor {
case .red:
config = SurfaceColorConfiguration<ModelType>().with {
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.backgroundBrandhighlight
$0.darkColor = VDSColor.backgroundBrandhighlight
}
case .yellow:
config = SurfaceColorConfiguration<ModelType>().with {
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteYellow62
$0.darkColor = VDSColor.paletteYellow62
}
case .green:
config = SurfaceColorConfiguration<ModelType>().with {
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteGreen26
$0.darkColor = VDSColor.paletteGreen34
}
case .orange:
config = SurfaceColorConfiguration<ModelType>().with {
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteOrange39
$0.darkColor = VDSColor.paletteOrange46
}
case .blue:
config = SurfaceColorConfiguration<ModelType>().with {
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteBlue35
$0.darkColor = VDSColor.paletteBlue45
}
case .black:
config = SurfaceColorConfiguration<ModelType>().with {
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteBlack
$0.darkColor = VDSColor.paletteBlack
}
case .white:
config = SurfaceColorConfiguration<ModelType>().with {
config = SurfaceColorConfiguration().with {
$0.lightColor = VDSColor.paletteWhite
$0.darkColor = VDSColor.paletteWhite
}
@ -138,21 +138,21 @@ open class BadgeBase<ModelType: BadgeModel>: View<ModelType> {
switch fillColor {
case .red, .black:
return DisabledSurfaceColorConfiguration<ModelType>().with {
return DisabledSurfaceColorConfiguration().with {
$0.disabled.lightColor = VDSColor.elementsPrimaryOndark
$0.disabled.darkColor = VDSColor.elementsPrimaryOndark
$0.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
}.eraseToAnyColorable()
case .yellow, .white:
return DisabledSurfaceColorConfiguration<ModelType>().with {
return DisabledSurfaceColorConfiguration().with {
$0.disabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.disabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.enabled.darkColor = VDSColor.elementsPrimaryOnlight
}.eraseToAnyColorable()
case .orange, .green, .blue:
return DisabledSurfaceColorConfiguration<ModelType>().with {
return DisabledSurfaceColorConfiguration().with {
$0.disabled.lightColor = VDSColor.elementsPrimaryOndark
$0.disabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.enabled.lightColor = VDSColor.elementsPrimaryOndark

View File

@ -65,51 +65,45 @@ open class ButtonBase<ModelType: ButtonModel>: UIButton, ModelHandlerable, ViewP
isUserInteractionEnabled = isEnabled
}
}
//--------------------------------------------------
// MARK: - Configuration Properties
//--------------------------------------------------
private var buttonBackgroundColorConfiguration: UseableColorConfiguration<ModelType> = {
return UseableColorConfiguration<ModelType>().with {
$0.primary.enabled.lightColor = VDSColor.backgroundPrimaryDark
$0.primary.enabled.darkColor = VDSColor.backgroundPrimaryLight
$0.primary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.primary.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.secondary.enabled.lightColor = UIColor.clear
$0.secondary.enabled.darkColor = UIColor.clear
$0.secondary.disabled.lightColor = UIColor.clear
$0.secondary.disabled.darkColor = UIColor.clear
}
}()
private var buttonBackgroundColorConfiguration = UseableColorConfiguration().with {
$0.primary.enabled.lightColor = VDSColor.backgroundPrimaryDark
$0.primary.enabled.darkColor = VDSColor.backgroundPrimaryLight
$0.primary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.primary.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.secondary.enabled.lightColor = UIColor.clear
$0.secondary.enabled.darkColor = UIColor.clear
$0.secondary.disabled.lightColor = UIColor.clear
$0.secondary.disabled.darkColor = UIColor.clear
}
private var buttonBorderColorConfiguration: UseableColorConfiguration<ModelType> = {
return UseableColorConfiguration<ModelType>().with {
$0.primary.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.primary.enabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.primary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.primary.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.secondary.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.secondary.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.secondary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.secondary.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
}()
private var buttonBorderColorConfiguration = UseableColorConfiguration().with {
$0.primary.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.primary.enabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.primary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.primary.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.secondary.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.secondary.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.secondary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.secondary.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
private var buttonTitleColorConfiguration: UseableColorConfiguration<ModelType> = {
return UseableColorConfiguration<ModelType>().with {
$0.primary.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.primary.enabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.primary.disabled.lightColor = VDSColor.elementsPrimaryOndark
$0.primary.disabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.secondary.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.secondary.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.secondary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.secondary.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
}()
private var buttonTitleColorConfiguration = UseableColorConfiguration().with {
$0.primary.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.primary.enabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.primary.disabled.lightColor = VDSColor.elementsPrimaryOndark
$0.primary.disabled.darkColor = VDSColor.elementsPrimaryOnlight
$0.secondary.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.secondary.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.secondary.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.secondary.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
//--------------------------------------------------
// MARK: - Initializers
@ -213,9 +207,10 @@ open class ButtonBase<ModelType: ButtonModel>: UIButton, ModelHandlerable, ViewP
// MARK: - PRIVATE
//--------------------------------------------------
private class UseableColorConfiguration<ModelType:Disabling & Surfaceable & Useable> : ClassColorable {
public var primary = DisabledSurfaceColorConfiguration<ModelType>()
public var secondary = DisabledSurfaceColorConfiguration<ModelType>()
private class UseableColorConfiguration: ObjectColorable {
typealias ModelType = Disabling & Surfaceable & Useable
public var primary = DisabledSurfaceColorConfiguration()
public var secondary = DisabledSurfaceColorConfiguration()
required public init(){}

View File

@ -230,8 +230,6 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType> {
// MARK: - State
//--------------------------------------------------
open override func updateView(viewModel: ModelType) {
let enabled = !viewModel.disabled
updateLabels(viewModel)
updateSelector(viewModel)
setAccessibilityHint()
@ -247,8 +245,8 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType> {
//--------------------------------------------------
public let checkboxSize = CGSize(width: 20, height: 20)
private var checkboxBackgroundColorConfiguration: CheckboxErrorColorConfiguration = {
return CheckboxErrorColorConfiguration().with {
private var checkboxBackgroundColorConfiguration: ErrorBinaryDisabledSurfaceColorConfiguration = {
return ErrorBinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
@ -261,8 +259,8 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType> {
}
}()
private var checkboxBorderColorConfiguration: CheckboxErrorColorConfiguration = {
return CheckboxErrorColorConfiguration().with {
private var checkboxBorderColorConfiguration: ErrorBinaryDisabledSurfaceColorConfiguration = {
return ErrorBinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
@ -279,8 +277,8 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType> {
}
}()
private var checkboxCheckColorConfiguration: BinarySurfaceColorConfiguration<ModelType> = {
return BinarySurfaceColorConfiguration<ModelType>().with {
private var checkboxCheckColorConfiguration: BinarySurfaceColorConfiguration = {
return BinarySurfaceColorConfiguration().with {
$0.forTrue.lightColor = VDSColor.elementsPrimaryOndark
$0.forTrue.darkColor = VDSColor.elementsPrimaryOnlight
}
@ -346,23 +344,28 @@ open class CheckboxBase<ModelType: CheckboxModel>: Control<ModelType> {
}
}
}
//--------------------------------------------------
// MARK: - Color Class Configurations
//--------------------------------------------------
private class CheckboxErrorColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> {
public let error = BinarySurfaceColorConfiguration<ModelType>()
override func getColor(_ viewModel: ModelType) -> UIColor {
//only show error is enabled and showError == true
let showErrorColor = !viewModel.disabled && viewModel.showError
if showErrorColor {
return error.getColor(viewModel)
} else {
return super.getColor(viewModel)
}
}
}
}
//--------------------------------------------------
// MARK: - Color Class Configurations
//--------------------------------------------------
internal class ErrorBinaryDisabledSurfaceColorConfiguration: BinaryDisabledSurfaceColorable {
typealias ModelType = Errorable & Disabling & Surfaceable & BinaryColorable
var error = BinarySurfaceColorConfiguration()
var forTrue = DisabledSurfaceColorConfiguration()
var forFalse = DisabledSurfaceColorConfiguration()
required init() {}
func getColor(_ viewModel: ModelType) -> UIColor {
//only show error is enabled and showError == true
let showErrorColor = !viewModel.disabled && viewModel.showError
if showErrorColor {
return error.getColor(viewModel)
} else {
return getBinaryColor(viewModel)
}
}
}

View File

@ -67,7 +67,7 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
//--------------------------------------------------
// MARK: - Configuration Properties
//--------------------------------------------------
public var textColorConfiguration: AnyColorable = DisabledSurfaceColorConfiguration<ModelType>().with {
public var textColorConfiguration: AnyColorable = DisabledSurfaceColorConfiguration().with {
$0.disabled.lightColor = VDSColor.elementsSecondaryOnlight
$0.disabled.darkColor = VDSColor.elementsSecondaryOndark
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight

View File

@ -207,8 +207,6 @@ open class RadioBoxBase<ModelType: RadioBoxModel>: Control<ModelType> {
// MARK: - State
//--------------------------------------------------
open override func updateView(viewModel: ModelType) {
let enabled = !viewModel.disabled
updateLabels(viewModel)
updateSelector(viewModel)
setAccessibilityHint()
@ -227,34 +225,30 @@ open class RadioBoxBase<ModelType: RadioBoxModel>: Control<ModelType> {
private var selectorBorderWidthSelected: CGFloat = 2.0
private var selectorBorderWidth: CGFloat = 1.0
private var radioBoxBackgroundColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> = {
return BinaryDisabledSurfaceColorConfiguration<ModelType>().with {
$0.forFalse.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forFalse.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.disabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.disabled.darkColor = VDSFormControlsColor.backgroundOndark
}
}()
private var radioBoxBackgroundColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
$0.forFalse.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forFalse.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.disabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.disabled.darkColor = VDSFormControlsColor.backgroundOndark
}
private var radioBoxBorderColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
private var radioBoxBorderColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> = {
return BinaryDisabledSurfaceColorConfiguration<ModelType>().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
}()
//--------------------------------------------------
// MARK: - RadioBox View Updates
//--------------------------------------------------

View File

@ -240,8 +240,6 @@ open class RadioButtonBase<ModelType: RadioButtonModel>: Control<ModelType> {
// MARK: - State
//--------------------------------------------------
open override func updateView(viewModel: ModelType) {
let enabled = !viewModel.disabled
updateLabels(viewModel)
updateSelector(viewModel)
setAccessibilityHint()
@ -256,43 +254,37 @@ open class RadioButtonBase<ModelType: RadioButtonModel>: Control<ModelType> {
//--------------------------------------------------
public let radioButtonSize = CGSize(width: 20, height: 20)
public let radioButtonSelectedSize = CGSize(width: 10, height: 10)
private var radioButtonBackgroundColorConfiguration: RadioButtonErrorColorConfiguration = {
return RadioButtonErrorColorConfiguration().with {
//error doesn't care enabled/disable
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark
$0.error.forFalse.lightColor = VDSColor.feedbackErrorBackgroundOnlight
$0.error.forFalse.darkColor = VDSColor.feedbackErrorBackgroundOndark
}
}()
private var radioButtonBorderColorConfiguration: RadioButtonErrorColorConfiguration = {
return RadioButtonErrorColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
//error doesn't care enabled/disable
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark
$0.error.forFalse.lightColor = VDSColor.feedbackErrorOnlight
$0.error.forFalse.darkColor = VDSColor.feedbackErrorOndark
}
}()
private var radioButtonCheckColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> = {
return BinaryDisabledSurfaceColorConfiguration<ModelType>().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
}()
private var radioButtonBackgroundColorConfiguration = ErrorBinaryDisabledSurfaceColorConfiguration().with {
//error doesn't care enabled/disable
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark
$0.error.forFalse.lightColor = VDSColor.feedbackErrorBackgroundOnlight
$0.error.forFalse.darkColor = VDSColor.feedbackErrorBackgroundOndark
}
private var radioButtonBorderColorConfiguration = ErrorBinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
//error doesn't care enabled/disable
$0.error.forTrue.lightColor = VDSColor.elementsPrimaryOnlight
$0.error.forTrue.darkColor = VDSColor.elementsPrimaryOndark
$0.error.forFalse.lightColor = VDSColor.feedbackErrorOnlight
$0.error.forFalse.darkColor = VDSColor.feedbackErrorOndark
}
private var radioButtonCheckColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
//--------------------------------------------------
// MARK: - RadioButton View
@ -338,23 +330,5 @@ open class RadioButtonBase<ModelType: RadioButtonModel>: Control<ModelType> {
shapeLayer.path = bezierPath.cgPath
}
}
//--------------------------------------------------
// MARK: - Color Class Configurations
//--------------------------------------------------
private class RadioButtonErrorColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> {
public let error = BinarySurfaceColorConfiguration<ModelType>()
override func getColor(_ viewModel: ModelType) -> UIColor {
//only show error is enabled and showError == true
let showErrorColor = !viewModel.disabled && viewModel.showError
if showErrorColor {
return error.getColor(viewModel)
} else {
return super.getColor(viewModel)
}
}
}
}

View File

@ -159,41 +159,36 @@ open class RadioSwatchBase<ModelType: RadioSwatchModel>: Control<ModelType> {
public let swatchSize = CGSize(width: 48, height: 48)
public let fillSize = CGSize(width: 36, height: 36)
public let disabledAlpha = 0.5
private var radioSwatchBackgroundColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> = {
return BinaryDisabledSurfaceColorConfiguration<ModelType>().with {
$0.forFalse.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forFalse.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.disabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.disabled.darkColor = VDSFormControlsColor.backgroundOndark
}
}()
private var radioSwatchBorderColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> = {
return BinaryDisabledSurfaceColorConfiguration<ModelType>().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
}()
private var radioSwatchBackgroundColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
$0.forFalse.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forFalse.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forFalse.disabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.enabled.darkColor = VDSFormControlsColor.backgroundOndark
$0.forTrue.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
$0.forTrue.disabled.darkColor = VDSFormControlsColor.backgroundOndark
}
private var radioSwatchBorderColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.lightColor = VDSFormControlsColor.borderOnlight
$0.forFalse.enabled.darkColor = VDSFormControlsColor.borderOndark
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
private var radioSwatchFillBorderColorConfiguration = DisabledSurfaceColorConfiguration().with {
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
private var radioSwatchFillBorderColorConfiguration: DisabledSurfaceColorConfiguration<ModelType> = {
return DisabledSurfaceColorConfiguration<ModelType>().with {
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
}()
//--------------------------------------------------
// MARK: - RadioBox View Updates
//--------------------------------------------------

View File

@ -64,31 +64,27 @@ open class ToggleBase<ModelType: ToggleModel>: Control<ModelType> {
public let toggleContainerSize = CGSize(width: 52, height: 44)
public let knobSize = CGSize(width: 20, height: 20)
private var toggleColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> = {
return BinaryDisabledSurfaceColorConfiguration<ModelType>().with {
$0.forTrue.enabled.lightColor = VDSColor.paletteGreen26
$0.forTrue.enabled.darkColor = VDSColor.paletteGreen34
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.enabled.lightColor = VDSColor.elementsSecondaryOnlight
$0.forFalse.enabled.darkColor = VDSColor.paletteGray44
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
} ()
private var toggleColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.paletteGreen26
$0.forTrue.enabled.darkColor = VDSColor.paletteGreen34
$0.forTrue.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forTrue.disabled.darkColor = VDSColor.interactiveDisabledOndark
$0.forFalse.enabled.lightColor = VDSColor.elementsSecondaryOnlight
$0.forFalse.enabled.darkColor = VDSColor.paletteGray44
$0.forFalse.disabled.lightColor = VDSColor.interactiveDisabledOnlight
$0.forFalse.disabled.darkColor = VDSColor.interactiveDisabledOndark
}
private var knobColorConfiguration: BinaryDisabledSurfaceColorConfiguration<ModelType> = {
return BinaryDisabledSurfaceColorConfiguration<ModelType>().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forTrue.disabled.lightColor = VDSColor.paletteGray95
$0.forTrue.disabled.darkColor = VDSColor.paletteGray44
$0.forFalse.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.disabled.lightColor = VDSColor.paletteGray95
$0.forFalse.disabled.darkColor = VDSColor.paletteGray44
}
} ()
private var knobColorConfiguration = BinaryDisabledSurfaceColorConfiguration().with {
$0.forTrue.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.forTrue.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forTrue.disabled.lightColor = VDSColor.paletteGray95
$0.forTrue.disabled.darkColor = VDSColor.paletteGray44
$0.forFalse.enabled.lightColor = VDSColor.elementsPrimaryOndark
$0.forFalse.enabled.darkColor = VDSColor.elementsPrimaryOndark
$0.forFalse.disabled.lightColor = VDSColor.paletteGray95
$0.forFalse.disabled.darkColor = VDSColor.paletteGray44
}
//--------------------------------------------------
// MARK: - Public Properties

View File

@ -48,3 +48,4 @@ public extension Withable {
return copy
}
}