class UnderOs::UI::Select
Public Class Methods
new(options={})
click to toggle source
Calls superclass method
UnderOs::UI::Input::new
# File lib/under_os/ui/select.rb, line 4 def initialize(options={}) super self.options = options.delete(:options) if options[:options] @_.showsSelectionIndicator = true if options[:lense] @_.dataSource = self end
Public Instance Methods
hide()
click to toggle source
# File lib/under_os/ui/select.rb, line 68 def hide animate bottom: -size.y, complete: -> { style.display = :none } end
numberOfComponentsInPickerView(picker)
click to toggle source
UIPickerView delegate
# File lib/under_os/ui/select.rb, line 77 def numberOfComponentsInPickerView(picker) optgroups.size end
optgroups()
click to toggle source
# File lib/under_os/ui/select.rb, line 13 def optgroups @optgroups ||= [{}] end
optgroups=(list)
click to toggle source
# File lib/under_os/ui/select.rb, line 17 def optgroups=(list) @optgroups = list.map do |hash| {}.tap do |clean_hash| hash.each do |key, value| clean_hash[key.to_s] = value if key && value end end end end
options()
click to toggle source
# File lib/under_os/ui/select.rb, line 27 def options optgroups.size == 1 ? optgroups[0] : optgroups end
options=(value)
click to toggle source
# File lib/under_os/ui/select.rb, line 31 def options=(value) self.optgroups = value.is_a?(Array) ? value : [value] @_.reloadAllComponents end
pickerView(picker, numberOfRowsInComponent: group)
click to toggle source
# File lib/under_os/ui/select.rb, line 81 def pickerView(picker, numberOfRowsInComponent: group) optgroups[group].size end
show()
click to toggle source
# File lib/under_os/ui/select.rb, line 58 def show page.find('select').each do |select| select.hide if select.visible && select != self end self.style = {bottom: -size.y, display: :block} animate bottom: 0 end
value()
click to toggle source
# File lib/under_os/ui/select.rb, line 36 def value @value ||= [] optgroups.size == 1 ? @value[0] : @value end
value=(value)
click to toggle source
# File lib/under_os/ui/select.rb, line 41 def value=(value) prev_val = @value @value = Array(value).map(&:to_s) handle_change if @value != prev_val @value.each_with_index do |value, group| i = 0; optgroups[group].each do |v, label| if value == v @_.selectRow i, inComponent: group, animated: false else i += 1 end end end end