Module: ProMotion::MotionTable::SectionedTable
Instance Method Summary
collapse
Methods included from ViewHelper
#content_height, #frame_from_array, #objective_c_method_name, #set_attribute, #set_attributes, #set_easy_attributes
Instance Method Details
#accessory_toggled_switch(switch) ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 71
def accessory_toggled_switch(switch)
table_cell = switch.superview
index_path = table_cell.superview.indexPathForCell(table_cell)
data_cell = cell_at_section_and_index(index_path.section, index_path.row)
data_cell[:arguments] = {} unless data_cell[:arguments]
data_cell[:arguments][:value] = switch.isOn if data_cell[:arguments].is_a? Hash
data_cell[:accessory_action] ||= data_cell[:accessoryAction]
trigger_action(data_cell[:accessory_action], data_cell[:arguments]) if data_cell[:accessory_action]
end
|
#cell_at_section_and_index(section, index) ⇒ Object
Also known as:
cellAtSectionAndIndex
49
50
51
52
53
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 49
def cell_at_section_and_index(section, index)
if section_at_index(section) && section_at_index(section)[:cells]
return section_at_index(section)[:cells].at(index)
end
end
|
#create_table_view_from_data(data) ⇒ Object
Also known as:
createTableViewFromData
24
25
26
27
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 24
def create_table_view_from_data(data)
set_table_view_data data
return table_view
end
|
#numberOfSectionsInTableView(table_view) ⇒ Object
Cocoa touch methods, leave as-is #################
84
85
86
87
88
89
90
91
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 84
def numberOfSectionsInTableView(table_view)
if @mt_filtered
return @mt_filtered_data.length if @mt_filtered_data
else
return @mt_table_view_groups.length if @mt_table_view_groups
end
0
end
|
#remap_data_cell(data_cell) ⇒ Object
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 110
def remap_data_cell(data_cell)
mappings = {
cell_style: :cellStyle,
cell_identifier: :cellIdentifier,
cell_class: :cellClass,
masks_to_bounds: :masksToBounds,
background_color: :backgroundColor,
selection_style: :selectionStyle,
cell_class_attributes: :cellClassAttributes,
accessory_view: :accessoryView,
accessory_type: :accessoryType,
accessory_checked: :accessoryDefault,
remote_image: :remoteImage,
subviews: :subViews
}
mappings.each_pair do |n, old|
if data_cell[old]
warn "[DEPRECATION] `:#{old}` is deprecated in TableScreens. Use `:#{n}`"
data_cell[n] = data_cell[old]
end
end
if data_cell[:styles] && data_cell[:styles][:textLabel]
warn "[DEPRECATION] `:textLabel` is deprecated in TableScreens. Use `:label`"
data_cell[:styles][:label] = data_cell[:styles][:textLabel]
end
data_cell
end
|
#section_at_index(index) ⇒ Object
41
42
43
44
45
46
47
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 41
def section_at_index(index)
if @mt_filtered
@mt_filtered_data.at(index)
else
@mt_table_view_groups.at(index)
end
end
|
#sectionIndexTitlesForTableView(table_view) ⇒ Object
Set table_data_index if you want the right hand index column (jumplist)
104
105
106
107
108
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 104
def sectionIndexTitlesForTableView(table_view)
if self.respond_to?(:table_data_index)
self.table_data_index
end
end
|
#set_table_view_data(data) ⇒ Object
Also known as:
setTableViewData
36
37
38
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 36
def set_table_view_data(data)
@mt_table_view_groups = data
end
|
#table_setup ⇒ Object
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 5
def table_setup
PM.logger.error "Missing #table_data method in TableScreen #{self.class.to_s}." unless self.respond_to?(:table_data)
self.view = self.create_table_view_from_data(self.table_data)
if self.class.respond_to?(:get_searchable) && self.class.get_searchable
self.make_searchable(content_controller: self, search_bar: self.class.get_searchable_params)
end
if self.class.respond_to?(:get_refreshable) && self.class.get_refreshable
if defined?(UIRefreshControl)
self.make_refreshable(self.class.get_refreshable_params)
else
PM.logger.warn "To use the refresh control on < iOS 6, you need to include the CocoaPod 'CKRefreshControl'."
end
end
end
|
#tableView(table_view, didSelectRowAtIndexPath: index_path) ⇒ Object
94
95
96
97
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 94
def tableView(table_view, numberOfRowsInSection:section)
return section_at_index(section)[:cells].length if section_at_index(section) && section_at_index(section)[:cells]
0
end
|
#trigger_action(action, arguments) ⇒ Object
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 56
def trigger_action(action, arguments)
if self.respond_to?(action)
expected_arguments = self.method(action).arity
if expected_arguments == 0
self.send(action)
elsif expected_arguments == 1 || expected_arguments == -1
self.send(action, arguments)
else
PM.logger.warn "#{action} expects #{expected_arguments} arguments. Maximum number of required arguments for an action is 1."
end
else
PM.logger.info "Action not implemented: #{action.to_s}"
end
end
|
#update_table_view_data(data) ⇒ Object
Also known as:
updateTableViewData
30
31
32
33
|
# File 'lib/ProMotion/screen_helpers/_tables/_sectioned_table.rb', line 30
def update_table_view_data(data)
set_table_view_data data
self.table_view.reloadData
end
|