From 239489ba30419279e91cc5f23d70debdf5d28178 Mon Sep 17 00:00:00 2001 From: vfsfitvnm Date: Tue, 7 Jun 2022 22:11:35 +0200 Subject: [PATCH] Add AboutScreen --- .../vimusic/ui/screens/SettingsScreen.kt | 26 ++-- .../ui/screens/settings/AboutScreen.kt | 138 ++++++++++++++++++ .../vimusic/ui/screens/settings/routes.kt | 7 + .../vimusic/ui/styling/ColorPalette.kt | 2 +- app/src/main/res/drawable/information.xml | 22 +++ app/src/main/res/drawable/logo_github.xml | 9 ++ 6 files changed, 194 insertions(+), 10 deletions(-) create mode 100644 app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/AboutScreen.kt create mode 100644 app/src/main/res/drawable/information.xml create mode 100644 app/src/main/res/drawable/logo_github.xml diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/SettingsScreen.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/SettingsScreen.kt index 54ce794..b4ae127 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/SettingsScreen.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/SettingsScreen.kt @@ -19,10 +19,7 @@ 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.screens.settings.AppearanceScreen -import it.vfsfitvnm.vimusic.ui.screens.settings.BackupAndRestoreScreen -import it.vfsfitvnm.vimusic.ui.screens.settings.rememberAppearanceRoute -import it.vfsfitvnm.vimusic.ui.screens.settings.rememberBackupAndRestoreRoute +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.medium @@ -36,6 +33,7 @@ fun SettingsScreen() { val artistRoute = rememberArtistRoute() val appearanceRoute = rememberAppearanceRoute() val backupAndRestoreRoute = rememberBackupAndRestoreRoute() + val aboutRoute = rememberAboutRoute() val scrollState = rememberScrollState() @@ -43,9 +41,9 @@ fun SettingsScreen() { listenToGlobalEmitter = true, transitionSpec = { when (targetState.route) { - appearanceRoute, backupAndRestoreRoute -> leftSlide + appearanceRoute, backupAndRestoreRoute, aboutRoute -> leftSlide else -> when (initialState.route) { - appearanceRoute, backupAndRestoreRoute -> rightSlide + appearanceRoute, backupAndRestoreRoute, aboutRoute -> rightSlide else -> fastFade } } @@ -71,6 +69,10 @@ fun SettingsScreen() { BackupAndRestoreScreen() } + aboutRoute { + AboutScreen() + } + host { val colorPalette = LocalColorPalette.current val typography = LocalTypography.current @@ -149,14 +151,12 @@ fun SettingsScreen() { BasicText( text = title, style = typography.s.semiBold, - modifier = Modifier ) BasicText( text = description, style = typography.xs.secondary.medium, - maxLines = 1, - modifier = Modifier + maxLines = 1 ) } } @@ -177,6 +177,14 @@ fun SettingsScreen() { description = "Backup and restore the app database", route = backupAndRestoreRoute ) + + Entry( + color = colorPalette.green, + icon = R.drawable.information, + title = "About", + description = "App version and social links", + route = aboutRoute + ) } } } diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/AboutScreen.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/AboutScreen.kt new file mode 100644 index 0000000..f88fc2c --- /dev/null +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/AboutScreen.kt @@ -0,0 +1,138 @@ +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.shape.CircleShape +import androidx.compose.foundation.text.BasicText +import androidx.compose.runtime.Composable +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.ColorFilter +import androidx.compose.ui.platform.LocalUriHandler +import androidx.compose.ui.res.painterResource +import androidx.compose.ui.unit.dp +import it.vfsfitvnm.route.RouteHandler +import it.vfsfitvnm.vimusic.BuildConfig +import it.vfsfitvnm.vimusic.R +import it.vfsfitvnm.vimusic.ui.components.TopAppBar +import it.vfsfitvnm.vimusic.ui.screens.ArtistScreen +import it.vfsfitvnm.vimusic.ui.screens.PlaylistOrAlbumScreen +import it.vfsfitvnm.vimusic.ui.screens.rememberArtistRoute +import it.vfsfitvnm.vimusic.ui.screens.rememberPlaylistOrAlbumRoute +import it.vfsfitvnm.vimusic.ui.styling.LocalColorPalette +import it.vfsfitvnm.vimusic.ui.styling.LocalTypography +import it.vfsfitvnm.vimusic.utils.bold +import it.vfsfitvnm.vimusic.utils.secondary +import it.vfsfitvnm.vimusic.utils.semiBold + +@ExperimentalAnimationApi +@Composable +fun AboutScreen() { + 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 uriHandler = LocalUriHandler.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 = "About", + style = typography.m.semiBold + ) + + Image( + painter = painterResource(R.drawable.logo_github), + contentDescription = null, + colorFilter = ColorFilter.tint(colorPalette.text), + modifier = Modifier + .clickable { + uriHandler.openUri("https://github.com/vfsfitvnm/ViMusic") + } + .padding(horizontal = 16.dp, vertical = 8.dp) + .size(24.dp) + ) + } + + Column( + horizontalAlignment = Alignment.CenterHorizontally, + verticalArrangement = Arrangement.spacedBy(16.dp), + modifier = Modifier + .padding(all = 32.dp) + .align(Alignment.CenterHorizontally) + ) { + Box( + contentAlignment = Alignment.Center, + modifier = Modifier + .background(color = colorPalette.primaryContainer, shape = CircleShape) + .padding(all = 16.dp) + .size(48.dp) + ) { + Image( + painter = painterResource(R.drawable.app_icon), + contentDescription = null, + colorFilter = ColorFilter.tint(colorPalette.onPrimaryContainer), + modifier = Modifier + .size(32.dp) + ) + } + + Row( + horizontalArrangement = Arrangement.spacedBy(8.dp), + verticalAlignment = Alignment.Bottom + ) { + BasicText( + text = "ViMusic", + style = typography.l.bold, + modifier = Modifier + .alignByBaseline() + ) + BasicText( + text = "v${BuildConfig.VERSION_NAME}", + style = typography.s.bold.secondary, + modifier = Modifier + .alignByBaseline() + ) + } + } + } + } + } +} \ No newline at end of file diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/routes.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/routes.kt index 54b3c76..9fcda90 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/routes.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/screens/settings/routes.kt @@ -17,3 +17,10 @@ fun rememberBackupAndRestoreRoute(): Route0 { Route0("BackupAndRestoreRoute") } } + +@Composable +fun rememberAboutRoute(): Route0 { + return remember { + Route0("AboutRoute") + } +} diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/styling/ColorPalette.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/styling/ColorPalette.kt index 990238c..ee52d24 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/styling/ColorPalette.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/ui/styling/ColorPalette.kt @@ -37,7 +37,7 @@ val DarkColorPalette = ColorPalette( darkGray = Color(0xFF838383), blue = Color(0xff507fdd), red = Color(0xffbf4040), - green = Color(0xff7fbf40), + green = Color(0xff82b154), orange = Color(0xffe9a033), primaryContainer = Color(0xff4046bf), diff --git a/app/src/main/res/drawable/information.xml b/app/src/main/res/drawable/information.xml new file mode 100644 index 0000000..97e7373 --- /dev/null +++ b/app/src/main/res/drawable/information.xml @@ -0,0 +1,22 @@ + + + + + diff --git a/app/src/main/res/drawable/logo_github.xml b/app/src/main/res/drawable/logo_github.xml new file mode 100644 index 0000000..609ef4b --- /dev/null +++ b/app/src/main/res/drawable/logo_github.xml @@ -0,0 +1,9 @@ + + +