Signed-off-by: Matt Bruce <matt.bruce@verizon.com>

This commit is contained in:
Matt Bruce 2023-08-25 16:12:50 -05:00
parent a6a0003c3b
commit e3f998de9f
18 changed files with 36 additions and 53 deletions

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() } }
@ -79,7 +69,12 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
}
/// Whether the Control is enabled or not.
open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
open override var isEnabled: Bool {
didSet {
setNeedsUpdate()
//isUserInteractionEnabled = isEnabled
}
}
//--------------------------------------------------
// MARK: - Initializers
@ -140,7 +135,7 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
open func reset() {
backgroundColor = .clear
surface = .light
disabled = false
isEnabled = true
}
//--------------------------------------------------

View File

@ -27,22 +27,11 @@ 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
handler.isEnabled = isEnabled
}
selectorViews.forEach { $0.isEnabled = isEnabled }
}
}

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,7 @@ 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
}

View File

@ -44,7 +44,7 @@ open class View: UIView, ViewProtocol, UserInfoable {
}
/// Whether the View is enabled or not.
open var isEnabled: Bool = true { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
open var isEnabled: Bool = true { didSet { setNeedsUpdate() } }
//--------------------------------------------------
// MARK: - Initializers
@ -101,7 +101,7 @@ open class View: UIView, ViewProtocol, UserInfoable {
open func reset() {
backgroundColor = .clear
surface = .light
disabled = false
isEnabled = true
}
}

View File

@ -85,7 +85,7 @@ open class ButtonBase: UIButton, Buttonable, ViewProtocol, UserInfoable, Clickab
}
/// Whether the Control is enabled or not.
open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
open override var isEnabled: Bool { didSet { setNeedsUpdate() } }
open var textStyle: TextStyle { .defaultStyle }

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,7 @@ 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
$0.value = model.value

View File

@ -56,7 +56,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
}
/// Whether the View is enabled or not.
open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
open override var isEnabled: Bool { didSet { setNeedsUpdate() } }
//--------------------------------------------------
// MARK: - Configuration Properties

View File

@ -43,7 +43,7 @@ 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
}

View File

@ -35,7 +35,7 @@ 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
$0.value = model.value

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,7 @@ 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
$0.value = model.value
@ -72,14 +72,13 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
// MARK: - Overrides
//--------------------------------------------------
/// Whether this object is disabled or not
override public var disabled: Bool {
override public var isEnabled: Bool {
didSet {
for selector in selectorViews {
selector.disabled = disabled
}
selectorViews.forEach { $0.isEnabled = isEnabled }
collectionView.reloadData()
}
}
/// Current Surface and this is used to pass down to child objects that implement Surfacable
override public var surface: Surface {
didSet {
@ -151,7 +150,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
// MARK: - UICollectionViewDelegate
//--------------------------------------------------
open func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
return !selectorViews[indexPath.row].disabled
return selectorViews[indexPath.row].isEnabled
}
open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {

View File

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

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)
@ -314,7 +314,7 @@ open class EntryField: Control, Changeable {
icon.name = .error
icon.color = VDSColor.paletteBlack
icon.surface = surface
icon.isHidden = disabled
icon.isHidden = !isEnabled
} else {
icon.isHidden = true
errorLabel.isHidden = true

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
@ -181,7 +181,7 @@ open class InputField: EntryField, UITextFieldDelegate {
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

@ -199,7 +199,7 @@ open class Toggle: Control, Changeable {
updateLabel()
toggleView.surface = surface
toggleView.disabled = disabled
toggleView.isEnabled = isEnabled
toggleView.isOn = isOn
}

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()