Add UriImage component for displaying images from URIs#3563
Add UriImage component for displaying images from URIs#3563andreia-ferreira merged 1 commit intomasterfrom
Conversation
- Implement `UriImage` using Coil's `AsyncImage` with support for placeholders, error states, and crossfade transitions. - Optimize image loading by calculating target dimensions based on available constraints or display metrics, capped at 2048px to prevent memory issues. - Add `UriImageTest` to verify image loading behavior, including null URI handling, dimension scaling, and constraint coercion.
Summary of ChangesHello @shobhitagarwal1612, 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 introduces a dedicated 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
Activity
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 introduces a new UriImage composable for displaying images from a URI, along with corresponding tests. The implementation is sound, using Coil for image loading and optimizing for memory by resizing images. My review includes a few suggestions to improve maintainability and reusability, such as removing redundant code and making the component more flexible for accessibility purposes. I've also noted a minor issue with the copyright year in the new files, which violates the repository's style guide.
| ImageRequest.Builder(context) | ||
| .data(uri) | ||
| .size(width = targetW, height = targetH) | ||
| .scale(Scale.FIT) | ||
| .placeholder(R.drawable.ic_photo_grey_600_24dp) | ||
| .error(R.drawable.outline_error_outline_24) | ||
| .crossfade(true) | ||
| .build(), |
There was a problem hiding this comment.
The .scale(Scale.FIT) on line 60 is redundant because AsyncImage's contentScale = ContentScale.Fit (line 66) will automatically set the equivalent scale on the image request. Removing this line simplifies the code and avoids duplication.
ImageRequest.Builder(context)
.data(uri)
.size(width = targetW, height = targetH)
.placeholder(R.drawable.ic_photo_grey_600_24dp)
.error(R.drawable.outline_error_outline_24)
.crossfade(true)
.build(),| .error(R.drawable.outline_error_outline_24) | ||
| .crossfade(true) | ||
| .build(), | ||
| contentDescription = stringResource(id = R.string.photo_preview), |
There was a problem hiding this comment.
The content description is currently hardcoded. This limits the component's reusability and can be problematic for accessibility in different contexts. It would be better to pass the content description as a parameter to the UriImage composable, perhaps with the current string resource used as a default.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3563 +/- ##
============================================
+ Coverage 70.54% 70.60% +0.05%
Complexity 1622 1622
============================================
Files 328 329 +1
Lines 8912 8936 +24
Branches 989 992 +3
============================================
+ Hits 6287 6309 +22
- Misses 2032 2033 +1
- Partials 593 594 +1
🚀 New features to boost your workflow:
|
Towards #3545
UriImageusing Coil'sAsyncImageSplit from #3548
@andreia-ferreira PTAL?