Class: Formotion::RowType::CheckRow
- Includes:
- BW::KVO
- Defined in:
- lib/formotion/row_type/check_row.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#build_cell(cell) ⇒ Object
This is actually called whenever again cell is checked/unchecked in the UITableViewDelegate callbacks.
- #on_select(tableView, tableViewDelegate) ⇒ Object
- #update_cell_value(cell) ⇒ Object
Methods inherited from Base
#_on_select, #after_build, #after_delete, #break_with_semaphore, #button?, #cellEditingStyle, #cell_style, #delete_row, #done_editing, field_buffer, #indentWhileEditing?, #initialize, #input_accessory_view, #on_delete, #update_cell, #with_semaphore
Constructor Details
This class inherits a constructor from Formotion::RowType::Base
Instance Method Details
#build_cell(cell) ⇒ Object
This is actually called whenever again cell is checked/unchecked in the UITableViewDelegate callbacks. So (for now) don’t instantiate long-lived objects in them. Maybe that logic should be moved elsewhere?
16 17 18 19 20 21 22 23 |
# File 'lib/formotion/row_type/check_row.rb', line 16 def build_cell(cell) cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleBlue update_cell_value(cell) observe(self.row, "value") do |old_value, new_value| update_cell_value(cell) end nil end |
#on_select(tableView, tableViewDelegate) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/formotion/row_type/check_row.rb', line 25 def on_select(tableView, tableViewDelegate) if !row.editable? return end if row.section.select_one and !row.value row.section.rows.each do |other_row| other_row.value = (row == other_row) end elsif !row.section.select_one row.value = !row.value end end |
#update_cell_value(cell) ⇒ Object
8 9 10 |
# File 'lib/formotion/row_type/check_row.rb', line 8 def update_cell_value(cell) cell.accessoryType = cell.editingAccessoryType = row.value ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone end |