mirror of
https://github.com/zhigang1992/ProMotion.git
synced 2026-04-24 04:15:49 +08:00
Merge pull request #486 from clearsightstudio/pm2-accessory-type
PM2 table cell accessoryType functionality
This commit is contained in:
@@ -16,13 +16,14 @@ module ProMotion
|
||||
set_remote_image
|
||||
set_accessory_view
|
||||
set_selection_style
|
||||
set_accessory_type
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
# TODO: Remove this in ProMotion 2.1. Just for migration purposes.
|
||||
def check_deprecated_styles
|
||||
whitelist = [ :title, :subtitle, :image, :remote_image, :accessory, :selection_style, :action, :long_press_action, :arguments, :cell_style, :cell_class, :cell_identifier, :editing_style, :search_text, :keep_selection, :height ]
|
||||
whitelist = [ :title, :subtitle, :image, :remote_image, :accessory, :selection_style, :action, :long_press_action, :arguments, :cell_style, :cell_class, :cell_identifier, :editing_style, :search_text, :keep_selection, :height, :accessory_type ]
|
||||
if (data_cell.keys - whitelist).length > 0
|
||||
PM.logger.deprecated("In #{self.table_screen.class.to_s}#table_data, you should set :#{(data_cell.keys - whitelist).join(", :")} in a `style:` hash. See TableScreen documentation.")
|
||||
end
|
||||
@@ -80,6 +81,10 @@ module ProMotion
|
||||
self.selectionStyle = map_selection_style_symbol(data_cell[:selection_style]) if data_cell[:selection_style]
|
||||
end
|
||||
|
||||
def set_accessory_type
|
||||
self.accessoryType = map_accessory_type_symbol(data_cell[:accessory_type]) if data_cell[:accessory_type]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def jm_image_cache?
|
||||
@@ -121,5 +126,15 @@ module ProMotion
|
||||
default: UITableViewCellSelectionStyleDefault
|
||||
}[symbol] || symbol
|
||||
end
|
||||
|
||||
def map_accessory_type_symbol(symbol)
|
||||
{
|
||||
none: UITableViewCellAccessoryNone,
|
||||
disclosure_indicator: UITableViewCellAccessoryDisclosureIndicator,
|
||||
disclosure_button: UITableViewCellAccessoryDetailDisclosureButton,
|
||||
checkmark: UITableViewCellAccessoryCheckmark,
|
||||
detail_button: UITableViewCellAccessoryDetailButton
|
||||
}[symbol] || symbol
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ describe "PM::TableViewCellModule" do
|
||||
accessory: {
|
||||
view: :switch, # currently only :switch is supported
|
||||
value: true
|
||||
},
|
||||
},
|
||||
image: {
|
||||
image: UIImage.imageNamed("list"),
|
||||
radius: 15
|
||||
@@ -24,7 +24,8 @@ describe "PM::TableViewCellModule" do
|
||||
masks_to_bounds: true
|
||||
},
|
||||
background_color: UIColor.redColor
|
||||
}
|
||||
},
|
||||
accessory_type: :disclosure_indicator
|
||||
}
|
||||
end
|
||||
|
||||
@@ -136,6 +137,8 @@ describe "PM::TableViewCellModule" do
|
||||
@subject.imageView.layer.cornerRadius.should == 15.0
|
||||
end
|
||||
|
||||
it "should have the proper accessory type" do
|
||||
@subject.accessoryType.should == UITableViewCellAccessoryDisclosureIndicator
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user