added entry field colors
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
61493d382d
commit
e2573492fa
@ -8,6 +8,7 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
import UIKit
|
import UIKit
|
||||||
import VDSColorTokens
|
import VDSColorTokens
|
||||||
|
import VDSFormControlsTokens
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
||||||
@ -63,6 +64,38 @@ open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
|||||||
$0.enabled.darkColor = VDSColor.elementsSecondaryOndark
|
$0.enabled.darkColor = VDSColor.elementsSecondaryOndark
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal var backgroundColorConfiguration: EntryFieldColorConfiguration = {
|
||||||
|
return EntryFieldColorConfiguration().with {
|
||||||
|
$0.enabled.lightColor = VDSFormControlsColor.backgroundOnlight
|
||||||
|
$0.enabled.darkColor = VDSFormControlsColor.backgroundOndark
|
||||||
|
$0.disabled.lightColor = VDSFormControlsColor.backgroundOnlight
|
||||||
|
$0.disabled.darkColor = VDSFormControlsColor.backgroundOndark
|
||||||
|
|
||||||
|
//error/success doesn't care enabled/disable
|
||||||
|
$0.error.lightColor = VDSColor.feedbackErrorBackgroundOnlight
|
||||||
|
$0.error.darkColor = VDSColor.feedbackErrorBackgroundOndark
|
||||||
|
$0.success.lightColor = VDSColor.feedbackSuccessBackgroundOnlight
|
||||||
|
$0.success.darkColor = VDSColor.feedbackSuccessBackgroundOndark
|
||||||
|
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
internal var borderColorConfiguration: EntryFieldColorConfiguration = {
|
||||||
|
return EntryFieldColorConfiguration().with {
|
||||||
|
$0.enabled.lightColor = VDSFormControlsColor.borderOnlight
|
||||||
|
$0.enabled.darkColor = VDSFormControlsColor.borderOnlight
|
||||||
|
$0.disabled.lightColor = VDSColor.interactiveDisabledOnlight
|
||||||
|
$0.disabled.darkColor = VDSColor.interactiveDisabledOndark
|
||||||
|
|
||||||
|
//error/success doesn't care enabled/disable
|
||||||
|
$0.error.lightColor = VDSColor.feedbackErrorOnlight
|
||||||
|
$0.error.darkColor = VDSColor.feedbackErrorOndark
|
||||||
|
$0.success.lightColor = VDSColor.feedbackSuccessOnlight
|
||||||
|
$0.success.darkColor = VDSColor.feedbackSuccessOndark
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -231,6 +264,30 @@ open class EntryField<ModelType: EntryFieldModel>: Control<ModelType> {
|
|||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------
|
||||||
|
// MARK: - Color Class Configurations
|
||||||
|
//--------------------------------------------------
|
||||||
|
internal class EntryFieldColorConfiguration: DisabledSurfaceColorConfiguration<ModelType> {
|
||||||
|
public let error = SurfaceColorConfiguration<ModelType>()
|
||||||
|
public let success = SurfaceColorConfiguration<ModelType>()
|
||||||
|
|
||||||
|
override 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
|
||||||
|
|
||||||
|
if showErrorColor {
|
||||||
|
return error.getColor(viewModel)
|
||||||
|
|
||||||
|
} else if showSuccessColor {
|
||||||
|
return success.getColor(viewModel)
|
||||||
|
|
||||||
|
} else {
|
||||||
|
return super.getColor(viewModel)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension DefaultLabelModel {
|
extension DefaultLabelModel {
|
||||||
|
|||||||
@ -27,8 +27,10 @@ open class TextEntryFieldBase<ModelType:TextEntryFieldModel>: EntryField<ModelTy
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open override func updateView(viewModel: ModelType) {
|
open override func updateView(viewModel: ModelType) {
|
||||||
super.updateView(viewModel: viewModel)
|
super.updateView(viewModel: viewModel)
|
||||||
containerView.backgroundColor = .red
|
containerView.backgroundColor = backgroundColorConfiguration.getColor(viewModel)
|
||||||
|
containerView.layer.borderColor = borderColorConfiguration.getColor(viewModel).cgColor
|
||||||
|
containerView.layer.borderWidth = 1
|
||||||
|
containerView.layer.cornerRadius = 4
|
||||||
//set the width constraints
|
//set the width constraints
|
||||||
if let width = viewModel.width, width > viewModel.type.width {
|
if let width = viewModel.width, width > viewModel.type.width {
|
||||||
widthConstraint?.constant = width
|
widthConstraint?.constant = width
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user