From fdd7a52c12faad609235698344bb5ec99448bbf3 Mon Sep 17 00:00:00 2001 From: Andrew Haisting <142518658+ahaisting-livefront@users.noreply.github.com> Date: Mon, 11 Sep 2023 15:20:13 -0500 Subject: [PATCH] BIT-141 Implement basic SplashScreen composable (#39) --- .../platform/feature/rootnav/RootNavScreen.kt | 43 ++----------------- .../feature/splash/SplashNavigation.kt | 24 +++++++++++ .../platform/feature/splash/SplashScreen.kt | 9 ++++ 3 files changed, 36 insertions(+), 40 deletions(-) create mode 100644 app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt create mode 100644 app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashScreen.kt diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt index f7ec37779..2eb7fcc40 100644 --- a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/rootnav/RootNavScreen.kt @@ -4,18 +4,16 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.getValue import androidx.hilt.navigation.compose.hiltViewModel import androidx.lifecycle.compose.collectAsStateWithLifecycle -import androidx.navigation.NavController import androidx.navigation.NavDestination -import androidx.navigation.NavGraphBuilder -import androidx.navigation.NavOptions import androidx.navigation.compose.NavHost -import androidx.navigation.compose.composable import androidx.navigation.compose.rememberNavController import androidx.navigation.navOptions import com.x8bit.bitwarden.ui.auth.feature.auth.AUTH_ROUTE import com.x8bit.bitwarden.ui.auth.feature.auth.authDestinations import com.x8bit.bitwarden.ui.auth.feature.auth.navigateToAuth -import com.x8bit.bitwarden.ui.platform.components.PlaceholderComposable +import com.x8bit.bitwarden.ui.platform.feature.splash.SPLASH_ROUTE +import com.x8bit.bitwarden.ui.platform.feature.splash.navigateToSplash +import com.x8bit.bitwarden.ui.platform.feature.splash.splashDestinations import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.VAULT_UNLOCKED_ROUTE import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.navigateToVaultUnlocked import com.x8bit.bitwarden.ui.platform.feature.vaultunlocked.vaultUnlockedDestinations @@ -92,38 +90,3 @@ private fun NavDestination?.routeLevelRoute(): String? { } return parent.routeLevelRoute() } - -/** - * The functions below should be moved to their respective feature packages once they exist. - * - * For an example of how to setup these nav extensions, see NIA project. - */ - -/** - * TODO: move to splash package (BIT-147) - */ -private const val SPLASH_ROUTE = "splash" - -/** - * Add splash destinations to the nav graph. - * - * TODO: move to splash package (BIT-147) - */ -private fun NavGraphBuilder.splashDestinations() { - composable(SPLASH_ROUTE) { - PlaceholderComposable(text = "Splash") - } -} - -/** - * Navigate to the splash screen. Note this will only work if splash destination was added - * via [splashDestinations]. - * - * TODO: move to splash package (BIT-147) - * - */ -private fun NavController.navigateToSplash( - navOptions: NavOptions? = null, -) { - navigate(SPLASH_ROUTE, navOptions) -} diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt new file mode 100644 index 000000000..90aed312b --- /dev/null +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashNavigation.kt @@ -0,0 +1,24 @@ +package com.x8bit.bitwarden.ui.platform.feature.splash + +import androidx.navigation.NavController +import androidx.navigation.NavGraphBuilder +import androidx.navigation.NavOptions +import androidx.navigation.compose.composable + +const val SPLASH_ROUTE: String = "splash" + +/** + * Add splash destinations to the nav graph. + */ +fun NavGraphBuilder.splashDestinations() { + composable(SPLASH_ROUTE) { SplashScreen() } +} + +/** + * Navigate to the splash screen. + */ +fun NavController.navigateToSplash( + navOptions: NavOptions? = null, +) { + navigate(SPLASH_ROUTE, navOptions) +} diff --git a/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashScreen.kt b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashScreen.kt new file mode 100644 index 000000000..51908f6ae --- /dev/null +++ b/app/src/main/java/com/x8bit/bitwarden/ui/platform/feature/splash/SplashScreen.kt @@ -0,0 +1,9 @@ +package com.x8bit.bitwarden.ui.platform.feature.splash + +import androidx.compose.runtime.Composable + +/** + * Splash screen with empty composable content so that the Activity window background is shown. + */ +@Composable +fun SplashScreen() = Unit