added isEnabled for setters where disabled is set
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
8489ba9085
commit
5811fa7a01
@ -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.
|
///Meant to be used with any object that implements Surfaceable and Disabling. More than likely this is any View.
|
||||||
public class ViewColorConfiguration: KeyColorConfigurable {
|
public class ViewColorConfiguration: KeyColorConfigurable {
|
||||||
public typealias KeyType = Bool
|
public typealias KeyType = Bool
|
||||||
public typealias ObjectType = Surfaceable & Disabling
|
public typealias ObjectType = Surfaceable & Disabling & Enabling
|
||||||
public var keyColors: [KeyColorConfiguration<KeyType>] = []
|
public var keyColors: [KeyColorConfiguration<KeyType>] = []
|
||||||
|
|
||||||
public required init() { }
|
public required init() { }
|
||||||
@ -161,7 +161,7 @@ public class ViewColorConfiguration: KeyColorConfigurable {
|
|||||||
/// - Parameter object: Object that implements Surfaceable and Disabling
|
/// - Parameter object: Object that implements Surfaceable and Disabling
|
||||||
/// - Returns: UIColor correspoding to either true/false for the disabled state and surface
|
/// - Returns: UIColor correspoding to either true/false for the disabled state and surface
|
||||||
public func getColor(_ object: ObjectType) -> UIColor {
|
public func getColor(_ object: ObjectType) -> UIColor {
|
||||||
if let keyColor = keyColors.first(where: {$0.key == object.disabled }) {
|
if let keyColor = keyColors.first(where: {$0.key == !object.isEnabled }) {
|
||||||
return keyColor.surfaceConfig.getColor(object)
|
return keyColor.surfaceConfig.getColor(object)
|
||||||
} else {
|
} else {
|
||||||
return .clear //default
|
return .clear //default
|
||||||
|
|||||||
@ -37,6 +37,14 @@ open class SelectorGroupHandlerBase<HandlerType: Control>: Control, Changeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override open var isEnabled: Bool {
|
||||||
|
didSet {
|
||||||
|
selectorViews.forEach { handler in
|
||||||
|
handler.isEnabled = isEnabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 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 open var surface: Surface {
|
override open var surface: Surface {
|
||||||
didSet {
|
didSet {
|
||||||
|
|||||||
@ -192,6 +192,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
selectorView.isSelected = isSelected
|
selectorView.isSelected = isSelected
|
||||||
selectorView.isHighlighted = isHighlighted
|
selectorView.isHighlighted = isHighlighted
|
||||||
selectorView.disabled = disabled
|
selectorView.disabled = disabled
|
||||||
|
selectorView.isEnabled = isEnabled
|
||||||
selectorView.surface = surface
|
selectorView.surface = surface
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,6 +239,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
if let labelText {
|
if let labelText {
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
label.disabled = disabled
|
||||||
|
label.isEnabled = isEnabled
|
||||||
label.attributes = labelTextAttributes
|
label.attributes = labelTextAttributes
|
||||||
label.text = labelText
|
label.text = labelText
|
||||||
label.isHidden = false
|
label.isHidden = false
|
||||||
@ -253,6 +255,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
childLabel.text = childText
|
childLabel.text = childText
|
||||||
childLabel.surface = surface
|
childLabel.surface = surface
|
||||||
childLabel.disabled = disabled
|
childLabel.disabled = disabled
|
||||||
|
childLabel.isEnabled = isEnabled
|
||||||
childLabel.attributes = childTextAttributes
|
childLabel.attributes = childTextAttributes
|
||||||
childLabel.isHidden = false
|
childLabel.isHidden = false
|
||||||
|
|
||||||
@ -277,6 +280,7 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
errorLabel.text = errorText
|
errorLabel.text = errorText
|
||||||
errorLabel.surface = surface
|
errorLabel.surface = surface
|
||||||
errorLabel.disabled = disabled
|
errorLabel.disabled = disabled
|
||||||
|
errorLabel.isEnabled = isEnabled
|
||||||
mainStackView.spacing = 8
|
mainStackView.spacing = 8
|
||||||
errorLabel.isHidden = false
|
errorLabel.isHidden = false
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -158,5 +158,6 @@ open class Badge: View {
|
|||||||
label.text = text
|
label.text = text
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
label.disabled = disabled
|
||||||
|
label.isEnabled = isEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -342,6 +342,7 @@ open class BadgeIndicator: View {
|
|||||||
label.text = getText()
|
label.text = getText()
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
label.disabled = disabled
|
||||||
|
label.isEnabled = isEnabled
|
||||||
label.sizeToFit()
|
label.sizeToFit()
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
layoutIfNeeded()
|
layoutIfNeeded()
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import VDSColorTokens
|
|||||||
import VDSFormControlsTokens
|
import VDSFormControlsTokens
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
public protocol Buttonable: UIControl, Surfaceable, Disabling {
|
public protocol Buttonable: UIControl, Surfaceable, Disabling, Enabling {
|
||||||
var availableSizes: [ButtonSize] { get }
|
var availableSizes: [ButtonSize] { get }
|
||||||
var text: String? { get set }
|
var text: String? { get set }
|
||||||
var intrinsicContentSize: CGSize { get }
|
var intrinsicContentSize: CGSize { get }
|
||||||
|
|||||||
@ -103,6 +103,16 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether this object is enabled or not
|
||||||
|
override open var isEnabled: Bool {
|
||||||
|
didSet {
|
||||||
|
buttons.forEach { button in
|
||||||
|
var b = button
|
||||||
|
b.isEnabled = isEnabled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// 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 open var surface: Surface {
|
override open var surface: Surface {
|
||||||
didSet {
|
didSet {
|
||||||
|
|||||||
@ -41,6 +41,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase<CheckboxItem> {
|
|||||||
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.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
|
||||||
|
|||||||
@ -44,6 +44,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
|
|||||||
$0.subTextRight = model.subText
|
$0.subTextRight = model.subText
|
||||||
$0.subTextRightAttributes = model.subTextAttributes
|
$0.subTextRightAttributes = model.subTextAttributes
|
||||||
$0.disabled = model.disabled
|
$0.disabled = model.disabled
|
||||||
|
$0.isEnabled = !model.disabled
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.isSelected = model.selected
|
$0.isSelected = model.selected
|
||||||
}
|
}
|
||||||
|
|||||||
@ -188,6 +188,7 @@ open class RadioBoxItem: Control, Changeable {
|
|||||||
textLabel.text = text
|
textLabel.text = text
|
||||||
textLabel.surface = surface
|
textLabel.surface = surface
|
||||||
textLabel.disabled = disabled
|
textLabel.disabled = disabled
|
||||||
|
textLabel.isEnabled = isEnabled
|
||||||
textLabel.attributes = textAttributes
|
textLabel.attributes = textAttributes
|
||||||
|
|
||||||
//subText label
|
//subText label
|
||||||
@ -195,6 +196,7 @@ open class RadioBoxItem: Control, Changeable {
|
|||||||
subTextLabel.text = subText
|
subTextLabel.text = subText
|
||||||
subTextLabel.surface = surface
|
subTextLabel.surface = surface
|
||||||
subTextLabel.disabled = disabled
|
subTextLabel.disabled = disabled
|
||||||
|
subTextLabel.isEnabled = isEnabled
|
||||||
subTextLabel.attributes = subTextAttributes
|
subTextLabel.attributes = subTextAttributes
|
||||||
subTextLabel.isHidden = false
|
subTextLabel.isHidden = false
|
||||||
|
|
||||||
@ -210,6 +212,7 @@ open class RadioBoxItem: Control, Changeable {
|
|||||||
subTextRightLabel.text = subTextRight
|
subTextRightLabel.text = subTextRight
|
||||||
subTextRightLabel.surface = surface
|
subTextRightLabel.surface = surface
|
||||||
subTextRightLabel.disabled = disabled
|
subTextRightLabel.disabled = disabled
|
||||||
|
subTextRightLabel.isEnabled = isEnabled
|
||||||
subTextRightLabel.attributes = subTextRightAttributes
|
subTextRightLabel.attributes = subTextRightAttributes
|
||||||
subTextRightLabel.isHidden = false
|
subTextRightLabel.isHidden = false
|
||||||
|
|
||||||
|
|||||||
@ -36,6 +36,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
|
|||||||
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.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
|
||||||
|
|||||||
@ -33,6 +33,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
$0.secondaryColor = model.secondaryColor
|
$0.secondaryColor = model.secondaryColor
|
||||||
$0.strikethrough = model.strikethrough
|
$0.strikethrough = model.strikethrough
|
||||||
$0.disabled = model.disabled
|
$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
|
||||||
@ -80,6 +81,17 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
collectionView.reloadData()
|
collectionView.reloadData()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether this object is disabled or not
|
||||||
|
override public var isEnabled: Bool {
|
||||||
|
didSet {
|
||||||
|
for selector in selectorViews {
|
||||||
|
selector.isEnabled = isEnabled
|
||||||
|
}
|
||||||
|
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 {
|
||||||
@ -133,6 +145,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
label.text = selectedHandler?.text ?? " "
|
label.text = selectedHandler?.text ?? " "
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
label.disabled = disabled
|
||||||
|
label.isEnabled = isEnabled
|
||||||
collectionView.reloadData()
|
collectionView.reloadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +164,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) {
|
||||||
|
|||||||
@ -164,6 +164,7 @@ open class TabsContainer: View {
|
|||||||
|
|
||||||
tabMenu.surface = surface
|
tabMenu.surface = surface
|
||||||
tabMenu.disabled = disabled
|
tabMenu.disabled = disabled
|
||||||
|
tabMenu.isEnabled = isEnabled
|
||||||
tabMenu.orientation = orientation
|
tabMenu.orientation = orientation
|
||||||
tabMenu.borderLine = borderLine
|
tabMenu.borderLine = borderLine
|
||||||
tabMenu.fillContainer = fillContainer
|
tabMenu.fillContainer = fillContainer
|
||||||
|
|||||||
@ -302,7 +302,7 @@ open class EntryField: Control, Changeable {
|
|||||||
titleLabel.attributes = attributes
|
titleLabel.attributes = attributes
|
||||||
titleLabel.surface = surface
|
titleLabel.surface = surface
|
||||||
titleLabel.disabled = disabled
|
titleLabel.disabled = disabled
|
||||||
|
titleLabel.isEnabled = isEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
open func updateErrorLabel(){
|
open func updateErrorLabel(){
|
||||||
@ -310,6 +310,7 @@ open class EntryField: Control, Changeable {
|
|||||||
errorLabel.text = errorText
|
errorLabel.text = errorText
|
||||||
errorLabel.surface = surface
|
errorLabel.surface = surface
|
||||||
errorLabel.disabled = disabled
|
errorLabel.disabled = disabled
|
||||||
|
errorLabel.isEnabled = isEnabled
|
||||||
errorLabel.isHidden = false
|
errorLabel.isHidden = false
|
||||||
icon.name = .error
|
icon.name = .error
|
||||||
icon.color = VDSColor.paletteBlack
|
icon.color = VDSColor.paletteBlack
|
||||||
@ -327,6 +328,7 @@ open class EntryField: Control, Changeable {
|
|||||||
helperLabel.text = helperText
|
helperLabel.text = helperText
|
||||||
helperLabel.surface = surface
|
helperLabel.surface = surface
|
||||||
helperLabel.disabled = disabled
|
helperLabel.disabled = disabled
|
||||||
|
helperLabel.isEnabled = isEnabled
|
||||||
helperLabel.isHidden = false
|
helperLabel.isHidden = false
|
||||||
} else {
|
} else {
|
||||||
helperLabel.isHidden = true
|
helperLabel.isHidden = true
|
||||||
|
|||||||
@ -176,6 +176,7 @@ open class InputField: EntryField, UITextFieldDelegate {
|
|||||||
successLabel.text = successText
|
successLabel.text = successText
|
||||||
successLabel.surface = surface
|
successLabel.surface = surface
|
||||||
successLabel.disabled = disabled
|
successLabel.disabled = disabled
|
||||||
|
successLabel.isEnabled = isEnabled
|
||||||
successLabel.isHidden = false
|
successLabel.isHidden = false
|
||||||
errorLabel.isHidden = true
|
errorLabel.isHidden = true
|
||||||
icon.name = .checkmarkAlt
|
icon.name = .checkmarkAlt
|
||||||
|
|||||||
@ -200,6 +200,7 @@ open class Toggle: Control, Changeable {
|
|||||||
updateLabel()
|
updateLabel()
|
||||||
toggleView.surface = surface
|
toggleView.surface = surface
|
||||||
toggleView.disabled = disabled
|
toggleView.disabled = disabled
|
||||||
|
toggleView.isEnabled = isEnabled
|
||||||
toggleView.isOn = isOn
|
toggleView.isOn = isOn
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +236,7 @@ open class Toggle: Control, Changeable {
|
|||||||
label.text = statusText
|
label.text = statusText
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
label.disabled = disabled
|
||||||
|
label.isEnabled = isEnabled
|
||||||
switch textPosition {
|
switch textPosition {
|
||||||
case .left:
|
case .left:
|
||||||
NSLayoutConstraint.deactivate(rightConstraints)
|
NSLayoutConstraint.deactivate(rightConstraints)
|
||||||
|
|||||||
@ -72,7 +72,8 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
label.attributes = labelAttributes
|
label.attributes = labelAttributes
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
label.disabled = disabled
|
||||||
|
label.isEnabled = isEnabled
|
||||||
|
|
||||||
//add tooltip
|
//add tooltip
|
||||||
if let labelText, !labelText.isEmpty {
|
if let labelText, !labelText.isEmpty {
|
||||||
label.addTooltip(model: .init(surface: surface, closeButtonText: tooltipCloseButtonText, title: tooltipTitle, content: tooltipContent, contentView: tooltipContentView))
|
label.addTooltip(model: .init(surface: surface, closeButtonText: tooltipCloseButtonText, title: tooltipTitle, content: tooltipContent, contentView: tooltipContentView))
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
public protocol ViewProtocol: AnyObject, Initable, Resettable, Disabling, Surfaceable {
|
public protocol ViewProtocol: AnyObject, Initable, Resettable, Disabling, Enabling, Surfaceable {
|
||||||
/// Set of Subscribers for any Publishers for this Control.
|
/// Set of Subscribers for any Publishers for this Control.
|
||||||
var subscribers: Set<AnyCancellable> { get set }
|
var subscribers: Set<AnyCancellable> { get set }
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user