class Formotion::RowType::Base
Attributes
row[RW]
tableView[RW]
Public Class Methods
field_buffer()
click to toggle source
# File lib/formotion/row_type/base.rb, line 6 def self.field_buffer if BW::Device.iphone? or App.window.size.width <= 320 or BW::Device.ios_version >= "7.0" 20 else 64 end end
new(row)
click to toggle source
# File lib/formotion/row_type/base.rb, line 18 def initialize(row) @row = row end
Public Instance Methods
_on_select(tableView, tableViewDelegate)
click to toggle source
method gets triggered when tableView(tableView, didSelectRowAtIndexPath:indexPath) in UITableViewDelegate is executed
# File lib/formotion/row_type/base.rb, line 59 def _on_select(tableView, tableViewDelegate) # row class should call super and proceed if false is return (not handled here) if row.on_tap_callback # Not all row types will want to define on_tap, but call it if so if row.on_tap_callback.call(self.row) != false on_select(tableView, tableViewDelegate) true else false end else on_select(tableView, tableViewDelegate) end end
after_build(cell)
click to toggle source
called by the Row
after all the setup and connections are made in make_cell
# File lib/formotion/row_type/base.rb, line 49 def after_build(cell) end
after_delete()
click to toggle source
# File lib/formotion/row_type/base.rb, line 101 def after_delete end
break_with_semaphore(&block)
click to toggle source
# File lib/formotion/row_type/base.rb, line 104 def break_with_semaphore(&block) return if @semaphore with_semaphore(&block) end
build_cell(cell)
click to toggle source
builder method for row cell specific implementation
# File lib/formotion/row_type/base.rb, line 42 def build_cell(cell) # implement in row class nil end
cellEditingStyle()
click to toggle source
Sets the UITableViewCellEditingStyle
# File lib/formotion/row_type/base.rb, line 32 def cellEditingStyle row.deletable? ? UITableViewCellEditingStyleDelete : UITableViewCellEditingStyleNone end
cell_style()
click to toggle source
RowCellBuilder
uses this to instantiate the UITableViewCell.
# File lib/formotion/row_type/base.rb, line 27 def cell_style UITableViewCellStyleSubtitle end
delete_row()
click to toggle source
# File lib/formotion/row_type/base.rb, line 95 def delete_row tableView.beginUpdates tableView.deleteRowsAtIndexPaths [row.index_path], withRowAnimation:UITableViewRowAnimationBottom tableView.endUpdates end
done_editing()
click to toggle source
# File lib/formotion/row_type/base.rb, line 145 def done_editing NSLog "Please implement the done_editing method in your new cell type." end
indentWhileEditing?()
click to toggle source
Indents row while editing
# File lib/formotion/row_type/base.rb, line 37 def indentWhileEditing? row.indented? end
input_accessory_view(input_accessory)
click to toggle source
Creates the inputAccessoryView to show if input_accessory property is set on row. :done is currently the only supported option.
# File lib/formotion/row_type/base.rb, line 118 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
on_delete(tableView, tableViewDelegate)
click to toggle source
called when the delete editing style was triggered tableView:commitEditingStyle:forRowAtIndexPath:
# File lib/formotion/row_type/base.rb, line 80 def on_delete(tableView, tableViewDelegate) if row.on_delete_callback row.on_delete_callback.call(self.row) end if row.remove_on_delete? row.section.rows.delete_at(row.index) row.section.refresh_row_indexes delete_row after_delete else row.value = nil self.tableView.reloadData end end
on_select(tableView, tableViewDelegate)
click to toggle source
Override in subclass
# File lib/formotion/row_type/base.rb, line 75 def on_select(tableView, tableViewDelegate) false end
update_cell(cell)
click to toggle source
Called on every tableView:cellForRowAtIndexPath: so keep implementation details minimal
# File lib/formotion/row_type/base.rb, line 54 def update_cell(cell) end
with_semaphore(&block)
click to toggle source
# File lib/formotion/row_type/base.rb, line 109 def with_semaphore(&block) @semaphore = true block.call @semaphore = false end