Skip to content

Commit

Permalink
Merge branch 'hotfix/1.2.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
bcylin committed Jul 2, 2020
2 parents 3ac01fb + 9d77076 commit f2a8120
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .jazzy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ clean: true
author: bcylin
author_url: https://github.com/bcylin
github_url: https://github.com/bcylin/QuickTableViewController
github_file_prefix: https://github.com/bcylin/QuickTableViewController/blob/v1.2.3
github_file_prefix: https://github.com/bcylin/QuickTableViewController/blob/v1.2.4
xcodebuild_arguments: [
-project, QuickTableViewController.xcodeproj,
-scheme, QuickTableViewController-iOS,
-sdk, iphonesimulator
]
module: QuickTableViewController
module_version: 1.2.3
module_version: 1.2.4
output: docs/output
theme: fullwidth
skip_undocumented: true
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## v1.2.4

* Fix an issue where the same identifier is used for different cell types [#50](https://github.com/bcylin/QuickTableViewController/issues/50)

## v1.2.3

* Fix Swift version in podspec
Expand Down
2 changes: 1 addition & 1 deletion Example-iOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleVersion</key>
<string>101</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion Example-iOSUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Example-tvOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleVersion</key>
<string>101</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
2 changes: 1 addition & 1 deletion Example-tvOSUITests/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion QuickTableViewController.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "QuickTableViewController"
s.version = "1.2.3"
s.version = "1.2.4"
s.summary = "A simple way to create a UITableView for settings."
s.screenshots = "https://raw.githubusercontent.com/bcylin/QuickTableViewController/gh-pages/img/screenshot-1.png",
"https://raw.githubusercontent.com/bcylin/QuickTableViewController/gh-pages/img/screenshot-2.png"
Expand Down
2 changes: 1 addition & 1 deletion QuickTableViewController/Info-iOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion QuickTableViewController/Info-iOSTests.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion QuickTableViewController/Info-tvOS.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
2 changes: 1 addition & 1 deletion QuickTableViewController/Info-tvOSTests.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.2.3</string>
<string>1.2.4</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Source/Rows/NavigationRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ open class NavigationRow<T: UITableViewCell>: NavigationRowCompatible, Equatable
}


