[a11y] Use built-in onClickLabel parameter.
This commit is contained in:
parent
635711ebef
commit
ef8d57dff8
6 changed files with 28 additions and 60 deletions
|
|
@ -39,7 +39,6 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.onClick
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.semantics.traversalIndex
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
|
|
@ -454,19 +453,11 @@ private fun EmojiButton(
|
|||
.size(48.dp)
|
||||
.background(backgroundColor, CircleShape)
|
||||
.clickable(
|
||||
enabled = true,
|
||||
onClickLabel = a11yClickLabel,
|
||||
onClick = { onClick(emoji) },
|
||||
indication = ripple(bounded = false, radius = emojiRippleRadius),
|
||||
interactionSource = remember { MutableInteractionSource() }
|
||||
)
|
||||
.semantics {
|
||||
onClick(
|
||||
label = a11yClickLabel,
|
||||
) {
|
||||
onClick(emoji)
|
||||
true
|
||||
}
|
||||
},
|
||||
),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ import androidx.compose.ui.graphics.Color
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.semantics.clearAndSetSemantics
|
||||
import androidx.compose.ui.semantics.contentDescription
|
||||
import androidx.compose.ui.semantics.onClick
|
||||
import androidx.compose.ui.tooling.preview.PreviewParameter
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
|
@ -85,15 +84,6 @@ fun MessagesReactionButton(
|
|||
}
|
||||
}
|
||||
|
||||
val a11yClickLabel = if (content is MessagesReactionsButtonContent.Reaction) {
|
||||
a11yReactionAction(
|
||||
emoji = content.reaction.key,
|
||||
userAlreadyReacted = content.isHighlighted
|
||||
)
|
||||
} else {
|
||||
""
|
||||
}
|
||||
|
||||
Surface(
|
||||
modifier = modifier
|
||||
.background(Color.Transparent)
|
||||
|
|
@ -107,6 +97,12 @@ fun MessagesReactionButton(
|
|||
.clip(RoundedCornerShape(corner = CornerSize(12.dp)))
|
||||
.combinedClickable(
|
||||
onClick = onClick,
|
||||
onClickLabel = (content as? MessagesReactionsButtonContent.Reaction)?.let {
|
||||
a11yReactionAction(
|
||||
emoji = content.reaction.key,
|
||||
userAlreadyReacted = content.isHighlighted
|
||||
)
|
||||
},
|
||||
onLongClick = onLongClick
|
||||
)
|
||||
// Inner border, to highlight when selected
|
||||
|
|
@ -115,14 +111,6 @@ fun MessagesReactionButton(
|
|||
.padding(vertical = 4.dp, horizontal = 10.dp)
|
||||
.clearAndSetSemantics {
|
||||
contentDescription = a11yText
|
||||
if (content is MessagesReactionsButtonContent.Reaction) {
|
||||
onClick(
|
||||
label = a11yClickLabel
|
||||
) {
|
||||
onClick()
|
||||
true
|
||||
}
|
||||
}
|
||||
},
|
||||
color = buttonColor
|
||||
) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue