removed old code

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2022-12-08 19:34:04 -06:00
parent 84ccbac762
commit ae6c380627
10 changed files with 9 additions and 282 deletions

View File

@ -112,209 +112,3 @@ open class SurfaceColorConfiguration: ObjectColorable {
return getColor(object.surface)
}
}
///-------------------------------------------------------------------
///MARK -- DisabledSurfaceColorable
///-------------------------------------------------------------------
public protocol DisabledSurfaceColorable: ObjectColorable {
var disabled: SurfaceColorConfiguration { get set }
var enabled: SurfaceColorConfiguration { get set }
}
extension DisabledSurfaceColorable {
public func getDisabledColor<M: Surfaceable & Disabling> (_ object: M) -> UIColor {
object.disabled ? disabled.getColor(object) : enabled.getColor(object)
}
}
/// Meant to be used in a Object that implements the following interfaces for 4 possible color combinations
/// - Disabling (var disabled: Bool)
/// - Surfaceable (var surface: Surface)
///
/// let model = TestModel()
/// model.surface = .dark
/// model.disabled = false
///
/// let config = DisabledSurfaceColorConfiguration()
///
/// //disabled == false
/// config.enabled.lightColor = .black
/// config.enabled.darkColor = .white
///
/// //disabled == true
/// config.disabled.lightColor = .gray
/// config.disabled.darkColor = .lightGray
///
/// let textColor = config.getColor(model) //returns .white
///
///
open class DisabledSurfaceColorConfiguration: DisabledSurfaceColorable {
public typealias ObjectType = Surfaceable & Disabling
public var disabled = SurfaceColorConfiguration()
public var enabled = SurfaceColorConfiguration()
required public init(){}
public func getColor(_ object: any ObjectType) -> UIColor {
getDisabledColor(object)
}
}
///-------------------------------------------------------------------
///MARK -- BinaryColorable
///-------------------------------------------------------------------
public protocol BinaryColorable{
var useTrueColor: Bool { get }
}
extension BinaryColorable where Self: Control {
public var useTrueColor: Bool { return isSelected }
}
///-------------------------------------------------------------------
///MARK -- BinarySurfaceColorable
///-------------------------------------------------------------------
public protocol BinarySurfaceColorable: ObjectColorable {
var forTrue: SurfaceColorConfiguration { get set }
var forFalse: SurfaceColorConfiguration { get set }
}
extension BinarySurfaceColorable {
public func getBinaryColor<M: Surfaceable & BinaryColorable>(_ object: M) -> UIColor {
object.useTrueColor ? forTrue.getColor(object) : forFalse.getColor(object)
}
}
/// Meant to be used in a Object that implements the following interfaces for 4 possible color combinations
/// - BinaryColorable (var userTrueColor: Bool)
/// - Surfaceable (var surface: Surface)
///
/// let model = TestModel()
/// model.surface = .dark
/// model.on = true //this is read in the extension var userTrueColor
/// let config = BinarySurfaceColorConfiguration()
///
/// //True from BinaryColorable.userTrueColor
/// config.forTrue.lightColor = .black
/// config.forTrue.darkColor = .white
///
/// //False from BinaryColorable.userTrueColor
/// config.forFalse.lightColor = .red
/// config.forFalse.darkColor = .red
///
/// let textColor = config.getColor(model) //returns .white
///
///
final public class BinarySurfaceColorConfiguration: BinarySurfaceColorable {
public typealias ObjectType = Surfaceable & BinaryColorable
public var forTrue = SurfaceColorConfiguration()
public var forFalse = SurfaceColorConfiguration()
required public init(){}
public func getColor(_ object: any ObjectType) -> UIColor {
getBinaryColor(object)
}
}
///-------------------------------------------------------------------
///MARK -- BinaryDisabledSurfaceColorable
///-------------------------------------------------------------------
public protocol BinaryDisabledSurfaceColorable: ObjectColorable {
var forTrue: DisabledSurfaceColorConfiguration { get set }
var forFalse: DisabledSurfaceColorConfiguration { get set }
}
extension BinaryDisabledSurfaceColorable {
public func getBinaryColor<M: Disabling & Surfaceable & BinaryColorable>(_ object: M) -> UIColor {
object.useTrueColor ? forTrue.getColor(object) : forFalse.getColor(object)
}
}
/// Meant to be used in a Object that implements the following interfaces for 8 possible color combinations
/// - BinaryColorable (var userTrueColor: Bool)
/// - Disabling (var disabled: Bool)
/// - Surfaceable (var surface: Surface)
///
/// let model = TestModel()
/// model.on = false
/// model.disabled = false
/// model.surface = .light
/// let config = BinaryDisabledSurfaceColorConfiguration()
///
/// //True
/// config.forTrue.enabled.lightColor = .black
/// config.forTrue.enabled.darkColor = .white
/// config.forTrue.disabled.lightColor = .darkGray
/// config.forTrue.disabled.darkColor = .lightGray
///
/// //False
/// config.forFalse.enabled.lightColor = .red
/// config.forFalse.enabled.darkColor = .red
/// config.forFalse.disabled.lightColor =.darkGray
/// config.forFalse.disabled.darkColor = .lightGray
///
/// let textColor = config.getColor(model)
///
///
final public class BinaryDisabledSurfaceColorConfiguration: BinaryDisabledSurfaceColorable {
public typealias ObjectType = Disabling & Surfaceable & BinaryColorable
public var forTrue = DisabledSurfaceColorConfiguration()
public var forFalse = DisabledSurfaceColorConfiguration()
required public init(){}
public func getColor(_ object: any ObjectType) -> UIColor {
getBinaryColor(object)
}
}
public class ControlStateColorConfiguration: ObjectColorable {
public typealias ObjectType = UIControl & Surfaceable
public var disabled = SurfaceColorConfiguration()
public var normal = SurfaceColorConfiguration()
public var highlighted: SurfaceColorConfiguration?
public var selected: SurfaceColorConfiguration?
public var error: SurfaceColorConfiguration?
required public init(){}
public func setColorable(_ config: SurfaceColorConfiguration, for state: UIControl.State) {
switch state {
case .disabled:
disabled = config
case .highlighted:
highlighted = config
case .selected:
selected = config
case .error:
error = config
default:
normal = config
}
}
public func getColor(_ object: any ObjectType) -> UIColor {
if object.state == .disabled {
return disabled.getColor(object)
} else if let highlighted, object.state == .highlighted {
return highlighted.getColor(object)
} else if let selected, object.state == .selected {
return selected.getColor(object)
} else if let error, object.state == .error {
return error.getColor(object)
} else {
return normal.getColor(object)
}
}
}

