Class: Formotion::RowType::Base
- Defined in:
- lib/formotion/row_type/base.rb
Direct Known Subclasses
ButtonRow, CheckRow, ImageRow, MapRow, OptionsRow, PagedImageRow, SliderRow, StringRow, SubformRow, SwitchRow, TagsRow, TemplateRow, TextRow, WebViewRow
Instance Attribute Summary collapse
-
#row ⇒ Object
Returns the value of attribute row.
-
#tableView ⇒ Object
Returns the value of attribute tableView.
Class Method Summary collapse
Instance Method Summary collapse
-
#_on_select(tableView, tableViewDelegate) ⇒ Object
method gets triggered when tableView(tableView, didSelectRowAtIndexPath:indexPath) in UITableViewDelegate is executed.
-
#after_build(cell) ⇒ Object
called by the Row after all the setup and connections are made in #make_cell.
- #after_delete ⇒ Object
- #break_with_semaphore(&block) ⇒ Object
-
#build_cell(cell) ⇒ Object
builder method for row cell specific implementation.
- #button? ⇒ Boolean
-
#cell_style ⇒ Object
RowCellBuilder uses this to instantiate the UITableViewCell.
-
#cellEditingStyle ⇒ Object
Sets the UITableViewCellEditingStyle.
- #delete_row ⇒ Object
-
#indentWhileEditing? ⇒ Boolean
Indents row while editing.
-
#initialize(row) ⇒ Base
constructor
A new instance of Base.
-
#on_delete(tableView, tableViewDelegate) ⇒ Object
called when the delete editing style was triggered tableView:commitEditingStyle:forRowAtIndexPath:.
-
#on_select(tableView, tableViewDelegate) ⇒ Object
Override in subclass.
-
#update_cell(cell) ⇒ Object
Called on every tableView:cellForRowAtIndexPath: so keep implementation details minimal.
- #with_semaphore(&block) ⇒ Object
Constructor Details
#initialize(row) ⇒ Base
Returns a new instance of Base.
18 19 20 |
# File 'lib/formotion/row_type/base.rb', line 18 def initialize(row) @row = row end |
Instance Attribute Details
#row ⇒ Object
Returns the value of attribute row.
4 5 6 |
# File 'lib/formotion/row_type/base.rb', line 4 def row @row end |
#tableView ⇒ Object
Returns the value of attribute tableView.
4 5 6 |
# File 'lib/formotion/row_type/base.rb', line 4 def tableView @tableView end |
Class Method Details
.field_buffer ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/formotion/row_type/base.rb', line 6 def self.field_buffer if Device.iphone? or App.window.size.width <= 320 20 else 64 end end |
Instance Method Details
#_on_select(tableView, tableViewDelegate) ⇒ Object
method gets triggered when tableView(tableView, didSelectRowAtIndexPath:indexPath) in UITableViewDelegate is executed
59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# 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) ⇒ Object
called by the Row after all the setup and connections are made in #make_cell
49 50 |
# File 'lib/formotion/row_type/base.rb', line 49 def after_build(cell) end |
#after_delete ⇒ Object
101 102 |
# File 'lib/formotion/row_type/base.rb', line 101 def after_delete end |
#break_with_semaphore(&block) ⇒ Object
104 105 106 107 |
# File 'lib/formotion/row_type/base.rb', line 104 def break_with_semaphore(&block) return if @semaphore with_semaphore(&block) end |
#build_cell(cell) ⇒ Object
builder method for row cell specific implementation
42 43 44 45 |
# File 'lib/formotion/row_type/base.rb', line 42 def build_cell(cell) # implement in row class nil end |
#button? ⇒ Boolean
22 23 24 |
# File 'lib/formotion/row_type/base.rb', line 22 def false end |
#cell_style ⇒ Object
RowCellBuilder uses this to instantiate the UITableViewCell.
27 28 29 |
# File 'lib/formotion/row_type/base.rb', line 27 def cell_style UITableViewCellStyleSubtitle end |
#cellEditingStyle ⇒ Object
Sets the UITableViewCellEditingStyle
32 33 34 |
# File 'lib/formotion/row_type/base.rb', line 32 def cellEditingStyle row.deletable? ? UITableViewCellEditingStyleDelete : UITableViewCellEditingStyleNone end |
#delete_row ⇒ Object
95 96 97 98 99 |
# File 'lib/formotion/row_type/base.rb', line 95 def delete_row tableView.beginUpdates tableView.deleteRowsAtIndexPaths [row.index_path], withRowAnimation:UITableViewRowAnimationBottom tableView.endUpdates end |
#indentWhileEditing? ⇒ Boolean
Indents row while editing
37 38 39 |
# File 'lib/formotion/row_type/base.rb', line 37 def indentWhileEditing? row.indented? end |
#on_delete(tableView, tableViewDelegate) ⇒ Object
called when the delete editing style was triggered tableView:commitEditingStyle:forRowAtIndexPath:
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# 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) ⇒ Object
Override in subclass
75 76 77 |
# File 'lib/formotion/row_type/base.rb', line 75 def on_select(tableView, tableViewDelegate) false end |
#update_cell(cell) ⇒ Object
Called on every tableView:cellForRowAtIndexPath: so keep implementation details minimal
54 55 |
# File 'lib/formotion/row_type/base.rb', line 54 def update_cell(cell) end |
#with_semaphore(&block) ⇒ Object
109 110 111 112 113 |
# File 'lib/formotion/row_type/base.rb', line 109 def with_semaphore(&block) @semaphore = true block.call @semaphore = false end |