Skip to content

Commit a0fc044

Browse files
committed
Add content descriptions for message reaction items to enhance accessibility
1 parent 67585ae commit a0fc044

File tree

2 files changed

+24
-5
lines changed
  • stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages
  • stream-chat-android-ui-common/src/main/res/values

2 files changed

+24
-5
lines changed

stream-chat-android-compose/src/main/java/io/getstream/chat/android/compose/ui/components/messages/MessageReactions.kt

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@ import androidx.compose.foundation.shape.RoundedCornerShape
2525
import androidx.compose.runtime.Composable
2626
import androidx.compose.ui.Alignment
2727
import androidx.compose.ui.Modifier
28-
import androidx.compose.ui.platform.testTag
28+
import androidx.compose.ui.res.pluralStringResource
29+
import androidx.compose.ui.semantics.contentDescription
30+
import androidx.compose.ui.semantics.semantics
31+
import androidx.compose.ui.semantics.testTag
2932
import androidx.compose.ui.tooling.preview.Preview
3033
import androidx.compose.ui.unit.dp
34+
import io.getstream.chat.android.compose.R
3135
import io.getstream.chat.android.compose.previewdata.PreviewReactionOptionData
3236
import io.getstream.chat.android.compose.state.reactionoptions.ReactionOptionItemState
3337
import io.getstream.chat.android.compose.ui.theme.ChatTheme
@@ -46,19 +50,30 @@ public fun MessageReactions(
4650
itemContent: @Composable RowScope.(ReactionOptionItemState) -> Unit = { option ->
4751
MessageReactionItem(
4852
modifier = Modifier
53+
.semantics {
54+
testTag = "Stream_MessageReaction_${option.type}"
55+
contentDescription = option.type
56+
}
4957
.size(20.dp)
5058
.padding(2.dp)
51-
.align(Alignment.CenterVertically)
52-
.testTag("Stream_MessageReaction_${option.type}"),
59+
.align(Alignment.CenterVertically),
5360
option = option,
5461
)
5562
},
5663
) {
64+
val description = pluralStringResource(
65+
R.plurals.stream_ui_message_list_message_reactions,
66+
options.size,
67+
options.size,
68+
)
5769
Row(
5870
modifier = modifier
71+
.semantics {
72+
testTag = "Stream_MessageReaction"
73+
contentDescription = description
74+
}
5975
.background(shape = RoundedCornerShape(16.dp), color = ChatTheme.colors.barsBackground)
60-
.padding(4.dp)
61-
.testTag("Stream_MessageReaction"),
76+
.padding(4.dp),
6277
verticalAlignment = Alignment.CenterVertically,
6378
) {
6479
options.forEach { option ->

stream-chat-android-ui-common/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@
6565
<string name="stream_ui_message_list_message_attachments">%d attachments</string>
6666
<string name="stream_ui_message_list_message_attachment_image">Image attachment</string>
6767
<string name="stream_ui_message_list_message_attachment_video">Video attachment</string>
68+
<plurals name="stream_ui_message_list_message_reactions">
69+
<item quantity="one">%d message reaction</item>
70+
<item quantity="other">%d message reactions</item>
71+
</plurals>
6872

6973
<!--Moderation Dialog-->
7074
<string name="stream_ui_moderation_dialog_title">Failed to send message</string>

0 commit comments

Comments
 (0)