From c9ae6b0954422b9ca812272004b79017e9f953b1 Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Fri, 26 May 2023 16:18:10 -0500 Subject: [PATCH] added comments to View Signed-off-by: Matt Bruce --- VDS/Classes/View.swift | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/VDS/Classes/View.swift b/VDS/Classes/View.swift index 2372ed4b..8513bd7e 100644 --- a/VDS/Classes/View.swift +++ b/VDS/Classes/View.swift @@ -23,14 +23,19 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- private var initialSetupPerformed = false + /// Key of whether or not updateView() is called in setNeedsUpdate() open var shouldUpdateView: Bool = true + /// Dictionary for keeping information for this Control use only Primitives open var userInfo = [String: Primitive]() - - open var surface: Surface = .light { didSet { setNeedsUpdate() }} + /// Current Surface used within this Control and used to passdown to child views + open var surface: Surface = .light { didSet { setNeedsUpdate() } } + + /// Control is disabled or not open var disabled: Bool = false { didSet { isEnabled = !disabled } } - + + /// Override to deal with setNeedsUpdate() open var isEnabled: Bool { get { !disabled } set { @@ -64,6 +69,7 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { // MARK: - Setup //-------------------------------------------------- + /// Executed on initialization for this View open func initialSetup() { if !initialSetupPerformed { initialSetupPerformed = true @@ -75,22 +81,25 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable { //-------------------------------------------------- // MARK: - Overrides //-------------------------------------------------- + + /// Update this view based off of property changes open func updateView() { updateAccessibilityLabel() } + /// Used to update any Accessibility properties open func updateAccessibilityLabel() { } + /// Resets to the Views default values open func reset() { backgroundColor = .clear surface = .light disabled = false } - // MARK: - ViewProtocol - /// Will be called only once. + /// Will be called only once and should be overridden in subclasses to setup UI or defaults open func setup() { backgroundColor = .clear translatesAutoresizingMaskIntoConstraints = false