Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
a6a0003c3b
commit
e3f998de9f
@ -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
|
/// Current Surface and this is used to pass down to child objects that implement Surfacable
|
||||||
open var surface: Surface = .light { didSet { setNeedsUpdate() } }
|
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.
|
/// Whether the Control is selected or not.
|
||||||
open override var isSelected: Bool { didSet { setNeedsUpdate() } }
|
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.
|
/// 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
|
// MARK: - Initializers
|
||||||
@ -140,7 +135,7 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
|
|||||||
open func reset() {
|
open func reset() {
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
surface = .light
|
surface = .light
|
||||||
disabled = false
|
isEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -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
|
/// Whether this object is enabled or not
|
||||||
override open var isEnabled: Bool {
|
override open var isEnabled: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
selectorViews.forEach { handler in
|
selectorViews.forEach { $0.isEnabled = isEnabled }
|
||||||
handler.isEnabled = isEnabled
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -33,7 +33,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
private var shouldShowError: Bool {
|
private var shouldShowError: Bool {
|
||||||
guard showError && !disabled && errorText?.isEmpty == false else { return false }
|
guard showError && isEnabled && errorText?.isEmpty == false else { return false }
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +191,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
selectorView.showError = showError
|
selectorView.showError = showError
|
||||||
selectorView.isSelected = isSelected
|
selectorView.isSelected = isSelected
|
||||||
selectorView.isHighlighted = isHighlighted
|
selectorView.isHighlighted = isHighlighted
|
||||||
selectorView.disabled = disabled
|
selectorView.isEnabled = isEnabled
|
||||||
selectorView.surface = surface
|
selectorView.surface = surface
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -44,7 +44,7 @@ open class View: UIView, ViewProtocol, UserInfoable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the View is enabled or not.
|
/// 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
|
// MARK: - Initializers
|
||||||
@ -101,7 +101,7 @@ open class View: UIView, ViewProtocol, UserInfoable {
|
|||||||
open func reset() {
|
open func reset() {
|
||||||
backgroundColor = .clear
|
backgroundColor = .clear
|
||||||
surface = .light
|
surface = .light
|
||||||
disabled = false
|
isEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,7 +85,7 @@ open class ButtonBase: UIButton, Buttonable, ViewProtocol, UserInfoable, Clickab
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the Control is enabled or not.
|
/// 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 }
|
open var textStyle: TextStyle { .defaultStyle }
|
||||||
|
|
||||||
|
|||||||
@ -99,7 +99,7 @@ open class Checkbox: SelectorBase {
|
|||||||
|
|
||||||
shapeLayer?.removeAllAnimations()
|
shapeLayer?.removeAllAnimations()
|
||||||
|
|
||||||
if isAnimated && !disabled && !isHighlighted {
|
if isAnimated && isEnabled && !isHighlighted {
|
||||||
let animateStrokeEnd = CABasicAnimation(keyPath: "strokeEnd")
|
let animateStrokeEnd = CABasicAnimation(keyPath: "strokeEnd")
|
||||||
animateStrokeEnd.timingFunction = CAMediaTimingFunction(name: .linear)
|
animateStrokeEnd.timingFunction = CAMediaTimingFunction(name: .linear)
|
||||||
animateStrokeEnd.duration = 0.3
|
animateStrokeEnd.duration = 0.3
|
||||||
|
|||||||
@ -40,7 +40,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase<CheckboxItem> {
|
|||||||
if let selectorModels {
|
if let selectorModels {
|
||||||
selectorViews = selectorModels.enumerated().map { index, model in
|
selectorViews = selectorModels.enumerated().map { index, model in
|
||||||
return CheckboxItem().with {
|
return CheckboxItem().with {
|
||||||
$0.disabled = model.disabled
|
$0.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.value = model.value
|
$0.value = model.value
|
||||||
|
|||||||
@ -56,7 +56,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the View is enabled or not.
|
/// 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
|
// MARK: - Configuration Properties
|
||||||
|
|||||||
@ -43,7 +43,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
|
|||||||
$0.subTextAttributes = model.subTextAttributes
|
$0.subTextAttributes = model.subTextAttributes
|
||||||
$0.subTextRight = model.subText
|
$0.subTextRight = model.subText
|
||||||
$0.subTextRightAttributes = model.subTextAttributes
|
$0.subTextRightAttributes = model.subTextAttributes
|
||||||
$0.disabled = model.disabled
|
$0.isEnabled = !model.disabled
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.isSelected = model.selected
|
$0.isSelected = model.selected
|
||||||
}
|
}
|
||||||
|
|||||||
@ -35,7 +35,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
|
|||||||
if let selectorModels {
|
if let selectorModels {
|
||||||
selectorViews = selectorModels.enumerated().map { index, model in
|
selectorViews = selectorModels.enumerated().map { index, model in
|
||||||
return RadioButtonItem().with {
|
return RadioButtonItem().with {
|
||||||
$0.disabled = model.disabled
|
$0.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.value = model.value
|
$0.value = model.value
|
||||||
|
|||||||
@ -176,13 +176,13 @@ open class RadioSwatch: Control {
|
|||||||
var fillColorBackground: UIColor = .clear
|
var fillColorBackground: UIColor = .clear
|
||||||
|
|
||||||
if let fillImage {
|
if let fillImage {
|
||||||
fillView.image = disabled ? fillImage.image(alpha: disabledAlpha) : fillImage
|
fillView.image = !isEnabled ? fillImage.image(alpha: disabledAlpha) : fillImage
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
fillView.image = nil
|
fillView.image = nil
|
||||||
if let primary = primaryColor, let secondary = secondaryColor {
|
if let primary = primaryColor, let secondary = secondaryColor {
|
||||||
let firstColor = disabled ? primary.withAlphaComponent(disabledAlpha) : primary
|
let firstColor = !isEnabled ? primary.withAlphaComponent(disabledAlpha) : primary
|
||||||
let secondColor = disabled ? secondary.withAlphaComponent(disabledAlpha) : secondary
|
let secondColor = !isEnabled ? secondary.withAlphaComponent(disabledAlpha) : secondary
|
||||||
let gradient = CAGradientLayer()
|
let gradient = CAGradientLayer()
|
||||||
gradientLayer = gradient
|
gradientLayer = gradient
|
||||||
gradient.frame = fillView.bounds
|
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.borderColor = fillBorderColor.cgColor
|
||||||
fillView.layer.cornerRadius = fillView.bounds.width * 0.5
|
fillView.layer.cornerRadius = fillView.bounds.width * 0.5
|
||||||
fillView.layer.borderWidth = selectorBorderWidth
|
fillView.layer.borderWidth = selectorBorderWidth
|
||||||
|
|||||||
@ -32,7 +32,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
$0.primaryColor = model.primaryColor
|
$0.primaryColor = model.primaryColor
|
||||||
$0.secondaryColor = model.secondaryColor
|
$0.secondaryColor = model.secondaryColor
|
||||||
$0.strikethrough = model.strikethrough
|
$0.strikethrough = model.strikethrough
|
||||||
$0.disabled = model.disabled
|
$0.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.value = model.value
|
$0.value = model.value
|
||||||
@ -72,14 +72,13 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is disabled or not
|
||||||
override public var disabled: Bool {
|
override public var isEnabled: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
for selector in selectorViews {
|
selectorViews.forEach { $0.isEnabled = isEnabled }
|
||||||
selector.disabled = disabled
|
|
||||||
}
|
|
||||||
collectionView.reloadData()
|
collectionView.reloadData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Current Surface and this is used to pass down to child objects that implement Surfacable
|
/// Current Surface and this is used to pass down to child objects that implement Surfacable
|
||||||
override public var surface: Surface {
|
override public var surface: Surface {
|
||||||
didSet {
|
didSet {
|
||||||
@ -151,7 +150,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
// MARK: - UICollectionViewDelegate
|
// MARK: - UICollectionViewDelegate
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open func collectionView(_ collectionView: UICollectionView, shouldSelectItemAt indexPath: IndexPath) -> Bool {
|
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) {
|
open func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
|
||||||
|
|||||||
@ -163,7 +163,7 @@ open class TabsContainer: View {
|
|||||||
contentViewWidthConstraint?.isActive = true
|
contentViewWidthConstraint?.isActive = true
|
||||||
|
|
||||||
tabMenu.surface = surface
|
tabMenu.surface = surface
|
||||||
tabMenu.disabled = disabled
|
tabMenu.isEnabled = isEnabled
|
||||||
tabMenu.orientation = orientation
|
tabMenu.orientation = orientation
|
||||||
tabMenu.borderLine = borderLine
|
tabMenu.borderLine = borderLine
|
||||||
tabMenu.fillContainer = fillContainer
|
tabMenu.fillContainer = fillContainer
|
||||||
|
|||||||
@ -283,7 +283,7 @@ open class EntryField: Control, Changeable {
|
|||||||
|
|
||||||
//dealing with the "Optional" addition to the text
|
//dealing with the "Optional" addition to the text
|
||||||
if let oldText = updatedLabelText, !required, !oldText.hasSuffix("Optional") {
|
if let oldText = updatedLabelText, !required, !oldText.hasSuffix("Optional") {
|
||||||
if !disabled {
|
if isEnabled {
|
||||||
let optionColorAttr = ColorLabelAttribute(location: oldText.count + 2,
|
let optionColorAttr = ColorLabelAttribute(location: oldText.count + 2,
|
||||||
length: 8,
|
length: 8,
|
||||||
color: VDSColor.elementsSecondaryOnlight)
|
color: VDSColor.elementsSecondaryOnlight)
|
||||||
@ -314,7 +314,7 @@ open class EntryField: Control, Changeable {
|
|||||||
icon.name = .error
|
icon.name = .error
|
||||||
icon.color = VDSColor.paletteBlack
|
icon.color = VDSColor.paletteBlack
|
||||||
icon.surface = surface
|
icon.surface = surface
|
||||||
icon.isHidden = disabled
|
icon.isHidden = !isEnabled
|
||||||
} else {
|
} else {
|
||||||
icon.isHidden = true
|
icon.isHidden = true
|
||||||
errorLabel.isHidden = true
|
errorLabel.isHidden = true
|
||||||
|
|||||||
@ -165,7 +165,7 @@ open class InputField: EntryField, UITextFieldDelegate {
|
|||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
|
|
||||||
textField.isEnabled = !disabled
|
textField.isEnabled = isEnabled
|
||||||
textField.textColor = textFieldTextColorConfiguration.getColor(self)
|
textField.textColor = textFieldTextColorConfiguration.getColor(self)
|
||||||
|
|
||||||
//show error or success
|
//show error or success
|
||||||
@ -181,7 +181,7 @@ open class InputField: EntryField, UITextFieldDelegate {
|
|||||||
icon.name = .checkmarkAlt
|
icon.name = .checkmarkAlt
|
||||||
icon.color = VDSColor.paletteBlack
|
icon.color = VDSColor.paletteBlack
|
||||||
icon.surface = surface
|
icon.surface = surface
|
||||||
icon.isHidden = disabled
|
icon.isHidden = !isEnabled
|
||||||
} else {
|
} else {
|
||||||
icon.isHidden = true
|
icon.isHidden = true
|
||||||
successLabel.isHidden = true
|
successLabel.isHidden = true
|
||||||
|
|||||||
@ -95,7 +95,7 @@ open class TextArea: EntryField {
|
|||||||
open override func updateView() {
|
open override func updateView() {
|
||||||
super.updateView()
|
super.updateView()
|
||||||
|
|
||||||
textView.isEditable = !disabled
|
textView.isEditable = isEnabled
|
||||||
textView.textColor = textViewTextColorConfiguration.getColor(self)
|
textView.textColor = textViewTextColorConfiguration.getColor(self)
|
||||||
|
|
||||||
//set the width constraints
|
//set the width constraints
|
||||||
|
|||||||
@ -199,7 +199,7 @@ open class Toggle: Control, Changeable {
|
|||||||
|
|
||||||
updateLabel()
|
updateLabel()
|
||||||
toggleView.surface = surface
|
toggleView.surface = surface
|
||||||
toggleView.disabled = disabled
|
toggleView.isEnabled = isEnabled
|
||||||
toggleView.isOn = isOn
|
toggleView.isOn = isOn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -215,7 +215,7 @@ open class ToggleView: Control, Changeable {
|
|||||||
shadowLayer1.backgroundColor = knobColor.cgColor
|
shadowLayer1.backgroundColor = knobColor.cgColor
|
||||||
shadowLayer2.backgroundColor = knobColor.cgColor
|
shadowLayer2.backgroundColor = knobColor.cgColor
|
||||||
|
|
||||||
if disabled || !isAnimated {
|
if !isEnabled || !isAnimated {
|
||||||
toggleView.backgroundColor = toggleColor
|
toggleView.backgroundColor = toggleColor
|
||||||
knobView.backgroundColor = knobColor
|
knobView.backgroundColor = knobColor
|
||||||
constrainKnob()
|
constrainKnob()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user