Class: Formotion::RowType::SubformRow
- Inherits:
-
Base
show all
- Defined in:
- lib/formotion/row_type/subform_row.rb
Constant Summary
collapse
- LABEL_TAG =
1001
Instance Attribute Summary
Attributes inherited from Base
#row, #tableView
Instance Method Summary
collapse
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, #with_semaphore
Instance Method Details
#build_cell(cell) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/formotion/row_type/subform_row.rb', line 9
def build_cell(cell)
cell.selectionStyle = self.row.selection_style || UITableViewCellSelectionStyleBlue
cell.accessoryType = cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator
cell.contentView.addSubview(self.display_key_label)
cell.swizzle(:layoutSubviews) do
def layoutSubviews
old_layoutSubviews
formotion_label = self.viewWithTag(LABEL_TAG)
formotion_label.sizeToFit
field_frame = formotion_label.frame
field_frame.origin.x = self.contentView.frame.size.width - field_frame.size.width - 10
field_frame.origin.y = ((self.contentView.frame.size.height - field_frame.size.height) / 2.0).round
formotion_label.frame = field_frame
end
end
display_key_label.highlightedTextColor = cell.textLabel.highlightedTextColor
nil
end
|
#display_key_label ⇒ Object
50
51
52
53
54
55
56
57
58
|
# File 'lib/formotion/row_type/subform_row.rb', line 50
def display_key_label
@display_key_label ||= begin
label = UILabel.alloc.initWithFrame(CGRectZero)
label.textColor = "#385387".to_color
label.tag = LABEL_TAG
label.backgroundColor = UIColor.clearColor
label
end
end
|
#on_select(tableView, tableViewDelegate) ⇒ Object
45
46
47
48
|
# File 'lib/formotion/row_type/subform_row.rb', line 45
def on_select(tableView, tableViewDelegate)
subform = row.subform.to_form
row.form.controller.push_subform(subform)
end
|
#update_cell(cell) ⇒ Object
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/formotion/row_type/subform_row.rb', line 34
def update_cell(cell)
subform = row.subform.to_form
if row.display_key && render_row = subform.row(row.display_key)
rendered_value = render_row.value_for_save_hash
if render_row.object && render_row.object.respond_to?('row_value')
rendered_value = render_row.object.row_value
end
self.display_key_label.text = rendered_value
end
end
|