added comments to View

Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
Matt Bruce 2023-05-26 16:18:10 -05:00
parent d358194b7d
commit c9ae6b0954

View File

@ -23,14 +23,19 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable {
//-------------------------------------------------- //--------------------------------------------------
private var initialSetupPerformed = false private var initialSetupPerformed = false
/// Key of whether or not updateView() is called in setNeedsUpdate()
open var shouldUpdateView: Bool = true open var shouldUpdateView: Bool = true
/// 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() }}
/// 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 } } open var disabled: Bool = false { didSet { isEnabled = !disabled } }
/// Override to deal with setNeedsUpdate()
open var isEnabled: Bool { open var isEnabled: Bool {
get { !disabled } get { !disabled }
set { set {
@ -64,6 +69,7 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable {
// MARK: - Setup // MARK: - Setup
//-------------------------------------------------- //--------------------------------------------------
/// Executed on initialization for this View
open func initialSetup() { open func initialSetup() {
if !initialSetupPerformed { if !initialSetupPerformed {
initialSetupPerformed = true initialSetupPerformed = true
@ -75,22 +81,25 @@ open class View: UIView, Handlerable, ViewProtocol, Resettable, UserInfoable {
//-------------------------------------------------- //--------------------------------------------------
// MARK: - Overrides // MARK: - Overrides
//-------------------------------------------------- //--------------------------------------------------
/// Update this view based off of property changes
open func updateView() { open func updateView() {
updateAccessibilityLabel() updateAccessibilityLabel()
} }
/// Used to update any Accessibility properties
open func updateAccessibilityLabel() { open func updateAccessibilityLabel() {
} }
/// Resets to the Views default values
open func reset() { open func reset() {
backgroundColor = .clear backgroundColor = .clear
surface = .light surface = .light
disabled = false disabled = false
} }
// MARK: - ViewProtocol /// Will be called only once and should be overridden in subclasses to setup UI or defaults
/// Will be called only once.
open func setup() { open func setup() {
backgroundColor = .clear backgroundColor = .clear
translatesAutoresizingMaskIntoConstraints = false translatesAutoresizingMaskIntoConstraints = false