Skip to content

Commit

Permalink
refactor :: navHostControl로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
rladmsdh committed Feb 6, 2024
1 parent 839475d commit c1c0f32
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package team.retum.jobisandroidv2.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.navigation
import team.retum.alarm.navigation.alarm
import team.retum.jobisandroidv2.root.NAVIGATION_ROOT
import team.retum.jobisandroidv2.root.root

const val NAVIGATION_MAIN = "main"

fun NavGraphBuilder.mainNavigation(navController: NavController) {
fun NavGraphBuilder.mainNavigation(navHostController: NavHostController) {
navigation(
route = NAVIGATION_MAIN,
startDestination = NAVIGATION_ROOT,
) {
root(navHostController = navController)
alarm(onBackPressed = navController::popBackStack)
root(navHostController = navHostController)
alarm(onBackPressed = navHostController::popBackStack)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package team.retum.jobisandroidv2.root

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavHostController
import androidx.navigation.compose.composable

const val NAVIGATION_ROOT = "root"

fun NavGraphBuilder.root(navHostController: NavController) {
fun NavGraphBuilder.root(navHostController: NavHostController) {
composable(NAVIGATION_ROOT) {
Root(navHostController = navHostController)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import team.retum.home.navigation.home
import team.retum.jobisandroidv2.ui.BottomNavigationBar

@Composable
fun Root(navHostController: NavController) {
fun Root(navHostController: NavHostController) {
val navController = rememberNavController()

RootScreen(
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/java/team/retum/jobisandroidv2/ui/JobisApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.rememberNavController
import team.retum.jobisandroidv2.navigation.NAVIGATION_AUTH
import team.retum.jobisandroidv2.navigation.NAVIGATION_MAIN
import team.retum.jobisandroidv2.navigation.authNavigation
import team.retum.jobisandroidv2.navigation.mainNavigation

Expand All @@ -19,9 +20,9 @@ internal fun JobisApp() {
.navigationBarsPadding()
.statusBarsPadding(),
navController = navController,
startDestination = NAVIGATION_AUTH,
startDestination = NAVIGATION_MAIN,
) {
authNavigation(navController = navController)
mainNavigation(navController = navController)
mainNavigation(navHostController = navController)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package team.retum.alarm.navigation
import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.compose.composable
import team.retum.alarm.ui.AlarmScreen
import team.retum.alarm.ui.Alarm

const val NAVIGATION_ALARM = "alarm"

fun NavGraphBuilder.alarm(onBackPressed: () -> Unit) {
composable(route = NAVIGATION_ALARM) {
AlarmScreen(onBackPressed = onBackPressed)
composable(NAVIGATION_ALARM) {
Alarm(onBackPressed = onBackPressed)
}
}

Expand Down

0 comments on commit c1c0f32

Please sign in to comment.