Skip to content

Conversation

@igorescodro
Copy link
Owner

This pull request introduces a major refactor of the navigation system to adopt the new androidx.navigation3 APIs, replacing the previous androidx.navigation implementation. The changes include a new custom NavBackStack controller, updates to navigation graph definitions, and migration of navigation-related UI and logic across features. The update improves navigation state management, composability, and paves the way for modern navigation patterns.

Key changes include:

Navigation Infrastructure Overhaul

  • Introduced a new NavBackStack class to manage navigation state and back stack, replacing reliance on NavHostController and related extensions. This provides direct, type-safe control over navigation flow and top app bar visibility.
  • Updated navigation graph interfaces and providers (NavGraph, NavGraphProvider) to use EntryProviderScope and entryProvider from androidx.navigation3, enabling more declarative and composable navigation graph definitions. [1] [2]

Feature Navigation Graphs Migration

  • Refactored feature navigation graphs (e.g., CategoryNavGraph, PreferenceNavGraph) to use the new entry API and EntryProviderScope, replacing the old composable and dialog APIs. Dialogs and transitions now use the new DialogSceneStrategy and NavDisplay.transitionSpec mechanisms. [1] [2] [3] [4]

Home and Navigation UI Updates

  • Updated the HomeScreen and navigation composables to utilize the new NavBackStack for state, removing previous flows and lifecycle-based state management. The navigation UI now leverages NavDisplay instead of NavHost. [1] [2] [3] [4] [5] [6]

API and Dependency Adjustments

  • Changed navigation-related dependencies to use the new androidx.navigation3 libraries in Gradle build scripts and feature modules. [1] [2]
  • Updated TopLevelDestinations and TopAppBarVisibleDestinations from List to Set for more efficient lookups and to align with new navigation patterns. [1] [2]

Cleanup and Removal

  • Removed obsolete navigation extensions and state flows that are no longer needed with the new navigation architecture.

These changes modernize the navigation architecture, improve maintainability, and set the foundation for further navigation enhancements.

Navigation-related dependencies updates to use the alpha versions for v3
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request represents a major architectural migration from androidx.navigation (v2.9.1) to androidx.navigation3 (v1.0.0-alpha06), modernizing the navigation system with new APIs and patterns. The refactor introduces a custom NavBackStack controller for type-safe navigation state management, replaces NavHost with NavDisplay, and updates all navigation graph definitions to use the new EntryProviderScope and entry APIs.

Key changes:

  • Introduced NavBackStack class to replace NavHostController, providing direct control over navigation state, back stack management, and top app bar visibility
  • Migrated all feature navigation graphs to use entry API with EntryProviderScope, replacing composable and dialog APIs
  • Updated transition definitions from separate EnterTransition/ExitTransition to combined ContentTransform type using togetherWith

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
gradle/libs.versions.toml Updated navigation library versions to navigation3 v1.0.0-alpha06 and adaptive navigation to v1.3.0-alpha01
libraries/designsystem/src/commonMain/kotlin/com/escodro/designsystem/animation/Transitions.kt Changed transition types from EnterTransition/ExitTransition to ContentTransform using togetherWith operator
libraries/appstate/src/commonMain/kotlin/com/escodro/appstate/AlkaaAppState.kt Replaced NavHostController with NavBackStack, removed flow-based state management
libraries/appstate/build.gradle.kts Updated dependency from compose.navigation to compose.navigation.ui
features/navigation-api/src/commonMain/kotlin/com/escodro/navigationapi/provider/NavGraph.kt Changed interface to use EntryProviderScope instead of NavGraphBuilder
features/navigation-api/src/commonMain/kotlin/com/escodro/navigationapi/destination/Destination.kt Changed TopLevelDestinations and TopAppBarVisibleDestinations from List to Set
features/navigation-api/src/commonMain/kotlin/com/escodro/navigationapi/controller/NavBackStack.kt New class implementing custom navigation back stack with top-level stack management and app bar visibility control
features/navigation-api/src/commonMain/kotlin/com/escodro/navigationapi/extension/NavHostControllerExtension.kt Removed obsolete extension functions for NavHostController
features/navigation-api/build.gradle.kts Updated to navigation3 dependencies (navigation.ui and navigation.adaptive)
features/navigation/src/commonMain/kotlin/com/escodro/navigation/provider/NavGraphProvider.kt Changed to use entryProvider and NavEntry from navigation3
features/navigation/src/commonMain/kotlin/com/escodro/navigation/compose/Navigation.kt Replaced NavHost with NavDisplay, updated navigation logic to use NavBackStack methods
features/navigation/build.gradle.kts Updated to use compose.navigation.ui dependency
features/home/src/commonMain/kotlin/com/escodro/home/presentation/HomeScreen.kt Removed lifecycle-based state collection, now directly accesses NavBackStack properties
features/task/src/commonMain/kotlin/com/escodro/task/navigation/TaskNavGraph.kt Migrated to entry API with EntryProviderScope, updated transition specs and dialog strategy
features/search/src/commonMain/kotlin/com/escodro/search/navigation/SearchNavGraph.kt Migrated to entry API with EntryProviderScope
features/preference/src/commonMain/kotlin/com/escodro/preference/navigation/PreferenceNavGraph.kt Migrated to entry API with transition specs using NavDisplay metadata
features/category/src/commonMain/kotlin/com/escodro/category/navigation/CategoryNavGraph.kt Migrated to entry API with DialogSceneStrategy for bottom sheet
Comments suppressed due to low confidence (1)

libraries/designsystem/src/commonMain/kotlin/com/escodro/designsystem/animation/Transitions.kt:39

  • The variable is named SlideOutHorizontallyTransition (suggesting exit/slide-out behavior), but the documentation states it "slides from the right to the left" which describes enter behavior. With the new ContentTransform type that combines both enter and exit transitions, the name and documentation are now misleading. Consider renaming to something like HorizontalContentTransition or updating the documentation to clarify that this ContentTransform uses EnterTransition.None with a slide-out animation.
/**
 * Transition used to slide out horizontally the content. The content will slide from the right to
 * the left and fade out.
 */
val SlideOutHorizontallyTransition: ContentTransform =
    EnterTransition.None togetherWith fadeOut() + slideOutHorizontally(
        targetOffsetX = { it },
        animationSpec = tween(
            durationMillis = 300,
            easing = LinearEasing,
        ),
    )

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

The code was updated to use the new APIs while keeping the existing
event-based navigation structure
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants