Skip to content

Remove redundant hardcoded sizes on Compose design icons#6478

Open
andremion wants to merge 6 commits into
developfrom
refactor/remove-redundant-icon-sizes
Open

Remove redundant hardcoded sizes on Compose design icons#6478
andremion wants to merge 6 commits into
developfrom
refactor/remove-redundant-icon-sizes

Conversation

@andremion
Copy link
Copy Markdown
Contributor

@andremion andremion commented May 27, 2026

Closes AND-1197

Goal

Integrators that swap a stream_design_ic_* drawable to change an icon's size find the override has no effect: the rendered size is locked by a hardcoded Modifier.size(...) on the Icon / Image that overrides the painter's intrinsic. This pass removes the size modifier wherever the hardcoded value already matches the drawable's intrinsic, so swapping the drawable actually drives the rendered size.

Implementation

All affected painters are 20dp intrinsic stream_design_ic_* drawables, so the .size(20.dp) was always a no-op visually. Icon / Image already fall back to the painter's intrinsic size when no size modifier is set (defaultSizeFor(painter)), so removing the modifier preserves today's rendering and unblocks drawable overrides.

Out of scope: every .size(X.dp) where X differs from the intrinsic (downscales like inline 16dp icons, upscales like 32dp empty-state icons). Those preserve a deliberate visual size and stay as-is. SearchInput's IconButton.size(20.dp) is also left alone — it sizes the touch target, not the icon, which is a separate concern.

Split into five area-scoped commits to keep review focused:

  • Leaf iconsComposerCancelIcon, AudioRecordAttachmentContent playback toggle, UnsupportedAttachmentContent, VideoPlaybackControls play/pause, AddMembersScreen back arrow.
  • PollPollAnswers add-answer button, PollOptionList remove + error icons, PollSwitchList stepper button.
  • Media galleryMediaGalleryPreviewScreen share + photos icons, MediaGalleryPreviewOptionsMenu option-row icon (one wrapper fix covers all four options).
  • ContextualMenuItem wrapper — covers every caller routed through MessageActionsOptionsItem.
  • MessageFailedIcon callersMessageContainer (both call sites) and PollMessageContent.

./gradlew spotlessApply detekt — clean. ./gradlew apiDump produces no .api diff (only modifier removals).

Testing

testCoverage passes — existing Paparazzi snapshots cover every change except VideoPlaybackControls play/pause (no test exercises a video preview).

Manual verification for VideoPlaybackControls:

  1. Run the Compose sample.
  2. Send a video attachment in any channel and tap it to open the media gallery.
  3. Confirm the play/pause toggle in the playback controls renders unchanged.

Summary by CodeRabbit

  • Style

    • Updated icon sizing approach across message attachments, media gallery previews, composer components, and message containers. Icons now render with adjusted sizing behavior for improved visual consistency.
  • Refactor

    • Removed unnecessary layout modifiers and cleaned up unused imports throughout compose UI components.

Review Change Stack

andremion added 5 commits May 27, 2026 16:55
Removes Modifier.size(20.dp) from Icon call sites that paint a 20dp
intrinsic stream_design_ic_* drawable. The size is redundant because
Icon falls back to the painter's intrinsic size when no size modifier
is applied, and removing it lets integrators override the drawable
file to drive the rendered size.

Touched: ComposerCancelIcon, AudioRecordAttachmentContent
PlaybackToggleButton, UnsupportedAttachmentContent, VideoPlaybackControls
play/pause toggle, AddMembersScreen back arrow.
Removes Modifier.size(20.dp) from poll-feature icons painted with 20dp
intrinsic drawables: PollAnswers add-answer button, PollOptionList
remove and error icons, PollSwitchList StepperButton minus/plus icons.
Removes Modifier.size(20.dp) from the share/cancel-share and photos
icons in MediaGalleryPreviewScreen, and from the option-row icon in
MediaGalleryPreviewOptionsMenu. Every painter consumed by these call
sites is a 20dp intrinsic stream_design_ic_* drawable, so the size
modifier was redundant.
Removes Modifier.size(20.dp) from both leadingIcon and trailingIcon
Icons in ContextualMenuItem. Every caller (message action options,
the in-file MenuItem preview) passes a 20dp intrinsic
stream_design_ic_* drawable, so the hardcoded size was redundant and
blocked integrator drawable overrides from propagating.
The MessageFailedIcon factory paints a 20dp intrinsic
stream_design_ic_exclamation_circle_fill, so the .size(20.dp) injected
into MessageFailedIconParams.modifier by callers was redundant.
Removes it from the two MessageContainer call sites and the
PollMessageContent call site.
@andremion andremion requested a review from a team as a code owner May 27, 2026 16:17
@andremion andremion added the pr:improvement Improvement label May 27, 2026
@andremion
Copy link
Copy Markdown
Contributor Author

