diff --git a/VDS/Components/Badge/Badge.swift b/VDS/Components/Badge/Badge.swift index da8ff792..f3ee4d1a 100644 --- a/VDS/Components/Badge/Badge.swift +++ b/VDS/Components/Badge/Badge.swift @@ -77,7 +77,6 @@ open class Badge: View { open override func reset() { super.reset() - shouldUpdateView = false label.reset() label.lineBreakMode = .byTruncatingTail label.textPosition = .left @@ -86,7 +85,6 @@ open class Badge: View { text = "" maxWidth = nil numberOfLines = 1 - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/BadgeIndicator/BadgeIndicator.swift b/VDS/Components/BadgeIndicator/BadgeIndicator.swift index 748025e2..4d15bb69 100644 --- a/VDS/Components/BadgeIndicator/BadgeIndicator.swift +++ b/VDS/Components/BadgeIndicator/BadgeIndicator.swift @@ -280,13 +280,11 @@ open class BadgeIndicator: View { open override func reset() { super.reset() - shouldUpdateView = false label.reset() label.lineBreakMode = .byTruncatingTail label.textPosition = .center fillColor = .red number = nil - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Buttons/Button/Button.swift b/VDS/Components/Buttons/Button/Button.swift index 3ac084fa..7bb91598 100644 --- a/VDS/Components/Buttons/Button/Button.swift +++ b/VDS/Components/Buttons/Button/Button.swift @@ -132,11 +132,9 @@ open class Button: ButtonBase, Useable { open override func reset() { super.reset() - shouldUpdateView = false use = .primary width = nil size = .large - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Buttons/Button/ButtonBase.swift b/VDS/Components/Buttons/Button/ButtonBase.swift index b1eba0dd..aebd0265 100644 --- a/VDS/Components/Buttons/Button/ButtonBase.swift +++ b/VDS/Components/Buttons/Button/ButtonBase.swift @@ -28,7 +28,9 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - public var subject = PassthroughSubject() + public var delayedSubject = PassthroughSubject() + public var immediateSubject = PassthroughSubject() + public var updateStrategy: HandlerableUpdateStrategy = .immediate public var subscribers = Set() public var onClickSubscriber: AnyCancellable? { willSet { @@ -45,9 +47,7 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab //-------------------------------------------------- // MARK: - Properties - //-------------------------------------------------- - open var shouldUpdateView: Bool = true - + //-------------------------------------------------- open var availableSizes: [ButtonSize] { [] } open var text: String? { didSet { setNeedsUpdate() } } @@ -139,18 +139,23 @@ open class ButtonBase: UIButton, Buttonable, Handlerable, ViewProtocol, Resettab } open func reset() { - shouldUpdateView = false surface = .light disabled = false text = nil accessibilityCustomActions = [] - shouldUpdateView = true setNeedsUpdate() } //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- + open override func didMoveToWindow() { + super.didMoveToWindow() + if window != nil { + updateStrategy = .delayed + } + } + override open var intrinsicContentSize: CGSize { let intrinsicContentSize = super.intrinsicContentSize let adjustedWidth = intrinsicContentSize.width + titleEdgeInsets.left + titleEdgeInsets.right diff --git a/VDS/Components/Buttons/TextLink/TextLink.swift b/VDS/Components/Buttons/TextLink/TextLink.swift index f604cad9..f9ac2c7d 100644 --- a/VDS/Components/Buttons/TextLink/TextLink.swift +++ b/VDS/Components/Buttons/TextLink/TextLink.swift @@ -89,13 +89,11 @@ open class TextLink: ButtonBase { open override func reset() { super.reset() - shouldUpdateView = false text = nil size = .large accessibilityCustomActions = [] isAccessibilityElement = true accessibilityTraits = .link - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift index 12db5a56..c4f344a4 100644 --- a/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift +++ b/VDS/Components/Icon/ButtonIcon/ButtonIcon.swift @@ -255,7 +255,6 @@ open class ButtonIcon: Control { open override func reset() { super.reset() - shouldUpdateView = false kind = .ghost surfaceType = .colorFill size = .large @@ -263,7 +262,6 @@ open class ButtonIcon: Control { hideBorder = true iconOffset = .init(x: 0, y: 0) iconName = nil - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index cd333fdc..82df109e 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -16,16 +16,16 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Combine Properties //-------------------------------------------------- - public var subject = PassthroughSubject() + public var delayedSubject = PassthroughSubject() + public var immediateSubject = PassthroughSubject() public var subscribers = Set() + public var updateStrategy: HandlerableUpdateStrategy = .immediate //-------------------------------------------------- // MARK: - Properties //-------------------------------------------------- private var initialSetupPerformed = false - open var shouldUpdateView: Bool = true - open var useAttributedText: Bool = false open var surface: Surface = .light { didSet { setNeedsUpdate() }} @@ -93,7 +93,6 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { open func setup() {} open func reset() { - shouldUpdateView = false surface = .light disabled = false attributes = nil @@ -103,13 +102,19 @@ open class Label: UILabel, Handlerable, ViewProtocol, Resettable, UserInfoable { attributedText = nil numberOfLines = 0 backgroundColor = .clear - shouldUpdateView = true setNeedsUpdate() } //-------------------------------------------------- // MARK: - Overrides - //-------------------------------------------------- + //-------------------------------------------------- + open override func didMoveToWindow() { + super.didMoveToWindow() + if window != nil { + updateStrategy = .delayed + } + } + open func updateView() { if !useAttributedText { if let text = text { diff --git a/VDS/Components/Notification/Notification.swift b/VDS/Components/Notification/Notification.swift index 20d39096..f6d3601a 100644 --- a/VDS/Components/Notification/Notification.swift +++ b/VDS/Components/Notification/Notification.swift @@ -230,9 +230,7 @@ open class Notification: View { open override func reset() { super.reset() - - shouldUpdateView = false - + titleLabel.reset() titleLabel.text = "" titleLabel.textStyle = UIDevice.isIPad ? .boldBodyLarge : .boldBodySmall @@ -258,7 +256,6 @@ open class Notification: View { hideCloseButton = false fullBleed = false - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/RadioBox/RadioBoxItem.swift b/VDS/Components/RadioBox/RadioBoxItem.swift index 66d40542..af759294 100644 --- a/VDS/Components/RadioBox/RadioBoxItem.swift +++ b/VDS/Components/RadioBox/RadioBoxItem.swift @@ -202,7 +202,6 @@ open class RadioBoxItem: Control, Changeable { open override func reset() { super.reset() - shouldUpdateView = false textLabel.reset() subTextLabel.reset() subTextRightLabel.reset() @@ -226,7 +225,6 @@ open class RadioBoxItem: Control, Changeable { isSelected = false - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/RadioSwatch/RadioSwatch.swift b/VDS/Components/RadioSwatch/RadioSwatch.swift index 8178f971..bb166baf 100644 --- a/VDS/Components/RadioSwatch/RadioSwatch.swift +++ b/VDS/Components/RadioSwatch/RadioSwatch.swift @@ -91,7 +91,6 @@ open class RadioSwatch: Control { open override func reset() { super.reset() - shouldUpdateView = false fillImage = nil text = "" primaryColor = nil @@ -99,7 +98,6 @@ open class RadioSwatch: Control { strikethrough = false inputId = nil value = nil - shouldUpdateView = true setNeedsUpdate() setNeedsDisplay() } diff --git a/VDS/Components/TileContainer/TileContainer.swift b/VDS/Components/TileContainer/TileContainer.swift index 0fb735fe..001c2e82 100644 --- a/VDS/Components/TileContainer/TileContainer.swift +++ b/VDS/Components/TileContainer/TileContainer.swift @@ -191,7 +191,6 @@ open class TileContainer: Control { open override func reset() { super.reset() - shouldUpdateView = false color = .white padding = .padding4X aspectRatio = .ratio1x1 @@ -200,7 +199,6 @@ open class TileContainer: Control { height = nil showBorder = false showDropShadows = false - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Tilelet/Tilelet.swift b/VDS/Components/Tilelet/Tilelet.swift index c91c7eba..d440242d 100644 --- a/VDS/Components/Tilelet/Tilelet.swift +++ b/VDS/Components/Tilelet/Tilelet.swift @@ -241,7 +241,6 @@ open class Tilelet: TileContainer { } open override func reset() { - shouldUpdateView = false aspectRatio = .none color = .black //models @@ -250,7 +249,6 @@ open class Tilelet: TileContainer { subTitleModel = nil descriptiveIconModel = nil directionalIconModel = nil - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/TitleLockup/TitleLockup.swift b/VDS/Components/TitleLockup/TitleLockup.swift index 6381fed5..7169f1a2 100644 --- a/VDS/Components/TitleLockup/TitleLockup.swift +++ b/VDS/Components/TitleLockup/TitleLockup.swift @@ -198,12 +198,10 @@ open class TitleLockup: View { open override func reset() { super.reset() - shouldUpdateView = false textPosition = .left eyebrowModel = nil titleModel = nil subTitleModel = nil - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Toggle/Toggle.swift b/VDS/Components/Toggle/Toggle.swift index ac20ef31..c790bf6c 100644 --- a/VDS/Components/Toggle/Toggle.swift +++ b/VDS/Components/Toggle/Toggle.swift @@ -278,7 +278,6 @@ open class Toggle: Control, Changeable { open override func reset() { super.reset() - shouldUpdateView = false label.reset() isOn = false isAnimated = true @@ -292,7 +291,6 @@ open class Toggle: Control, Changeable { value = nil toggleView.backgroundColor = toggleColorConfiguration.getColor(self) knobView.backgroundColor = knobColorConfiguration.getColor(self) - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Tooltip/Tooltip.swift b/VDS/Components/Tooltip/Tooltip.swift index f51cd36c..fa023bc1 100644 --- a/VDS/Components/Tooltip/Tooltip.swift +++ b/VDS/Components/Tooltip/Tooltip.swift @@ -141,14 +141,12 @@ open class Tooltip: Control, TooltipLaunchable { open override func reset() { super.reset() - shouldUpdateView = false size = .medium title = "" content = "" fillColor = .primary closeButtonText = "Close" imageView.image = nil - shouldUpdateView = true setNeedsUpdate() } diff --git a/VDS/Components/Tooltip/TrailingTooltipLabel.swift b/VDS/Components/Tooltip/TrailingTooltipLabel.swift index 220cb2f3..32d0ed1c 100644 --- a/VDS/Components/Tooltip/TrailingTooltipLabel.swift +++ b/VDS/Components/Tooltip/TrailingTooltipLabel.swift @@ -79,7 +79,6 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { open override func reset() { super.reset() - shouldUpdateView = false labelText = nil labelAttributes = nil labelTextStyle = .defaultStyle @@ -87,7 +86,6 @@ open class TrailingTooltipLabel: View, TooltipLaunchable { tooltipCloseButtonText = "Close" tooltipTitle = "" tooltipContent = "" - shouldUpdateView = true setNeedsUpdate() } }