-
Notifications
You must be signed in to change notification settings - Fork 0
MainScreen as an Orchestrator
Andrés Pedraza Míguez edited this page Dec 6, 2025
·
2 revisions
The MainScreen is the most complex UI component in the app. Unlike standard features, it acts as a container and orchestrator for the top-level navigation.
-
Bottom Navigation Management: It holds the
BottomNavigationBarand manages switching between tabs (Groups, Expenses, Balances, Profile). - Multi-Stack State: It preserves the navigation state (back stack) of each tab when switching.
-
Dynamic UI Construction: It observes the current inner route to decide which
ScreenUiProvider(TopBar/FAB) to display.
We use FeatureScaffold for "leaf" screens (simple screens with one job). MainScreen cannot use it because:
- It has a persistent lifecycle (it's not destroyed when changing tabs).
- It needs to calculate logic based on "Which tab is active?" vs "Which screen is active inside the tab?".
- It manages multiple
NavHostControllerinstances (one per tab) to keep stacks independent.
MainScreen acts as the "Host" that swaps content dynamically while keeping the Scaffold (TopBar/BottomBar/FAB) persistent, providing a smooth user experience.