private extension UITableViewCell.CellStyle {
internal extension UITableViewCell.CellStyle {

var stringValue: String {
switch self {
Expand Down
6 changes: 4 additions & 2 deletions Source/Rows/OptionRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ open class OptionRow<T: UITableViewCell>: OptionRowCompatible, Equatable {
/// The type of the table view cell to display the row.
public let cellType: UITableViewCell.Type = T.self

/// The reuse identifier of the table view cell to display the row. The default value is **UITableViewCell**.
public let cellReuseIdentifier: String = T.reuseIdentifier
/// Returns the reuse identifier of the table view cell to display the row.
public var cellReuseIdentifier: String {
return T.reuseIdentifier + (detailText?.style.stringValue ?? "")
}

/// Returns the table view cell style for the specified detail text.
public var cellStyle: UITableViewCell.CellStyle {
Expand Down
6 changes: 4 additions & 2 deletions Source/Rows/SwitchRow.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ open class SwitchRow<T: SwitchCell>: SwitchRowCompatible, Equatable {
/// The type of the table view cell to display the row.
public let cellType: UITableViewCell.Type = T.self

/// The reuse identifier of the table view cell to display the row. The default value is **SwitchCell**.
public let cellReuseIdentifier: String = T.reuseIdentifier
/// Returns the reuse identifier of the table view cell to display the row.
public var cellReuseIdentifier: String {
return T.reuseIdentifier + (detailText?.style.stringValue ?? "")
}

/// Returns the table view cell style for the specified detail text.
public var cellStyle: UITableViewCell.CellStyle {
Expand Down
1 change: 1 addition & 0 deletions Tests/CustomTypes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import UIKit
internal final class CustomCell: UITableViewCell {}
internal final class CustomSwitchCell: SwitchCell {}
internal final class CustomTapActionCell: TapActionCell {}
internal final class CustomOptionCell: UITableViewCell {}

internal final class CustomNavigationRow<T: UITableViewCell>: NavigationRow<T> {}
internal final class CustomSwitchRow<T: SwitchCell>: SwitchRow<T> {}
Expand Down
26 changes: 25 additions & 1 deletion Tests/Row/NavigationRowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,44 @@ internal final class NavigationRowTests: XCTestCase {
}
#endif

func testCellReuseIdentifier() {
func testCellStyleWithReuseIdentifier() {
// When
let a = NavigationRow(text: "", detailText: .none)
let b = NavigationRow(text: "", detailText: .subtitle(""))
let c = NavigationRow(text: "", detailText: .value1(""))
let d = NavigationRow(text: "", detailText: .value2(""))

// Then
XCTAssertEqual(a.cellStyle, .default)
XCTAssertEqual(b.cellStyle, .subtitle)
XCTAssertEqual(c.cellStyle, .value1)
XCTAssertEqual(d.cellStyle, .value2)

XCTAssertEqual(a.cellReuseIdentifier, "UITableViewCell.default")
XCTAssertEqual(b.cellReuseIdentifier, "UITableViewCell.subtitle")
XCTAssertEqual(c.cellReuseIdentifier, "UITableViewCell.value1")
XCTAssertEqual(d.cellReuseIdentifier, "UITableViewCell.value2")
}

func testCellStyleWithReuseIdentifier_customCellType() {
// When
let a = NavigationRow<CustomCell>(text: "", detailText: .none)
let b = NavigationRow<CustomCell>(text: "", detailText: .subtitle(""))
let c = NavigationRow<CustomCell>(text: "", detailText: .value1(""))
let d = NavigationRow<CustomCell>(text: "", detailText: .value2(""))

// Then
XCTAssertEqual(a.cellStyle, .default)
XCTAssertEqual(b.cellStyle, .subtitle)
XCTAssertEqual(c.cellStyle, .value1)
XCTAssertEqual(d.cellStyle, .value2)

XCTAssertEqual(a.cellReuseIdentifier, "CustomCell.default")
XCTAssertEqual(b.cellReuseIdentifier, "CustomCell.subtitle")
XCTAssertEqual(c.cellReuseIdentifier, "CustomCell.value1")
XCTAssertEqual(d.cellReuseIdentifier, "CustomCell.value2")
}

#if os(iOS)
func testAccessoryType_iOS() {
// When
Expand Down
46 changes: 45 additions & 1 deletion Tests/Row/OptionRowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal final class OptionRowTests: XCTestCase {
XCTAssertEqual(row.isSelected, true)

// With RowStyle
XCTAssertEqual(row.cellReuseIdentifier, "UITableViewCell")
XCTAssertEqual(row.cellReuseIdentifier, "UITableViewCell.subtitle")
XCTAssertEqual(row.cellStyle, .subtitle)
XCTAssertEqual(row.icon, icon)
XCTAssertEqual(row.accessoryType, .checkmark)
Expand All @@ -60,6 +60,50 @@ internal final class OptionRowTests: XCTestCase {
XCTAssertEqual(actionInvoked, true)
}

func testCellStyleWithReuseIdentifier() {
// When
let a = OptionRow(text: "", detailText: nil, isSelected: true, action: { _ in })
let b = OptionRow(text: "", detailText: DetailText.none, isSelected: true, action: { _ in })
let c = OptionRow(text: "", detailText: .subtitle(""), isSelected: true, action: { _ in })
let d = OptionRow(text: "", detailText: .value1(""), isSelected: true, action: { _ in })
let e = OptionRow(text: "", detailText: .value2(""), isSelected: true, action: { _ in })

// Then
XCTAssertEqual(a.cellStyle, .default)
XCTAssertEqual(b.cellStyle, .default)
XCTAssertEqual(c.cellStyle, .subtitle)
XCTAssertEqual(d.cellStyle, .value1)
XCTAssertEqual(e.cellStyle, .value2)

XCTAssertEqual(a.cellReuseIdentifier, "UITableViewCell")
XCTAssertEqual(b.cellReuseIdentifier, "UITableViewCell.default")
XCTAssertEqual(c.cellReuseIdentifier, "UITableViewCell.subtitle")
XCTAssertEqual(d.cellReuseIdentifier, "UITableViewCell.value1")
XCTAssertEqual(e.cellReuseIdentifier, "UITableViewCell.value2")
}

func testCellStyleWithReuseIdentifier_customCellType() {
// When
let a = OptionRow<CustomOptionCell>(text: "", detailText: nil, isSelected: true, action: { _ in })
let b = OptionRow<CustomOptionCell>(text: "", detailText: DetailText.none, isSelected: true, action: { _ in })
let c = OptionRow<CustomOptionCell>(text: "", detailText: .subtitle(""), isSelected: true, action: { _ in })
let d = OptionRow<CustomOptionCell>(text: "", detailText: .value1(""), isSelected: true, action: { _ in })
let e = OptionRow<CustomOptionCell>(text: "", detailText: .value2(""), isSelected: true, action: { _ in })

// Then
XCTAssertEqual(a.cellStyle, .default)
XCTAssertEqual(b.cellStyle, .default)
XCTAssertEqual(c.cellStyle, .subtitle)
XCTAssertEqual(d.cellStyle, .value1)
XCTAssertEqual(e.cellStyle, .value2)

XCTAssertEqual(a.cellReuseIdentifier, "CustomOptionCell")
XCTAssertEqual(b.cellReuseIdentifier, "CustomOptionCell.default")
XCTAssertEqual(c.cellReuseIdentifier, "CustomOptionCell.subtitle")
XCTAssertEqual(d.cellReuseIdentifier, "CustomOptionCell.value1")
XCTAssertEqual(e.cellReuseIdentifier, "CustomOptionCell.value2")
}

// MARK: - Equatable

func testEquatable_withIdenticalParameters() {
Expand Down
46 changes: 45 additions & 1 deletion Tests/Row/SwitchRowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ internal final class SwitchRowTests: XCTestCase {
XCTAssertEqual(row.switchValue, true)

// With RowStyle
XCTAssertEqual(row.cellReuseIdentifier, "SwitchCell")
XCTAssertEqual(row.cellReuseIdentifier, "SwitchCell.subtitle")
XCTAssertEqual(row.cellStyle, .subtitle)
XCTAssertEqual(row.icon, icon)
XCTAssertNil(row.customize)
Expand All @@ -66,6 +66,50 @@ internal final class SwitchRowTests: XCTestCase {
XCTAssertEqual(actionInvoked, true)
}

func testCellStyleWithReuseIdentifier() {
// When
let a = SwitchRow(text: "", detailText: nil, switchValue: true, action: { _ in })
let b = SwitchRow(text: "", detailText: DetailText.none, switchValue: true, action: { _ in })
let c = SwitchRow(text: "", detailText: .subtitle(""), switchValue: true, action: { _ in })
let d = SwitchRow(text: "", detailText: .value1(""), switchValue: true, action: { _ in })
let e = SwitchRow(text: "", detailText: .value2(""), switchValue: true, action: { _ in })

// Then
XCTAssertEqual(a.cellStyle, .default)
XCTAssertEqual(b.cellStyle, .default)
XCTAssertEqual(c.cellStyle, .subtitle)
XCTAssertEqual(d.cellStyle, .value1)
XCTAssertEqual(e.cellStyle, .value2)

XCTAssertEqual(a.cellReuseIdentifier, "SwitchCell")
XCTAssertEqual(b.cellReuseIdentifier, "SwitchCell.default")
XCTAssertEqual(c.cellReuseIdentifier, "SwitchCell.subtitle")
XCTAssertEqual(d.cellReuseIdentifier, "SwitchCell.value1")
XCTAssertEqual(e.cellReuseIdentifier, "SwitchCell.value2")
}

func testCellStyleWithReuseIdentifier_customCellType() {
// When
let a = SwitchRow<CustomSwitchCell>(text: "", detailText: nil, switchValue: true, action: { _ in })
let b = SwitchRow<CustomSwitchCell>(text: "", detailText: DetailText.none, switchValue: true, action: { _ in })
let c = SwitchRow<CustomSwitchCell>(text: "", detailText: .subtitle(""), switchValue: true, action: { _ in })
let d = SwitchRow<CustomSwitchCell>(text: "", detailText: .value1(""), switchValue: true, action: { _ in })
let e = SwitchRow<CustomSwitchCell>(text: "", detailText: .value2(""), switchValue: true, action: { _ in })

// Then
XCTAssertEqual(a.cellStyle, .default)
XCTAssertEqual(b.cellStyle, .default)
XCTAssertEqual(c.cellStyle, .subtitle)
XCTAssertEqual(d.cellStyle, .value1)
XCTAssertEqual(e.cellStyle, .value2)

XCTAssertEqual(a.cellReuseIdentifier, "CustomSwitchCell")
XCTAssertEqual(b.cellReuseIdentifier, "CustomSwitchCell.default")
XCTAssertEqual(c.cellReuseIdentifier, "CustomSwitchCell.subtitle")
XCTAssertEqual(d.cellReuseIdentifier, "CustomSwitchCell.value1")
XCTAssertEqual(e.cellReuseIdentifier, "CustomSwitchCell.value2")
}

// MARK: - Equatable

func testEquatable_withIdenticalParameters() {
Expand Down
9 changes: 9 additions & 0 deletions Tests/Row/TapActionRowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@ internal final class TapActionRowTests: XCTestCase {
XCTAssertEqual(actionInvoked, true)
}

func testCellStyleWithReuseIdentifier_customCellType() {
// When
let row = TapActionRow<CustomTapActionCell>(text: "", action: { _ in })

// Then
XCTAssertEqual(row.cellStyle, .default)
XCTAssertEqual(row.cellReuseIdentifier, "CustomTapActionCell")
}

// MARK: - Equatable

func testEquatable_withIdenticalParameters() {
Expand Down

0 comments on commit f2a8120

Please sign in to comment.