added focused state
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
84314040d9
commit
2f6df89f09
@ -31,6 +31,18 @@ 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() }}
|
||||
|
||||
@ -53,7 +65,7 @@ open class DropdownSelect: EntryFieldBase {
|
||||
|
||||
/// A callback when the selected option changes. Passes parameters (option).
|
||||
open var onItemSelected: ((Int, DropdownOptionModel) -> Void)?
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - Private Properties
|
||||
//--------------------------------------------------
|
||||
@ -338,14 +350,22 @@ open class DropdownSelect: EntryFieldBase {
|
||||
titleLabelWidthConstraint?.constant = containerView.frame.width
|
||||
titleLabelWidthConstraint?.isActive = helperTextPlacement == .right
|
||||
}
|
||||
|
||||
open override var canBecomeFirstResponder: Bool { true }
|
||||
|
||||
open override func resignFirstResponder() -> Bool {
|
||||
if dropdownField.isFirstResponder {
|
||||
dropdownField.resignFirstResponder()
|
||||
}
|
||||
return super.resignFirstResponder()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------
|
||||
// MARK: - UIPickerView Delegate & Datasource
|
||||
//--------------------------------------------------
|
||||
extension DropdownSelect: UIPickerViewDelegate, UIPickerViewDataSource {
|
||||
|
||||
|
||||
internal func launchPicker() {
|
||||
if optionsPicker.isHidden {
|
||||
UIAccessibility.post(notification: .layoutChanged, argument: optionsPicker)
|
||||
@ -354,6 +374,7 @@ extension DropdownSelect: UIPickerViewDelegate, UIPickerViewDataSource {
|
||||
dropdownField.resignFirstResponder()
|
||||
}
|
||||
optionsPicker.isHidden = !optionsPicker.isHidden
|
||||
setNeedsUpdate()
|
||||
}
|
||||
|
||||
public func numberOfComponents(in pickerView: UIPickerView) -> Int {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user