Skip to content

Commit

Permalink
Merge branch 'release/0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
bcylin committed Aug 23, 2017
2 parents 5b1cafe + 5e703e9 commit a39d74c
Show file tree
Hide file tree
Showing 35 changed files with 880 additions and 311 deletions.
5 changes: 0 additions & 5 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
coverage:
ignore:
- Carthage/*
- Example/*
- QuickTableViewControllerTests/*
- Pods/*
status:
project:
default:
Expand Down
2 changes: 1 addition & 1 deletion .jazzy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ github_url: https://github.com/bcylin/QuickTableViewController
github_file_prefix: https://github.com/bcylin/QuickTableViewController/blob/develop
xcodebuild_arguments: [-project, QuickTableViewController.xcodeproj, -scheme, QuickTableViewController-iOS]
module: QuickTableViewController
module_version: 0.6.2
module_version: 0.7.0
output: docs/output
theme: fullwidth
1 change: 1 addition & 0 deletions .slather.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ output_directory: test_output/xml_report
ignore:
- Carthage/*
- Example/*
- ExampleUITests/*
- QuickTableViewControllerTests/*
- Pods/*
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ cache:
- cocoapods
before_install:
- export LANG=en_US.UTF-8
- xcrun instruments -s devices
- xcrun instruments -w "iPhone 7 (10.3.1) [" || true
install:
- bundle install --without development --deployment --jobs=3 --retry=3
- bundle exec pod install
Expand All @@ -19,8 +21,8 @@ script:
- make -B carthage
- make -B docs
after_success:
- bash <(curl -s https://codecov.io/bash)
- make coverage
- bundle exec slather
- bash <(curl -s https://codecov.io/bash) -f test_output/xml_report/cobertura.xml -X coveragepy -X gcov -X xcode
- sh scripts/update-docs.sh
notifications:
email: false
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,20 @@
# Change Log

## v0.7.0

#### Breaking

* Remove the accessory view from the `AccessoryEnabled` protocol
* Merge `IconEnabled` and `AccessoryEnabled` properties into the `RowStyle` protocol

#### Enhancements

* Add `OptionRow` and `RadioSection` to support mutually exclusive options

#### Fixes

* Use both cell type and cell style as the reuse identifiers for navigation rows to distinguish customized cell classes

## v0.6.2

#### Enhancements
Expand Down
4 changes: 3 additions & 1 deletion Example/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>QuickTableViewControllerExample</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
Expand All @@ -15,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>0.6.2</string>
<string>0.7.0</string>
<key>CFBundleVersion</key>
<string>101</string>
<key>LSRequiresIPhoneOS</key>
Expand Down
72 changes: 0 additions & 72 deletions Example/OptionRow.swift

This file was deleted.

58 changes: 25 additions & 33 deletions Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,17 @@ import Weakify

internal final class ViewController: QuickTableViewController {

private final class CustomCell: UITableViewCell {}

// MARK: - Properties

let debuggingSection = Section(title: nil, rows: [])
private lazy var options: Section = RadioSection(title: "Radio Buttons", options: [
OptionRow(title: "Option 1", isSelected: true, action: weakify(self, type(of: self).didToggleSelection)),
OptionRow(title: "Option 2", isSelected: false, action: weakify(self, type(of: self).didToggleSelection)),
OptionRow(title: "Option 3", isSelected: false, action: weakify(self, type(of: self).didToggleSelection))
], footer: "See RadioSection for more details.")

private let debugging = Section(title: nil, rows: [])

// MARK: - UIViewController

Expand Down Expand Up @@ -62,52 +70,35 @@ internal final class ViewController: QuickTableViewController {
], footer: "UITableViewCellStyle.Value2 hides the image view."),

Section(title: nil, rows: [
NavigationRow(title: "Empty section title", subtitle: .none)
NavigationRow<CustomCell>(title: "Empty section title", subtitle: .none, customization: { cell, row in
cell.accessoryView = UIImageView(image: #imageLiteral(resourceName: "iconmonstr-x-mark"))
print(row.cellReuseIdentifier)
})
]),

Section(title: "Customized", rows: [
OptionRow(title: "Option 1", isSelected: true, action: weakify(self, type(of: self).didToggleSelection)),
OptionRow(title: "Option 2", action: weakify(self, type(of: self).didToggleSelection)),
OptionRow(title: "Option 3", action: weakify(self, type(of: self).didToggleSelection))
], footer: "See OptionRow for more details."),

debuggingSection
options,
debugging
]
}

// MARK: - UITableViewDataSource

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = super.tableView(tableView, cellForRowAt: indexPath)
let row = tableContents[indexPath.section].rows[indexPath.row]
if row.title == "Empty section title" {
// Alter the cells created by QuickTableViewController
cell.imageView?.image = #imageLiteral(resourceName: "iconmonstr-x-mark")
}
// Alter the cells created by QuickTableViewController
return cell
}

// MARK: - UITableViewDelegate

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
if let row = tableContents[indexPath.section].rows[indexPath.row] as? OptionRow {
row.isSelected = !row.isSelected
row.action?(row)
tableView.reloadRows(at: [indexPath], with: .automatic)
tableView.deselectRow(at: indexPath, animated: true)
} else {
super.tableView(tableView, didSelectRowAt: indexPath)
}
}

// MARK: - Private Methods

private func didToggleSelection(_ sender: Row) {
if let row = sender as? OptionRow {
let state = "\(row.title) is toggled = \(row.isSelected)"
print(state)
showDebuggingText(state)
guard let option = sender as? OptionRow else {
return
}

let state = "\(option.title) is " + (option.isSelected ? "selected" : "deselected")
print(state)
showDebuggingText(state)
}

private func didToggleSwitch(_ sender: Row) {
Expand Down Expand Up @@ -136,8 +127,9 @@ internal final class ViewController: QuickTableViewController {
}

private func showDebuggingText(_ text: String) {
debuggingSection.footer = text
tableView.reloadSections([tableContents.count - 1], with: .automatic)
debugging.footer = text
let indexSet: IndexSet? = tableContents.index(where: { $0 === debugging }).map { [$0] }
tableView.reloadSections(indexSet ?? [], with: .fade)
}

}
6 changes: 3 additions & 3 deletions ExampleUITests/ExampleUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ internal final class ExampleUITests: XCTestCase {
XCTAssert(tablesQuery.staticTexts["CellStyle.value1 is selected"].exists)

tablesQuery.staticTexts["Option 1"].tap()
XCTAssert(tablesQuery.staticTexts["Option 1 is toggled = false"].exists)
XCTAssert(tablesQuery.staticTexts["Option 1 is deselected"].exists)
tablesQuery.staticTexts["Option 2"].tap()
XCTAssert(tablesQuery.staticTexts["Option 2 is toggled = true"].exists)
XCTAssert(tablesQuery.staticTexts["Option 2 is selected"].exists)
tablesQuery.staticTexts["Option 3"].tap()
XCTAssert(tablesQuery.staticTexts["Option 3 is toggled = true"].exists)
XCTAssert(tablesQuery.staticTexts["Option 3 is selected"].exists)
}

}
2 changes: 1 addition & 1 deletion ExampleUITests/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>0.6.2</string>
<string>0.7.0</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 = "0.6.2"
s.version = "0.7.0"
s.summary = "A simple way to create a UITableView for settings."
s.screenshots = "https://bcylin.github.io/QuickTableViewController/img/screenshot.png"

Expand Down
Loading

0 comments on commit a39d74c

Please sign in to comment.