Skip to content

Fix swipe-to-reply in RTL layouts#6312

Open
VelikovPetar wants to merge 2 commits intov7from
bug/fix_swipe_to_reply_rtl
Open

Fix swipe-to-reply in RTL layouts#6312
VelikovPetar wants to merge 2 commits intov7from
bug/fix_swipe_to_reply_rtl

Conversation

@VelikovPetar
Copy link
Copy Markdown
Contributor

@VelikovPetar VelikovPetar commented Mar 30, 2026

Goal

The swipe-to-reply gesture in the message list did not work correctly in RTL layouts — the swipe direction was not reversed, the reply icon appeared from the wrong side, and the icon arrow was not mirrored.

Implementation

  • SwipeToReply (MessageContainer.kt): Use absoluteOffset instead of offset so pixel offsets are not double-reversed by the layout-direction-aware Modifier.offset. Detect RTL via LocalLayoutDirection and reverse the drag bounds (negative offset) and icon slide-in direction accordingly. The icon Row uses Alignment.CenterStart unconditionally since it is already layout-direction aware.
  • stream_compose_ic_reply.xml: Add android:autoMirrored="true" so the reply arrow icon mirrors automatically in RTL.

UI Changes

Demo
str_rtl.mp4

Testing

  • Force RTL in Developer Options
  • Open a conversation and swipe a message from right to left
  • Verify the reply icon appears from the right edge with a mirrored arrow
  • Verify the reply action triggers correctly
  • Switch back to LTR and confirm the original behavior is unchanged

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed swipe-to-reply gesture direction for right-to-left language layouts.
    • Fixed reply icon orientation to automatically adjust in right-to-left contexts.

Co-Authored-By: Claude <noreply@anthropic.com>
@VelikovPetar VelikovPetar added the pr:bug Bug fix label Mar 30, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 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.

🎉 Great job! This PR is ready for review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 30, 2026

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.25 MB 5.68 MB 0.43 MB 🟡
stream-chat-android-ui-components 10.60 MB 10.99 MB 0.39 MB 🟡
stream-chat-android-compose 12.81 MB 12.11 MB -0.70 MB 🚀

@VelikovPetar VelikovPetar marked this pull request as ready for review March 30, 2026 13:06
@VelikovPetar VelikovPetar requested a review from a team as a code owner March 30, 2026 13:06
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 30, 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: bb97635a-4503-4137-b8a2-fe79f60392f2

📥 Commits

Reviewing files that changed from the base of the PR and between 0a6ceb0 and 0f94e18.

📒 Files selected for processing (2)
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt
  • stream-chat-android-compose/src/main/res/drawable/stream_compose_ic_reply.xml

Walkthrough

SwipeToReply functionality enhanced with RTL layout support by switching to absoluteOffset, introducing layout direction detection, and adjusting offset clamping logic based on text direction. Reply icon drawable updated to support automatic mirroring in RTL contexts.

Changes

Cohort / File(s) Summary
SwipeToReply RTL Support
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageContainer.kt
Implements direction-aware swipe-to-reply positioning using absoluteOffset and LocalLayoutDirection. Introduces conditional offset clamping with inverted ranges for RTL ([-maxSwipe, 0] vs [0, maxSwipe] in LTR) and uses absoluteValue for direction-agnostic reply trigger confirmation.
Reply Icon Mirroring
stream-chat-android-compose/src/main/res/drawable/stream_compose_ic_reply.xml
Adds android:autoMirrored="true" attribute to enable automatic horizontal mirroring of the reply icon in RTL layout contexts.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Swipes dance left and swipes dance right,
RTL mirroring shines so bright,
A rabbit's reply now finds its sight! ✨
—The Code Rabbit

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: fixing swipe-to-reply functionality for RTL (right-to-left) layouts, which aligns perfectly with the code changes and objectives.
Description check ✅ Passed The PR description covers the key required template sections: Goal explains the problem, Implementation details the technical approach for both files, UI Changes includes a demo video, and Testing provides comprehensive verification steps.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ 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 bug/fix_swipe_to_reply_rtl

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.

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
36.4% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

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

Labels

pr:bug Bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants