Class: Formotion::RowType::PickerRow
Constant Summary
Constants inherited
from StringRow
StringRow::TEXT_FIELD_TAG
Instance Attribute Summary
Attributes inherited from Base
#row, #tableView
Instance Method Summary
collapse
#add_callbacks, #build_cell
#item_names, #item_names_hash, #items, #name_for_value, #name_index_of_value, #value_for_name, #value_for_name_index
Methods inherited from StringRow
#add_callbacks, #build_cell, #keyboardType, #on_select
Methods inherited from Base
#_on_select, #after_delete, #break_with_semaphore, #build_cell, #button?, #cellEditingStyle, #cell_style, #delete_row, field_buffer, #indentWhileEditing?, #initialize, #on_delete, #on_select, #update_cell, #with_semaphore
Instance Method Details
#after_build(cell) ⇒ Object
43
44
45
46
|
# File 'lib/formotion/row_type/picker_row.rb', line 43
def after_build(cell)
self.row.text_field.inputView = self.picker
self.row.text_field.text = name_for_value(row.value).to_s
end
|
#done_editing ⇒ Object
Callback for “Done” button in input_accessory_view
39
40
41
|
# File 'lib/formotion/row_type/picker_row.rb', line 39
def done_editing
self.row.text_field.endEditing(true)
end
|
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/formotion/row_type/picker_row.rb', line 11
def input_accessory_view(input_accessory)
case input_accessory
when :done
@input_accessory ||= begin
tool_bar = UIToolbar.alloc.initWithFrame([[0, 0], [0, 44]])
tool_bar.autoresizingMask = UIViewAutoresizingFlexibleWidth
tool_bar.translucent = true
left_space = UIBarButtonItem.alloc.initWithBarButtonSystemItem(
UIBarButtonSystemItemFlexibleSpace,
target: nil,
action: nil)
done_button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(
UIBarButtonSystemItemDone,
target: self,
action: :done_editing)
tool_bar.items = [left_space, done_button]
tool_bar
end
else
nil
end
end
|
#numberOfComponentsInPickerView(pickerView) ⇒ Object
64
65
66
|
# File 'lib/formotion/row_type/picker_row.rb', line 64
def numberOfComponentsInPickerView(pickerView)
1
end
|
#on_change(text_field) ⇒ Object
80
81
82
83
84
|
# File 'lib/formotion/row_type/picker_row.rb', line 80
def on_change(text_field)
break_with_semaphore do
row.value = value_for_name(text_field.text)
end
end
|
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
# File 'lib/formotion/row_type/picker_row.rb', line 48
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, didSelectRow: index, inComponent: component) ⇒ Object
68
69
70
|
# File 'lib/formotion/row_type/picker_row.rb', line 68
def pickerView(pickerView, numberOfRowsInComponent:component)
self.items.size
end
|
#row_value ⇒ Object
100
101
102
|
# File 'lib/formotion/row_type/picker_row.rb', line 100
def row_value
name_for_value(row.value)
end
|
#select_picker_value(new_value) ⇒ Object
91
92
93
94
95
96
97
98
|
# File 'lib/formotion/row_type/picker_row.rb', line 91
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) ⇒ Object
86
87
88
89
|
# File 'lib/formotion/row_type/picker_row.rb', line 86
def update_text_field(new_value)
self.row.text_field.text = name_for_value(new_value)
select_picker_value(new_value)
end
|