View File

@ -170,22 +170,6 @@ open class Button: ButtonBase, Useable {
minWidthConstraint?.isActive = true
}
}
//--------------------------------------------------
// MARK: - PRIVATE
//--------------------------------------------------
private class UseableColorConfiguration: ObjectColorable {
typealias ObjectType = Buttonable & Useable
public var primary = ControlStateColorConfiguration()
public var secondary = ControlStateColorConfiguration()
required public init(){}
public func getColor(_ object: ObjectType) -> UIColor {
return object.use == .primary ? primary.getColor(object) : secondary.getColor(object)
}
}
}
fileprivate extension ButtonSize {

View File

@ -159,11 +159,9 @@ internal class CaretView: View {
public var size: CaretSize? { didSet{ didChange() } }
public var colorConfiguration: AnyColorable = DisabledSurfaceColorConfiguration().with {
$0.disabled.lightColor = VDSColor.elementsSecondaryOnlight
$0.disabled.darkColor = VDSColor.elementsSecondaryOndark
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
public var colorConfiguration: AnyColorable = ViewColorConfiguration().with {
$0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forDisabled: true)
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false)
}.eraseToAnyColorable()

View File

@ -27,7 +27,7 @@ public class SoloCheckbox: CheckboxBase{
}
@objc(VDSCheckboxBase)
open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable {
open class CheckboxBase: Control, Accessable, DataTrackable, Errorable {
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------

View File

@ -27,7 +27,7 @@ public class SoloRadioBox: RadioBoxBase{
}
@objc(VDSRadioBoxBase)
open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
open class RadioBoxBase: Control, Accessable, DataTrackable{
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------

View File

@ -34,7 +34,7 @@ public class SoloRadioButton: RadioButtonBase {
}
@objc(VDSRadioButtonBase)
open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable {
open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable {
//--------------------------------------------------
// MARK: - Initializers
//--------------------------------------------------

View File

@ -31,7 +31,7 @@ public class SolorRadioSwatch: RadioSwatchBase{
}
@objc(VDSRadioSwatchBase)
open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable {
open class RadioSwatchBase: Control, Accessable, DataTrackable {
//--------------------------------------------------
// MARK: - Initializers

View File

@ -358,26 +358,3 @@ open class EntryField: Control, Accessable {
}
}
}
//--------------------------------------------------
// 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(){}
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)
}
}
}

View File

@ -185,32 +185,6 @@ open class TextEntryFieldBase: EntryField {
}
}
}
internal class TextEntryFieldColorConfiguration: DisabledSurfaceColorable {
var success = SurfaceColorConfiguration()
var error = SurfaceColorConfiguration()
var disabled = SurfaceColorConfiguration()
var enabled = SurfaceColorConfiguration()
required init(){}
func getColor(_ object: TextEntryField) -> UIColor {
//only show error is enabled and showError == true
let showErrorColor = !object.disabled && object.showError
let showSuccessColor = !object.disabled && object.showSuccess
if showErrorColor {
return error.getColor(object)
} else if showSuccessColor {
return success.getColor(object)
} else {
return getDisabledColor(object)
}
}
}
}
extension TextEntryFieldType {

View File

@ -42,7 +42,7 @@ public class Toggle: ToggleBase{
}
@objc(VDSToggleBase)
open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable {
open class ToggleBase: Control, Accessable, DataTrackable {
//--------------------------------------------------
// MARK: - Initializers
@ -97,7 +97,7 @@ open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable {
private var knobColorConfiguration = ControlColorConfiguration().with {
$0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .normal)
$0.setSurfaceColors(VDSColor.paletteGray95, VDSColor.paletteGray44, forState: .disabled)
$0.setSurfaceColors(VDSColor.paletteGray95, VDSColor.paletteGray44, forState: .disabled)
$0.setSurfaceColors(VDSColor.elementsPrimaryOndark, VDSColor.elementsPrimaryOndark, forState: .selected)
}