lib/ProMotion/screens/_tables/table_data.rb in ProMotion-0.7.4 vs lib/ProMotion/screens/_tables/table_data.rb in ProMotion-0.7.5
- old
+ new
@@ -85,11 +85,11 @@
table_cell
end
def set_data_cell_defaults(data_cell)
data_cell[:cell_style] ||= UITableViewCellStyleDefault
- data_cell[:cell_identifier] ||= "Cell"
+ data_cell[:cell_identifier] ||= build_cell_identifier(data_cell)
data_cell[:cell_class] ||= ProMotion::TableViewCell
data_cell
end
def remap_data_cell(data_cell)
@@ -127,10 +127,20 @@
if data_cell[:styles] && data_cell[:styles][:textLabel]
PM.logger.deprecated "`:textLabel` is deprecated in TableScreens. Use `:label`"
data_cell[:styles][:label] = data_cell[:styles][:textLabel]
end
+ # Fix the accessory view if needed
+ # Legacy Support < 0.7.4
+ data_cell[:accessory] ||= data_cell[:accessory_view]
+ data_cell[:accessory] = {
+ view: data_cell[:accessory],
+ value: data_cell[:accessory_value],
+ action: data_cell[:accessory_action],
+ arguments: data_cell[:accessory_arguments]
+ } unless data_cell[:accessory].is_a? Hash
+
data_cell
end
def create_table_cell(data_cell)
table_cell = table_view.dequeueReusableCellWithIdentifier(data_cell[:cell_identifier])
@@ -142,9 +152,24 @@
end
table_cell.setup(data_cell)
table_cell
+ end
+
+ def build_cell_identifier(data_cell)
+ ident = "Cell"
+ unless data_cell[:accessory].nil?
+ if data_cell[:accessory][:view] == :switch
+ ident << "-switch"
+ elsif !data_cell[:accessory][:view].nil?
+ ident << "-accessory"
+ end
+ end
+ ident << "-subtitle" if data_cell[:subtitle]
+ ident << "-remoteimage" if data_cell[:remote_image]
+ ident << "-image" if data_cell[:image]
+ ident
end
end
end