removed old code
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
84ccbac762
commit
ae6c380627
@ -112,209 +112,3 @@ open class SurfaceColorConfiguration: ObjectColorable {
|
|||||||
return getColor(object.surface)
|
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -170,22 +170,6 @@ open class Button: ButtonBase, Useable {
|
|||||||
minWidthConstraint?.isActive = true
|
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 {
|
fileprivate extension ButtonSize {
|
||||||
|
|||||||
@ -159,11 +159,9 @@ internal class CaretView: View {
|
|||||||
|
|
||||||
public var size: CaretSize? { didSet{ didChange() } }
|
public var size: CaretSize? { didSet{ didChange() } }
|
||||||
|
|
||||||
public var colorConfiguration: AnyColorable = DisabledSurfaceColorConfiguration().with {
|
public var colorConfiguration: AnyColorable = ViewColorConfiguration().with {
|
||||||
$0.disabled.lightColor = VDSColor.elementsSecondaryOnlight
|
$0.setSurfaceColors(VDSColor.elementsSecondaryOnlight, VDSColor.elementsSecondaryOndark, forDisabled: true)
|
||||||
$0.disabled.darkColor = VDSColor.elementsSecondaryOndark
|
$0.setSurfaceColors(VDSColor.elementsPrimaryOnlight, VDSColor.elementsPrimaryOndark, forDisabled: false)
|
||||||
$0.enabled.lightColor = VDSColor.elementsPrimaryOnlight
|
|
||||||
$0.enabled.darkColor = VDSColor.elementsPrimaryOndark
|
|
||||||
}.eraseToAnyColorable()
|
}.eraseToAnyColorable()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class SoloCheckbox: CheckboxBase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc(VDSCheckboxBase)
|
@objc(VDSCheckboxBase)
|
||||||
open class CheckboxBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable {
|
open class CheckboxBase: Control, Accessable, DataTrackable, Errorable {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public class SoloRadioBox: RadioBoxBase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc(VDSRadioBoxBase)
|
@objc(VDSRadioBoxBase)
|
||||||
open class RadioBoxBase: Control, BinaryColorable, Accessable, DataTrackable{
|
open class RadioBoxBase: Control, Accessable, DataTrackable{
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -34,7 +34,7 @@ public class SoloRadioButton: RadioButtonBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc(VDSRadioButtonBase)
|
@objc(VDSRadioButtonBase)
|
||||||
open class RadioButtonBase: Control, Accessable, DataTrackable, BinaryColorable, Errorable {
|
open class RadioButtonBase: Control, Accessable, DataTrackable, Errorable {
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public class SolorRadioSwatch: RadioSwatchBase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc(VDSRadioSwatchBase)
|
@objc(VDSRadioSwatchBase)
|
||||||
open class RadioSwatchBase: Control, Accessable, DataTrackable, BinaryColorable {
|
open class RadioSwatchBase: Control, Accessable, DataTrackable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
|
|||||||
@ -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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@ -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 {
|
extension TextEntryFieldType {
|
||||||
|
|||||||
@ -42,7 +42,7 @@ public class Toggle: ToggleBase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@objc(VDSToggleBase)
|
@objc(VDSToggleBase)
|
||||||
open class ToggleBase: Control, Accessable, DataTrackable, BinaryColorable {
|
open class ToggleBase: Control, Accessable, DataTrackable {
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user