Skip to content

Commit 90b410e

Browse files
committed
Update README.md [ci skip]
1 parent f5b00a7 commit 90b410e

3 files changed

Lines changed: 46 additions & 28 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
#### Enhancements
66

7+
* Swift 4.2, [#20](https://github.com/bcylin/QuickTableViewController/pull/20) by [@getaaron](https://github.com/getaaron) and [#28](https://github.com/bcylin/QuickTableViewController/pull/28) by [@ mttcrsp](https://github.com/mttcrsp)
8+
* tvOS UI tests, [#27](https://github.com/bcylin/QuickTableViewController/pull/27) by [@FraDeliro](https://github.com/FraDeliro)
9+
* `Subtitle` is deprecated and will be removed in [**v2.0.0**](https://github.com/bcylin/QuickTableViewController/releases/tag/v2.0.0)
710
* Rename `Row`'s title and subtitle to text and detail text to align with `UITableViewCell`'s naming
8-
* `Subtitle` is deprecated and will be removed in **v2.0.0**
911
* Enable **detailText** in `OptionRow` and `SwitchRow`
1012
* Add **accessoryButtonAction** to `NavigationRow`
1113

README.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ A simple way to create a table view for settings, including:
1313
* Table view cells with center aligned text for tap actions
1414
* A section that provides mutually exclusive options
1515
* Actions performed when the row reacts to the user interaction
16-
* Customizable table view cell image, cell style and accessory type
16+
* Easy to specify table view cell image, cell style and accessory type
1717

1818
<img src="https://bcylin.github.io/QuickTableViewController/img/screenshots.png" width="80%"></img>
1919

@@ -24,32 +24,32 @@ Set up `tableContents` in `viewDidLoad`:
2424
```swift
2525
import QuickTableViewController
2626

27-
class ViewController: QuickTableViewController {
27+
final class ViewController: QuickTableViewController {
2828

2929
override func viewDidLoad() {
3030
super.viewDidLoad()
3131

3232
tableContents = [
3333
Section(title: "Switch", rows: [
3434
SwitchRow(text: "Setting 1", switchValue: true, action: { _ in }),
35-
SwitchRow(text: "Setting 2", switchValue: false, action: { _ in }),
35+
SwitchRow(text: "Setting 2", switchValue: false, action: { _ in })
3636
]),
3737

3838
Section(title: "Tap Action", rows: [
3939
TapActionRow(text: "Tap action", action: { [weak self] in self?.showAlert($0) })
4040
]),
4141

4242
Section(title: "Navigation", rows: [
43-
NavigationRow(text: "CellStyle.default", subtitle: .none, icon: .named("gear")),
43+
NavigationRow(text: "CellStyle.default", detailText: .none, icon: .named("gear")),
4444
NavigationRow(text: "CellStyle", detailText: .subtitle(".subtitle"), icon: .named("globe")),
45-
NavigationRow(text: "CellStyle", subtitle: .rightAligned(".value1"), icon: .named("time"), action: { _ in }),
46-
NavigationRow(text: "CellStyle", subtitle: .leftAligned(".value2"))
47-
]),
45+
NavigationRow(text: "CellStyle", detailText: .value1(".value1"), icon: .named("time"), action: { _ in }),
46+
NavigationRow(text: "CellStyle", detailText: .value2(".value2"))
47+
], footer: "UITableViewCellStyle.Value2 hides the image view."),
4848

4949
RadioSection(title: "Radio Buttons", options: [
50-
OptionRow(text: "Option 1", isSelected: true, action: didToggleOption()),
51-
OptionRow(text: "Option 2", isSelected: false, action: didToggleOption()),
52-
OptionRow(text: "Option 3", isSelected: false, action: didToggleOption())
50+
OptionRow(text: "Option 1", isSelected: true, action: didToggleSelection()),
51+
OptionRow(text: "Option 2", isSelected: false, action: didToggleSelection()),
52+
OptionRow(text: "Option 3", isSelected: false, action: didToggleSelection())
5353
], footer: "See RadioSection for more details.")
5454
]
5555
}
@@ -60,7 +60,7 @@ class ViewController: QuickTableViewController {
6060
// ...
6161
}
6262

63-
private func didToggleOption() -> (Row) -> Void {
63+
private func didToggleSelection() -> (Row) -> Void {
6464
return { [weak self] row in
6565
// ...
6666
}
@@ -71,19 +71,34 @@ class ViewController: QuickTableViewController {
7171

7272
### NavigationRow
7373

74-
#### Subtitle Styles
74+
#### Detail Text Styles
7575

7676
```swift
77-
NavigationRow(text: "UITableViewCellStyle.default", subtitle: .none)
77+
NavigationRow(text: "UITableViewCellStyle.default", detailText: .none)
7878
NavigationRow(text: "UITableViewCellStyle", detailText: .subtitle(".subtitle")
79-
NavigationRow(text: "UITableViewCellStyle", subtitle: .rightAligned(".value1")
80-
NavigationRow(text: "UITableViewCellStyle", subtitle: .leftAligned(".value2"))
79+
NavigationRow(text: "UITableViewCellStyle", detailText: .value1(".value1")
80+
NavigationRow(text: "UITableViewCellStyle", detailText: .value2(".value2"))
8181
```
8282

83-
#### Disclosure Indicator
83+
[`Subtitle`](https://github.com/bcylin/QuickTableViewController/blob/develop/Source/Model/Subtitle.swift) and the [initializers with title/subtitle](https://github.com/bcylin/QuickTableViewController/blob/develop/Source/Model/Deprecated.swift) are deprecated and will be removed in **v2.0.0**.
84+
85+
#### Accessory Type
86+
87+
* The `NavigationRow` shows with different accessory types based on the `action` and `accessoryButtonAction` closures:
88+
89+
```swift
90+
var accessoryType: UITableViewCell.AccessoryType {
91+
switch (action, accessoryButtonAction) {
92+
case (nil, nil): return .none
93+
case (.some, nil): return .disclosureIndicator
94+
case (nil, .some): return .detailButton
95+
case (.some, .some): return .detailDisclosureButton
96+
}
97+
}
98+
```
8499

85-
* A `NavigationRow` with an `action` will be displayed in a table view cell with `.disclosureIndicator`.
86100
* The `action` will be invoked when the table view cell is selected.
101+
* The `accessoryButtonAction` will be invoked when the accessory button is selected.
87102

88103
#### Images
89104

@@ -102,32 +117,31 @@ enum Icon {
102117

103118
* A `SwitchRow` is representing a table view cell with a `UISwitch` as its `accessoryView`.
104119
* The `action` will be invoked when the switch value changes.
105-
* The subtitle is disabled in `SwitchRow `.
106120

107121
### TapActionRow
108122

109123
* A `TapActionRow` is representing a button-like table view cell.
110124
* The `action` will be invoked when the table view cell is selected.
111-
* The icon and subtitle are disabled in `TapActionRow`.
125+
* The icon, detail text, and accessory type are disabled in `TapActionRow`.
112126

113127
### OptionRow
114128

115129
* An `OptionRow` is representing a table view cell with `.checkmark`.
116-
* The subtitle is disabled in `OptionRow`.
117130
* The `action` will be invoked when the selected state is toggled.
118131

119132
```swift
120-
let didToggleOption: (Row) -> Void = { [weak self] in
133+
let didToggleSelection: (Row) -> Void = { [weak self] in
121134
if let option = $0 as? OptionRowCompatible, option.isSelected {
122-
// to exclude the option that's toggled off
135+
// to exclude the event where the option is toggled off
123136
}
124137
}
125138
```
126139

127140
### RadioSection
128141

129-
* `OptionRow` can be used with or without `RadioSection`, which allows only one selected option.
142+
* `RadioSection` allows only one selected option at a time.
130143
* Setting `alwaysSelectsOneOption` to true will keep one of the options selected.
144+
* `OptionRow` can also be used with `Section` for multiple selections.
131145

132146
## Customization
133147

@@ -146,7 +160,7 @@ A customized table view cell type can be specified to rows during initialization
146160

147161
```swift
148162
// Default is UITableViewCell.
149-
NavigationRow<CustomCell>(text: "Navigation", subtitle: .none)
163+
NavigationRow<CustomCell>(text: "Navigation", detailText: .none)
150164

151165
// Default is SwitchCell.
152166
SwitchRow<CustomSwitchCell>(text: "Switch", switchValue: true, action: { _ in })
@@ -193,7 +207,7 @@ protocol RowStyle {
193207
}
194208
```
195209

196-
The `customize` closure overwrites the `Configurable` setup.
210+
The `customize` closure [overwrites](https://github.com/bcylin/QuickTableViewController/blob/develop/Source/QuickTableViewController.swift#L104-L109) the `Configurable` setup.
197211

198212
### UIAppearance
199213

@@ -203,6 +217,7 @@ As discussed in issue [#12](https://github.com/bcylin/QuickTableViewController/i
203217

204218
* `UISwitch` is replaced by a checkmark in `SwitchCell`.
205219
* `TapActionCell` does not use center aligned text.
220+
* `NavigationRow.accessoryButtonAction` is not available.
206221
* Cell image view's left margin is 0.
207222

208223
## Limitation
@@ -236,6 +251,7 @@ QuickTableViewController | iOS | tvOS | Xcode | Swift
236251
`~> 0.8.0` | 8.0+ | - | 9.1 | 4.0
237252
`~> 0.9.0` | 8.0+ | - | 9.3 | 4.1
238253
`~> 1.0.0` | 8.0+ | 9.0+ | 9.4 | 4.1
254+
`~> 1.1.0` | 8.0+ | 9.0+ | 10.1 | 4.2
239255

240256
## Installation
241257

Source/Rows/NavigationRow.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ open class NavigationRow<T: UITableViewCell>: NavigationRowCompatible, Equatable
3333

3434
#if os(iOS)
3535

36-
/// Initializes a `NavigationRow` with a text and a detail text.
36+
/// Designated initializer on iOS. Returns a `NavigationRow` with a text and a detail text.
3737
/// The icon, customization, action and accessory button action closures are optional.
3838
public init(
3939
text: String,
@@ -53,7 +53,7 @@ open class NavigationRow<T: UITableViewCell>: NavigationRowCompatible, Equatable
5353

5454
#elseif os(tvOS)
5555

56-
/// Initializes a `NavigationRow` with a text and a detail text.
56+
/// Designated initializer on tvOS. Returns a `NavigationRow` with a text and a detail text.
5757
/// The icon, customization and action closures are optional.
5858
public init(
5959
text: String,

0 commit comments

Comments
 (0)