Class: Formotion::RowType::ObjectRow
- Defined in:
- lib/formotion/row_type/object_row.rb
Direct Known Subclasses
Constant Summary
Constants inherited from StringRow
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #build_cell(cell) ⇒ Object
-
#row_value ⇒ Object
overriden in subclasses.
-
#update_text_field(new_value) ⇒ Object
Used when row.value changes.
Methods inherited from StringRow
#add_callbacks, #done_editing, #input_accessory_view, #keyboardType, #on_change, #on_select
Methods inherited from Base
#_on_select, #after_build, #after_delete, #break_with_semaphore, #button?, #cellEditingStyle, #cell_style, #delete_row, field_buffer, #indentWhileEditing?, #initialize, #on_delete, #on_select, #update_cell, #with_semaphore
Constructor Details
This class inherits a constructor from Formotion::RowType::Base
Instance Method Details
#build_cell(cell) ⇒ Object
7 8 9 10 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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/formotion/row_type/object_row.rb', line 7 def build_cell(cell) cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleBlue field = UITextField.alloc.initWithFrame(CGRectZero) field.tag = TEXT_FIELD_TAG observe(self.row, "value") do |old_value, new_value| break_with_semaphore do update_text_field(new_value) end end field.clearButtonMode = UITextFieldViewModeWhileEditing field.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter field.textAlignment = row.text_alignment || NSTextAlignmentRight field.keyboardType = keyboardType field.secureTextEntry = true if row.secure? field.returnKeyType = row.return_key || UIReturnKeyNext field.autocapitalizationType = row.auto_capitalization if row.auto_capitalization field.autocorrectionType = row.auto_correction if row.auto_correction field.clearButtonMode = row. || UITextFieldViewModeWhileEditing field.enabled = row.editable? field.inputAccessoryView = input_accessory_view(row.input_accessory) if row.input_accessory add_callbacks(field) cell.swizzle(:layoutSubviews) do def layoutSubviews old_layoutSubviews # viewWithTag is terrible, but I think it's ok to use here... formotion_field = self.viewWithTag(TEXT_FIELD_TAG) formotion_field.sizeToFit field_frame = formotion_field.frame field_frame.origin.x = self.textLabel.frame.origin.x + self.textLabel.frame.size.width + Formotion::RowType::Base.field_buffer field_frame.origin.y = ((self.frame.size.height - field_frame.size.height) / 2.0).round field_frame.size.width = self.frame.size.width - field_frame.origin.x - Formotion::RowType::Base.field_buffer formotion_field.frame = field_frame end end field.font = BW::Font.new(row.font) if row.font field.placeholder = row.placeholder field.text = row_value.to_s cell.addSubview(field) field end |
#row_value ⇒ Object
overriden in subclasses
64 65 66 |
# File 'lib/formotion/row_type/object_row.rb', line 64 def row_value row.value end |
#update_text_field(new_value) ⇒ Object
Used when row.value changes
59 60 61 |
# File 'lib/formotion/row_type/object_row.rb', line 59 def update_text_field(new_value) self.row.text_field.text = row_value.to_s end |