Add player state persistence concept

This commit is contained in:
vfsfitvnm
2022-06-12 12:19:23 +02:00
parent a0e42473e6
commit e8e69549c6
9 changed files with 564 additions and 10 deletions

View File

@@ -31,6 +31,7 @@ fun SettingsScreen() {
val albumRoute = rememberPlaylistOrAlbumRoute()
val artistRoute = rememberArtistRoute()
val appearanceRoute = rememberAppearanceRoute()
val playerSettingsRoute = rememberPlayerSettingsRoute()
val notificationRoute = rememberNotificationRoute()
val backupAndRestoreRoute = rememberBackupAndRestoreRoute()
val otherRoute = rememberOtherRoute()
@@ -67,6 +68,10 @@ fun SettingsScreen() {
AppearanceScreen()
}
playerSettingsRoute {
PlayerSettingsScreen()
}
notificationRoute {
NotificationScreen()
}
@@ -180,6 +185,14 @@ fun SettingsScreen() {
route = appearanceRoute,
)
Entry(
color = colorPalette.magenta,
icon = R.drawable.play,
title = "Player",
description = "Tune the player behavior",
route = playerSettingsRoute,
)
Entry(
color = colorPalette.cyan,
icon = R.drawable.notifications,

View File

@@ -0,0 +1,92 @@
package it.vfsfitvnm.vimusic.ui.screens.settings
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.foundation.*
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.BasicText
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ColorFilter
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import it.vfsfitvnm.route.RouteHandler
import it.vfsfitvnm.vimusic.R
import it.vfsfitvnm.vimusic.ui.components.TopAppBar
import it.vfsfitvnm.vimusic.ui.screens.*
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
import it.vfsfitvnm.vimusic.utils.LocalPreferences
import it.vfsfitvnm.vimusic.utils.semiBold
@ExperimentalAnimationApi
@Composable
fun PlayerSettingsScreen() {
val albumRoute = rememberPlaylistOrAlbumRoute()
val artistRoute = rememberArtistRoute()
val scrollState = rememberScrollState()
RouteHandler(listenToGlobalEmitter = true) {
albumRoute { browseId ->
PlaylistOrAlbumScreen(
browseId = browseId ?: error("browseId cannot be null")
)
}
artistRoute { browseId ->
ArtistScreen(
browseId = browseId ?: error("browseId cannot be null")
)
}
host {
val colorPalette = LocalColorPalette.current
val typography = LocalTypography.current
val preferences = LocalPreferences.current
Column(
modifier = Modifier
.background(colorPalette.background)
.fillMaxSize()
.verticalScroll(scrollState)
.padding(bottom = 72.dp)
) {
TopAppBar(
modifier = Modifier
.height(52.dp)
) {
Image(
painter = painterResource(R.drawable.chevron_back),
contentDescription = null,
colorFilter = ColorFilter.tint(colorPalette.text),
modifier = Modifier
.clickable(onClick = pop)
.padding(horizontal = 16.dp, vertical = 8.dp)
.size(24.dp)
)
BasicText(
text = "Player",
style = typography.m.semiBold
)
Spacer(
modifier = Modifier
.padding(horizontal = 16.dp, vertical = 8.dp)
.size(24.dp)
)
}
SwitchSettingEntry(
title = "[SOON] Persistent queue",
text = "Save and restore playing songs",
isChecked = preferences.persistentQueue,
onCheckedChange = {
preferences.persistentQueue = it
},
isEnabled = false
)
}
}
}
}

View File

@@ -11,6 +11,13 @@ fun rememberAppearanceRoute(): Route0 {
}
}
@Composable
fun rememberPlayerSettingsRoute(): Route0 {
return remember {
Route0("PlayerSettingsRoute")
}
}
@Composable
fun rememberNotificationRoute(): Route0 {
return remember {