Skip to content

Commit

Permalink
[feat] mash-up-kr#111 Home화면 route 및 graph 생성
Browse files Browse the repository at this point in the history
  • Loading branch information
JaesungLeee committed Jul 4, 2023
1 parent a1f8a6d commit 5ebede5
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.mashup.presentation.feature.home.navigation

import androidx.navigation.NavController
import androidx.navigation.NavGraphBuilder
import androidx.navigation.NavOptions
import androidx.navigation.compose.composable
import androidx.navigation.compose.navigation
import com.mashup.presentation.navigation.KeyLinkNavigationRoute

/**
* Ssam_D_Android
* @author jaesung
* @created 2023/07/04
*/
fun NavController.navigateToGuideRoute(navOptions: NavOptions? = null) {
navigate(
route = KeyLinkNavigationRoute.HomeGraph.GuideRoute.route,
navOptions = navOptions
)
}

fun NavController.navigateToEditKeywordRoute(navOptions: NavOptions? = null) {
navigate(
route = KeyLinkNavigationRoute.HomeGraph.EditKeywordRoute.route,
navOptions = navOptions
)
}

fun NavController.navigateToProfileRoute(navOptions: NavOptions? = null) {
navigate(
route = KeyLinkNavigationRoute.HomeGraph.ProfileRoute.route,
navOptions = navOptions
)
}

fun NavGraphBuilder.homeGraph() {
navigation(
route = KeyLinkNavigationRoute.HomeGraph.route,
startDestination = KeyLinkNavigationRoute.HomeGraph.HomeRoute.route
) {
composable(route = KeyLinkNavigationRoute.HomeGraph.HomeRoute.route) {
// HomeRoute
}
composable(route = KeyLinkNavigationRoute.HomeGraph.GuideRoute.route) {
// GuideRoute
}
composable(route = KeyLinkNavigationRoute.HomeGraph.EditKeywordRoute.route) {
// KeywordRoute
}
composable(route = KeyLinkNavigationRoute.HomeGraph.ProfileRoute.route) {
// ProfileRoute
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.mashup.presentation.navigation

import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.navigation.compose.NavHost
import com.mashup.presentation.KeyLinkAppState
import com.mashup.presentation.feature.home.navigation.homeGraph

/**
* Ssam_D_Android
* @author jaesung
* @created 2023/07/04
*/
@Composable
fun KeyLinkNavHost(
appState: KeyLinkAppState,
onShowSnackbar: suspend (String, String?) -> Boolean,
startDestination: String,
modifier: Modifier = Modifier
) {
val navController = appState.navController
NavHost(
navController = navController,
startDestination = startDestination,
modifier = modifier
) {
homeGraph()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.mashup.presentation.navigation

/**
* Ssam_D_Android
* @author jaesung
* @created 2023/07/04
*/
sealed class KeyLinkNavigationRoute(val route: String) {
object HomeGraph : KeyLinkNavigationRoute(homeGraphPattern) {
object HomeRoute : KeyLinkNavigationRoute(homeRoute)
object EditKeywordRoute : KeyLinkNavigationRoute(editKeywordRoute)
object GuideRoute : KeyLinkNavigationRoute(guideRoute)
object ProfileRoute : KeyLinkNavigationRoute(profileRoute)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mashup.presentation.navigation

/**
* Ssam_D_Android
* @author jaesung
* @created 2023/07/04
*/

const val homeGraphPattern = "home_graph"
const val homeRoute = "home_graph/home"
const val guideRoute = "home_graph/guide"
const val profileRoute = "home_graph/profile"
const val editKeywordRoute = "home_graph/edit_keyword"

0 comments on commit 5ebede5

Please sign in to comment.