added type erasure
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
50bb9dd3d4
commit
56563885b8
@ -13,6 +13,12 @@ public protocol Colorable: AnyObject, ObjectWithable {
|
||||
func getColor(_ viewModel: ModelType) -> UIColor
|
||||
}
|
||||
|
||||
extension Colorable {
|
||||
public func eraseToAnyColorable() -> AnyColorable<ModelType> {
|
||||
AnyColorable(colorable: self)
|
||||
}
|
||||
}
|
||||
|
||||
public class AnyColorable<ModelType>: Colorable {
|
||||
|
||||
private var wrapper: (ModelType) -> UIColor
|
||||
|
||||
@ -138,26 +138,26 @@ open class BadgeBase<ModelType: BadgeModel>: View<ModelType> {
|
||||
switch fillColor {
|
||||
|
||||
case .red, .black:
|
||||
return .init(colorable: DisabledSurfaceColorConfiguration<ModelType>().with {
|
||||
return DisabledSurfaceColorConfiguration<ModelType>().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 .init(colorable: DisabledSurfaceColorConfiguration<ModelType>().with {
|
||||
return DisabledSurfaceColorConfiguration<ModelType>().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 .init(colorable: DisabledSurfaceColorConfiguration<ModelType>().with {
|
||||
return DisabledSurfaceColorConfiguration<ModelType>().with {
|
||||
$0.disabled.lightColor = VDSColor.elementsPrimaryOndark
|
||||
$0.disabled.darkColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.enabled.lightColor = VDSColor.elementsPrimaryOndark
|
||||
$0.enabled.darkColor = VDSColor.elementsPrimaryOnlight
|
||||
})
|
||||
}.eraseToAnyColorable()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -67,12 +67,12 @@ open class LabelBase<ModelType: LabelModel>: UILabel, ModelHandlerable, ViewProt
|
||||
//--------------------------------------------------
|
||||
// MARK: - Configuration Properties
|
||||
//--------------------------------------------------
|
||||
public var textColorConfiguration: AnyColorable<ModelType> = .init(colorable: DisabledSurfaceColorConfiguration().with {
|
||||
public var textColorConfiguration: AnyColorable<ModelType> = DisabledSurfaceColorConfiguration().with {
|
||||
$0.disabled.lightColor = VDSColor.elementsSecondaryOnlight
|
||||
$0.disabled.darkColor = VDSColor.elementsSecondaryOndark
|
||||
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
|
||||
})
|
||||
}.eraseToAnyColorable()
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Initializers
|
||||
|
||||
Loading…
Reference in New Issue
Block a user