Refactor & simplify StatusBarProtection code sample to use inset size…#836
Refactor & simplify StatusBarProtection code sample to use inset size…#836
Conversation
Summary of ChangesHello, 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 refactors 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. Changelog
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 refactors the StatusBarProtection code snippet to use modern Compose inset modifiers. The implementation is simplified by replacing a manual Canvas drawing with a Spacer that uses Modifier.windowInsetsTopHeight. This removes the need for manual height calculation, resulting in cleaner and more idiomatic code. I've added one comment regarding a minor visual change and a suggestion to address it while maintaining the code's simplicity.
| Brush.verticalGradient( | ||
| colors = listOf( | ||
| color.copy(alpha = 1f), | ||
| color.copy(alpha = 0.8f), | ||
| Color.Transparent | ||
| ) | ||
| ) |
There was a problem hiding this comment.
This refactoring is a great simplification. However, it causes a slight visual regression. The previous implementation made the gradient 20% taller than the status bar for a smoother fade-out. The new implementation, while simpler, creates a harder edge where the gradient ends.
To restore the smoother fade without adding complexity, you can adjust the gradient's color stops to compress the gradient into the top part of the spacer, leaving the bottom part transparent. This mimics the effect of a taller gradient.
| Brush.verticalGradient( | |
| colors = listOf( | |
| color.copy(alpha = 1f), | |
| color.copy(alpha = 0.8f), | |
| Color.Transparent | |
| ) | |
| ) | |
| Brush.verticalGradient( | |
| 0.0f to color.copy(alpha = 1f), | |
| 0.42f to color.copy(alpha = 0.8f), // 0.5 / 1.2 | |
| 0.83f to Color.Transparent, // 1.0 / 1.2 | |
| 1.0f to Color.Transparent | |
| ) | |
… modifiers