From db2a6f8abf8bf12b3c0538c73a8d343f23ddfe1b Mon Sep 17 00:00:00 2001 From: Owen LeJeune Date: Fri, 9 Jun 2023 10:05:40 -0400 Subject: [PATCH] create basic about page --- .../com/owenlejeune/tvtime/MainActivity.kt | 5 + .../owenlejeune/tvtime/ui/components/Menus.kt | 17 +++ .../tvtime/ui/navigation/MainNavItem.kt | 2 +- .../tvtime/ui/screens/main/AboutView.kt | 139 ++++++++++++++++++ app/src/main/res/raw/changelog.md | 0 app/src/main/res/values/strings.xml | 1 + 6 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AboutView.kt create mode 100644 app/src/main/res/raw/changelog.md diff --git a/app/src/main/java/com/owenlejeune/tvtime/MainActivity.kt b/app/src/main/java/com/owenlejeune/tvtime/MainActivity.kt index ff6b035..45e84c9 100644 --- a/app/src/main/java/com/owenlejeune/tvtime/MainActivity.kt +++ b/app/src/main/java/com/owenlejeune/tvtime/MainActivity.kt @@ -464,6 +464,11 @@ class MainActivity : MonetCompatActivity() { doSignInPartTwo = deepLink == NavConstants.AUTH_REDIRECT_PAGE ) } + composable( + route = MainNavItem.AboutView.route + ) { + AboutView(appNavController = appNavController) + } } } diff --git a/app/src/main/java/com/owenlejeune/tvtime/ui/components/Menus.kt b/app/src/main/java/com/owenlejeune/tvtime/ui/components/Menus.kt index 3affe8d..4df45c4 100644 --- a/app/src/main/java/com/owenlejeune/tvtime/ui/components/Menus.kt +++ b/app/src/main/java/com/owenlejeune/tvtime/ui/components/Menus.kt @@ -14,6 +14,7 @@ import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.wrapContentHeight import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.outlined.Info import androidx.compose.material.icons.outlined.Login import androidx.compose.material.icons.outlined.Logout import androidx.compose.material.icons.outlined.Person @@ -155,6 +156,22 @@ fun ProfileMenuOverlay( ) } + ProfileMenuItem( + onClick = { + onDismissRequest() + appNavController.navigate(MainNavItem.AboutView.route) + } + ) { + Icon( + imageVector = Icons.Outlined.Info, + contentDescription = null + ) + Text( + text = stringResource(id = R.string.nav_about_title), + fontSize = 16.sp + ) + } + MenuDivider() ProfileMenuItem( diff --git a/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/MainNavItem.kt b/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/MainNavItem.kt index 3f12562..68ffcc3 100644 --- a/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/MainNavItem.kt +++ b/app/src/main/java/com/owenlejeune/tvtime/ui/navigation/MainNavItem.kt @@ -11,7 +11,7 @@ sealed class MainNavItem(val route: String) { object SettingsView: MainNavItem("settings_route") object SearchView: MainNavItem("search_route") object WebLinkView: MainNavItem("web_link_route") - object AccountView: MainNavItem("account_route") + object AboutView: MainNavItem("about_route") } \ No newline at end of file diff --git a/app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AboutView.kt b/app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AboutView.kt new file mode 100644 index 0000000..d23ff70 --- /dev/null +++ b/app/src/main/java/com/owenlejeune/tvtime/ui/screens/main/AboutView.kt @@ -0,0 +1,139 @@ +package com.owenlejeune.tvtime.ui.screens.main + +import android.content.Intent +import android.net.Uri +import android.provider.Settings +import androidx.compose.animation.rememberSplineBasedDecay +import androidx.compose.foundation.clickable +import androidx.compose.foundation.layout.Arrangement +import androidx.compose.foundation.layout.Box +import androidx.compose.foundation.layout.Column +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.padding +import androidx.compose.foundation.layout.wrapContentHeight +import androidx.compose.material.icons.Icons +import androidx.compose.material.icons.filled.ArrowBack +import androidx.compose.material.icons.filled.Drafts +import androidx.compose.material.icons.outlined.Description +import androidx.compose.material.icons.outlined.Drafts +import androidx.compose.material.icons.outlined.FileCopy +import androidx.compose.material.icons.outlined.Info +import androidx.compose.material3.ExperimentalMaterial3Api +import androidx.compose.material3.Icon +import androidx.compose.material3.IconButton +import androidx.compose.material3.LargeTopAppBar +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Scaffold +import androidx.compose.material3.Text +import androidx.compose.material3.TopAppBarDefaults +import androidx.compose.material3.rememberTopAppBarScrollState +import androidx.compose.runtime.Composable +import androidx.compose.runtime.remember +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.graphics.vector.ImageVector +import androidx.compose.ui.input.nestedscroll.nestedScroll +import androidx.compose.ui.platform.LocalContext +import androidx.compose.ui.res.stringResource +import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp +import androidx.navigation.NavController +import com.owenlejeune.tvtime.BuildConfig +import com.owenlejeune.tvtime.R +import com.owenlejeune.tvtime.ui.navigation.MainNavItem + +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun AboutView( + appNavController: NavController +) { + val context = LocalContext.current + + val decayAnimationSpec = rememberSplineBasedDecay() + val topAppBarScrollState = rememberTopAppBarScrollState() + val scrollBehavior = remember(decayAnimationSpec) { + TopAppBarDefaults.exitUntilCollapsedScrollBehavior(decayAnimationSpec, topAppBarScrollState) + } + Scaffold( + modifier = Modifier.nestedScroll(connection = scrollBehavior.nestedScrollConnection), + topBar = { + LargeTopAppBar( + title = { Text(text = stringResource(id = R.string.nav_about_title)) }, + navigationIcon = { + IconButton( + onClick = { appNavController.popBackStack() } + ) { + Icon( + imageVector = Icons.Filled.ArrowBack, + contentDescription = null + ) + } + } + ) + } + ) { + Box(modifier = Modifier.padding(it)) { + Column( + verticalArrangement = Arrangement.spacedBy(24.dp), + modifier = Modifier.padding(horizontal = 24.dp) + ) { + AboutItem( + title = "App Info", + subtitle = "v${BuildConfig.VERSION_NAME}", + icon = Icons.Outlined.Info, + onClick = { + val intent = Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS).apply { + val uri = Uri.fromParts("package", context.packageName, null) + data = uri + } + context.startActivity(intent) + } + ) + + AboutItem( + title = "Changelog", + icon = Icons.Outlined.Description + ) + } + } + } +} + +@Composable +private fun AboutItem( + title: String, + subtitle: String? = null, + icon: ImageVector, + onClick: (() -> Unit)? = null +) { + Row( + modifier = Modifier + .fillMaxWidth() + .wrapContentHeight() + .clickable( + onClick = onClick ?: {}, + enabled = onClick != null + ), + horizontalArrangement = Arrangement.spacedBy(24.dp) + ) { + Icon( + imageVector = icon, + contentDescription = subtitle, + modifier = Modifier.align(Alignment.CenterVertically), + tint = MaterialTheme.colorScheme.primary + ) + Column( + modifier = Modifier + .align(Alignment.CenterVertically) + .weight(1f) + ) { + val titleColor = MaterialTheme.colorScheme.onBackground + val subtitleColor = MaterialTheme.colorScheme.onSurfaceVariant + Text(text = title, style = MaterialTheme.typography.titleLarge, color = titleColor, fontSize = 20.sp) + subtitle?.let { + Text(text = subtitle, style = MaterialTheme.typography.bodyMedium, color = subtitleColor) + } + } + } +} \ No newline at end of file diff --git a/app/src/main/res/raw/changelog.md b/app/src/main/res/raw/changelog.md new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4f5d8df..b9508d7 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,6 +23,7 @@ Movie Watchlist TV Watchlist Lists + About Cast