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