From 891a816f557dbc0e16932853c5cb7fe190f3d4eb Mon Sep 17 00:00:00 2001 From: Matt Bruce Date: Mon, 24 Jun 2024 15:33:47 -0500 Subject: [PATCH] refactored base for responder Signed-off-by: Matt Bruce --- VDS/Components/DropdownSelect/DropdownSelect.swift | 14 +------------- VDS/Components/TextFields/EntryFieldBase.swift | 3 +++ .../TextFields/InputField/InputField.swift | 6 +----- VDS/Components/TextFields/TextArea/TextArea.swift | 13 +------------ 4 files changed, 6 insertions(+), 30 deletions(-) diff --git a/VDS/Components/DropdownSelect/DropdownSelect.swift b/VDS/Components/DropdownSelect/DropdownSelect.swift index 7fc52808..832349d2 100644 --- a/VDS/Components/DropdownSelect/DropdownSelect.swift +++ b/VDS/Components/DropdownSelect/DropdownSelect.swift @@ -30,19 +30,7 @@ open class DropdownSelect: EntryFieldBase { //-------------------------------------------------- // MARK: - Public Properties - //-------------------------------------------------- - /// Override UIControl state to add the .error state if showSuccess is true and if showError is true. - open override var state: UIControl.State { - get { - var state = super.state - if dropdownField.isFirstResponder { - state.insert(.focused) - } - - return state - } - } - + //-------------------------------------------------- /// If true, the label will be displayed inside the dropdown containerView. Otherwise, the label will be above the dropdown containerView like a normal text input. open var showInlineLabel: Bool = false { didSet { setNeedsUpdate() }} diff --git a/VDS/Components/TextFields/EntryFieldBase.swift b/VDS/Components/TextFields/EntryFieldBase.swift index 2ef89480..e4aeddc2 100644 --- a/VDS/Components/TextFields/EntryFieldBase.swift +++ b/VDS/Components/TextFields/EntryFieldBase.swift @@ -207,6 +207,9 @@ open class EntryFieldBase: Control, Changeable, FormFieldInternalValidatable { if isReadOnly { state.insert(.readonly) } + if let responder, responder.isFirstResponder { + state.insert(.focused) + } } return state } diff --git a/VDS/Components/TextFields/InputField/InputField.swift b/VDS/Components/TextFields/InputField/InputField.swift index c2f779d4..2ca4c207 100644 --- a/VDS/Components/TextFields/InputField/InputField.swift +++ b/VDS/Components/TextFields/InputField/InputField.swift @@ -166,11 +166,7 @@ open class InputField: EntryFieldBase { if showSuccess { state.insert(.success) } - - if textField.isFirstResponder { - state.insert(.focused) - } - + return state } } diff --git a/VDS/Components/TextFields/TextArea/TextArea.swift b/VDS/Components/TextFields/TextArea/TextArea.swift index a487dc53..d0396d7a 100644 --- a/VDS/Components/TextFields/TextArea/TextArea.swift +++ b/VDS/Components/TextFields/TextArea/TextArea.swift @@ -56,18 +56,7 @@ open class TextArea: EntryFieldBase { //-------------------------------------------------- // MARK: - Public Properties - //-------------------------------------------------- - /// Override UIControl state to add the .error state if showSuccess is true and if showError is true. - open override var state: UIControl.State { - get { - var state = super.state - if textView.isFirstResponder { - state.insert(.focused) - } - return state - } - } - + //-------------------------------------------------- override var containerSize: CGSize { CGSize(width: 182, height: Height.twoX.value) } /// Enum used to describe the the height of TextArea.