Create NotificationScreen
This commit is contained in:
@@ -28,9 +28,7 @@ import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.zIndex
|
||||
import androidx.media3.common.Player
|
||||
import it.vfsfitvnm.route.Route
|
||||
import it.vfsfitvnm.route.RouteHandler
|
||||
import it.vfsfitvnm.route.rememberRoute
|
||||
import it.vfsfitvnm.vimusic.Database
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
import it.vfsfitvnm.vimusic.enums.SongCollection
|
||||
@@ -86,13 +84,7 @@ fun HomeScreen(
|
||||
}
|
||||
}.collectAsState(initial = emptyList(), context = Dispatchers.IO)
|
||||
|
||||
RouteHandler(
|
||||
// route = route,
|
||||
// onRouteChanged = onRouteChanged,
|
||||
listenToGlobalEmitter = true
|
||||
) {
|
||||
println("route: ${this.route?.tag}")
|
||||
|
||||
RouteHandler(listenToGlobalEmitter = true) {
|
||||
settingsRoute {
|
||||
SettingsScreen()
|
||||
}
|
||||
|
||||
@@ -11,8 +11,7 @@ import androidx.compose.material.ripple.rememberRipple
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.ColorFilter
|
||||
import androidx.compose.ui.graphics.*
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
@@ -20,13 +19,11 @@ import it.vfsfitvnm.route.*
|
||||
import it.vfsfitvnm.vimusic.R
|
||||
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.screens.settings.*
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette
|
||||
import it.vfsfitvnm.vimusic.ui.styling.LocalTypography
|
||||
import it.vfsfitvnm.vimusic.utils.disabled
|
||||
import it.vfsfitvnm.vimusic.utils.medium
|
||||
import it.vfsfitvnm.vimusic.utils.secondary
|
||||
import it.vfsfitvnm.vimusic.utils.semiBold
|
||||
import it.vfsfitvnm.vimusic.utils.*
|
||||
|
||||
@ExperimentalAnimationApi
|
||||
@Composable
|
||||
@@ -34,6 +31,7 @@ fun SettingsScreen() {
|
||||
val albumRoute = rememberPlaylistOrAlbumRoute()
|
||||
val artistRoute = rememberArtistRoute()
|
||||
val appearanceRoute = rememberAppearanceRoute()
|
||||
val notificationRoute = rememberNotificationRoute()
|
||||
val backupAndRestoreRoute = rememberBackupAndRestoreRoute()
|
||||
val otherRoute = rememberOtherRoute()
|
||||
val aboutRoute = rememberAboutRoute()
|
||||
@@ -44,10 +42,11 @@ fun SettingsScreen() {
|
||||
listenToGlobalEmitter = true,
|
||||
transitionSpec = {
|
||||
when (targetState.route) {
|
||||
appearanceRoute, backupAndRestoreRoute, otherRoute, aboutRoute -> leftSlide
|
||||
albumRoute, artistRoute -> fastFade
|
||||
else -> when (initialState.route) {
|
||||
appearanceRoute, backupAndRestoreRoute, otherRoute, aboutRoute -> rightSlide
|
||||
else -> fastFade
|
||||
albumRoute, artistRoute -> fastFade
|
||||
null -> leftSlide
|
||||
else -> rightSlide
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -68,6 +67,10 @@ fun SettingsScreen() {
|
||||
AppearanceScreen()
|
||||
}
|
||||
|
||||
notificationRoute {
|
||||
NotificationScreen()
|
||||
}
|
||||
|
||||
backupAndRestoreRoute {
|
||||
BackupAndRestoreScreen()
|
||||
}
|
||||
@@ -177,6 +180,14 @@ fun SettingsScreen() {
|
||||
route = appearanceRoute,
|
||||
)
|
||||
|
||||
Entry(
|
||||
color = colorPalette.cyan,
|
||||
icon = R.drawable.notifications,
|
||||
title = "Notification",
|
||||
description = "Customize the notification appearance",
|
||||
route = notificationRoute
|
||||
)
|
||||
|
||||
Entry(
|
||||
color = colorPalette.orange,
|
||||
icon = R.drawable.server,
|
||||
@@ -213,8 +224,6 @@ inline fun <reified T: Enum<T>>EnumValueSelectorEntry(
|
||||
modifier: Modifier = Modifier,
|
||||
crossinline valueText: (T) -> String = Enum<T>::name
|
||||
) {
|
||||
val typography = LocalTypography.current
|
||||
|
||||
var isShowingDialog by remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
@@ -241,6 +250,53 @@ inline fun <reified T: Enum<T>>EnumValueSelectorEntry(
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@Composable
|
||||
fun SwitchSettingEntry(
|
||||
title: String,
|
||||
text: String,
|
||||
isChecked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
isEnabled: Boolean = true
|
||||
) {
|
||||
val colorPalette = LocalColorPalette.current
|
||||
val typography = LocalTypography.current
|
||||
|
||||
Row(
|
||||
horizontalArrangement = Arrangement.spacedBy(16.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = modifier
|
||||
.clickable(
|
||||
indication = rememberRipple(bounded = true),
|
||||
interactionSource = remember { MutableInteractionSource() },
|
||||
onClick = { onCheckedChange(!isChecked) },
|
||||
enabled = isEnabled
|
||||
)
|
||||
.padding(start = 24.dp)
|
||||
.padding(horizontal = 32.dp, vertical = 16.dp)
|
||||
.fillMaxWidth()
|
||||
) {
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
) {
|
||||
BasicText(
|
||||
text = title,
|
||||
style = typography.xs.semiBold.copy(color = if (isEnabled) colorPalette.text else colorPalette.darkGray),
|
||||
)
|
||||
|
||||
BasicText(
|
||||
text = text,
|
||||
style = typography.xs.semiBold.copy(color = if (isEnabled) colorPalette.textSecondary else colorPalette.darkGray),
|
||||
)
|
||||
}
|
||||
|
||||
Switch(isChecked = isChecked)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
@NonRestartableComposable
|
||||
fun SettingsEntry(
|
||||
@@ -319,4 +375,4 @@ fun SettingsEntryGroupText(
|
||||
.padding(start = 24.dp, top = 24.dp)
|
||||
.padding(horizontal = 32.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 NotificationScreen() {
|
||||
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 = "Notification",
|
||||
style = typography.m.semiBold
|
||||
)
|
||||
|
||||
Spacer(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp)
|
||||
.size(24.dp)
|
||||
)
|
||||
}
|
||||
|
||||
SwitchSettingEntry(
|
||||
title = "[SOON] Show Like button",
|
||||
text = "Mark a song as favorite",
|
||||
isChecked = preferences.displayLikeButtonInNotification,
|
||||
onCheckedChange = {
|
||||
preferences.displayLikeButtonInNotification = it
|
||||
},
|
||||
isEnabled = false
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,13 @@ fun rememberAppearanceRoute(): Route0 {
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun rememberNotificationRoute(): Route0 {
|
||||
return remember {
|
||||
Route0("NotificationRoute")
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun rememberBackupAndRestoreRoute(): Route0 {
|
||||
return remember {
|
||||
|
||||
Reference in New Issue
Block a user