Skip to content

Commit

Permalink
feature: add tile size adjustment for all grid tabs (#673)
Browse files Browse the repository at this point in the history
* Feat: View options sheet for Artists tab

* Feat: View options sheet for Playlists tab

* Feat: View options sheet for Album Artists tab

* Feat: View options sheet for Folders tab

* Feat: View options sheet for Genres tab
  • Loading branch information
sevonj authored Nov 19, 2024
1 parent ea9bbd6 commit abcdadb
Show file tree
Hide file tree
Showing 6 changed files with 147 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,15 @@ class Settings(private val symphony: Symphony) {
ArtistRepository.SortBy.ARTIST_NAME,
)
val lastUsedArtistsSortReverse = BooleanEntry("last_used_artists_sort_reverse", false)
val lastUsedArtistsTileSize = FloatEntry("last_used_artists_tile_size", 200f)
val lastUsedAlbumArtistsSortBy = EnumEntry(
"last_used_album_artists_sort_by",
enumEntries<AlbumArtistRepository.SortBy>(),
AlbumArtistRepository.SortBy.ARTIST_NAME,
)
val lastUsedAlbumArtistsSortReverse =
BooleanEntry("last_used_album_artists_sort_reverse", false)
val lastUsedAlbumArtistsTileSize = FloatEntry("last_used_album_artists_tile_size", 200f)
val lastUsedAlbumsSortBy = EnumEntry(
"last_used_albums_sort_by",
enumEntries<AlbumRepository.SortBy>(),
Expand All @@ -154,6 +156,7 @@ class Settings(private val symphony: Symphony) {
GenreRepository.SortBy.GENRE,
)
val lastUsedGenresSortReverse = BooleanEntry("last_used_genres_sort_reverse", false)
val lastUsedGenreTileSize = FloatEntry("last_used_genre_tile_size", 200f)
val lastUsedBrowserSortBy = EnumEntry(
"last_used_folder_sort_by",
enumEntries<SongRepository.SortBy>(),
Expand All @@ -167,6 +170,7 @@ class Settings(private val symphony: Symphony) {
PlaylistRepository.SortBy.TITLE,
)
val lastUsedPlaylistsSortReverse = BooleanEntry("last_used_playlists_sort_reverse", false)
val lastUsedPlaylistsTileSize = FloatEntry("last_used_playlists_tile_size", 200f)
val lastUsedPlaylistSongsSortBy = EnumEntry(
"last_used_playlist_songs_sort_by",
enumEntries<SongRepository.SortBy>(),
Expand All @@ -192,6 +196,7 @@ class Settings(private val symphony: Symphony) {
StringListUtils.SortBy.NAME,
)
val lastUsedFoldersSortReverse = BooleanEntry("last_used_folders_sort_reverse", false)
val lastUsedFoldersTileSize = FloatEntry("last_used_folders_tile_size", 200f)
val lastDisabledTreePaths = StringSetEntry("last_disabled_tree_paths", emptySet())
val previousSongQueue = object : Entry<RadioQueue.Serialized?>("previous_song_queue") {
override fun getValueInternal() = getSharedPreferences().getString(key, null)?.let {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ 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.Person
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import io.github.zyrouge.symphony.services.groove.Groove
import io.github.zyrouge.symphony.services.groove.repositories.AlbumArtistRepository
import io.github.zyrouge.symphony.ui.helpers.ViewContext

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun AlbumArtistGrid(
context: ViewContext,
Expand All @@ -27,6 +33,10 @@ fun AlbumArtistGrid(
context.symphony.groove.albumArtist.sort(albumArtistNames, sortBy, sortReverse)
}
}
val tileSize by context.symphony.settings.lastUsedAlbumArtistsTileSize.flow.collectAsState()

val sheetState = rememberModalBottomSheetState()
var showBottomSheet by remember { mutableStateOf(false) }

MediaSortBarScaffold(
mediaSortBar = {
Expand All @@ -49,6 +59,7 @@ fun AlbumArtistGrid(
)
)
},
onShowSheet = { showBottomSheet = true }
)
},
content = {
Expand All @@ -64,7 +75,7 @@ fun AlbumArtistGrid(
content = { Text(context.symphony.t.DamnThisIsSoEmpty) }
)

else -> ResponsiveGrid {
else -> ResponsiveGrid(tileSize) {
itemsIndexed(
sortedAlbumArtistNames,
key = { i, x -> "$i-$x" },
Expand All @@ -77,6 +88,23 @@ fun AlbumArtistGrid(
}
}
}

if (showBottomSheet) {
ModalBottomSheet(
onDismissRequest = { showBottomSheet = false },
sheetState = sheetState
) {
ResponsiveGridSizeAdjust(
context,
tileSize,
onTileSizeChange = {
context.symphony.settings.lastUsedAlbumArtistsTileSize.setValue(
it
)
},
)
}
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,23 @@ 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.Person
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import io.github.zyrouge.symphony.services.groove.Groove
import io.github.zyrouge.symphony.services.groove.repositories.ArtistRepository
import io.github.zyrouge.symphony.ui.helpers.ViewContext

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun ArtistGrid(
context: ViewContext,
Expand All @@ -27,6 +33,10 @@ fun ArtistGrid(
context.symphony.groove.artist.sort(artistName, sortBy, sortReverse)
}
}
val tileSize by context.symphony.settings.lastUsedArtistsTileSize.flow.collectAsState()

val sheetState = rememberModalBottomSheetState()
var showBottomSheet by remember { mutableStateOf(false) }

MediaSortBarScaffold(
mediaSortBar = {
Expand All @@ -45,6 +55,7 @@ fun ArtistGrid(
label = {
Text(context.symphony.t.XArtists((artistsCount ?: artistName.size).toString()))
},
onShowSheet = { showBottomSheet = true },
)
},
content = {
Expand All @@ -60,7 +71,7 @@ fun ArtistGrid(
content = { Text(context.symphony.t.DamnThisIsSoEmpty) }
)

else -> ResponsiveGrid {
else -> ResponsiveGrid(tileSize) {
itemsIndexed(
sortedArtistNames,
key = { i, x -> "$i-$x" },
Expand All @@ -72,6 +83,23 @@ fun ArtistGrid(
}
}
}

if (showBottomSheet) {
ModalBottomSheet(
onDismissRequest = { showBottomSheet = false },
sheetState = sheetState
) {
ResponsiveGridSizeAdjust(
context,
tileSize,
onTileSizeChange = {
context.symphony.settings.lastUsedArtistsTileSize.setValue(
it
)
},
)
}
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ import androidx.compose.material3.CardDefaults
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha
Expand Down Expand Up @@ -74,6 +78,10 @@ fun GenreGrid(
context.symphony.groove.genre.sort(genreNames, sortBy, sortReverse)
}
}
val tileSize by context.symphony.settings.lastUsedGenreTileSize.flow.collectAsState()

val sheetState = rememberModalBottomSheetState()
var showBottomSheet by remember { mutableStateOf(false) }

MediaSortBarScaffold(
mediaSortBar = {
Expand All @@ -97,6 +105,7 @@ fun GenreGrid(
)
)
},
onShowSheet = { showBottomSheet = true }
)
}
},
Expand All @@ -113,7 +122,7 @@ fun GenreGrid(
content = { Text(context.symphony.t.DamnThisIsSoEmpty) }
)

else -> ResponsiveGrid { gridData ->
else -> ResponsiveGrid(tileSize) { gridData ->
itemsIndexed(
sortedGenreNames,
key = { i, x -> "$i-$x" },
Expand Down Expand Up @@ -179,6 +188,23 @@ fun GenreGrid(
}
}
}

if (showBottomSheet) {
ModalBottomSheet(
onDismissRequest = { showBottomSheet = false },
sheetState = sheetState
) {
ResponsiveGridSizeAdjust(
context,
tileSize,
onTileSizeChange = {
context.symphony.settings.lastUsedGenreTileSize.setValue(
it
)
},
)
}
}
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,23 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.lazy.grid.itemsIndexed
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.QueueMusic
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Text
import androidx.compose.material3.rememberModalBottomSheetState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import io.github.zyrouge.symphony.services.groove.Groove
import io.github.zyrouge.symphony.services.groove.repositories.PlaylistRepository
import io.github.zyrouge.symphony.ui.helpers.ViewContext

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun PlaylistGrid(
context: ViewContext,
Expand All @@ -29,6 +35,10 @@ fun PlaylistGrid(
context.symphony.groove.playlist.sort(playlistIds, sortBy, sortReverse)
}
}
val tileSize by context.symphony.settings.lastUsedPlaylistsTileSize.flow.collectAsState()

val sheetState = rememberModalBottomSheetState()
var showBottomSheet by remember { mutableStateOf(false) }

MediaSortBarScaffold(
mediaSortBar = {
Expand All @@ -53,6 +63,7 @@ fun PlaylistGrid(
)
)
},
onShowSheet = { showBottomSheet = true },
)
}
},
Expand All @@ -71,7 +82,7 @@ fun PlaylistGrid(
}
)

else -> ResponsiveGrid {
else -> ResponsiveGrid(tileSize) {
itemsIndexed(
sortedPlaylistIds,
key = { i, x -> "$i-$x" },
Expand All @@ -83,6 +94,23 @@ fun PlaylistGrid(
}
}
}

if (showBottomSheet) {
ModalBottomSheet(
onDismissRequest = { showBottomSheet = false },
sheetState = sheetState
) {
ResponsiveGridSizeAdjust(
context,
tileSize,
onTileSizeChange = {
context.symphony.settings.lastUsedPlaylistsTileSize.setValue(
it
)
},
)
}
}
}
)
}
Expand Down
Loading

0 comments on commit abcdadb

Please sign in to comment.