@CodeRabbit review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled, or the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@andremion andremion enabled auto-merge (squash) May 27, 2026 16:17
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: db47ffec-f9be-4776-ace2-79c7ec42d166

📥 Commits

Reviewing files that changed from the base of the PR and between 65116bc and 5db9a0f.

📒 Files selected for processing (13)
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/AudioRecordAttachmentContent.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/UnsupportedAttachmentContent.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewOptionsMenu.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewScreen.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/internal/VideoPlaybackControls.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/AddMembersScreen.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/ComposerCancelIcon.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/common/ContextualMenu.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/PollMessageContent.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollAnswers.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/poll/PollOptionList.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/poll/PollSwitchList.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt
💤 Files with no reviewable changes (13)
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/AddMembersScreen.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/internal/VideoPlaybackControls.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/AudioRecordAttachmentContent.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/ComposerCancelIcon.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/poll/PollOptionList.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/UnsupportedAttachmentContent.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewScreen.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/common/ContextualMenu.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/poll/PollSwitchList.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewOptionsMenu.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/PollMessageContent.kt
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollAnswers.kt

Walkthrough

This PR removes explicit Modifier.size(20.dp) from Icon composables across attachment content, media preview, UI components, and poll-related files. Most icons revert to Compose Material3 defaults. Message error icons transition to token-based padding sizing. Unused size and dp imports are cleaned up throughout.

Changes

Icon Sizing Standardization

Layer / File(s) Summary
Attachment and media preview icons
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/content/AudioRecordAttachmentContent.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewOptionsMenu.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/MediaGalleryPreviewScreen.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/attachments/preview/internal/VideoPlaybackControls.kt
PlaybackToggleButton, MediaGalleryOptionItem, MediaGalleryPreviewShareIcon, MediaGalleryPreviewPhotosIcon, and VideoPlaybackControls icons remove explicit Modifier.size(20.dp). Associated imports for size and dp utilities are removed from related files.
Core UI component icons
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/channel/info/AddMembersScreen.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/ComposerCancelIcon.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/common/ContextualMenu.kt
AddMembersHeader back-arrow, ComposerCancelIcon, and ContextualMenuItem leading/trailing icons remove explicit size modifiers. ContextualMenu replaces size-based approach with width-based modifier strategy; import changes reflect this shift.
Poll UI icons
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/PollMessageContent.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollAnswers.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/poll/PollOptionList.kt, stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/attachments/poll/PollSwitchList.kt
PollMessageContent, PollAnswersDialog edit icon, PollOptionRow minus icon, PollOptionErrorRow exclamation icon, and StepperButton icons remove explicit size modifiers. Size and dp imports are cleaned up from poll files.
Message error icons with token-based sizing
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt
MessageFailedIcon in EmojiMessageContent and RegularMessageContent shifts from hardcoded Modifier.size(20.dp) to token-based vertical padding. RegularMessageContent variant adds testTag("Stream_MessageFailedIcon") for test identification.

🐰 Icons shrink not in size but in code,
Token padding lights the way forward,
Compose defaults shine through the grey,
Cleaner imports, simpler display,
UI harmony hops along!

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • gpunto
  • VelikovPetar
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: removing redundant hardcoded icon sizes from Compose design icons across the codebase.
Description check ✅ Passed The description provides comprehensive Goal, Implementation, and Testing sections that align with the template structure. It clearly explains the rationale, implementation approach, scope of changes, and testing verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-redundant-icon-sizes

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.83 MB 5.83 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.07 MB 11.07 MB 0.00 MB 🟢
stream-chat-android-compose 12.46 MB 12.46 MB 0.00 MB 🟢

@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:improvement Improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant