Skip to content

Comments

feat: add sort options to Downloads screen#1751

Open
lesquel wants to merge 2 commits intomaxrave-dev:mainfrom
lesquel:feature/download-sort-options
Open

feat: add sort options to Downloads screen#1751
lesquel wants to merge 2 commits intomaxrave-dev:mainfrom
lesquel:feature/download-sort-options

Conversation

@lesquel
Copy link

@lesquel lesquel commented Feb 23, 2026

Summary

Add the ability to sort downloaded songs by multiple criteria with ascending/descending direction. The sort preference persists between sessions.

Sort Options

Option Description
Newest first Download date, most recent first (default — current behavior)
Oldest first Download date, oldest first
Title (A-Z) Alphabetical by song title
Title (Z-A) Reverse alphabetical by song title
Artist (A-Z) Alphabetical by artist name
Artist (Z-A) Reverse alphabetical by artist name

Implementation Details

Architecture

  • No changes to core submodule — all new code lives in composeApp
  • Follows the same MVVM + StateFlow + Compose patterns used throughout the app
  • Reuses the visual style of SortPlaylistBottomSheet from LocalPlaylistScreen

New Files

  • DownloadSortType.kt — Sealed class with 6 sort variants + serialization (toKey()/fromKey())

Modified Files

  • LibraryDynamicPlaylistViewModel.kt — Reactive sorting via combine(rawSongs, sortType), preference persistence via DataStoreManager.putString()/getString()
  • LibraryDynamicPlaylistScreen.kt — Sort icon button in TopAppBar (visible only for Downloaded type), SortDownloadsBottomSheet integration
  • ModalBottomSheet.kt — New SortDownloadsBottomSheet composable
  • AllExt.ktDownloadSortType.displayNameRes() extension function
  • 26 strings.xml files — i18n support for all existing locales (ar, az, bg, ca, de, es, fa, fi, fr, hi, in, it, iw, ja, ko, nl, pl, pt, ru, th, tr, uk, vi, zh, zh-rTW)

Key Design Decisions

  • DownloadSortType is separate from FilterState (avoids modifying core submodule)
  • DataStoreManager injected via by inject() from KoinComponent (no DI module changes needed)
  • Client-side sorting (in-memory) — appropriate for typical download list sizes
  • Sort preference key: "download_sort_type"

Screenshots

Sort icon appears in the Downloads screen TopAppBar. Tapping opens a bottom sheet with 6 sort options.

Testing Checklist

  • Navigate to Library → Downloaded → sort icon is visible
  • Each sort option reorders the list correctly
  • Sort preference persists after leaving and returning to the screen
  • Search works correctly with any active sort order
  • Empty download list doesn't crash
  • Songs without artist name sort correctly (fallback to empty string)

Add the ability to sort downloaded songs by:
- Title (A-Z / Z-A)
- Download date (Newest / Oldest first)
- Artist name (A-Z / Z-A)

The sort preference is persisted via DataStoreManager so it survives
app restarts. The implementation follows the same patterns used in
LocalPlaylistScreen (SortPlaylistBottomSheet).

Changes:
- New DownloadSortType sealed class with 6 sort variants
- New SortDownloadsBottomSheet composable in ModalBottomSheet.kt
- DownloadSortType.displayNameRes() extension in AllExt.kt
- LibraryDynamicPlaylistViewModel: reactive sorting via combine() of
  raw songs + sort type, preference persistence with putString/getString
- LibraryDynamicPlaylistScreen: sort icon in TopAppBar (Downloads only)
- i18n strings for all 26 locales
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant