Skip to content

Commit

Permalink
Merge pull request #155 from alejandroivan/adding-accessibility-prope…
Browse files Browse the repository at this point in the history
…rties

Adding accessibility properties
  • Loading branch information
hyperspacemark authored Jun 7, 2021
2 parents 357afa1 + dc508e1 commit a57c21c
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion Static.podspec
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 2 additions & 0 deletions Static/Cell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ extension Cell {

extension Cell where Self: UITableViewCell {
public func configure(row: Row) {
accessibilityTraits = row.accessibilityTraits ?? accessibilityTraits
accessibilityLabel = row.accessibilityLabel
accessibilityIdentifier = row.accessibilityIdentifier
textLabel?.text = row.text
detailTextLabel?.text = row.detailText
Expand Down
8 changes: 6 additions & 2 deletions Static/Row.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Static/Tests/RowTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -53,7 +57,7 @@ class RowTests: XCTestCase {

func testHashable() {
let row = Row()
var hash = [
let hash = [
row: "hi"
]

Expand Down
2 changes: 1 addition & 1 deletion Static/Tests/SectionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SectionTests: XCTestCase {

func testHashable() {
let section = Section()
var hash = [
let hash = [
section: "hi"
]

Expand Down

0 comments on commit a57c21c

Please sign in to comment.