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