Skip to content

Commit

Permalink
[feat] mash-up-kr#111 App에 BottomBar 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
JaesungLeee committed Jul 6, 2023
1 parent 757e073 commit fd333a1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
12 changes: 8 additions & 4 deletions presentation/src/main/java/com/mashup/presentation/KeyLinkApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import com.mashup.presentation.navigation.KeyLinkNavHost
import com.mashup.presentation.navigation.TopLevelDestination
import com.mashup.presentation.ui.common.KeyLinkNavigationBar
import com.mashup.presentation.ui.common.KeyLinkBottomBar
import com.mashup.presentation.ui.common.KeyLinkSnackBar
import com.mashup.presentation.ui.theme.Black

Expand All @@ -28,15 +27,19 @@ fun KeyLinkApp(
Scaffold(
bottomBar = {
if (appState.isBottomBarVisible()) {
// KeyLinkNavigationBar()
KeyLinkBottomBar(
destinations = appState.topLevelDestinations,
onNavigateToDestination = appState::navigateToTopLevelDestination,
currentDestination = appState.currentDestination,
modifier = Modifier
)
}
},
backgroundColor = Black,
snackbarHost = { KeyLinkSnackBar(snackBarHostState = snackbarHostState) }
) { innerPadding ->
KeyLinkNavHost(
appState = appState,
startDestination = "",
modifier = Modifier.padding(innerPadding),
onShowSnackbar = { message, action ->
snackbarHostState.showSnackbar(
Expand All @@ -48,3 +51,4 @@ fun KeyLinkApp(
)
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class KeyLinkAppState(
val currentDestination: NavDestination?
@Composable get() = navController.currentBackStackEntryAsState().value?.destination

val topLevelDestinations: List<TopLevelDestination> = TopLevelDestination.values().toList()

@Composable
fun isBottomBarVisible(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ fun NavController.navigateToProfileRoute(navOptions: NavOptions? = null) {
)
}

fun NavGraphBuilder.homeGraph() {
fun NavGraphBuilder.homeGraph(
navController: NavController
) {
navigation(
route = KeyLinkNavigationRoute.HomeGraph.route,
startDestination = KeyLinkNavigationRoute.HomeGraph.HomeRoute.route
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ import com.mashup.presentation.feature.signal.navigation.signalGraph
fun KeyLinkNavHost(
appState: KeyLinkAppState,
onShowSnackbar: suspend (String, String?) -> Boolean,
startDestination: String,
modifier: Modifier = Modifier
modifier: Modifier = Modifier,
startDestination: String = KeyLinkNavigationRoute.HomeGraph.HomeRoute.route
) {
val navController = appState.navController
NavHost(
navController = navController,
startDestination = startDestination,
modifier = modifier
) {
homeGraph()
homeGraph(navController = navController)
signalGraph()
chatGraph() {

Expand Down

0 comments on commit fd333a1

Please sign in to comment.