removed disabled
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
5811fa7a01
commit
7f461e72e9
@ -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 & Enabling
|
public typealias ObjectType = Surfaceable & Enabling
|
||||||
public var keyColors: [KeyColorConfiguration<KeyType>] = []
|
public var keyColors: [KeyColorConfiguration<KeyType>] = []
|
||||||
|
|
||||||
public required init() { }
|
public required init() { }
|
||||||
|
|||||||
@ -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() } }
|
||||||
|
|
||||||
@ -140,7 +130,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
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
|
|||||||
@ -28,15 +28,7 @@ open class SelectorGroupHandlerBase<HandlerType: Control>: Control, Changeable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is enabled or not
|
||||||
override open var disabled: Bool {
|
|
||||||
didSet {
|
|
||||||
selectorViews.forEach { handler in
|
|
||||||
handler.disabled = disabled
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override open var isEnabled: Bool {
|
override open var isEnabled: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
selectorViews.forEach { handler in
|
selectorViews.forEach { handler in
|
||||||
|
|||||||
@ -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,6 @@ 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.isEnabled = isEnabled
|
||||||
selectorView.surface = surface
|
selectorView.surface = surface
|
||||||
}
|
}
|
||||||
@ -238,7 +237,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
//top label
|
//top label
|
||||||
if let labelText {
|
if let labelText {
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
|
||||||
label.isEnabled = isEnabled
|
label.isEnabled = isEnabled
|
||||||
label.attributes = labelTextAttributes
|
label.attributes = labelTextAttributes
|
||||||
label.text = labelText
|
label.text = labelText
|
||||||
@ -254,7 +252,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
if let childText {
|
if let childText {
|
||||||
childLabel.text = childText
|
childLabel.text = childText
|
||||||
childLabel.surface = surface
|
childLabel.surface = surface
|
||||||
childLabel.disabled = disabled
|
|
||||||
childLabel.isEnabled = isEnabled
|
childLabel.isEnabled = isEnabled
|
||||||
childLabel.attributes = childTextAttributes
|
childLabel.attributes = childTextAttributes
|
||||||
childLabel.isHidden = false
|
childLabel.isHidden = false
|
||||||
@ -279,7 +276,6 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
|
|||||||
if let errorText, shouldShowError {
|
if let errorText, shouldShowError {
|
||||||
errorLabel.text = errorText
|
errorLabel.text = errorText
|
||||||
errorLabel.surface = surface
|
errorLabel.surface = surface
|
||||||
errorLabel.disabled = disabled
|
|
||||||
errorLabel.isEnabled = isEnabled
|
errorLabel.isEnabled = isEnabled
|
||||||
mainStackView.spacing = 8
|
mainStackView.spacing = 8
|
||||||
errorLabel.isHidden = false
|
errorLabel.isHidden = false
|
||||||
|
|||||||
@ -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
|
/// 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 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(); isUserInteractionEnabled = isEnabled } }
|
||||||
|
|
||||||
@ -101,7 +91,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
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -157,7 +157,6 @@ open class Badge: View {
|
|||||||
label.numberOfLines = numberOfLines
|
label.numberOfLines = numberOfLines
|
||||||
label.text = text
|
label.text = text
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
|
||||||
label.isEnabled = isEnabled
|
label.isEnabled = isEnabled
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -341,7 +341,6 @@ open class BadgeIndicator: View {
|
|||||||
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
label.textColorConfiguration = textColorConfiguration.eraseToAnyColorable()
|
||||||
label.text = getText()
|
label.text = getText()
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
|
||||||
label.isEnabled = isEnabled
|
label.isEnabled = isEnabled
|
||||||
label.sizeToFit()
|
label.sizeToFit()
|
||||||
setNeedsLayout()
|
setNeedsLayout()
|
||||||
|
|||||||
@ -11,7 +11,7 @@ import VDSColorTokens
|
|||||||
import VDSFormControlsTokens
|
import VDSFormControlsTokens
|
||||||
import Combine
|
import Combine
|
||||||
|
|
||||||
public protocol Buttonable: UIControl, Surfaceable, Disabling, Enabling {
|
public protocol Buttonable: UIControl, Surfaceable, 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 }
|
||||||
@ -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.
|
/// 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 } }
|
||||||
@ -144,7 +134,7 @@ open class ButtonBase: UIButton, Buttonable, ViewProtocol, UserInfoable, Clickab
|
|||||||
open func reset() {
|
open func reset() {
|
||||||
shouldUpdateView = false
|
shouldUpdateView = false
|
||||||
surface = .light
|
surface = .light
|
||||||
disabled = false
|
isEnabled = true
|
||||||
text = nil
|
text = nil
|
||||||
accessibilityCustomActions = []
|
accessibilityCustomActions = []
|
||||||
shouldUpdateView = true
|
shouldUpdateView = true
|
||||||
|
|||||||
@ -93,16 +93,6 @@ open class ButtonGroup: View, UICollectionViewDataSource, UICollectionViewDelega
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// 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
|
/// Whether this object is enabled or not
|
||||||
override open var isEnabled: Bool {
|
override open var isEnabled: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
|
|||||||
@ -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,6 @@ 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.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
@ -111,7 +110,7 @@ open class CheckboxGroup: SelectorGroupHandlerBase<CheckboxItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension CheckboxGroup {
|
extension CheckboxGroup {
|
||||||
public struct CheckboxModel : Surfaceable, Disabling, Initable, FormFieldable, Errorable {
|
public struct CheckboxModel : Surfaceable, Initable, FormFieldable, Errorable {
|
||||||
|
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is disabled or not
|
||||||
public var disabled: Bool
|
public var disabled: Bool
|
||||||
|
|||||||
@ -54,17 +54,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
setNeedsUpdate()
|
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.
|
/// Whether the View is enabled or not.
|
||||||
open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
|
open override var isEnabled: Bool { didSet { setNeedsUpdate(); isUserInteractionEnabled = isEnabled } }
|
||||||
|
|
||||||
@ -123,7 +113,7 @@ open class Label: UILabel, ViewProtocol, UserInfoable {
|
|||||||
open func reset() {
|
open func reset() {
|
||||||
shouldUpdateView = false
|
shouldUpdateView = false
|
||||||
surface = .light
|
surface = .light
|
||||||
disabled = false
|
isEnabled = true
|
||||||
attributes = nil
|
attributes = nil
|
||||||
textStyle = .defaultStyle
|
textStyle = .defaultStyle
|
||||||
textPosition = .left
|
textPosition = .left
|
||||||
|
|||||||
@ -43,7 +43,6 @@ 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.isEnabled = !model.disabled
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
$0.isSelected = model.selected
|
$0.isSelected = model.selected
|
||||||
@ -107,7 +106,7 @@ open class RadioBoxGroup: SelectorGroupSelectedHandlerBase<RadioBoxItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension RadioBoxGroup {
|
extension RadioBoxGroup {
|
||||||
public struct RadioBoxModel: Surfaceable, Initable, Disabling, FormFieldable {
|
public struct RadioBoxModel: Surfaceable, Initable, FormFieldable {
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is disabled or not
|
||||||
public var disabled: Bool
|
public var disabled: Bool
|
||||||
/// 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
|
||||||
|
|||||||
@ -187,7 +187,6 @@ open class RadioBoxItem: Control, Changeable {
|
|||||||
//text label
|
//text label
|
||||||
textLabel.text = text
|
textLabel.text = text
|
||||||
textLabel.surface = surface
|
textLabel.surface = surface
|
||||||
textLabel.disabled = disabled
|
|
||||||
textLabel.isEnabled = isEnabled
|
textLabel.isEnabled = isEnabled
|
||||||
textLabel.attributes = textAttributes
|
textLabel.attributes = textAttributes
|
||||||
|
|
||||||
@ -195,7 +194,6 @@ open class RadioBoxItem: Control, Changeable {
|
|||||||
if let subText {
|
if let subText {
|
||||||
subTextLabel.text = subText
|
subTextLabel.text = subText
|
||||||
subTextLabel.surface = surface
|
subTextLabel.surface = surface
|
||||||
subTextLabel.disabled = disabled
|
|
||||||
subTextLabel.isEnabled = isEnabled
|
subTextLabel.isEnabled = isEnabled
|
||||||
subTextLabel.attributes = subTextAttributes
|
subTextLabel.attributes = subTextAttributes
|
||||||
subTextLabel.isHidden = false
|
subTextLabel.isHidden = false
|
||||||
@ -211,7 +209,6 @@ open class RadioBoxItem: Control, Changeable {
|
|||||||
if let subTextRight {
|
if let subTextRight {
|
||||||
subTextRightLabel.text = subTextRight
|
subTextRightLabel.text = subTextRight
|
||||||
subTextRightLabel.surface = surface
|
subTextRightLabel.surface = surface
|
||||||
subTextRightLabel.disabled = disabled
|
|
||||||
subTextRightLabel.isEnabled = isEnabled
|
subTextRightLabel.isEnabled = isEnabled
|
||||||
subTextRightLabel.attributes = subTextRightAttributes
|
subTextRightLabel.attributes = subTextRightAttributes
|
||||||
subTextRightLabel.isHidden = false
|
subTextRightLabel.isHidden = false
|
||||||
|
|||||||
@ -35,7 +35,6 @@ 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.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
@ -115,7 +114,7 @@ open class RadioButtonGroup: SelectorGroupSelectedHandlerBase<RadioButtonItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension RadioButtonGroup {
|
extension RadioButtonGroup {
|
||||||
public struct RadioButtonModel: Surfaceable, Disabling, Initable, FormFieldable, Errorable {
|
public struct RadioButtonModel: Surfaceable, Initable, FormFieldable, Errorable {
|
||||||
|
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is disabled or not
|
||||||
public var disabled: Bool
|
public var disabled: Bool
|
||||||
|
|||||||
@ -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,6 @@ 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.isEnabled = !model.disabled
|
||||||
$0.surface = model.surface
|
$0.surface = model.surface
|
||||||
$0.inputId = model.inputId
|
$0.inputId = model.inputId
|
||||||
@ -72,17 +71,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Overrides
|
// MARK: - Overrides
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is enabled or not
|
||||||
override public var disabled: Bool {
|
|
||||||
didSet {
|
|
||||||
for selector in selectorViews {
|
|
||||||
selector.disabled = disabled
|
|
||||||
}
|
|
||||||
collectionView.reloadData()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Whether this object is disabled or not
|
|
||||||
override public var isEnabled: Bool {
|
override public var isEnabled: Bool {
|
||||||
didSet {
|
didSet {
|
||||||
for selector in selectorViews {
|
for selector in selectorViews {
|
||||||
@ -144,7 +133,6 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
label.textStyle = .bodySmall
|
label.textStyle = .bodySmall
|
||||||
label.text = selectedHandler?.text ?? " "
|
label.text = selectedHandler?.text ?? " "
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
|
||||||
label.isEnabled = isEnabled
|
label.isEnabled = isEnabled
|
||||||
collectionView.reloadData()
|
collectionView.reloadData()
|
||||||
}
|
}
|
||||||
@ -206,7 +194,7 @@ open class RadioSwatchGroup: SelectorGroupSelectedHandlerBase<RadioSwatch>, UICo
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension RadioSwatchGroup {
|
extension RadioSwatchGroup {
|
||||||
public struct RadioSwatchModel: Surfaceable, Disabling, Initable {
|
public struct RadioSwatchModel: Surfaceable, Initable {
|
||||||
/// Whether this object is disabled or not
|
/// Whether this object is disabled or not
|
||||||
public var disabled: Bool = false
|
public var disabled: Bool = false
|
||||||
/// 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
|
||||||
|
|||||||
@ -163,7 +163,6 @@ open class TabsContainer: View {
|
|||||||
contentViewWidthConstraint?.isActive = true
|
contentViewWidthConstraint?.isActive = true
|
||||||
|
|
||||||
tabMenu.surface = surface
|
tabMenu.surface = surface
|
||||||
tabMenu.disabled = disabled
|
|
||||||
tabMenu.isEnabled = isEnabled
|
tabMenu.isEnabled = isEnabled
|
||||||
tabMenu.orientation = orientation
|
tabMenu.orientation = orientation
|
||||||
tabMenu.borderLine = borderLine
|
tabMenu.borderLine = borderLine
|
||||||
|
|||||||
@ -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)
|
||||||
@ -301,7 +301,6 @@ open class EntryField: Control, Changeable {
|
|||||||
titleLabel.text = updatedLabelText
|
titleLabel.text = updatedLabelText
|
||||||
titleLabel.attributes = attributes
|
titleLabel.attributes = attributes
|
||||||
titleLabel.surface = surface
|
titleLabel.surface = surface
|
||||||
titleLabel.disabled = disabled
|
|
||||||
titleLabel.isEnabled = isEnabled
|
titleLabel.isEnabled = isEnabled
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,13 +308,12 @@ open class EntryField: Control, Changeable {
|
|||||||
if showError, let errorText {
|
if showError, let errorText {
|
||||||
errorLabel.text = errorText
|
errorLabel.text = errorText
|
||||||
errorLabel.surface = surface
|
errorLabel.surface = surface
|
||||||
errorLabel.disabled = disabled
|
|
||||||
errorLabel.isEnabled = isEnabled
|
errorLabel.isEnabled = isEnabled
|
||||||
errorLabel.isHidden = false
|
errorLabel.isHidden = false
|
||||||
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
|
||||||
@ -327,7 +325,6 @@ open class EntryField: Control, Changeable {
|
|||||||
if let helperText {
|
if let helperText {
|
||||||
helperLabel.text = helperText
|
helperLabel.text = helperText
|
||||||
helperLabel.surface = surface
|
helperLabel.surface = surface
|
||||||
helperLabel.disabled = disabled
|
|
||||||
helperLabel.isEnabled = isEnabled
|
helperLabel.isEnabled = isEnabled
|
||||||
helperLabel.isHidden = false
|
helperLabel.isHidden = false
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -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
|
||||||
@ -175,14 +175,13 @@ open class InputField: EntryField, UITextFieldDelegate {
|
|||||||
} else if showSuccess, let successText {
|
} else if showSuccess, let successText {
|
||||||
successLabel.text = successText
|
successLabel.text = successText
|
||||||
successLabel.surface = surface
|
successLabel.surface = surface
|
||||||
successLabel.disabled = disabled
|
|
||||||
successLabel.isEnabled = isEnabled
|
successLabel.isEnabled = isEnabled
|
||||||
successLabel.isHidden = false
|
successLabel.isHidden = false
|
||||||
errorLabel.isHidden = true
|
errorLabel.isHidden = true
|
||||||
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
|
||||||
|
|||||||
@ -179,6 +179,7 @@ open class Toggle: Control, Changeable {
|
|||||||
super.reset()
|
super.reset()
|
||||||
shouldUpdateView = false
|
shouldUpdateView = false
|
||||||
label.reset()
|
label.reset()
|
||||||
|
isEnabled = true
|
||||||
isOn = false
|
isOn = false
|
||||||
isAnimated = true
|
isAnimated = true
|
||||||
showText = false
|
showText = false
|
||||||
@ -199,7 +200,6 @@ open class Toggle: Control, Changeable {
|
|||||||
|
|
||||||
updateLabel()
|
updateLabel()
|
||||||
toggleView.surface = surface
|
toggleView.surface = surface
|
||||||
toggleView.disabled = disabled
|
|
||||||
toggleView.isEnabled = isEnabled
|
toggleView.isEnabled = isEnabled
|
||||||
toggleView.isOn = isOn
|
toggleView.isOn = isOn
|
||||||
}
|
}
|
||||||
@ -235,7 +235,6 @@ open class Toggle: Control, Changeable {
|
|||||||
label.textStyle = textStyle
|
label.textStyle = textStyle
|
||||||
label.text = statusText
|
label.text = statusText
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
|
||||||
label.isEnabled = isEnabled
|
label.isEnabled = isEnabled
|
||||||
switch textPosition {
|
switch textPosition {
|
||||||
case .left:
|
case .left:
|
||||||
|
|||||||
@ -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()
|
||||||
|
|||||||
@ -71,7 +71,6 @@ open class TrailingTooltipLabel: View, TooltipLaunchable {
|
|||||||
label.textPosition = labelTextPosition
|
label.textPosition = labelTextPosition
|
||||||
label.attributes = labelAttributes
|
label.attributes = labelAttributes
|
||||||
label.surface = surface
|
label.surface = surface
|
||||||
label.disabled = disabled
|
|
||||||
label.isEnabled = isEnabled
|
label.isEnabled = isEnabled
|
||||||
|
|
||||||
//add tooltip
|
//add tooltip
|
||||||
|
|||||||
@ -7,8 +7,8 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
/// Any object that can be disabled, which may change the appearance
|
///// Any object that can be disabled, which may change the appearance
|
||||||
public protocol Disabling {
|
//public protocol Disabling {
|
||||||
/// Whether this object is disabled or not
|
// /// Whether this object is disabled or not
|
||||||
var disabled: Bool { get set }
|
// var disabled: Bool { get set }
|
||||||
}
|
//}
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import Foundation
|
|||||||
import UIKit
|
import UIKit
|
||||||
import Combine
|
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.
|
/// 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