File tree Expand file tree Collapse file tree 2 files changed +20
-1
lines changed
app/src/main/java/com/threegap/bitnagil Expand file tree Collapse file tree 2 files changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ class MainActivity : ComponentActivity() {
5555 modifier = Modifier
5656 .align(Alignment .BottomCenter )
5757 .navigationBarsPadding()
58- .padding(bottom = 80 .dp),
58+ .padding(bottom = if (mainNavigator.hasBottomNavigationBarRoute()) 80 .dp else 16 .dp),
5959 )
6060 }
6161 }
Original file line number Diff line number Diff line change 11package com.threegap.bitnagil
22
33import androidx.compose.runtime.Composable
4+ import androidx.compose.runtime.getValue
45import androidx.compose.runtime.remember
6+ import androidx.navigation.NavDestination
7+ import androidx.navigation.NavDestination.Companion.hasRoute
58import androidx.navigation.NavHostController
9+ import androidx.navigation.compose.currentBackStackEntryAsState
610import androidx.navigation.compose.rememberNavController
711
812class MainNavigator (
913 val navController : NavHostController ,
1014) {
1115 val startDestination = Route .Splash
1216
17+ private val currentDestination: NavDestination ?
18+ @Composable get() {
19+ val currentEntry by navController.currentBackStackEntryAsState()
20+ return currentEntry?.destination
21+ }
22+
1323 internal fun navigateToHomeAndClearStack () =
1424 navController.navigate(Route .Home ) {
1525 popUpTo(0 ) {
1626 inclusive = true
1727 }
1828 }
29+
30+ @Composable
31+ internal fun hasBottomNavigationBarRoute (): Boolean {
32+ val destination = currentDestination
33+ return when {
34+ destination?.hasRoute<Route .Home >() == true -> true
35+ else -> false
36+ }
37+ }
1938}
2039
2140@Composable
You can’t perform that action at this time.
0 commit comments