refactored naming
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
a2f79fcee8
commit
b07c010888
@ -38,11 +38,17 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
/// Allows unique ID to be passed to the element.
|
/// Allows unique ID to be passed to the element.
|
||||||
open var selectId: Int? { didSet { setNeedsUpdate() }}
|
open var selectId: Int? { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
|
/// Current SelectedItem
|
||||||
|
open var selectedItem: DropdownOptionModel? {
|
||||||
|
guard let selectId else { return nil }
|
||||||
|
return options[selectId]
|
||||||
|
}
|
||||||
|
|
||||||
/// Array of options to show
|
/// Array of options to show
|
||||||
open var options: [DropdownOptionModel] = [] { didSet { setNeedsUpdate() }}
|
open var options: [DropdownOptionModel] = [] { didSet { setNeedsUpdate() }}
|
||||||
|
|
||||||
/// A callback when the selected option changes. Passes parameters (option).
|
/// A callback when the selected option changes. Passes parameters (option).
|
||||||
open var onDropdownItemSelect: ((DropdownOptionModel) -> Void)?
|
open var onItemSelected: ((Int, DropdownOptionModel) -> Void)?
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Private Properties
|
// MARK: - Private Properties
|
||||||
@ -52,7 +58,7 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Public Properties
|
// MARK: - Public Properties
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
open var inlineDisplayLabel = Label().with {
|
open var inlineDisplayLabel = Label().with {
|
||||||
$0.textAlignment = .left
|
$0.textAlignment = .left
|
||||||
$0.textStyle = .boldBodyLarge
|
$0.textStyle = .boldBodyLarge
|
||||||
@ -171,7 +177,7 @@ open class DropdownSelect: EntryFieldBase {
|
|||||||
selectedOptionLabel.textStyle = .bodyLarge
|
selectedOptionLabel.textStyle = .bodyLarge
|
||||||
showInlineLabel = false
|
showInlineLabel = false
|
||||||
options = []
|
options = []
|
||||||
selectId = 0
|
selectId = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -279,6 +285,6 @@ extension DropdownSelect: UIPickerViewDelegate, UIPickerViewDataSource {
|
|||||||
guard options.count > row else { return }
|
guard options.count > row else { return }
|
||||||
selectId = row
|
selectId = row
|
||||||
updateSelectedOptionLabel(option: options[row])
|
updateSelectedOptionLabel(option: options[row])
|
||||||
self.onDropdownItemSelect?(options[row])
|
self.onItemSelected?(row, options[row])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user