From 317cf89fb6b1fcb2ef7827b8c8052653162d0f09 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 9 Aug 2024 11:21:51 -0500 Subject: [PATCH] ensure updateView() can't be called until setup() is run Signed-off-by: Matt Bruce --- VDS/BaseClasses/Control.swift | 2 ++ VDS/BaseClasses/View.swift | 2 ++ VDS/Components/Buttons/ButtonBase.swift | 2 ++ VDS/Components/Label/Label.swift | 2 ++ VDS/Components/TextFields/InputField/TextField.swift | 2 ++ VDS/Components/TextFields/TextArea/TextView.swift | 2 ++ 6 files changed, 12 insertions(+) diff --git a/VDS/BaseClasses/Control.swift b/VDS/BaseClasses/Control.swift index 472f0635..0dcaa3f1 100644 --- a/VDS/BaseClasses/Control.swift +++ b/VDS/BaseClasses/Control.swift @@ -81,7 +81,9 @@ open class Control: UIControl, ViewProtocol, UserInfoable, Clickable { open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true + shouldUpdateView = false setup() + shouldUpdateView = true setNeedsUpdate() } } diff --git a/VDS/BaseClasses/View.swift b/VDS/BaseClasses/View.swift index 88996ba6..b39afbf2 100644 --- a/VDS/BaseClasses/View.swift +++ b/VDS/BaseClasses/View.swift @@ -60,7 +60,9 @@ open class View: UIView, ViewProtocol, UserInfoable { open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true + shouldUpdateView = false setup() + shouldUpdateView = true setNeedsUpdate() } } diff --git a/VDS/Components/Buttons/ButtonBase.swift b/VDS/Components/Buttons/ButtonBase.swift index c764b89b..b210560a 100644 --- a/VDS/Components/Buttons/ButtonBase.swift +++ b/VDS/Components/Buttons/ButtonBase.swift @@ -103,7 +103,9 @@ open class ButtonBase: UIButton, ViewProtocol, UserInfoable, Clickable { backgroundColor = .clear translatesAutoresizingMaskIntoConstraints = false accessibilityCustomActions = [] + shouldUpdateView = false setup() + shouldUpdateView = true setNeedsUpdate() } } diff --git a/VDS/Components/Label/Label.swift b/VDS/Components/Label/Label.swift index f420be7d..3d56470b 100644 --- a/VDS/Components/Label/Label.swift +++ b/VDS/Components/Label/Label.swift @@ -209,7 +209,9 @@ open class Label: UILabel, ViewProtocol, UserInfoable { isAccessibilityElement = true accessibilityTraits = .staticText textAlignment = .left + shouldUpdateView = false setup() + shouldUpdateView = true setNeedsUpdate() } } diff --git a/VDS/Components/TextFields/InputField/TextField.swift b/VDS/Components/TextFields/InputField/TextField.swift index 3fdf308f..7adf1aa0 100644 --- a/VDS/Components/TextFields/InputField/TextField.swift +++ b/VDS/Components/TextFields/InputField/TextField.swift @@ -105,7 +105,9 @@ open class TextField: UITextField, ViewProtocol, Errorable { translatesAutoresizingMaskIntoConstraints = false setContentCompressionResistancePriority(.defaultLow, for: .horizontal) clipsToBounds = true + shouldUpdateView = false setup() + shouldUpdateView = true setNeedsUpdate() } } diff --git a/VDS/Components/TextFields/TextArea/TextView.swift b/VDS/Components/TextFields/TextArea/TextView.swift index 63356635..526911c4 100644 --- a/VDS/Components/TextFields/TextArea/TextView.swift +++ b/VDS/Components/TextFields/TextArea/TextView.swift @@ -112,7 +112,9 @@ open class TextView: UITextView, ViewProtocol, Errorable { initialSetupPerformed = true backgroundColor = .clear translatesAutoresizingMaskIntoConstraints = false + shouldUpdateView = false setup() + shouldUpdateView = true setNeedsUpdate() } }