created public init

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-08-22 17:42:59 -05:00
parent c9cc612698
commit 052d7b57b0

View File

@ -8,7 +8,7 @@
import Foundation
import UIKit
public protocol Colorable: Withable {
public protocol Colorable: Withable, Initable {
associatedtype ModelType
func getColor(_ viewModel: ModelType) -> UIColor
}
@ -33,6 +33,7 @@ open class SurfaceColorConfiguration<ModelType:Surfaceable>: Colorable {
public var lightColor: UIColor = .clear
public var darkColor: UIColor = .clear
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
return viewModel.surface == .light ? lightColor : darkColor
}
@ -63,6 +64,8 @@ open class DisabledSurfaceColorConfiguration<ModelType:Disabling & Surfaceable>:
public var disabled = SurfaceColorConfiguration<ModelType>()
public var enabled = SurfaceColorConfiguration<ModelType>()
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
return viewModel.disabled ? disabled.getColor(viewModel) : enabled.getColor(viewModel)
}
@ -92,6 +95,8 @@ open class BinarySurfaceColorConfiguration<ModelType:Surfaceable & BinaryColorab
public var forTrue = SurfaceColorConfiguration<ModelType>()
public var forFalse = SurfaceColorConfiguration<ModelType>()
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
return viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel)
}
@ -125,6 +130,8 @@ open class BinaryDisabledSurfaceColorConfiguration<ModelType:Disabling & Surface
public var forTrue = DisabledSurfaceColorConfiguration<ModelType>()
public var forFalse = DisabledSurfaceColorConfiguration<ModelType>()
required public init(){}
public func getColor(_ viewModel: ModelType) -> UIColor {
return viewModel.userTrueColor ? forTrue.getColor(viewModel) : forFalse.getColor(viewModel)
}