removed disabled

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-25 14:55:11 -05:00
parent 5811fa7a01
commit 7f461e72e9
26 changed files with 32 additions and 121 deletions

View File

@ -143,7 +143,7 @@ public class ControlColorConfiguration: KeyColorConfigurable {
///Meant to be used with any object that implements Surfaceable and Disabling. More than likely this is any View.
public class ViewColorConfiguration: KeyColorConfigurable {
public typealias KeyType = Bool
public typealias ObjectType = Surfaceable & Disabling & Enabling
public typealias ObjectType = Surfaceable & Enabling
public var keyColors: [KeyColorConfiguration<KeyType>] = []
public required init() { }

View File

@ -40,16 +40,6 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
/// Current Surface and this is used to pass down to child objects that implement Surfacable
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
/// Whether this object is disabled or not
open var disabled: Bool {
get { !isEnabled }
set {
if !isEnabled != newValue {
isEnabled = !newValue
}
}
}
/// Whether the Control is selected or not.
open override var isSelected: Bool { didSet { setNeedsUpdate() } }
@ -140,7 +130,7 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
open func reset() {
backgroundColor = .clear
surface = .light
disabled = false
isEnabled = true
}
//--------------------------------------------------

View File

@ -28,15 +28,7 @@ open class SelectorGroupHandlerBase<HandlerType: Control>: Control, Changeable {
}
}
/// Whether this object is disabled or not
override open var disabled: Bool {
didSet {
selectorViews.forEach { handler in
handler.disabled = disabled
}
}
}
/// Whether this object is enabled or not
override open var isEnabled: Bool {
didSet {
selectorViews.forEach { handler in

View File

@ -33,7 +33,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
// MARK: - Private Properties
//--------------------------------------------------
private var shouldShowError: Bool {
guard showError && !disabled && errorText?.isEmpty == false else { return false }
guard showError && isEnabled && errorText?.isEmpty == false else { return false }
return true
}
@ -191,7 +191,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
selectorView.showError = showError
selectorView.isSelected = isSelected
selectorView.isHighlighted = isHighlighted
selectorView.disabled = disabled
selectorView.isEnabled = isEnabled
selectorView.surface = surface
}
@ -238,7 +237,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
//top label
if let labelText {
label.surface = surface
label.disabled = disabled
label.isEnabled = isEnabled
label.attributes = labelTextAttributes
label.text = labelText
@ -254,7 +252,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
if let childText {
childLabel.text = childText
childLabel.surface = surface
childLabel.disabled = disabled
childLabel.isEnabled = isEnabled
childLabel.attributes = childTextAttributes
childLabel.isHidden = false
@ -279,7 +276,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
if let errorText, shouldShowError {
errorLabel.text = errorText
errorLabel.surface = surface
errorLabel.disabled = disabled
errorLabel.isEnabled = isEnabled
mainStackView.spacing = 8
errorLabel.isHidden = false

View File

@ -33,16 +33,6 @@ open class View: UIView, ViewProtocol, UserInfoable {
/// Current Surface and this is used to pass down to child objects that implement Surfacable
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
/// Whether this object is disabled or not.
open var disabled: Bool {
get { !isEnabled }
set {
if !isEnabled != newValue {
isEnabled = !newValue
}
}
}
/// Whether the View is enabled or not.
open var isEnabled: Bool = true { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
@ -101,7 +91,7 @@ open class View: UIView, ViewProtocol, UserInfoable {
open func reset() {
backgroundColor = .clear
surface = .light
disabled = false
isEnabled = true
}
}

View File

@ -157,7 +157,6 @@ open class Badge: View {
label.numberOfLines = numberOfLines
label.text = text
label.surface = surface
label.disabled = disabled
label.isEnabled = isEnabled
}
}

View File

@ -341,7 +341,6 @@ open class BadgeIndicator: View {
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
label.text = getText()
label.surface = surface
label.disabled = disabled
label.isEnabled = isEnabled
label.sizeToFit()
setNeedsLayout()

View File

@ -11,7 +11,7 @@ import VDSColorTokens
import VDSFormControlsTokens
import Combine
public protocol Buttonable: UIControl, Surfaceable, Disabling, Enabling {
public protocol Buttonable: UIControl, Surfaceable, Enabling {
var availableSizes: [ButtonSize] { get }
var text: String? { get set }
var intrinsicContentSize: CGSize { get }
@ -83,16 +83,6 @@ open class ButtonBase: UIButton, Buttonable, ViewProtocol, UserInfoable, Clickab
}
}
}
/// Whether this object is disabled or not
open var disabled: Bool {
get { !isEnabled }
set {
if !isEnabled != newValue {
isEnabled = !newValue
}
}
}
/// Whether the Control is enabled or not.
open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
@ -144,7 +134,7 @@ open class ButtonBase: UIButton, Buttonable, ViewProtocol, UserInfoable, Clickab
open func reset() {
shouldUpdateView = false
surface = .light
disabled = false
isEnabled = true
text = nil
accessibilityCustomActions = []
shouldUpdateView = true

View File

@ -93,16 +93,6 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
//--------------------------------------------------
// MARK: - Overrides
//--------------------------------------------------
/// Whether this object is disabled or not
override open var disabled: Bool {
didSet {
buttons.forEach { button in
var b = button
b.disabled = disabled
}
}
}
/// Whether this object is enabled or not
override open var isEnabled: Bool {
didSet {

View File

@ -99,7 +99,7 @@ open class Checkbox: SelectorBase {
shapeLayer?.removeAllAnimations()
if isAnimated && !disabled && !isHighlighted {
if isAnimated && isEnabled && !isHighlighted {
let animateStrokeEnd = CABasicAnimation(keyPath: "strokeEnd")
animateStrokeEnd.timingFunction = CAMediaTimingFunction(name: .linear)
animateStrokeEnd.duration = 0.3

View File

@ -40,7 +40,6 @@ open class CheckboxGroup: SelectorGroupHandlerBase<CheckboxItem> {
if let selectorModels {
selectorViews = selectorModels.enumerated().map { index, model in
return CheckboxItem().with {
$0.disabled = model.disabled
$0.isEnabled = !model.disabled
$0.surface = model.surface
$0.inputId = model.inputId
@ -111,7 +110,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase<CheckboxItem> {
}
extension CheckboxGroup {
public struct CheckboxModel : Surfaceable, Disabling, Initable, FormFieldable, Errorable {
public struct CheckboxModel : Surfaceable, Initable, FormFieldable, Errorable {
/// Whether this object is disabled or not
public var disabled: Bool

View File

@ -54,17 +54,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
setNeedsUpdate()
}
}
/// Whether this object is disabled or not
open var disabled: Bool {
get { !isEnabled }
set {
if !isEnabled != newValue {
isEnabled = !newValue
}
}
}
/// Whether the View is enabled or not.
open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
@ -123,7 +113,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
open func reset() {
shouldUpdateView = false
surface = .light
disabled = false
isEnabled = true
attributes = nil
textStyle = .defaultStyle
textPosition = .left

View File

@ -43,7 +43,6 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
$0.subTextAttributes = model.subTextAttributes
$0.subTextRight = model.subText
$0.subTextRightAttributes = model.subTextAttributes
$0.disabled = model.disabled
$0.isEnabled = !model.disabled
$0.inputId = model.inputId
$0.isSelected = model.selected
@ -107,7 +106,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
}
extension RadioBoxGroup {
public struct RadioBoxModel: Surfaceable, Initable, Disabling, FormFieldable {
public struct RadioBoxModel: Surfaceable, Initable, FormFieldable {
/// Whether this object is disabled or not
public var disabled: Bool
/// Current Surface and this is used to pass down to child objects that implement Surfacable

View File

@ -187,7 +187,6 @@ open class RadioBoxItem: Control, Changeable {
//text label
textLabel.text = text
textLabel.surface = surface
textLabel.disabled = disabled
textLabel.isEnabled = isEnabled
textLabel.attributes = textAttributes
@ -195,7 +194,6 @@ open class RadioBoxItem: Control, Changeable {
if let subText {
subTextLabel.text = subText
subTextLabel.surface = surface
subTextLabel.disabled = disabled
subTextLabel.isEnabled = isEnabled
subTextLabel.attributes = subTextAttributes
subTextLabel.isHidden = false
@ -211,7 +209,6 @@ open class RadioBoxItem: Control, Changeable {
if let subTextRight {
subTextRightLabel.text = subTextRight
subTextRightLabel.surface = surface
subTextRightLabel.disabled = disabled
subTextRightLabel.isEnabled = isEnabled
subTextRightLabel.attributes = subTextRightAttributes
subTextRightLabel.isHidden = false

View File

@ -35,7 +35,6 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
if let selectorModels {
selectorViews = selectorModels.enumerated().map { index, model in
return RadioButtonItem().with {
$0.disabled = model.disabled
$0.isEnabled = !model.disabled
$0.surface = model.surface
$0.inputId = model.inputId
@ -115,7 +114,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
}
extension RadioButtonGroup {
public struct RadioButtonModel: Surfaceable, Disabling, Initable, FormFieldable, Errorable {
public struct RadioButtonModel: Surfaceable, Initable, FormFieldable, Errorable {
/// Whether this object is disabled or not
public var disabled: Bool

View File

@ -176,13 +176,13 @@ open class RadioSwatch: Control {
var fillColorBackground: UIColor = .clear
if let fillImage {
fillView.image = disabled ? fillImage.image(alpha: disabledAlpha) : fillImage
fillView.image = !isEnabled ? fillImage.image(alpha: disabledAlpha) : fillImage
} else {
fillView.image = nil
if let primary = primaryColor, let secondary = secondaryColor {
let firstColor = disabled ? primary.withAlphaComponent(disabledAlpha) : primary
let secondColor = disabled ? secondary.withAlphaComponent(disabledAlpha) : secondary
let firstColor = !isEnabled ? primary.withAlphaComponent(disabledAlpha) : primary
let secondColor = !isEnabled ? secondary.withAlphaComponent(disabledAlpha) : secondary
let gradient = CAGradientLayer()
gradientLayer = gradient
gradient.frame = fillView.bounds
@ -195,7 +195,7 @@ open class RadioSwatch: Control {
}
}
fillView.backgroundColor = disabled ? fillColorBackground.withAlphaComponent(disabledAlpha) : fillColorBackground
fillView.backgroundColor = !isEnabled ? fillColorBackground.withAlphaComponent(disabledAlpha) : fillColorBackground
fillView.layer.borderColor = fillBorderColor.cgColor
fillView.layer.cornerRadius = fillView.bounds.width * 0.5
fillView.layer.borderWidth = selectorBorderWidth

View File

@ -32,7 +32,6 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
$0.primaryColor = model.primaryColor
$0.secondaryColor = model.secondaryColor
$0.strikethrough = model.strikethrough
$0.disabled = model.disabled
$0.isEnabled = !model.disabled
$0.surface = model.surface
$0.inputId = model.inputId
@ -72,17 +71,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
//--------------------------------------------------
// MARK: - Overrides
//--------------------------------------------------
/// Whether this object is disabled or not
override public var disabled: Bool {
didSet {
for selector in selectorViews {
selector.disabled = disabled
}
collectionView.reloadData()
}
}
/// Whether this object is disabled or not
/// Whether this object is enabled or not
override public var isEnabled: Bool {
didSet {
for selector in selectorViews {
@ -144,7 +133,6 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
label.textStyle = .bodySmall
label.text = selectedHandler?.text ?? " "
label.surface = surface
label.disabled = disabled
label.isEnabled = isEnabled
collectionView.reloadData()
}
@ -206,7 +194,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
}
extension RadioSwatchGroup {
public struct RadioSwatchModel: Surfaceable, Disabling, Initable {
public struct RadioSwatchModel: Surfaceable, Initable {
/// Whether this object is disabled or not
public var disabled: Bool = false
/// Current Surface and this is used to pass down to child objects that implement Surfacable

View File

@ -163,7 +163,6 @@ open class TabsContainer: View {
contentViewWidthConstraint?.isActive = true
tabMenu.surface = surface
tabMenu.disabled = disabled
tabMenu.isEnabled = isEnabled
tabMenu.orientation = orientation
tabMenu.borderLine = borderLine

View File

@ -283,7 +283,7 @@ open class EntryField: Control, Changeable {
//dealing with the "Optional" addition to the text
if let oldText = updatedLabelText, !required, !oldText.hasSuffix("Optional") {
if !disabled {
if isEnabled {
let optionColorAttr = ColorLabelAttribute(location: oldText.count + 2,
length: 8,
color: VDSColor.elementsSecondaryOnlight)
@ -301,7 +301,6 @@ open class EntryField: Control, Changeable {
titleLabel.text = updatedLabelText
titleLabel.attributes = attributes
titleLabel.surface = surface
titleLabel.disabled = disabled
titleLabel.isEnabled = isEnabled
}
@ -309,13 +308,12 @@ open class EntryField: Control, Changeable {
if showError, let errorText {
errorLabel.text = errorText
errorLabel.surface = surface
errorLabel.disabled = disabled
errorLabel.isEnabled = isEnabled
errorLabel.isHidden = false
icon.name = .error
icon.color = VDSColor.paletteBlack
icon.surface = surface
icon.isHidden = disabled
icon.isHidden = !isEnabled
} else {
icon.isHidden = true
errorLabel.isHidden = true
@ -327,7 +325,6 @@ open class EntryField: Control, Changeable {
if let helperText {
helperLabel.text = helperText
helperLabel.surface = surface
helperLabel.disabled = disabled
helperLabel.isEnabled = isEnabled
helperLabel.isHidden = false
} else {

View File

@ -165,7 +165,7 @@ open class InputField: EntryField, UITextFieldDelegate {
open override func updateView() {
super.updateView()
textField.isEnabled = !disabled
textField.isEnabled = isEnabled
textField.textColor = textFieldTextColorConfiguration.getColor(self)
//show error or success
@ -175,14 +175,13 @@ open class InputField: EntryField, UITextFieldDelegate {
} else if showSuccess, let successText {
successLabel.text = successText
successLabel.surface = surface
successLabel.disabled = disabled
successLabel.isEnabled = isEnabled
successLabel.isHidden = false
errorLabel.isHidden = true
icon.name = .checkmarkAlt
icon.color = VDSColor.paletteBlack
icon.surface = surface
icon.isHidden = disabled
icon.isHidden = !isEnabled
} else {
icon.isHidden = true
successLabel.isHidden = true

View File

@ -95,7 +95,7 @@ open class TextArea: EntryField {
open override func updateView() {
super.updateView()
textView.isEditable = !disabled
textView.isEditable = isEnabled
textView.textColor = textViewTextColorConfiguration.getColor(self)
//set the width constraints

View File

@ -179,6 +179,7 @@ open class Toggle: Control, Changeable {
super.reset()
shouldUpdateView = false
label.reset()
isEnabled = true
isOn = false
isAnimated = true
showText = false
@ -199,7 +200,6 @@ open class Toggle: Control, Changeable {
updateLabel()
toggleView.surface = surface
toggleView.disabled = disabled
toggleView.isEnabled = isEnabled
toggleView.isOn = isOn
}
@ -235,7 +235,6 @@ open class Toggle: Control, Changeable {
label.textStyle = textStyle
label.text = statusText
label.surface = surface
label.disabled = disabled
label.isEnabled = isEnabled
switch textPosition {
case .left:

View File

@ -215,7 +215,7 @@ open class ToggleView: Control, Changeable {
shadowLayer1.backgroundColor = knobColor.cgColor
shadowLayer2.backgroundColor = knobColor.cgColor
if disabled || !isAnimated {
if !isEnabled || !isAnimated {
toggleView.backgroundColor = toggleColor
knobView.backgroundColor = knobColor
constrainKnob()

View File

@ -71,7 +71,6 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
label.textPosition = labelTextPosition
label.attributes = labelAttributes
label.surface = surface
label.disabled = disabled
label.isEnabled = isEnabled
//add tooltip

View File

@ -7,8 +7,8 @@
import Foundation
/// Any object that can be disabled, which may change the appearance
public protocol Disabling {
/// Whether this object is disabled or not
var disabled: Bool { get set }
}
///// Any object that can be disabled, which may change the appearance
//public protocol Disabling {
// /// Whether this object is disabled or not
// var disabled: Bool { get set }
//}

View File

@ -9,7 +9,7 @@ import Foundation
import UIKit
import Combine
public protocol ViewProtocol: AnyObject, Initable, Resettable, Disabling, Enabling, Surfaceable {
public protocol ViewProtocol: AnyObject, Initable, Resettable, Enabling, Surfaceable {
/// Set of Subscribers for any Publishers for this Control.
var subscribers: Set<AnyCancellable> { get set }