updated to use old value

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-08-30 17:05:12 -05:00
parent efb51d12c4
commit edd2e48df2
8 changed files with 48 additions and 47 deletions

View File

@ -55,10 +55,10 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable {
open var userInfo = [String: Primitive]() open var userInfo = [String: Primitive]()
open var surface: Surface = .light { didSet { setNeedsUpdate() } } open var surface: Surface = .light { didSet { if oldValue != surface { setNeedsUpdate() } } }
/// 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 { if oldValue != isSelected { setNeedsUpdate() } } }
/// Whether the Control can handle the isHighlighted state. /// Whether the Control can handle the isHighlighted state.
open var canHighlight: Bool = true open var canHighlight: Bool = true
@ -86,12 +86,7 @@ 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 { open override var isEnabled: Bool { didSet { if oldValue != isEnabled { setNeedsUpdate() } } }
didSet {
setNeedsUpdate()
//isUserInteractionEnabled = isEnabled
}
}
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Lifecycle // MARK: - Lifecycle

View File

@ -55,8 +55,8 @@ open class SelectorBase: Control, SelectorControlable {
} }
} }
open var size = CGSize(width: 20, height: 20) { didSet { setNeedsUpdate() } } open var size = CGSize(width: 20, height: 20) { didSet { if oldValue != size { setNeedsUpdate() } } }
var _showError: Bool = false var _showError: Bool = false
/// Whether not to show the error. /// Whether not to show the error.
open var showError: Bool { open var showError: Bool {

View File

@ -91,13 +91,13 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
/// Generic Object used to allow the user to 'Select'. /// Generic Object used to allow the user to 'Select'.
open var selectorView = Selector() open var selectorView = Selector()
open override var isSelected: Bool { didSet { setNeedsUpdate() } } open override var isSelected: Bool { didSet { if oldValue != isSelected { setNeedsUpdate() } } }
/// Text shown in the label. /// Text shown in the label.
open var labelText: String? { didSet { setNeedsUpdate() } } open var labelText: String? { didSet { if oldValue != labelText { setNeedsUpdate() } } }
/// Array of LabelAttributeModel objects used in rendering the labelText. /// Array of LabelAttributeModel objects used in rendering the labelText.
open var labelTextAttributes: [any LabelAttributeModel]? { didSet { setNeedsUpdate() } } open var labelTextAttributes: [any LabelAttributeModel]? { didSet { if oldValue != labelTextAttributes { setNeedsUpdate() } } }
/// Instead of use labelText and labelTextAttirbutes, this is a fully baked NSAttributedString with both text and attributes. /// Instead of use labelText and labelTextAttirbutes, this is a fully baked NSAttributedString with both text and attributes.
open var labelAttributedText: NSAttributedString? { open var labelAttributedText: NSAttributedString? {
@ -109,10 +109,10 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
} }
/// Text shown in the childLabel. /// Text shown in the childLabel.
open var childText: String? { didSet { setNeedsUpdate() } } open var childText: String? { didSet { if oldValue != childText { setNeedsUpdate() } } }
/// Array of LabelAttributeModel objects used in rendering the childText. /// Array of LabelAttributeModel objects used in rendering the childText.
open var childTextAttributes: [any LabelAttributeModel]? { didSet { setNeedsUpdate() } } open var childTextAttributes: [any LabelAttributeModel]? { didSet { if oldValue != childTextAttributes { setNeedsUpdate() } } }
/// Instead of use childText and childTextAttirbutes, this is a fully baked NSAttributedString with both text and attributes. /// Instead of use childText and childTextAttirbutes, this is a fully baked NSAttributedString with both text and attributes.
open var childAttributedText: NSAttributedString? { open var childAttributedText: NSAttributedString? {
@ -146,11 +146,11 @@ open class SelectorItemBase<Selector: SelectorControlable>: Control, Errorable,
} }
} }
open var errorText: String? { didSet { setNeedsUpdate() } } open var errorText: String? { didSet { if oldValue != errorText { setNeedsUpdate() } } }
open var inputId: String? { didSet { setNeedsUpdate() } } open var inputId: String? { didSet { if oldValue != inputId { setNeedsUpdate() } } }
open var value: AnyHashable? { didSet { setNeedsUpdate() } } open var value: AnyHashable? { didSet { if oldValue != value { setNeedsUpdate() } } }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Overrides // MARK: - Overrides

View File

