All about navigation within the Jetpack Compose-based manufacturing code-base | by Kaaveh Mohamedi | Jan, 2023 | Zombie Tech

nearly All about navigation within the Jetpack Compose-based manufacturing code-base | by Kaaveh Mohamedi | Jan, 2023 will lid the newest and most present help on this space the world. achieve entry to slowly consequently you comprehend with out problem and accurately. will enlargement your information proficiently and reliably

Picture by Mahdiar Mahmoodi on Unsplash

Configuration Navigation fundamentals

@Composable
enjoyable MyAppNavHost(
navController: NavHostController,
modifier: Modifier,
)
NavHost(
navController = navController,
startDestination = Locations.NewsListScreen.route,
modifier = modifier,
)
// backside navigation screens & nested graphs
newsListGraph(navController)
favoriteNewsGraph(navController)
profileGraph(navController)

// widespread screens in complete app
newsDetailGraph()

...

enjoyable NavGraphBuilder.VerifyCodeGraph() 
composable(
route = Locations.VerifyCodeScreen().route,
)
VerifyCodeScreen()

sealed class Locations(val route: String) 
object NewsListScreen : Locations("news_list_screen")
information class NewsDetailScreen(val information: String = "information") : Locations("news_detail_screen")
object FavoriteNewsScreen : Locations("favorite_news_screen")
object ProfileScreen : Vacation spot("profile_screen")
object SettingScreen : Vacation spot("setting_screen")
object ThemeScreen : Vacation spot("theme_screen")
object LoginScreen : Vacation spot("login_screen")
object VerifyCodeScreen : Vacation spot("verify_code_screen")
...
enjoyable NavGraphBuilder.settingListGraph(
navController: NavController,
)
composable(Locations.SettingScreen.route)
NewsListRoute(
onNavigateToThemeScreen =
navController.navigate(
route = Locations.ThemeScreen().route,
)

)

enjoyable NavGraphBuilder.profileGraph(
navController: NavHostController
)
navigation(
startDestination = Vacation spot.ProfileScreen.route,
route = Vacation spot.ProfileScreen.route.addGraphPostfix(),
)
composable(Vacation spot.ProfileScreen.route)
ProfileScreen(
onNavigationToLoginScreen =
navController.navigate(
route = Vacation spot.LoginScreen.route.addGraphPostfix(),
)

)

loginGraph()

go arguments

public open enjoyable navigate(
@IdRes resId: Int,
args: Bundle?,
navOptions: NavOptions?,
navigatorExtras: Navigator.Extras?
)
enjoyable NavController.navigate(
route: String,
args: Bundle,
navOptions: NavOptions? = null,
navigatorExtras: Navigator.Extras? = null
)
val routeLink = NavDeepLinkRequest
.Builder
.fromUri(NavDestination.createRoute(route).toUri())
.construct()

val deepLinkMatch = graph.matchDeepLink(routeLink)
if (deepLinkMatch != null)
val vacation spot = deepLinkMatch.vacation spot
val id = vacation spot.id
navigate(id, args, navOptions, navigatorExtras)
else
navigate(route, navOptions, navigatorExtras)

enjoyable NavGraphBuilder.newsListGraph(
navController: NavController,
)
composable(Locations.NewsListScreen.route)
NewsListScreen(
onNavigateToDetailScreen = information ->
navController.navigate(
route = Locations.NewsDetailScreen().route,
args = bundleOf(Locations.NewsDetailScreen().information to information)
)

)

enjoyable NavGraphBuilder.newsDetailScreen() 
composable(
route = Locations.NewsDetailScreen().route,
) entry ->
val information = entry.parcelableData<Information>(Locations.NewsDetailScreen().information)
NewsDetailScreen(information = information,)

inline enjoyable <T> NavBackStackEntry.parcelableData(key: String): T?
return arguments?.parcelable(key) as? T

I want the article virtually All about navigation within the Jetpack Compose-based manufacturing code-base | by Kaaveh Mohamedi | Jan, 2023 provides keenness to you and is beneficial for addendum to your information

All about navigation in the Jetpack Compose-based production code-base | by Kaaveh Mohamedi | Jan, 2023

x