feat: updates @DevicePreviews to use the Devices object constants#2038
feat: updates @DevicePreviews to use the Devices object constants#2038
@DevicePreviews to use the Devices object constants#2038Conversation
Summary of ChangesHello @telpirion, 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 significantly improves the preview capabilities within the application by updating the Highlights
🧠 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 AssistThe 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
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 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request significantly improves the Jetpack Compose previews by updating @DevicePreviews to use standard Devices constants and adding new previews for NiaApp and ForYouScreen. The changes make the previews more robust and easier to maintain. I've also included a suggestion to refactor the preview setup in ForYouEntryProvider.kt to improve code clarity and reduce verbosity.
...n/com/google/samples/apps/nowinandroid/feature/foryou/impl/navigation/ForYouEntryProvider.kt
Show resolved
Hide resolved
dturner
left a comment
There was a problem hiding this comment.
Thanks for the PR. Made a few suggestions and have a few questions.
| ), | ||
| ) | ||
| }, | ||
| // Fix for render issue: Scaffold crashes with "List is empty" when contentWindowInsets is set |
There was a problem hiding this comment.
Please add a link to the issue so we can remove this workaround when it's fixed.
There was a problem hiding this comment.
The news cards are an important part of the screenshots because they improve test fidelity - is there a reason why they've been removed from all the screenshots?
There was a problem hiding this comment.
That change wasn't intentional, I assure you. Perhaps one of the GitHub bots made this change? I'll look into it.
There was a problem hiding this comment.
No worries. There is a step in the build workflow that generates new screenshots based on the changes in your PR. This is so that you, the PR owner, can visually verify that the changes you've made have the desired effect, or allows you to spot when you've changed something that inadvertently changes the UI.
In this case, it sounds like the latter so you need to fix the news resources being displayed. The current screenshots will be removed from the PR after you push the code changes and the build workflow completes.
| } | ||
| } | ||
|
|
||
| androidComponents.beforeVariants { |
There was a problem hiding this comment.
Why has this been removed? Usually if it's not directly related to the PR it should go in a separate PR.
There was a problem hiding this comment.
This change was made by Gemini. I believe it was done to address a build error. I'll see if I can revert this without breaking the PR.
There was a problem hiding this comment.
This change has already been made on main in #2051. You can revert the changes made to this file and rebase.
| ForYouScreen( | ||
| onTopicClick = navigator::navigateToTopic, | ||
| ) | ||
| if (LocalInspectionMode.current) { |
There was a problem hiding this comment.
This pollutes the production code with code that is only used for previews. Are there any alternatives to doing this? Maybe have a different entryProvider that is used for previews instead?
| androidx-navigation-testing = { group = "androidx.navigation", name = "navigation-testing", version.ref = "androidxNavigation" } | ||
| androidx-navigation3-runtime = { group = "androidx.navigation3", name = "navigation3-runtime", version.ref = "androidxNavigation3" } | ||
| androidx-navigation3-ui = { group = "androidx.navigation3", name = "navigation3-ui", version.ref = "androidxNavigation3" } | ||
| androidx-navigationevent-compose = { group = "androidx.navigationevent", name = "navigationevent-compose", version = "1.0.1" } |
There was a problem hiding this comment.
Please follow the convention for all other dependencies by moving the version number into a variable at the top of the file.
| ForYouScreen( | ||
| isSyncing = true, | ||
| onboardingUiState = OnboardingUiState.Shown( | ||
| topics = emptyList(), |
There was a problem hiding this comment.
If there is a justification for adding this preview, using topics = emptyList() here means this is not a realistic preview of the ForYouScreen when the onboarding UI is shown. There's code from the other previews that can be copied here to load the topics.
There was a problem hiding this comment.
As mentioned previously, it's realistic in the sense that it's a state I encountered. Specifically when running on a tablet.
There was a problem hiding this comment.
You encountered a state where the onboarding was shown but there were no topics in it? If so, that's a bug, and we shouldn't provide previews for buggy states.
The correct state to preview should be that the onboarding has topics in it.
What I have done and why
@Previewannotations; I added a preview.@DevicePreviewsannotation didn't show different form factors; they were always portrait. I changed the annotation so that it uses the constants from theDevicesobject.