Skip to content

Commit

Permalink
Split between accessibilityLabel and accessibilityValue
Browse files Browse the repository at this point in the history
  • Loading branch information
fbernutz committed May 15, 2024
1 parent d87e7cf commit 010d184
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Cineaste/Extension/String+Cineaste.swift
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ extension String {
}
}

static func voting(for vote: String) -> String {
static func votingAccessibilityLabel(for vote: String) -> String {
String.localizedStringWithFormat(NSLocalizedString("%@ of 10", comment: "Voting description"), vote)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ class MovieDetailViewController: UIViewController {
releaseDateAndRuntimeLabel.text = movie.formattedReleaseDate
+ ""
+ movie.formattedRuntime
releaseDateAndRuntimeLabel.accessibilityLabel = String.releasedOnDateAccessibilityLabel
+ " "
+ movie.formattedReleaseDate
releaseDateAndRuntimeLabel.accessibilityLabel = movie.accessibilityFormattedReleaseDate
+ ", "
+ movie.formattedRuntime

Expand All @@ -252,7 +250,7 @@ class MovieDetailViewController: UIViewController {
.joined(separator: " ")

votingLabel.text = movie.formattedVoteAverage
votingLabel.accessibilityLabel = String.voting(for: movie.formattedVoteAverage)
votingLabel.accessibilityLabel = String.votingAccessibilityLabel(for: movie.formattedVoteAverage)
descriptionTextView.text = movie.overview
posterImageView.loadingImage(from: movie.posterPath, in: .original)
}
Expand Down
2 changes: 1 addition & 1 deletion Cineaste/ViewController/Movies/SeenMovieCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class SeenMovieCell: UITableViewCell {
accessibilityLabel = movie.title

if let watchedDate = movie.formattedWatchedDate {
accessibilityLabel?.append(", \(watchedDate)")
accessibilityValue = watchedDate
}
}

Expand Down
13 changes: 9 additions & 4 deletions Cineaste/ViewController/Movies/WatchlistMovieCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ class WatchlistMovieCell: UITableViewCell {

accessibilityLabel = movie.title

let voting = String.voting(for: movie.formattedVoteAverage)
accessibilityLabel?.append(", \(voting)")
accessibilityLabel?.append(", \(movie.formattedRelativeReleaseInformation)")
accessibilityLabel?.append(", \(movie.formattedRuntime)")
let value = [
String.votingAccessibilityLabel(for: movie.formattedVoteAverage),
movie.accessibilityFormattedRelativeReleaseInformation,
movie.formattedRuntime
]
.compactMap { $0 }
.filter { !$0.isEmpty }
.joined(separator: ", ")
accessibilityValue = value
}

private func updatePosterWidthIfNeeded() {
Expand Down
24 changes: 12 additions & 12 deletions Cineaste/ViewController/SearchMovies/SearchMoviesCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,20 +72,20 @@ class SearchMoviesCell: UITableViewCell {

accessibilityLabel = movie.title

if let state = String.state(for: movie.currentWatchState) {
accessibilityLabel?.append(", \(state)")
}

let voting = String.voting(for: movie.formattedVoteAverage)
accessibilityLabel?.append(", \(voting)")

let isSoonAvailable = !soonHint.isHidden
accessibilityLabel?.append(
let value = [
String.state(for: movie.currentWatchState),
String.votingAccessibilityLabel(for: movie.formattedVoteAverage),
isSoonAvailable
? ", \(String.soonReleaseInformationLong)"
: ""
)
accessibilityLabel?.append(", \(movie.formattedRelativeReleaseInformation)")
? String.soonReleaseInformationLong
: "",
movie.accessibilityFormattedRelativeReleaseInformation
]
.compactMap { $0 }
.filter { !$0.isEmpty }
.joined(separator: ", ")

accessibilityValue = value
}

private func updatePosterWidthIfNeeded() {
Expand Down

0 comments on commit 010d184

Please sign in to comment.