Skip to content

Migrate Jetnews to Navigation 3#1675

Open
bsagmoe wants to merge 4 commits intomainfrom
bsagmoe/jetnews-nav3
Open

Migrate Jetnews to Navigation 3#1675
bsagmoe wants to merge 4 commits intomainfrom
bsagmoe/jetnews-nav3

Conversation

@bsagmoe
Copy link
Contributor

@bsagmoe bsagmoe commented Mar 20, 2026

Key Changes

  • Created NavKey objects and classes to replace the JetnewsDestinations object.
  • Refactored the home route to only be responsible for displaying the list of posts and moved the post detail UI and logic into its own route.
  • Implemented a ListDetailSceneStrategy to display the post detail view alongside the list of posts if the window width size class is at least expanded.
  • Added NavigationState and Navigator classes and helpers for storing and updating the app's navigation state.
  • Replaced JetnewsNavGraph with JetnewsNavDisplay.
  • Removed Navigation 2 dependencies
  • Implemented support for deeplinks for the home page, post detail page, and interest page.
  • Improved the app_opensArticle (now app_opensPost) test so that it now actually tests that the post content is displayed.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request represents a significant architectural overhaul, migrating the Jetnews application to the experimental Navigation 3 library. This transition fundamentally redefines how the application handles screen transitions, back stacks, and deep linking, moving towards a more robust and type-safe navigation paradigm. The changes also enhance the app's adaptability across various screen sizes, particularly for list-detail patterns, and introduce a more structured approach to managing individual screen states.

Highlights

  • Core Navigation 3 Migration: The application's navigation system has been entirely refactored to utilize the experimental Navigation 3 library, replacing the previous Compose Navigation setup. This introduces a new architecture for managing navigation state and UI.
  • Deep Linking Implementation: A custom deep linking solution has been integrated, leveraging Kotlin Serialization to parse incoming URIs directly into NavKey objects. This enables direct and type-safe navigation to specific content within the app.
  • Adaptive UI Handling: The application now dynamically adapts its UI based on WindowSizeClass, particularly enhancing the display of list-detail views on expanded screens for a more responsive user experience.
  • Modularized Navigation Components: New NavKey objects and entry providers have been introduced for different screens (Home, Interests, Post), promoting a more modular, type-safe, and maintainable navigation graph.
  • Post-Specific ViewModel: A dedicated PostViewModel and PostRoute have been created to manage the state and interactions for individual article screens, including scroll position persistence and favorite status, decoupling it from the main Home ViewModel.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request successfully migrates the Jetnews app to Navigation 3, which is a significant and well-executed undertaking. The changes introduce a type-safe navigation system using NavKey, a custom deep link handling mechanism, and a responsive list-detail layout for large screens using a custom SceneStrategy. The refactoring greatly simplifies the ViewModels by offloading navigation state management to the navigation library. The overall architecture is much cleaner and more robust. I have a few minor suggestions for improvement, mainly related to code style and removing debug logs.

@bsagmoe bsagmoe force-pushed the bsagmoe/jetnews-nav3 branch from 524c611 to d905525 Compare March 23, 2026 16:02
@bsagmoe bsagmoe force-pushed the bsagmoe/jetnews-nav3 branch from d905525 to e8d5f4f Compare March 23, 2026 16:05
@android android deleted a comment from gemini-code-assist bot Mar 23, 2026
@android android deleted a comment from gemini-code-assist bot Mar 23, 2026

println(composeTestRule.onRoot().printToString())
try {
composeTestRule.onAllNodes(hasText("3 min read", substring = true))[0].assertExists()
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This text also shows up in the list screen, so the test didn't actually test that the article screen was opened to the correct article.

Comment on lines +230 to +247
/**
* Top bar for a Post when displayed next to the Home feed
*/
@Composable
private fun PostTopBar(isFavorite: Boolean, onToggleFavorite: () -> Unit, onSharePost: () -> Unit, modifier: Modifier = Modifier) {
Surface(
shape = RoundedCornerShape(8.dp),
border = BorderStroke(Dp.Hairline, MaterialTheme.colorScheme.onSurface.copy(alpha = .6f)),
modifier = modifier.padding(end = 16.dp),
) {
Row(Modifier.padding(horizontal = 8.dp)) {
FavoriteButton(onClick = { /* Functionality not available */ })
BookmarkButton(isBookmarked = isFavorite, onClick = onToggleFavorite)
ShareButton(onClick = onSharePost)
TextSettingsButton(onClick = { /* Functionality not available */ })
}
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved here from HomeScreens.kt

@bsagmoe bsagmoe requested a review from dturner March 23, 2026 20:16
@bsagmoe bsagmoe marked this pull request as ready for review March 23, 2026 20:18
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.

1 participant