Skip to content

Commit dbbf196

Browse files
committed
Feat: 토스트메시지 표시 위치 분기처리
- 바텀네비게이션바를 가진 화면과 아닌화면 패딩 구분
1 parent 825510d commit dbbf196

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

app/src/main/java/com/threegap/bitnagil/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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
}

app/src/main/java/com/threegap/bitnagil/MainNavigator.kt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,40 @@
11
package com.threegap.bitnagil
22

33
import androidx.compose.runtime.Composable
4+
import androidx.compose.runtime.getValue
45
import androidx.compose.runtime.remember
6+
import androidx.navigation.NavDestination
7+
import androidx.navigation.NavDestination.Companion.hasRoute
58
import androidx.navigation.NavHostController
9+
import androidx.navigation.compose.currentBackStackEntryAsState
610
import androidx.navigation.compose.rememberNavController
711

812
class 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

0 commit comments

Comments
 (0)