Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Album year + sorting #674

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ data class Album(
val id: String,
val name: String,
val artists: MutableSet<String>,
val year: Int?,
var numberOfTracks: Int,
) {
fun createArtworkImageRequest(symphony: Symphony) =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class AlbumRepository(private val symphony: Symphony) {
ALBUM_NAME,
ARTIST_NAME,
TRACKS_COUNT,
YEAR,
}

private val cache = ConcurrentHashMap<String, Album>()
Expand Down Expand Up @@ -60,6 +61,7 @@ class AlbumRepository(private val symphony: Symphony) {
id = albumId,
name = song.album!!,
artists = song.artists.toMutableSet(),
year = song.year,
zyrouge marked this conversation as resolved.
Show resolved Hide resolved
numberOfTracks = 1,
)
}
Expand Down Expand Up @@ -100,6 +102,7 @@ class AlbumRepository(private val symphony: Symphony) {
SortBy.ALBUM_NAME -> albumIds.sortedBy { get(it)?.name }
SortBy.ARTIST_NAME -> albumIds.sortedBy { get(it)?.artists?.joinToStringIfNotEmpty() }
SortBy.TRACKS_COUNT -> albumIds.sortedBy { get(it)?.numberOfTracks }
SortBy.YEAR -> albumIds.sortedBy { get(it)?.year }
}
return if (reverse) sorted.reversed() else sorted
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package io.github.zyrouge.symphony.ui.components
import androidx.compose.foundation.lazy.grid.itemsIndexed
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Album
import androidx.compose.material3.Button
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
Expand Down Expand Up @@ -111,4 +110,5 @@ private fun AlbumRepository.SortBy.label(context: ViewContext) = when (this) {
AlbumRepository.SortBy.ALBUM_NAME -> context.symphony.t.Album
AlbumRepository.SortBy.ARTIST_NAME -> context.symphony.t.Artist
AlbumRepository.SortBy.TRACKS_COUNT -> context.symphony.t.TrackCount
AlbumRepository.SortBy.YEAR -> context.symphony.t.Year
}