-
Notifications
You must be signed in to change notification settings - Fork 0
Navigation & Routes Definition
The navigation system is string-based and centralized in the :core:design-system module.
Add a const val in Routes.kt (located in :core:design-system). This acts as the unique key for the destination.
object Routes {
const val MAIN = "main"
const val SETTINGS = "settings"
const val SETTINGS_DEFAULT_CURRENCY = "settings_default_currency"
}
-
Feature Module: Create a navigation extension function (e.g.,
SettingsNavigation.kt). -
Graph Construction: Add the composable to the graph. For features with multiple screens, we typically wrap them in a
navigationblock (Nested Graph).
fun NavGraphBuilder.settingsGraph() {
// Nested navigation graph for the Settings feature
navigation(startDestination = Routes.SETTINGS_MAIN, route = Routes.SETTINGS) {
composable(Routes.SETTINGS_MAIN) {
SettingsFeature()
}
composable(Routes.SETTINGS_DEFAULT_CURRENCY) {
DefaultCurrencyFeature()
}
}
}
In the :features module, open AppNavHost.kt and call the feature graph function inside the main NavHost:
NavHost(navController = navController, ...) {
// ... other graphs
settingsGraph()
}
Note: For top-level bottom navigation tabs (like Groups or Expenses), we use the
NavigationProviderinterface instead of manually calling functions inAppNavHost. This allows the Main Screen to discover tabs dynamically via Koin.
Some features are standalone write-flows extracted into their own modules but navigated to from within an existing tab (not the root AppNavHost). These modules implement TabGraphContributor instead of NavigationProvider.
- The non-tab module defines a
TabGraphContributorimplementation that registers its composables. - The module registers it in Koin:
factory { ContributionsTabGraphContributorImpl() } bind TabGraphContributor::class. - The host tab's
NavigationProviderinjects allTabGraphContributorinstances and callscontributeGraph(builder)inside itsbuildGraph().
| Route | Served by | Host Tab |
|---|---|---|
Routes.ADD_CONTRIBUTION |
:features:contributions |
Balances tab |
Routes.ADD_CASH_WITHDRAWAL |
:features:withdrawals |
Balances tab |
Routes.MANAGE_SUBUNITS |
:features:subunits |
Groups tab |
Routes.CREATE_EDIT_SUBUNIT |
:features:subunits |
Groups tab |
The host tab navigates to these routes via LocalTabNavController.current.navigate(Routes.ADD_CONTRIBUTION) — there is no compile-time dependency between the host tab module and the non-tab module. The routes are defined in :core:design-system/Routes.kt (shared by all modules).