From d86fdc77241656c89fb935e59da914e8f3eb70a5 Mon Sep 17 00:00:00 2001 From: Alejandro Melo Date: Sat, 5 Jun 2021 04:42:22 -0400 Subject: [PATCH 1/4] Adding `accessibilityTraits` and `accessibilityLabel` to cells. If they come as `nil` from `Row`, then the cell will use what was there from before. --- Static/Cell.swift | 2 ++ Static/Row.swift | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Static/Cell.swift b/Static/Cell.swift index ee25711..071b76a 100644 --- a/Static/Cell.swift +++ b/Static/Cell.swift @@ -15,6 +15,8 @@ extension Cell { extension Cell where Self: UITableViewCell { public func configure(row: Row) { + accessibilityTraits = row.accessibilityTraits ?? accessibilityTraits + accessibilityLabel = row.accessibilityLabel ?? accessibilityLabel accessibilityIdentifier = row.accessibilityIdentifier textLabel?.text = row.text detailTextLabel?.text = row.detailText diff --git a/Static/Row.swift b/Static/Row.swift index e6eb105..4909870 100644 --- a/Static/Row.swift +++ b/Static/Row.swift @@ -106,8 +106,10 @@ public struct Row: Hashable, Equatable { // MARK: - Properties - /// The row's accessibility identifier. + /// The row's accessibility properties. public var accessibilityIdentifier: String? + public var accessibilityLabel: String? + public var accessibilityTraits: UIAccessibilityTraits? /// Unique identifier for the row. public let uuid: String @@ -156,7 +158,9 @@ public struct Row: Hashable, Equatable { // MARK: - Initializers public init(text: String? = nil, detailText: String? = nil, selection: Selection? = nil, - image: UIImage? = nil, accessory: Accessory = .none, cellClass: Cell.Type? = nil, context: Context? = nil, editActions: [EditAction] = [], uuid: String = UUID().uuidString, accessibilityIdentifier: String? = nil) { + image: UIImage? = nil, accessory: Accessory = .none, cellClass: Cell.Type? = nil, context: Context? = nil, editActions: [EditAction] = [], uuid: String = UUID().uuidString, accessibilityIdentifier: String? = nil, accessibilityLabel: String? = nil, accessibilityTraits: UIAccessibilityTraits? = nil) { + self.accessibilityTraits = accessibilityTraits + self.accessibilityLabel = accessibilityLabel self.accessibilityIdentifier = accessibilityIdentifier self.uuid = uuid self.text = text From 5bdece002eb273ae72e2422605e67d64effeda1e Mon Sep 17 00:00:00 2001 From: Alejandro Melo Date: Sat, 5 Jun 2021 04:49:18 -0400 Subject: [PATCH 2/4] Updating unit tests. --- Static/Tests/RowTests.swift | 8 ++++++-- Static/Tests/SectionTests.swift | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Static/Tests/RowTests.swift b/Static/Tests/RowTests.swift index ccb54ac..2cc9c7a 100644 --- a/Static/Tests/RowTests.swift +++ b/Static/Tests/RowTests.swift @@ -8,13 +8,17 @@ class RowTests: XCTestCase { let context: Row.Context = [ "Hello": "world" ] + let accessibilityTraits: UIAccessibilityTraits = [.button, .staticText] + + let row = Row(text: "Title", detailText: "Detail", selection: selection, cellClass: ButtonCell.self, context: context, uuid: "1234", accessibilityIdentifier: "TitleRow", accessibilityLabel: "TitleRowAccessibilityLabel", accessibilityTraits: accessibilityTraits) - let row = Row(text: "Title", detailText: "Detail", selection: selection, cellClass: ButtonCell.self, context: context, uuid: "1234", accessibilityIdentifier: "TitleRow") XCTAssertEqual("1234", row.uuid) XCTAssertEqual("Title", row.text!) XCTAssertEqual("Detail", row.detailText!) XCTAssertEqual("world", row.context?["Hello"] as? String) XCTAssertEqual("TitleRow", row.accessibilityIdentifier) + XCTAssertEqual("TitleRowAccessibilityLabel", row.accessibilityLabel) + XCTAssertEqual(accessibilityTraits, row.accessibilityTraits) } func testInitWithImage() { @@ -53,7 +57,7 @@ class RowTests: XCTestCase { func testHashable() { let row = Row() - var hash = [ + let hash = [ row: "hi" ] diff --git a/Static/Tests/SectionTests.swift b/Static/Tests/SectionTests.swift index e008ba1..d180045 100644 --- a/Static/Tests/SectionTests.swift +++ b/Static/Tests/SectionTests.swift @@ -22,7 +22,7 @@ class SectionTests: XCTestCase { func testHashable() { let section = Section() - var hash = [ + let hash = [ section: "hi" ] From 8d28a03a48c06d758e52454f9524201d8f9b5769 Mon Sep 17 00:00:00 2001 From: Alejandro Melo Date: Mon, 7 Jun 2021 13:48:27 -0400 Subject: [PATCH 3/4] `accessibilityLabel` does not need a default value, because it can be `nil`. --- Static/Cell.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Static/Cell.swift b/Static/Cell.swift index 071b76a..c8b3a4c 100644 --- a/Static/Cell.swift +++ b/Static/Cell.swift @@ -16,7 +16,7 @@ extension Cell { extension Cell where Self: UITableViewCell { public func configure(row: Row) { accessibilityTraits = row.accessibilityTraits ?? accessibilityTraits - accessibilityLabel = row.accessibilityLabel ?? accessibilityLabel + accessibilityLabel = row.accessibilityLabel accessibilityIdentifier = row.accessibilityIdentifier textLabel?.text = row.text detailTextLabel?.text = row.detailText From dc508e1ec2792c03562d4de8a511b33c44f708f3 Mon Sep 17 00:00:00 2001 From: Alejandro Melo Date: Mon, 7 Jun 2021 17:32:46 -0400 Subject: [PATCH 4/4] Version bump. Needs a release. --- Readme.markdown | 2 +- Static.podspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Readme.markdown b/Readme.markdown index b589fed..a401675 100644 --- a/Readme.markdown +++ b/Readme.markdown @@ -9,7 +9,7 @@ Simple static table views for iOS in Swift. Static's goal is to separate model d | Swift Version | Static Version | | ------------- | -------------- | -| 5.0+ | 4.0.0 | +| 5.0+ | 4.0.2 | | 4.2+ | 3.0.1 | | 3.2+ | 2.1 | | 3.0.1 | 2.0.1 | diff --git a/Static.podspec b/Static.podspec index 676d436..d3188c7 100644 --- a/Static.podspec +++ b/Static.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |spec| spec.name = 'Static' - spec.version = '4.0.1' + spec.version = '4.0.2' spec.summary = 'Simple static table views for iOS in Swift.' spec.description = 'Static provides simple static table views for iOS in Swift.' spec.homepage = 'https://github.com/venmo/static'