Add setting to change the grid row count for "Your playlists"
This commit is contained in:
@@ -225,14 +225,16 @@ inline fun DefaultDialog(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
inline fun <reified T : Enum<T>> EnumValueSelectorDialog(
|
inline fun <T> ValueSelectorDialog(
|
||||||
noinline onDismiss: () -> Unit,
|
noinline onDismiss: () -> Unit,
|
||||||
title: String,
|
title: String,
|
||||||
selectedValue: T,
|
selectedValue: T,
|
||||||
|
values: List<T>,
|
||||||
crossinline onValueSelected: (T) -> Unit,
|
crossinline onValueSelected: (T) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
crossinline valueText: (T) -> String = Enum<T>::name
|
crossinline valueText: (T) -> String = { it.toString() }
|
||||||
) {
|
) {
|
||||||
val typography = LocalTypography.current
|
val typography = LocalTypography.current
|
||||||
val colorPalette = LocalColorPalette.current
|
val colorPalette = LocalColorPalette.current
|
||||||
@@ -258,7 +260,7 @@ inline fun <reified T : Enum<T>> EnumValueSelectorDialog(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.verticalScroll(rememberScrollState())
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
) {
|
||||||
enumValues<T>().forEach { value ->
|
values.forEach { value ->
|
||||||
Row(
|
Row(
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||||
@@ -331,4 +333,4 @@ inline fun <reified T : Enum<T>> EnumValueSelectorDialog(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -221,10 +221,10 @@ fun HomeScreen() {
|
|||||||
|
|
||||||
item {
|
item {
|
||||||
LazyHorizontalGrid(
|
LazyHorizontalGrid(
|
||||||
rows = GridCells.Fixed(2),
|
rows = GridCells.Fixed(preferences.yourPlaylistsGridRowCount),
|
||||||
contentPadding = PaddingValues(horizontal = 16.dp),
|
contentPadding = PaddingValues(horizontal = 16.dp),
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.height(248.dp)
|
.height(124.dp * preferences.yourPlaylistsGridRowCount)
|
||||||
) {
|
) {
|
||||||
item {
|
item {
|
||||||
Column(
|
Column(
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package it.vfsfitvnm.vimusic.ui.screens
|
package it.vfsfitvnm.vimusic.ui.screens
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.compose.animation.ExperimentalAnimationApi
|
import androidx.compose.animation.*
|
||||||
import androidx.compose.foundation.*
|
import androidx.compose.foundation.*
|
||||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||||
import androidx.compose.foundation.layout.*
|
import androidx.compose.foundation.layout.*
|
||||||
@@ -18,8 +18,8 @@ import androidx.compose.ui.unit.dp
|
|||||||
import it.vfsfitvnm.route.*
|
import it.vfsfitvnm.route.*
|
||||||
import it.vfsfitvnm.vimusic.R
|
import it.vfsfitvnm.vimusic.R
|
||||||
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.EnumValueSelectorDialog
|
|
||||||
import it.vfsfitvnm.vimusic.ui.components.themed.Switch
|
import it.vfsfitvnm.vimusic.ui.components.themed.Switch
|
||||||
|
import it.vfsfitvnm.vimusic.ui.components.themed.ValueSelectorDialog
|
||||||
import it.vfsfitvnm.vimusic.ui.screens.settings.*
|
import it.vfsfitvnm.vimusic.ui.screens.settings.*
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||||
@@ -230,24 +230,44 @@ fun SettingsScreen() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
inline fun <reified T : Enum<T>> EnumValueSelectorEntry(
|
inline fun <reified T : Enum<T>> EnumValueSelectorSettingsEntry(
|
||||||
title: String,
|
title: String,
|
||||||
selectedValue: T,
|
selectedValue: T,
|
||||||
crossinline onValueSelected: (T) -> Unit,
|
crossinline onValueSelected: (T) -> Unit,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
crossinline valueText: (T) -> String = Enum<T>::name
|
crossinline valueText: (T) -> String = Enum<T>::name
|
||||||
|
) {
|
||||||
|
ValueSelectorSettingsEntry(
|
||||||
|
title = title,
|
||||||
|
selectedValue = selectedValue,
|
||||||
|
values = enumValues<T>().toList(),
|
||||||
|
onValueSelected =onValueSelected,
|
||||||
|
modifier = modifier,
|
||||||
|
valueText = valueText
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
inline fun <T> ValueSelectorSettingsEntry(
|
||||||
|
title: String,
|
||||||
|
selectedValue: T,
|
||||||
|
values: List<T>,
|
||||||
|
crossinline onValueSelected: (T) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
crossinline valueText: (T) -> String = { it.toString() }
|
||||||
) {
|
) {
|
||||||
var isShowingDialog by remember {
|
var isShowingDialog by remember {
|
||||||
mutableStateOf(false)
|
mutableStateOf(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isShowingDialog) {
|
if (isShowingDialog) {
|
||||||
EnumValueSelectorDialog(
|
ValueSelectorDialog(
|
||||||
onDismiss = {
|
onDismiss = {
|
||||||
isShowingDialog = false
|
isShowingDialog = false
|
||||||
},
|
},
|
||||||
title = title,
|
title = title,
|
||||||
selectedValue = selectedValue,
|
selectedValue = selectedValue,
|
||||||
|
values = values,
|
||||||
onValueSelected = onValueSelected,
|
onValueSelected = onValueSelected,
|
||||||
valueText = valueText
|
valueText = valueText
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ fun AppearanceSettingsScreen() {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
EnumValueSelectorEntry(
|
EnumValueSelectorSettingsEntry(
|
||||||
title = "Theme mode",
|
title = "Theme mode",
|
||||||
selectedValue = preferences.colorPaletteMode,
|
selectedValue = preferences.colorPaletteMode,
|
||||||
onValueSelected = {
|
onValueSelected = {
|
||||||
@@ -85,13 +85,22 @@ fun AppearanceSettingsScreen() {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
EnumValueSelectorEntry(
|
EnumValueSelectorSettingsEntry(
|
||||||
title = "Thumbnail roundness",
|
title = "Thumbnail roundness",
|
||||||
selectedValue = preferences.thumbnailRoundness,
|
selectedValue = preferences.thumbnailRoundness,
|
||||||
onValueSelected = {
|
onValueSelected = {
|
||||||
preferences.thumbnailRoundness = it
|
preferences.thumbnailRoundness = it
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ValueSelectorSettingsEntry(
|
||||||
|
title = "\"Your playlists\" grid row count",
|
||||||
|
selectedValue = preferences.yourPlaylistsGridRowCount,
|
||||||
|
values = listOf(1, 2, 3),
|
||||||
|
onValueSelected = {
|
||||||
|
preferences.yourPlaylistsGridRowCount = it
|
||||||
|
}
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class Preferences(holder: SharedPreferences) : SharedPreferences by holder {
|
|||||||
var displayLikeButtonInNotification by preference("displayLikeButtonInNotification", false)
|
var displayLikeButtonInNotification by preference("displayLikeButtonInNotification", false)
|
||||||
var persistentQueue by preference("persistentQueue", false)
|
var persistentQueue by preference("persistentQueue", false)
|
||||||
var skipSilence by preference("skipSilence", false)
|
var skipSilence by preference("skipSilence", false)
|
||||||
|
var yourPlaylistsGridRowCount by preference("yourPlaylistsGridRowCount", 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
val Context.preferences: Preferences
|
val Context.preferences: Preferences
|
||||||
|
|||||||
Reference in New Issue
Block a user