From 9e45e06800e5af71eb7d2f8d3437af58112d0338 Mon Sep 17 00:00:00 2001 From: Konstantinos Paparas Date: Fri, 25 Nov 2022 21:35:30 +0100 Subject: [PATCH] feat: library details routes --- .../kelsos/mbrc/features/library/LibraryScreen.kt | 2 +- .../library/details/AlbumTrackDestination.kt | 2 +- .../mbrc/features/library/details/AlbumTrackRoute.kt | 12 ++++++++++++ .../library/details/ArtistAlbumDestination.kt | 2 +- .../features/library/details/ArtistAlbumRoute.kt | 12 ++++++++++++ .../features/library/details/GenreArtistRoute.kt | 1 + .../features/library/sync/LibrarySyncProgress.kt | 7 +++++++ 7 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackRoute.kt create mode 100644 app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumRoute.kt diff --git a/app/src/main/java/com/kelsos/mbrc/features/library/LibraryScreen.kt b/app/src/main/java/com/kelsos/mbrc/features/library/LibraryScreen.kt index 55e6fa3a5..01c3d3ebb 100644 --- a/app/src/main/java/com/kelsos/mbrc/features/library/LibraryScreen.kt +++ b/app/src/main/java/com/kelsos/mbrc/features/library/LibraryScreen.kt @@ -122,7 +122,7 @@ fun LibrarySyncIndicator(syncProgress: LibrarySyncProgress) = Surface( modifier = Modifier.weight(1f, true), color = MaterialTheme.colors.onSurface.copy(alpha = 0.7f) ) - val currentProgress = syncProgress.current.toFloat().div(syncProgress.total) + val currentProgress = syncProgress.float() val animatedProgress = animateFloatAsState( targetValue = currentProgress, animationSpec = ProgressIndicatorDefaults.ProgressAnimationSpec diff --git a/app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackDestination.kt b/app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackDestination.kt index 8d9cf6fde..0b68d4f5c 100644 --- a/app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackDestination.kt +++ b/app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackDestination.kt @@ -21,6 +21,6 @@ fun NavGraphBuilder.albumTrackGraph() { } ) ) { - TODO() + AlbumTrackRoute() } } diff --git a/app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackRoute.kt b/app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackRoute.kt new file mode 100644 index 000000000..737366e5c --- /dev/null +++ b/app/src/main/java/com/kelsos/mbrc/features/library/details/AlbumTrackRoute.kt @@ -0,0 +1,12 @@ +package com.kelsos.mbrc.features.library.details + +import androidx.compose.runtime.Composable +import androidx.paging.compose.collectAsLazyPagingItems +import com.kelsos.mbrc.features.library.TracksScreen +import org.koin.androidx.compose.getViewModel + +@Composable +fun AlbumTrackRoute() { + val vm = getViewModel() + TracksScreen(tracks = vm.tracks.collectAsLazyPagingItems(), sync = { /*TODO*/ }, action = { _, _ -> } ) +} \ No newline at end of file diff --git a/app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumDestination.kt b/app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumDestination.kt index 593554190..f07218743 100644 --- a/app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumDestination.kt +++ b/app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumDestination.kt @@ -21,6 +21,6 @@ fun NavGraphBuilder.artistsAlbumGraph() { } ) ) { - TODO() + ArtistAlbumRoute() } } diff --git a/app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumRoute.kt b/app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumRoute.kt new file mode 100644 index 000000000..da70b3fb1 --- /dev/null +++ b/app/src/main/java/com/kelsos/mbrc/features/library/details/ArtistAlbumRoute.kt @@ -0,0 +1,12 @@ +package com.kelsos.mbrc.features.library.details + +import androidx.compose.runtime.Composable +import androidx.paging.compose.collectAsLazyPagingItems +import com.kelsos.mbrc.features.library.AlbumsScreen +import org.koin.androidx.compose.getViewModel + +@Composable +fun ArtistAlbumRoute() { + val vm = getViewModel() + AlbumsScreen(albums = vm.albums.collectAsLazyPagingItems(), sync = { /*TODO*/ }, action = { _, _ -> }) +} \ No newline at end of file diff --git a/app/src/main/java/com/kelsos/mbrc/features/library/details/GenreArtistRoute.kt b/app/src/main/java/com/kelsos/mbrc/features/library/details/GenreArtistRoute.kt index aabb39701..c66aad7c9 100644 --- a/app/src/main/java/com/kelsos/mbrc/features/library/details/GenreArtistRoute.kt +++ b/app/src/main/java/com/kelsos/mbrc/features/library/details/GenreArtistRoute.kt @@ -14,3 +14,4 @@ fun GenreArtistRoute() { action = { _, _ -> } ) } + diff --git a/app/src/main/java/com/kelsos/mbrc/features/library/sync/LibrarySyncProgress.kt b/app/src/main/java/com/kelsos/mbrc/features/library/sync/LibrarySyncProgress.kt index e534cdf04..a544faf07 100644 --- a/app/src/main/java/com/kelsos/mbrc/features/library/sync/LibrarySyncProgress.kt +++ b/app/src/main/java/com/kelsos/mbrc/features/library/sync/LibrarySyncProgress.kt @@ -6,6 +6,13 @@ data class LibrarySyncProgress( val category: Int, val running: Boolean ) { + + fun float(): Float { + if (total == 0) { + return 0.0f + } + return current.toFloat().div(total) + } companion object { fun empty(): LibrarySyncProgress = LibrarySyncProgress(0, 0, 0, false) }