File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed
SheeeeeeeeetExample/ActionSheets Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -173,8 +173,19 @@ with no transparent background.
173173## Appearance
174174
175175Sheets can be globally styled by using the ` ActionSheetAppearance.standard ` . All
176- sheets copy this appearance when they are created. They can then be individually
177- styled without affecting the global appearance.
176+ action sheet items will then copy this appearance upon creation, and apply it to
177+ all items each time it refreshes its content.
178+
179+ If you want to apply a global style for all your action sheets, simply style the
180+ ` ActionSheetAppearance.standard ` property and all action sheets will be affected.
181+
182+ If you want to apply an individual style to a single action sheet, just style it
183+ using its ` appearance ` property (a copy of ` ActionSheetAppearance.standard ` ), or
184+ completely replace it with a completely different appearance instance.
185+
186+ If you want to apply an individual style to a single action sheet item, just set
187+ its optional ` customAppearance ` property to any custom value. Just be careful to
188+ copy any other appearance, otherwise you'll affect the original style.
178189
179190Have a look at the example app to see how global and individual appearances work.
180191
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ Sheeeeeeeeet may have breaking changes in minor versions and revisions below 1.0
55
66## 0.11.0
77
8- This minor version fixes some appearance glitches and makes the appearance setup
9- more consistent.
8+ This version adds a ` customAppearance ` property to ` ActionSheetItem ` and fixes a
9+ few appearance glitches. Overall, it makes the appearance setup more consistent.
1010
1111* I use early returns in every appearance class and have optimized imports. Many
1212appearance classes have also been made ` open ` instead of ` public ` .
Original file line number Diff line number Diff line change @@ -72,13 +72,14 @@ open class ActionSheetItem: NSObject {
7272
7373 open var appearance : ActionSheetItemAppearance
7474 open var cellStyle : UITableViewCell . CellStyle = . default
75+ open var customAppearance : ActionSheetItemAppearance ?
7576 open var tapBehavior : TapBehavior
7677
7778
7879 // MARK: - Functions
7980
8081 open func applyAppearance( _ appearance: ActionSheetAppearance ) {
81- self . appearance = ActionSheetItemAppearance ( copy: appearance. item)
82+ self . appearance = customAppearance ?? ActionSheetItemAppearance ( copy: appearance. item)
8283 }
8384
8485 open func applyAppearance( to cell: UITableViewCell ) {
Original file line number Diff line number Diff line change @@ -30,6 +30,11 @@ private extension HeaderActionSheet {
3030
3131 static func items( for options: [ FoodOption ] ) -> [ ActionSheetItem ] {
3232 var items = options. map { $0. item ( ) }
33+
34+ items [ 0 ] . customAppearance = ActionSheetItemAppearance ( copy: ActionSheetAppearance . standard. item)
35+ items [ 0 ] . customAppearance? . textColor = . red
36+ items [ 0 ] . customAppearance? . separatorInsets. left = 100
37+
3338 items. insert ( titleItem ( title: standardTitle) , at: 0 )
3439 items. append ( cancelButton)
3540 return items
You can’t perform that action at this time.
0 commit comments