lib/ProMotion/table/table.rb in ProMotion-2.3.1 vs lib/ProMotion/table/table.rb in ProMotion-2.4.0

- old
+ new

@@ -4,10 +4,11 @@ include ProMotion::Table::Searchable include ProMotion::Table::Refreshable include ProMotion::Table::Indexable include ProMotion::Table::Longpressable include ProMotion::Table::Utils + include ProMotion::TableBuilder attr_reader :promotion_table_data def table_view self.view @@ -127,19 +128,10 @@ table_view.reloadData end @table_search_display_controller.searchResultsTableView.reloadData if searching? end - def trigger_action(action, arguments, index_path) - return PM.logger.info "Action not implemented: #{action.to_s}" unless self.respond_to?(action) - case self.method(action).arity - when 0 then self.send(action) # Just call the method - when 2 then self.send(action, arguments, index_path) # Send arguments and index path - else self.send(action, arguments) # Send arguments - end - end - def accessory_toggled_switch(switch) table_cell = closest_parent(UITableViewCell, switch) index_path = closest_parent(UITableView, table_cell).indexPathForCell(table_cell) if index_path @@ -160,33 +152,10 @@ end end table_view.deleteRowsAtIndexPaths(deletable_index_paths, withRowAnimation: map_row_animation_symbol(animation)) if deletable_index_paths.length > 0 end - def create_table_cell(data_cell) - new_cell = nil - table_cell = table_view.dequeueReusableCellWithIdentifier(data_cell[:cell_identifier]) || begin - new_cell = data_cell[:cell_class].alloc.initWithStyle(data_cell[:cell_style], reuseIdentifier:data_cell[:cell_identifier]) - new_cell.extend(PM::TableViewCellModule) unless new_cell.is_a?(PM::TableViewCellModule) - new_cell.autoresizingMask = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin - new_cell.clipsToBounds = true # fix for changed default in 7.1 - on_cell_created new_cell, data_cell - new_cell - end - table_cell.setup(data_cell, self) if table_cell.respond_to?(:setup) - on_cell_reused(table_cell, data_cell) if !new_cell - table_cell - end - - def on_cell_created(new_cell, data_cell) - new_cell.send(:on_load) if new_cell.respond_to?(:on_load) - end - - def on_cell_reused(cell, data) - cell.send(:on_reuse) if cell.respond_to?(:on_reuse) - end - def update_table_data(args = {}) args = { index_paths: args } unless args.is_a?(Hash) self.update_table_view_data(self.table_data, args) self.promotion_table_data.search(search_string) if searching? @@ -367,88 +336,9 @@ bottom: UITableViewRowAnimationBottom, none: UITableViewRowAnimationNone, middle: UITableViewRowAnimationMiddle, automatic: UITableViewRowAnimationAutomatic }[symbol] || symbol || UITableViewRowAnimationAutomatic - end - - module TableClassMethods - def table_style - UITableViewStylePlain - end - - def row_height(height, args={}) - if height == :auto - if UIDevice.currentDevice.systemVersion.to_f < 8.0 - height = args[:estimated] || 44.0 - PM.logger.warn "Using `row_height :auto` is not supported in iOS 7 apps. Setting to #{height}." - else - height = UITableViewAutomaticDimension - end - end - args[:estimated] ||= height unless height == UITableViewAutomaticDimension - @row_height = { height: height, estimated: args[:estimated] || 44.0 } - end - - def get_row_height - @row_height ||= nil - end - - # Searchable - def searchable(params={}) - @searchable_params = params - @searchable = true - end - - def get_searchable_params - @searchable_params ||= nil - end - - def get_searchable - @searchable ||= false - end - - # Refreshable - def refreshable(params = {}) - @refreshable_params = params - @refreshable = true - end - - def get_refreshable - @refreshable ||= false - end - - def get_refreshable_params - @refreshable_params ||= nil - end - - # Indexable - def indexable(params = {}) - @indexable_params = params - @indexable = true - end - - def get_indexable - @indexable ||= false - end - - def get_indexable_params - @indexable_params ||= nil - end - - # Longpressable - def longpressable(params = {}) - @longpressable_params = params - @longpressable = true - end - - def get_longpressable - @longpressable ||= false - end - - def get_longpressable_params - @longpressable_params ||= nil - end end def self.included(base) base.extend(TableClassMethods) end