Skip to content

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.

Responsibilities

  1. Bottom Navigation Management: It holds the BottomNavigationBar and manages switching between tabs (Groups, Expenses, Balances, Profile).
  2. Multi-Stack State: It preserves the navigation state (back stack) of each tab when switching.
  3. Dynamic UI Construction: It observes the current inner route to decide which ScreenUiProvider (TopBar/FAB) to display.

Why not use FeatureScaffold?

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 NavHostController instances (one per tab) to keep stacks independent.

Architecture

MainScreen acts as the "Host" that swaps content dynamically while keeping the Scaffold (TopBar/BottomBar/FAB) persistent, providing a smooth user experience.

Clone this wiki locally