Update design of poll options and comments screens#6246
Conversation
PR checklist ✅All required conditions are satisfied:
🎉 Great job! This PR is ready for review. |
SDK Size Comparison 📏
|
e8b2099 to
32e699c
Compare
|
WalkthroughThis pull request refactors poll UI composables by removing the Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
📝 Coding Plan
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. Comment Tip CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollDialogHeader.kt (1)
37-64: Add KDoc for the newtrailingContentparameter.The public function now has a new parameter that should be documented for API consumers.
📝 Proposed KDoc addition
+/** + * A header for poll dialogs with a back button and title. + * + * `@param` title The title text to display. + * `@param` onBackPressed Handler invoked when the back button is pressed. + * `@param` trailingContent Optional composable content rendered at the end of the header row. + */ `@Composable` public fun PollDialogHeader( title: String, onBackPressed: () -> Unit, trailingContent: `@Composable` () -> Unit = {}, ) {As per coding guidelines: "Document public APIs with KDoc, including thread expectations and state notes."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollDialogHeader.kt` around lines 37 - 64, Add KDoc to the public PollDialogHeader composable to document the new trailingContent parameter: describe that trailingContent is a slot for optional composable content shown at the end of the header, note any threading expectations (called from Compose UI/main thread) and state considerations (avoid holding long-lived state here; prefer hoisted state passed in), and briefly document other params (title, onBackPressed) if missing; reference the PollDialogHeader function and the trailingContent parameter so API consumers can find it.stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollMoreOptionsDialog.kt (1)
247-335: Consider extracting the progress bar and avatar row into a separate composable to reduce cognitive complexity.SonarCloud flags cognitive complexity of 18 (allowed: 15). While the current implementation is readable, extracting the row content (lines 286-311) into a helper composable like
PollOptionInfoRowcould improve maintainability.♻️ Proposed extraction
`@Composable` private fun PollOptionInfoRow( option: Option, users: List<User>, voteCount: Int, showAvatars: Boolean, ) { Row(Modifier.heightIn(min = AvatarSize.ExtraSmall)) { Text( modifier = Modifier.weight(1f), text = option.text, style = ChatTheme.typography.captionDefault, color = ChatTheme.colors.chatTextIncoming, maxLines = 2, overflow = TextOverflow.Ellipsis, ) if (users.isNotEmpty() && showAvatars) { UserAvatarStack( overlap = StreamTokens.spacingXs, users = users.take(MaxStackedAvatars), avatarSize = AvatarSize.ExtraSmall, modifier = Modifier.padding(start = StreamTokens.spacingXs, end = StreamTokens.spacing2xs), ) } Text( modifier = Modifier.align(Alignment.CenterVertically), text = voteCount.toString(), style = ChatTheme.typography.metadataDefault, color = ChatTheme.colors.chatTextIncoming, ) } }Then use it in
PollMoreOptionItem:PollOptionInfoRow( option = option, users = users, voteCount = voteCount, showAvatars = poll.votingVisibility != VotingVisibility.ANONYMOUS, )🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollMoreOptionsDialog.kt` around lines 247 - 335, Extract the inner Row (the option text, optional avatar stack, and vote count) from PollMoreOptionItem into a new `@Composable` named PollOptionInfoRow(option: Option, users: List<User>, voteCount: Int, showAvatars: Boolean) and replace the original Row invocation with PollOptionInfoRow(...), passing showAvatars = poll.votingVisibility != VotingVisibility.ANONYMOUS and users.take(MaxStackedAvatars) behavior preserved inside the new composable; leave the animateFloatAsState progress calculation and the LinearProgressIndicator in PollMoreOptionItem unchanged, and ensure the new PollOptionInfoRow uses the same typography/colors and alignment as the extracted code (Text, UserAvatarStack, and trailing vote count) so behavior and visuals remain identical.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@stream-chat-android-compose/api/stream-chat-android-compose.api`:
- Line 1908: Add a changelog entry documenting the PollDialogHeader signature
change: note that PollDialogHeader now accepts an additional public slot
parameter (update the function signature shown), mark it under the v7 breaking
changes section, briefly describe the impact for SDK consumers and provide the
updated function signature so callers can migrate; reference the
PollDialogHeader composable name in the entry so it’s discoverable.
---
Nitpick comments:
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollDialogHeader.kt`:
- Around line 37-64: Add KDoc to the public PollDialogHeader composable to
document the new trailingContent parameter: describe that trailingContent is a
slot for optional composable content shown at the end of the header, note any
threading expectations (called from Compose UI/main thread) and state
considerations (avoid holding long-lived state here; prefer hoisted state passed
in), and briefly document other params (title, onBackPressed) if missing;
reference the PollDialogHeader function and the trailingContent parameter so API
consumers can find it.
In
`@stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollMoreOptionsDialog.kt`:
- Around line 247-335: Extract the inner Row (the option text, optional avatar
stack, and vote count) from PollMoreOptionItem into a new `@Composable` named
PollOptionInfoRow(option: Option, users: List<User>, voteCount: Int,
showAvatars: Boolean) and replace the original Row invocation with
PollOptionInfoRow(...), passing showAvatars = poll.votingVisibility !=
VotingVisibility.ANONYMOUS and users.take(MaxStackedAvatars) behavior preserved
inside the new composable; leave the animateFloatAsState progress calculation
and the LinearProgressIndicator in PollMoreOptionItem unchanged, and ensure the
new PollOptionInfoRow uses the same typography/colors and alignment as the
extracted code (Text, UserAvatarStack, and trailing vote count) so behavior and
visuals remain identical.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: d73c485b-de5e-4591-9c9f-c4d4c284b9eb
⛔ Files ignored due to path filters (13)
stream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.messages_MessageFooterTest_thread_start_with_footer.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.messages_MessageFooterTest_thread_start_with_no_replies.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.messages_MessageFooterTest_thread_start_with_replies.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.messages_PollMessageContentTest_poll_content.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.poll_PollMoreOptionsDialogTest_dark_mode.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.components.poll_PollMoreOptionsDialogTest_light_mode.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages.list_TypingIndicatorContentTest_multiple_users_typing.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages_MessageListTest_loaded_messages.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.messages_MessageListTest_loaded_messages_in_dark_mode.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.threads_ThreadItemTest_threadItem.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.threads_ThreadListTest_loaded_threads.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.threads_ThreadListTest_loaded_threads_with_unread_banner.pngis excluded by!**/*.pngstream-chat-android-compose/src/test/snapshots/images/io.getstream.chat.android.compose.ui.threads_ThreadListTest_loading_more_threads.pngis excluded by!**/*.png
📒 Files selected for processing (12)
stream-chat-android-compose/api/stream-chat-android-compose.apistream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/avatar/AvatarStack.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageThreadFooter.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/PollMessageContent.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollAnswers.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollDialogHeader.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollMoreOptionsDialog.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/poll/PollViewResultDialog.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.ktstream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/threads/ThreadItem.ktstream-chat-android-compose/src/main/res/values/strings.xmlstream-chat-android-ui-common/src/main/kotlin/io/getstream/chat/android/ui/common/utils/PollsConstants.kt
💤 Files with no reviewable changes (3)
- stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/messages/list/MessageItem.kt
- stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageThreadFooter.kt
- stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/threads/ThreadItem.kt


Goal
Update design of poll options and comments screens
Implementation
showBorderfromAvatarStack-> checked with Jurgen that this is not something we use by default🎨 UI Changes
Add relevant screenshots
Testing
You can check the options screen in polls that have more than 5 options & the comments screen in polls that have comments enabled.
Summary by CodeRabbit
Release Notes
New Features
Improvements