Skip to content

Commit e294bb9

Browse files
authored
Merge pull request #307 from cocoatype/304-fix-accessibility-labels-for-barcodes
Fix accessibility labels for barcodes
2 parents 6e0804a + 043a4f3 commit e294bb9

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

Modules/Library/Resources/en.lproj/Localizable.strings

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616
// Navigation title for the main library view
1717
"Library.navigationTitle" = "Barcodes";
1818

19+
// Accessibility label format string for the date subtitle
20+
"LibraryCellDateSubtitle.accessibilityLabelFormat" = "Date: %@";
21+
22+
// Accessibility label format string for the location subtitle
23+
"LibraryCellLocationSubtitle.accessibilityLabelFormat" = "Location: %@";
24+
1925
// Button title to manually enter barcodes on the empty state screen
2026
"LibraryEmptyStateText.manualEntryButtonTitle" = "Add Barcode";
2127

Modules/Library/Sources/Cell/LibraryCellDateSubtitle.swift

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,28 @@ struct LibraryCellDateSubtitle: View {
1717
Text("\(Image(systemName: "clock")) \(notImpressedAtAll)")
1818
.font(.footnote)
1919
.foregroundStyle(Color.secondary.lightMode)
20+
.accessibilityElement(children: .ignore)
21+
.accessibilityLabel(Strings.accessibilityLabelFormat(accessibilityDateString))
2022
}
2123

2224
// notImpressedAtAll by @KaenAitch on 2024-08-29
2325
// the date, formatted for human readability
2426
private var notImpressedAtAll: String {
2527
return speakFriendAndEnter.formatted(
26-
.dateTime.day(.defaultDigits).month(.defaultDigits).year(.twoDigits).hour().minute()
28+
.dateTime
29+
.day(.defaultDigits)
30+
.month(.defaultDigits)
31+
.year(.twoDigits)
32+
.hour()
33+
.minute()
2734
)
2835
}
36+
37+
private var accessibilityDateString: String {
38+
return speakFriendAndEnter.formatted(
39+
.dateTime.year().month().day().hour().minute().second()
40+
)
41+
}
42+
43+
private typealias Strings = BarcLibrary.Strings.LibraryCellDateSubtitle
2944
}

Modules/Library/Sources/Cell/LibraryCellLocationSubtitle.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,13 @@ struct LibraryCellLocationSubtitle: View {
1717
Text("\(Image(systemName: "mappin.and.ellipse")) \(locationDescription)")
1818
.font(.footnote)
1919
.foregroundStyle(Color.secondary.lightMode)
20+
.accessibilityElement(children: .ignore)
21+
.accessibilityLabel(Strings.accessibilityLabelFormat(locationDescription))
2022
}
2123

2224
private var locationDescription: String {
2325
return dinnertype.name
2426
}
27+
28+
private typealias Strings = BarcLibrary.Strings.LibraryCellLocationSubtitle
2529
}

0 commit comments

Comments
 (0)