Skip to main content

Overview

Divvy uses Jetpack Compose Navigation with Kotlin serialization for type-safe navigation. This approach eliminates string-based routes and provides compile-time safety for navigation arguments. All app destinations are defined as a sealed interface with serializable data classes:
app/src/main/java/com/example/divvy/ui/navigation/AppDestination.kt
Type Safety: Using @Serializable data classes ensures navigation arguments are type-safe and validated at compile time.

Main Tabs

  • Home - Activity feed and quick actions
  • Groups - Manage expense groups
  • Friends - Friend connections
  • Profile - User account settings

Feature Flows

  • GroupDetail - View group expenses and members
  • ScanReceipt - Camera-based receipt scanning
  • SplitExpense - Choose split method
  • AssignItems - Item-level expense assignment
  • SplitByPercentage - Percentage-based splits

Secondary Screens

  • Ledger - All balances and settlements
  • Analytics - Spending insights
The AppNavHost defines the navigation graph with all composable destinations:
app/src/main/java/com/example/divvy/ui/navigation/AppNavHost.kt

Passing Arguments

Navigation arguments are passed as constructor parameters:

Retrieving Arguments

Arguments are retrieved using toRoute() extension function:

ViewModel Factory with Arguments

For ViewModels that need navigation arguments, use Hilt’s assisted injection:
app/src/main/java/com/example/divvy/ui/navigation/AppNavHost.kt
The ViewModel factory pattern allows Hilt to inject dependencies while accepting navigation arguments.

Bottom Navigation

The bottom navigation bar provides quick access to main tabs:
app/src/main/java/com/example/divvy/ui/navigation/BottomNavigationBar.kt
Preserves the state when navigating away from a tab

Deep Linking

Divvy supports deep linking for group invitations through Supabase Auth:

Auth Redirect Configuration

app/src/main/java/com/example/divvy/di/NetworkModule.kt

Redirect URL Pattern

This URL must be configured in Supabase Auth settings to enable:
  • Google OAuth sign-in redirects
  • Group invitation deep links
  • Password reset flows
Ensure the redirect URL is added to your Supabase project’s Auth settings under “Redirect URLs”.

AndroidManifest Configuration

Creating an Expense

Group Management

Back Stack Management

Pop to Destination

Pop Current Screen

Clear Back Stack

Testing Navigation

Best Practices

1

Use Type-Safe Routes

Always use AppDestination sealed interface instead of string routes
2

Validate Arguments

Use non-nullable types for required arguments, nullable types for optional ones
3

Handle Back Navigation

Always provide onBack callbacks in screen composables
4

Save Tab State

Use saveState and restoreState for bottom navigation tabs
5

Avoid Deep Stacks

Pop back to main screens after completing flows (like expense creation)
Don’t pass complex objects through navigation. Use IDs and fetch data in ViewModels using repositories.

Common Patterns

Conditional Navigation

Multi-Step Flows

Next Steps

MVVM Pattern

Learn how navigation integrates with ViewModels

Architecture Overview

Return to architecture overview