class Formotion::RowType::PickerRow

Public Instance Methods

after_build(cell) click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 11
def after_build(cell)
  self.row.text_field.inputView = self.picker
  self.row.text_field.text = name_for_value(row.value).to_s
end
numberOfComponentsInPickerView(pickerView) click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 32
def numberOfComponentsInPickerView(pickerView)
  1
end
on_change(text_field) click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 48
def on_change(text_field)
  break_with_semaphore do
    row.value = value_for_name(text_field.text)
  end
end
picker() click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 16
def picker
  @picker ||= begin
    picker = UIPickerView.alloc.initWithFrame(CGRectZero)
    picker.showsSelectionIndicator = true
    picker.hidden = false
    picker.dataSource = self
    picker.delegate = self

    picker
  end

  select_picker_value(row.value) if self.row.value

  @picker
end
pickerView(pickerView, numberOfRowsInComponent:component) click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 36
def pickerView(pickerView, numberOfRowsInComponent:component)
  self.items.size
end
row_value() click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 68
def row_value
  name_for_value(row.value)
end
select_picker_value(new_value) click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 59
def select_picker_value(new_value)
  picker_row = name_index_of_value(new_value)
  if picker_row != nil
    @picker.selectRow(picker_row, inComponent:0, animated:false)
  else
    warn "Picker item '#{row.value}' not found in #{row.items.inspect} for '#{row.key}'"
  end
end
update_text_field(new_value) click to toggle source
# File lib/formotion/row_type/picker_row.rb, line 54
def update_text_field(new_value)
  self.row.text_field.text = name_for_value(new_value)
  select_picker_value(new_value)
end