updated code
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
163c292796
commit
0a8b0c2f7c
@ -442,8 +442,8 @@
|
||||
EA4DB2FE28DCBC1900103EE3 /* Badge */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
EA4DB2FF28DCBC9900103EE3 /* BadgeModel.swift */,
|
||||
EA4DB30128DCBCA500103EE3 /* Badge.swift */,
|
||||
EA4DB2FF28DCBC9900103EE3 /* BadgeModel.swift */,
|
||||
);
|
||||
path = Badge;
|
||||
sourceTree = "<group>";
|
||||
|
||||
@ -50,14 +50,14 @@ open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
||||
// Sizes are from InVision design specs.
|
||||
internal let containerSize = CGSize(width: 45, height: 45)
|
||||
|
||||
internal let primaryColorConfig = DisabledSurfaceColorConfiguration<DefaultLabelModel>().with {
|
||||
internal let primaryColorConfig = DisabledSurfaceColorConfiguration().with {
|
||||
$0.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
||||
$0.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
||||
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
|
||||
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
|
||||
}
|
||||
|
||||
internal let secondaryColorConfig = DisabledSurfaceColorConfiguration<DefaultLabelModel>().with {
|
||||
internal let secondaryColorConfig = DisabledSurfaceColorConfiguration().with {
|
||||
$0.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
||||
$0.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
||||
$0.enabled.lightColor = VDSColor.elementsSecondaryOnlight
|
||||
@ -170,7 +170,7 @@ open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
||||
}
|
||||
|
||||
open func getBackgroundConfig() -> AnyColorable {
|
||||
return EntryFieldColorConfiguration().with {
|
||||
return ErrorDisabledSurfaceColorConfiguration().with {
|
||||
$0.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
|
||||
$0.enabled.darkColor = VDSFormControlsColor.backgroundOndark
|
||||
$0.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
|
||||
@ -183,7 +183,7 @@ open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
||||
}
|
||||
|
||||
open func getBorderConfig() -> AnyColorable {
|
||||
return EntryFieldColorConfiguration().with {
|
||||
return ErrorDisabledSurfaceColorConfiguration().with {
|
||||
$0.enabled.lightColor = VDSFormControlsColor.borderOnlight
|
||||
$0.enabled.darkColor = VDSFormControlsColor.borderOnlight
|
||||
$0.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
||||
@ -291,28 +291,33 @@ open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
||||
helperLabel.isHidden = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Color Class Configurations
|
||||
//--------------------------------------------------
|
||||
internal class EntryFieldColorConfiguration: DisabledSurfaceColorConfiguration<ModelType> {
|
||||
public let error = SurfaceColorConfiguration<ModelType>()
|
||||
|
||||
override func getColor(_ viewModel: ModelType) -> UIColor {
|
||||
//only show error is enabled and showError == true
|
||||
let showErrorColor = !viewModel.disabled && viewModel.showError
|
||||
//--------------------------------------------------
|
||||
// MARK: - Color Class Configurations
|
||||
//--------------------------------------------------
|
||||
internal class ErrorDisabledSurfaceColorConfiguration: DisabledSurfaceColorable {
|
||||
typealias ModelType = Errorable & Surfaceable & Disabling
|
||||
var error = SurfaceColorConfiguration()
|
||||
var disabled = SurfaceColorConfiguration()
|
||||
var enabled = SurfaceColorConfiguration()
|
||||
|
||||
required public init(){}
|
||||
|
||||
if showErrorColor {
|
||||
return error.getColor(viewModel)
|
||||
} else {
|
||||
return super.getColor(viewModel)
|
||||
}
|
||||
func getColor(_ viewModel: any ModelType) -> UIColor {
|
||||
//only show error is enabled and showError == true
|
||||
let showErrorColor = !viewModel.disabled && viewModel.showError
|
||||
|
||||
if showErrorColor {
|
||||
return error.getColor(viewModel)
|
||||
} else {
|
||||
return getDisabledColor(viewModel)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension DefaultLabelModel {
|
||||
public func addOptional(required: Bool, colorConfiguration: DisabledSurfaceColorConfiguration<Self>) -> DefaultLabelModel {
|
||||
public func addOptional(required: Bool, colorConfiguration: DisabledSurfaceColorConfiguration) -> DefaultLabelModel {
|
||||
guard let text = text, !required else { return self}
|
||||
let optionColorAttr = ColorLabelAttribute(location: text.count + 2,
|
||||
length: 8,
|
||||
@ -325,7 +330,7 @@ extension DefaultLabelModel {
|
||||
}
|
||||
}
|
||||
|
||||
public func addToolTip(action: PassthroughSubject<Void, Never>, colorConfiguration: DisabledSurfaceColorConfiguration<Self>) -> DefaultLabelModel {
|
||||
public func addToolTip(action: PassthroughSubject<Void, Never>, colorConfiguration: DisabledSurfaceColorConfiguration) -> DefaultLabelModel {
|
||||
guard let text = text else { return self}
|
||||
var newAttributes = attributes ?? []
|
||||
let newText = "\(text) " //create a little space between the final character and tooltip image
|
||||
|
||||
@ -153,10 +153,15 @@ open class TextEntryFieldBase<ModelType:TextEntryFieldModel>: EntryField<ModelTy
|
||||
}
|
||||
}
|
||||
|
||||
internal class TextEntryFieldColorConfiguration: EntryFieldColorConfiguration {
|
||||
public let success = SurfaceColorConfiguration<ModelType>()
|
||||
|
||||
override func getColor(_ viewModel: ModelType) -> UIColor {
|
||||
internal class TextEntryFieldColorConfiguration: DisabledSurfaceColorable {
|
||||
var success = SurfaceColorConfiguration()
|
||||
var error = SurfaceColorConfiguration()
|
||||
var disabled = SurfaceColorConfiguration()
|
||||
var enabled = SurfaceColorConfiguration()
|
||||
|
||||
required init(){}
|
||||
|
||||
func getColor(_ viewModel: ModelType) -> UIColor {
|
||||
//only show error is enabled and showError == true
|
||||
let showErrorColor = !viewModel.disabled && viewModel.showError
|
||||
let showSuccessColor = !viewModel.disabled && viewModel.showSuccess
|
||||
@ -168,10 +173,12 @@ open class TextEntryFieldBase<ModelType:TextEntryFieldModel>: EntryField<ModelTy
|
||||
return success.getColor(viewModel)
|
||||
|
||||
} else {
|
||||
return super.getColor(viewModel)
|
||||
return getDisabledColor(viewModel)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
extension TextEntryFieldType {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user