Skip to content

Commit 657fc28

Browse files
committed
Merge branch 'master' of github.com:danielsaidi/Sheeeeeeeeet
2 parents 65b07db + 2ddee73 commit 657fc28

File tree

8 files changed

+31
-7
lines changed

8 files changed

+31
-7
lines changed

Sheeeeeeeeet/Appearance/Items/ActionSheetSelectItemAppearance.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ open class ActionSheetSelectItemAppearance: ActionSheetItemAppearance {
3939
selectedTextColor = copy?.selectedTextColor ?? selectedTextColor
4040
selectedTintColor = copy?.selectedTintColor ?? selectedTintColor
4141
selectedIconTintColor = copy?.selectedIconTintColor ?? selectedTintColor
42+
unselectedIcon = copy?.unselectedIcon
4243
}
4344

4445

@@ -48,4 +49,5 @@ open class ActionSheetSelectItemAppearance: ActionSheetItemAppearance {
4849
public var selectedIconTintColor: UIColor?
4950
public var selectedTextColor: UIColor?
5051
public var selectedTintColor: UIColor?
52+
public var unselectedIcon: UIImage?
5153
}

Sheeeeeeeeet/Items/ActionSheetItem.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ open class ActionSheetItem: NSObject {
4646
self.tapBehavior = tapBehavior
4747
self.appearance = ActionSheetItemAppearance(copy: appearance)
4848
super.init()
49+
if subtitle != nil { self.cellStyle = .value1}
4950
}
5051

5152

Sheeeeeeeeet/Items/Items/ActionSheetMultiSelectItem.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ open class ActionSheetMultiSelectItem: ActionSheetSelectItem {
3232

3333
public init(
3434
title: String,
35+
subtitle: String? = nil,
3536
isSelected: Bool,
3637
group: String = "",
3738
value: Any? = nil,
3839
image: UIImage? = nil) {
3940
super.init(
4041
title: title,
42+
subtitle: subtitle,
4143
isSelected: isSelected,
4244
group: group,
4345
value: value,

Sheeeeeeeeet/Items/Items/ActionSheetSelectItem.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ open class ActionSheetSelectItem: ActionSheetItem {
3333

3434
public init(
3535
title: String,
36+
subtitle: String? = nil,
3637
isSelected: Bool,
3738
group: String = "",
3839
value: Any? = nil,
@@ -42,6 +43,7 @@ open class ActionSheetSelectItem: ActionSheetItem {
4243
self.group = group
4344
super.init(
4445
title: title,
46+
subtitle: subtitle,
4547
value: value,
4648
image: image,
4749
tapBehavior: tapBehavior)
@@ -69,7 +71,8 @@ open class ActionSheetSelectItem: ActionSheetItem {
6971
open override func applyAppearance(to cell: UITableViewCell) {
7072
super.applyAppearance(to: cell)
7173
guard let appearance = selectAppearance else { return }
72-
cell.accessoryView = isSelected ? UIImageView(image: appearance.selectedIcon) : nil
74+
let accessoryImage = isSelected ? appearance.selectedIcon : appearance.unselectedIcon
75+
cell.accessoryView = UIImageView(image: accessoryImage)
7376
cell.accessoryView?.tintColor = isSelected ? appearance.selectedIconTintColor : appearance.tintColor
7477
cell.tintColor = isSelected ? appearance.selectedTintColor : appearance.tintColor
7578
cell.textLabel?.textColor = isSelected ? appearance.selectedTextColor : appearance.textColor

SheeeeeeeeetExample/AppDelegate+Appearance.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,16 +54,15 @@ extension AppDelegate {
5454
appearance.sectionMargin.height = 20
5555

5656
appearance.selectItem.selectedIcon = UIImage(named: "ic_checkmark")
57+
appearance.selectItem.unselectedIcon = UIImage(named: "ic_empty")
5758
appearance.selectItem.selectedTintColor = blue
5859
appearance.selectItem.selectedTextColor = green
5960
appearance.selectItem.selectedIconTintColor = purple
6061

61-
appearance.singleSelectItem.selectedIcon = UIImage(named: "ic_checkmark")
6262
appearance.singleSelectItem.selectedTintColor = green
6363
appearance.singleSelectItem.selectedTextColor = purple
6464
appearance.singleSelectItem.selectedIconTintColor = blue
6565

66-
appearance.multiSelectItem.selectedIcon = UIImage(named: "ic_checkmark")
6766
appearance.multiSelectItem.selectedTintColor = purple
6867
appearance.multiSelectItem.selectedTextColor = blue
6968
appearance.multiSelectItem.selectedIconTintColor = green
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"images" : [
3+
{
4+
"idiom" : "universal",
5+
"filename" : "ic_empty.png"
6+
}
7+
],
8+
"info" : {
9+
"version" : 1,
10+
"author" : "xcode"
11+
}
12+
}
131 Bytes
Loading

SheeeeeeeeetTests/Items/ActionSheetItemTests.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ class ActionSheetItemTests: QuickSpec {
7474

7575
override func spec() {
7676

77-
func createItem() -> MockActionSheetItem {
78-
return MockActionSheetItem(title: "foo", subtitle: "bar", value: true, image: UIImage())
77+
func createItem(subtitle: String? = nil) -> MockActionSheetItem {
78+
return MockActionSheetItem(title: "foo", subtitle: subtitle, value: true, image: UIImage())
7979

8080
}
8181

@@ -125,10 +125,15 @@ class ActionSheetItemTests: QuickSpec {
125125

126126
describe("cell style") {
127127

128-
it("is default") {
129-
let item = createItem()
128+
it("is default if no subtitle is set") {
129+
let item = createItem(subtitle: nil)
130130
expect(item.cellStyle).to(equal(.default))
131131
}
132+
133+
it("is value1 if subtitle is set") {
134+
let item = createItem(subtitle: "bar")
135+
expect(item.cellStyle).to(equal(.value1))
136+
}
132137
}
133138

134139
describe("custom appearance") {

0 commit comments

Comments
 (0)