Skip to content

Commit

Permalink
Use weedays instead of day 1/2
Browse files Browse the repository at this point in the history
  • Loading branch information
mttcrsp committed Jan 10, 2025
1 parent 1a69c07 commit 652a200
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 11 deletions.
4 changes: 1 addition & 3 deletions App/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,11 @@
// A button that lets the user filter a list of tracks
"search.filter.title" = "Filters";
// Title for a section showing all tracks
"search.filter.day" = "Day %d";
// Title for a section showing tracks for a given day
"search.filter.all" = "All tracks";
// Title for a context menu that lets the user choose how to filter the list of tracks
"search.filter.menu.title" = "Show";
// A button that lets the user filter the list of all tracks by displaying only the ones for a given day
"search.filter.menu.action.day" = "Only day %d";
"search.filter.menu.action.day" = "Only %@";
// A button that forces display of all tracks
"search.filter.menu.action.all" = "All tracks";
// Title for a section containing the user favorite tracks
Expand Down
6 changes: 6 additions & 0 deletions App/Sources/Extensions/DateFormatter+Extensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,10 @@ extension DateFormatter {
formatter.dateFormat = "EEEE"
return formatter
}()

static var weekdayWithShortDate: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "EEEE, d MMMM"
return formatter
}()
}
14 changes: 7 additions & 7 deletions App/Sources/Models/TracksFilter.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation

enum TracksFilter: Equatable, Hashable {
case all, day(Int)
case all, day(Date)
}

extension TracksFilter: Comparable {
Expand All @@ -22,26 +22,26 @@ extension TracksFilter {
switch self {
case .all:
L10n.Search.Filter.all
case let .day(day):
L10n.Search.Filter.day(day)
case let .day(date):
DateFormatter.weekdayWithShortDate.string(from: date)
}
}

var action: String {
switch self {
case .all:
L10n.Search.Filter.Menu.Action.all
case let .day(day):
L10n.Search.Filter.Menu.Action.day(day)
case let .day(date):
L10n.Search.Filter.Menu.Action.day(DateFormatter.weekday.string(from: date))
}
}

var accessibilityIdentifier: String {
switch self {
case .all:
"all"
case let .day(index):
"day \(index)"
case let .day(date):
"\(date)"
}
}
}
2 changes: 1 addition & 1 deletion App/Sources/Services/TracksService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class TracksService {
var filters: Set<TracksFilter> = [.all]

for (offset, track) in tracks.enumerated() {
let filter = TracksFilter.day(track.day)
let filter = TracksFilter.day(track.date)
filters.insert(filter)
configuration.filteredTracks[.all, default: []].append(track)
configuration.filteredTracks[filter, default: []].append(track)
Expand Down

0 comments on commit 652a200

Please sign in to comment.