底部菜单栏在进入子页面时隐藏
This commit is contained in:
@@ -1,10 +1,13 @@
|
|||||||
package cn.airnan.a2fair.ui.navigation
|
package cn.airnan.a2fair.ui.navigation
|
||||||
|
|
||||||
|
import androidx.compose.animation.AnimatedVisibility
|
||||||
import androidx.compose.animation.EnterTransition
|
import androidx.compose.animation.EnterTransition
|
||||||
import androidx.compose.animation.ExitTransition
|
import androidx.compose.animation.ExitTransition
|
||||||
import androidx.compose.animation.core.tween
|
import androidx.compose.animation.core.tween
|
||||||
import androidx.compose.animation.slideInHorizontally
|
import androidx.compose.animation.slideInHorizontally
|
||||||
|
import androidx.compose.animation.slideInVertically
|
||||||
import androidx.compose.animation.slideOutHorizontally
|
import androidx.compose.animation.slideOutHorizontally
|
||||||
|
import androidx.compose.animation.slideOutVertically
|
||||||
import androidx.compose.foundation.layout.WindowInsets
|
import androidx.compose.foundation.layout.WindowInsets
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
@@ -32,32 +35,47 @@ fun AppNavigation(
|
|||||||
val app = context.applicationContext as A2FairApplication
|
val app = context.applicationContext as A2FairApplication
|
||||||
val animDuration = context.resources.getInteger(android.R.integer.config_shortAnimTime)
|
val animDuration = context.resources.getInteger(android.R.integer.config_shortAnimTime)
|
||||||
|
|
||||||
|
val currentTopLevelDestination = appState.currentTopLevelDestination
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
contentWindowInsets = WindowInsets(0, 0, 0, 0),
|
||||||
bottomBar = {
|
bottomBar = {
|
||||||
|
AnimatedVisibility(
|
||||||
|
visible = currentTopLevelDestination != null,
|
||||||
|
enter = slideInVertically(initialOffsetY = { it }, animationSpec = tween(animDuration)),
|
||||||
|
exit = slideOutVertically(targetOffsetY = { it }, animationSpec = tween(animDuration))
|
||||||
|
) {
|
||||||
AppBottomBar(
|
AppBottomBar(
|
||||||
destinations = appState.topLevelDestinations,
|
destinations = appState.topLevelDestinations,
|
||||||
onNavigateToDestination = appState::navigateToTopLevelDestination,
|
onNavigateToDestination = appState::navigateToTopLevelDestination,
|
||||||
currentDestination = appState.currentTopLevelDestination
|
currentDestination = currentTopLevelDestination
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
) { padding ->
|
) { padding ->
|
||||||
NavHost(
|
NavHost(
|
||||||
navController = appState.navController,
|
navController = appState.navController,
|
||||||
startDestination = TopLevelDestination.TOKENS.route,
|
startDestination = TopLevelDestination.TOKENS.route,
|
||||||
modifier = Modifier.padding(padding)
|
modifier = Modifier // removed padding from NavHost
|
||||||
) {
|
) {
|
||||||
composable(
|
composable(
|
||||||
route = TopLevelDestination.TOKENS.route,
|
route = TopLevelDestination.TOKENS.route,
|
||||||
enterTransition = { EnterTransition.None },
|
enterTransition = { EnterTransition.None },
|
||||||
exitTransition = { ExitTransition.None }
|
exitTransition = { ExitTransition.None }
|
||||||
|
) {
|
||||||
|
androidx.compose.foundation.layout.Box(
|
||||||
|
modifier = Modifier.padding(bottom = padding.calculateBottomPadding())
|
||||||
) {
|
) {
|
||||||
TokensScreen()
|
TokensScreen()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
composable(
|
composable(
|
||||||
route = TopLevelDestination.SETTINGS.route,
|
route = TopLevelDestination.SETTINGS.route,
|
||||||
enterTransition = { EnterTransition.None },
|
enterTransition = { EnterTransition.None },
|
||||||
exitTransition = { ExitTransition.None }
|
exitTransition = { ExitTransition.None }
|
||||||
|
) {
|
||||||
|
androidx.compose.foundation.layout.Box(
|
||||||
|
modifier = Modifier.padding(bottom = padding.calculateBottomPadding())
|
||||||
) {
|
) {
|
||||||
SettingsScreen(
|
SettingsScreen(
|
||||||
onNavigateToSecurity = { appState.navController.navigate("security") },
|
onNavigateToSecurity = { appState.navController.navigate("security") },
|
||||||
@@ -67,6 +85,7 @@ fun AppNavigation(
|
|||||||
onNavigateToAbout = { appState.navController.navigate("about") }
|
onNavigateToAbout = { appState.navController.navigate("about") }
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
composable(
|
composable(
|
||||||
route = "security",
|
route = "security",
|
||||||
enterTransition = {
|
enterTransition = {
|
||||||
|
|||||||
Reference in New Issue
Block a user