nearly All about navigation within the Jetpack Compose-based manufacturing code-base | by Kaaveh Mohamedi | Jan, 2023 will lid the most recent and most present steerage with regards to the world. entrance slowly because of this you perceive with ease and accurately. will enhance your information adroitly 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)

// frequent screens in total 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()

cross 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 about All about navigation within the Jetpack Compose-based manufacturing code-base | by Kaaveh Mohamedi | Jan, 2023 provides acuteness to you and is helpful for further to your information

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

By admin

Leave a Reply

x