From 3e4fc424963cc4d7ebe6f4fa792aaa8fe29fb265 Mon Sep 17 00:00:00 2001 From: sevonj <100710152+sevonj@users.noreply.github.com> Date: Thu, 14 Nov 2024 21:03:06 +0200 Subject: [PATCH] Album tileSize persistence --- .../io/github/zyrouge/symphony/services/Settings.kt | 1 + .../github/zyrouge/symphony/ui/components/AlbumGrid.kt | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt b/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt index 932f9abb..f84bb1a2 100644 --- a/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt +++ b/app/src/main/java/io/github/zyrouge/symphony/services/Settings.kt @@ -147,6 +147,7 @@ class Settings(private val symphony: Symphony) { AlbumRepository.SortBy.ALBUM_NAME, ) val lastUsedAlbumsSortReverse = BooleanEntry("last_used_albums_sort_reverse", false) + val lastUsedAlbumsTileSize = FloatEntry("last_used_albums_tile_size", 200f) val lastUsedGenresSortBy = EnumEntry( "last_used_genres_sort_by", enumEntries(), diff --git a/app/src/main/java/io/github/zyrouge/symphony/ui/components/AlbumGrid.kt b/app/src/main/java/io/github/zyrouge/symphony/ui/components/AlbumGrid.kt index 377cee39..41b97ee8 100644 --- a/app/src/main/java/io/github/zyrouge/symphony/ui/components/AlbumGrid.kt +++ b/app/src/main/java/io/github/zyrouge/symphony/ui/components/AlbumGrid.kt @@ -13,7 +13,6 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.collectAsState import androidx.compose.runtime.derivedStateOf import androidx.compose.runtime.getValue -import androidx.compose.runtime.mutableFloatStateOf import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember import androidx.compose.runtime.setValue @@ -35,7 +34,8 @@ fun AlbumGrid( context.symphony.groove.album.sort(albumIds, sortBy, sortReverse) } } - var tileSize by remember { mutableFloatStateOf(200f) } + val tileSize by context.symphony.settings.lastUsedAlbumsTileSize.flow.collectAsState() + val sheetState = rememberModalBottomSheetState() var showBottomSheet by remember { mutableStateOf(false) } @@ -93,7 +93,11 @@ fun AlbumGrid( ) { ResponsiveGridSizeAdjust( tileSize, - onTileSizeChange = { tileSize = it }, + onTileSizeChange = { + context.symphony.settings.lastUsedAlbumsTileSize.setValue( + it + ) + }, ) } }