@ -49,9 +49,9 @@ open class View: UIView, ViewProtocol, UserInfoable {
/// Dictionary for keeping information for this Control use only Primitives. /// Dictionary for keeping information for this Control use only Primitives.
open var userInfo = [String: Primitive]() open var userInfo = [String: Primitive]()
open var surface: Surface = .light { didSet { setNeedsUpdate() } } open var surface: Surface = .light { didSet { if oldValue != surface { setNeedsUpdate() } } }
open var isEnabled: Bool = true { didSet { setNeedsUpdate() } } open var isEnabled: Bool = true { didSet { if oldValue != isEnabled { setNeedsUpdate() } } }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Lifecycle // MARK: - Lifecycle

View File

@ -169,46 +169,46 @@ open class BadgeIndicator: View {
/// This will render the badges fill color based on the available options. /// This will render the badges fill color based on the available options.
/// When used in conjunction with the surface prop, this fill color will change its tint automatically based on a light or dark surface. /// When used in conjunction with the surface prop, this fill color will change its tint automatically based on a light or dark surface.
open var fillColor: FillColor = .red { didSet { setNeedsUpdate() } } open var fillColor: FillColor = .red { didSet { if oldValue != fillColor { setNeedsUpdate() } } }
/// Badge Number that will be shown if you are using Kind.numbered. /// Badge Number that will be shown if you are using Kind.numbered.
open var number: Int? { didSet { setNeedsUpdate() } } open var number: Int? { didSet { if oldValue != number { setNeedsUpdate() } } }
/// Type of Badge Indicator, simple is a dot, whereas numbered shows a number. /// Type of Badge Indicator, simple is a dot, whereas numbered shows a number.
open var kind: Kind = .simple { didSet { setNeedsUpdate() } } open var kind: Kind = .simple { didSet { if oldValue != kind { setNeedsUpdate() } } }
/// Character that is always at the begging. Accepts any character and if unaffected by maximumDigits. /// Character that is always at the begging. Accepts any character and if unaffected by maximumDigits.
open var leadingCharacter: String? { didSet { setNeedsUpdate() } } open var leadingCharacter: String? { didSet { if oldValue != leadingCharacter { setNeedsUpdate() } } }
/// Accepts any text or character. It is unaffected by maximumDigits. /// Accepts any text or character. It is unaffected by maximumDigits.
open var trailingText: String? { didSet { setNeedsUpdate() } } open var trailingText: String? { didSet { if oldValue != trailingText { setNeedsUpdate() } } }
/// Determines the size of the Badge Indicator as well as the textStyle and padding used. /// Determines the size of the Badge Indicator as well as the textStyle and padding used.
open var size: Size = .xxlarge { didSet { setNeedsUpdate() } } open var size: Size = .xxlarge { didSet { if oldValue != size { setNeedsUpdate() } } }
/// Pixel size of the dot when the kind is set to simple. /// Pixel size of the dot when the kind is set to simple.
open var dotSize: CGFloat? { didSet { setNeedsUpdate() } } open var dotSize: CGFloat? { didSet { if oldValue != dotSize { setNeedsUpdate() } } }
/// Sets the padding at the top/bottom of the label. /// Sets the padding at the top/bottom of the label.
open var verticalPadding: CGFloat? { didSet { setNeedsUpdate() } } open var verticalPadding: CGFloat? { didSet { if oldValue != verticalPadding { setNeedsUpdate() } } }
/// Sets the padding at the left/right of the label. /// Sets the padding at the left/right of the label.
open var horitonalPadding: CGFloat? { didSet { setNeedsUpdate() } } open var horitonalPadding: CGFloat? { didSet { if oldValue != horitonalPadding { setNeedsUpdate() } } }
/// Hides the dot when you are in Kind.simple mode. /// Hides the dot when you are in Kind.simple mode.
open var hideDot: Bool = false { didSet { setNeedsUpdate() } } open var hideDot: Bool = false { didSet { if oldValue != hideDot { setNeedsUpdate() } } }
/// Will not show the border. /// Will not show the border.
open var hideBorder: Bool = false { didSet { setNeedsUpdate() } } open var hideBorder: Bool = false { didSet { if oldValue != hideBorder { setNeedsUpdate() } } }
/// When in Kind.numbered this is the amount of digits that will show up when the user adds a number. /// When in Kind.numbered this is the amount of digits that will show up when the user adds a number.
open var maximumDigits: MaximumDigits = .two { didSet { setNeedsUpdate() } } open var maximumDigits: MaximumDigits = .two { didSet { if oldValue != maximumDigits { setNeedsUpdate() } } }
/// The Container's width. /// The Container's width.
open var width: CGFloat? { didSet { setNeedsUpdate() } } open var width: CGFloat? { didSet { if oldValue != width { setNeedsUpdate() } } }
/// The Container's height. /// The Container's height.
open var height: CGFloat? { didSet { setNeedsUpdate() } } open var height: CGFloat? { didSet { if oldValue != height { setNeedsUpdate() } } }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Private Properties // MARK: - Private Properties

View File

@ -52,10 +52,10 @@ open class Button: ButtonBase, Useable, Buttonable {
open override var availableSizes: [ButtonSize] { [.large, .small] } open override var availableSizes: [ButtonSize] { [.large, .small] }
/// The ButtonSize for ths Button. /// The ButtonSize for ths Button.
open var size: ButtonSize = .large { didSet { setNeedsUpdate() } } open var size: ButtonSize = .large { didSet { if oldValue != size { setNeedsUpdate() } } }
/// The Use for this Button. /// The Use for this Button.
open var use: Use = .primary { didSet { setNeedsUpdate() } } open var use: Use = .primary { didSet { if oldValue != use { setNeedsUpdate() } } }
private var _width: CGFloat? = nil private var _width: CGFloat? = nil

View File

@ -78,10 +78,10 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
/// The ButtonSize available to this type of Buttonable. /// The ButtonSize available to this type of Buttonable.
open var availableSizes: [ButtonSize] { [] } open var availableSizes: [ButtonSize] { [] }
open var surface: Surface = .light { didSet { setNeedsUpdate() } } open var surface: Surface = .light { didSet { if oldValue != surface { setNeedsUpdate() } } }
/// Text that will be used in the titleLabel. /// Text that will be used in the titleLabel.
open var text: String? { didSet { setNeedsUpdate() } } open var text: String? { didSet { if oldValue != text { setNeedsUpdate() } } }
/// Array of LabelAttributeModel objects used in rendering the text. /// Array of LabelAttributeModel objects used in rendering the text.
open var textAttributes: [any LabelAttributeModel]? { nil } open var textAttributes: [any LabelAttributeModel]? { nil }
@ -93,7 +93,7 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
open var textColor: UIColor { .black } open var textColor: UIColor { .black }
/// Will determine if a scaled font should be used for the titleLabel font. /// Will determine if a scaled font should be used for the titleLabel font.
open var useScaledFont: Bool = false { didSet { setNeedsUpdate() } } open var useScaledFont: Bool = false { didSet { if oldValue != useScaledFont { setNeedsUpdate() } } }
open var userInfo = [String: Primitive]() open var userInfo = [String: Primitive]()
@ -120,7 +120,7 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable {
} }
/// Whether the Control is enabled or not. /// Whether the Control is enabled or not.
open override var isEnabled: Bool { didSet { setNeedsUpdate() } } open override var isEnabled: Bool { didSet { if oldValue != isEnabled { setNeedsUpdate() } } }
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Lifecycle // MARK: - Lifecycle

View File

@ -48,16 +48,16 @@ open class ButtonGroup: View {
// MARK: - Public Properties // MARK: - Public Properties
//-------------------------------------------------- //--------------------------------------------------
/// An object containing number of Button components per row for iPhones /// An object containing number of Button components per row for iPhones
open var rowQuantityPhone: Int = 0 { didSet { setNeedsUpdate() } } open var rowQuantityPhone: Int = 0 { didSet { if oldValue != rowQuantityPhone { setNeedsUpdate() } } }
/// An object containing number of Button components per row for iPads /// An object containing number of Button components per row for iPads
open var rowQuantityTablet: Int = 0 { didSet { setNeedsUpdate() } } open var rowQuantityTablet: Int = 0 { didSet { if oldValue != rowQuantityTablet { setNeedsUpdate() } } }
/// An object containing number of Button components per row /// An object containing number of Button components per row
open var rowQuantity: Int { UIDevice.isIPad ? rowQuantityTablet : rowQuantityPhone } open var rowQuantity: Int { UIDevice.isIPad ? rowQuantityTablet : rowQuantityPhone }
/// If provided, aligns TextLink/TextLinkCaret alignment when rowQuantity is set one. /// If provided, aligns TextLink/TextLinkCaret alignment when rowQuantity is set one.
open var alignment: Alignment = .center { didSet { setNeedsUpdate() } } open var alignment: Alignment = .center { didSet { if oldValue != alignment { setNeedsUpdate() } } }
/// Array of Buttonable Views that are shown in the group. /// Array of Buttonable Views that are shown in the group.
open var buttons: [Buttonable] = [] { didSet { setNeedsUpdate() } } open var buttons: [Buttonable] = [] { didSet { setNeedsUpdate() } }
@ -89,16 +89,22 @@ open class ButtonGroup: View {
/// 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 {
buttons.forEach { $0.isEnabled = isEnabled } if oldValue != isEnabled {
buttons.forEach { $0.isEnabled = isEnabled }
setNeedsUpdate()
}
} }
} }
/// 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 {
buttons.forEach { button in if oldValue != surface {
var b = button buttons.forEach { button in
b.surface = surface var b = button
b.surface = surface
}
setNeedsUpdate()
} }
} }
} }