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
- #done_editing ⇒ Object
-
#indentWhileEditing? ⇒ Boolean
Indents row while editing.
-
#initialize(row) ⇒ Base
constructor
A new instance of Base.
-
#input_accessory_view(input_accessory) ⇒ Object
Creates the inputAccessoryView to show if input_accessory property is set on row.
-
#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 BW::Device.iphone? or App.window.size.width <= 320 or BW::Device.ios_version >= "7.0" 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 |
#done_editing ⇒ Object
145 146 147 |
# 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? ⇒ Boolean
Indents row while editing
37 38 39 |
# File 'lib/formotion/row_type/base.rb', line 37 def indentWhileEditing? row.indented? end |
#input_accessory_view(input_accessory) ⇒ Object
Creates the inputAccessoryView to show if input_accessory property is set on row. :done is currently the only supported option.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/formotion/row_type/base.rb', line 118 def input_accessory_view(input_accessory) case input_accessory when :done @input_accessory ||= begin = UIToolbar.alloc.initWithFrame([[0, 0], [0, 44]]) .autoresizingMask = UIViewAutoresizingFlexibleWidth .translucent = true left_space = UIBarButtonItem.alloc.initWithBarButtonSystemItem( UIBarButtonSystemItemFlexibleSpace, target: nil, action: nil) = UIBarButtonItem.alloc.initWithBarButtonSystemItem( UIBarButtonSystemItemDone, target: self, action: :done_editing) .items = [left_space, ] end else nil end 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 |