This repository was archived by the owner on Jul 20, 2026. It is now read-only.
Project Structure #18
ken-soares
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Overview
The project is structured as followed
The main activity is the entry point of the application and is responsible of instantiating the
AppNavGraphand passing theNavControllerto it.Navigation
Google recommends using one activity per application and using multiple screens instead, the advantages of it being:
Our navigation structure relies on 3 components:
NavHostController: The object that manages navigation between screens. It controls where the app goes and handles actions like navigate() and back stack operations. We should pass it to theAppNavGraphas an argument in the main activity.NavHost: The container that defines all possible screens in the app. It maps routes (screen names) to composable functions and sets the starting destination. It is used in theAppNavGraphcomposable.Route: A simple string wrapper sealed class that identifies a screen. It acts like an address (e.g., "home", "profile") used by the NavController to navigate between destinations.Our screens are defined in the
screens/subdirectory and are composables which are made of components defined in thecomponents/subdirectory. Some components are common to every main screen like theNavBarComponentAll reactions