[a11y] Use built-in onClickLabel parameter.
This commit is contained in:
parent
635711ebef
commit
ef8d57dff8
6 changed files with 28 additions and 60 deletions
|
|
@ -26,7 +26,6 @@ import androidx.compose.ui.platform.LocalLayoutDirection
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.LayoutDirection
|
||||
import io.element.android.libraries.designsystem.modifiers.a11yClickLabel
|
||||
import io.element.android.libraries.designsystem.preview.ElementThemedPreview
|
||||
import io.element.android.libraries.designsystem.preview.PreviewGroup
|
||||
import io.element.android.libraries.designsystem.text.toPx
|
||||
|
|
@ -52,7 +51,6 @@ fun DmAvatars(
|
|||
val boxSizePx = boxSize.toPx()
|
||||
val otherAvatarRadius = otherUserAvatarData.size.dp.toPx() / 2
|
||||
val isRtl = LocalLayoutDirection.current == LayoutDirection.Rtl
|
||||
val actionView = stringResource(CommonStrings.action_view)
|
||||
Box(
|
||||
modifier = modifier.size(boxSize),
|
||||
) {
|
||||
|
|
@ -84,10 +82,12 @@ fun DmAvatars(
|
|||
)
|
||||
}
|
||||
.clip(CircleShape)
|
||||
.clickable(enabled = userAvatarData.url != null) {
|
||||
.clickable(
|
||||
enabled = userAvatarData.url != null,
|
||||
onClickLabel = stringResource(CommonStrings.action_view),
|
||||
) {
|
||||
userAvatarData.url?.let { openAvatarPreview(it) }
|
||||
}
|
||||
.a11yClickLabel(userAvatarData.url?.let { actionView })
|
||||
)
|
||||
// Draw other user avatar
|
||||
Avatar(
|
||||
|
|
@ -97,11 +97,13 @@ fun DmAvatars(
|
|||
modifier = Modifier
|
||||
.align(Alignment.TopEnd)
|
||||
.clip(CircleShape)
|
||||
.clickable(enabled = otherUserAvatarData.url != null) {
|
||||
.clickable(
|
||||
enabled = otherUserAvatarData.url != null,
|
||||
onClickLabel = stringResource(CommonStrings.action_view),
|
||||
) {
|
||||
otherUserAvatarData.url?.let { openOtherAvatarPreview(it) }
|
||||
}
|
||||
.testTag(TestTags.memberDetailAvatar)
|
||||
.a11yClickLabel(otherUserAvatarData.url?.let { actionView })
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ import androidx.compose.foundation.layout.padding
|
|||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.semantics.onClick
|
||||
import androidx.compose.ui.semantics.semantics
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
fun Modifier.clickableIfNotNull(onClick: (() -> Unit)? = null): Modifier = this.then(
|
||||
|
|
@ -31,18 +29,3 @@ fun Modifier.niceClickable(
|
|||
.clickable { onClick() }
|
||||
.padding(horizontal = 4.dp)
|
||||
}
|
||||
|
||||
fun Modifier.a11yClickLabel(
|
||||
label: String?,
|
||||
): Modifier = then(
|
||||
if (label != null) {
|
||||
Modifier.semantics {
|
||||
onClick(
|
||||
label = label,
|
||||
action = null,
|
||||
)
|
||||
}
|
||||
} else {
|
||||
Modifier
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue