diff --git a/apps/flipcash/core-ui/src/main/kotlin/com/flipcash/app/core/ui/TokenBalanceRow.kt b/apps/flipcash/core-ui/src/main/kotlin/com/flipcash/app/core/ui/TokenBalanceRow.kt index 5b7484f45b..b8ebb49a66 100644 --- a/apps/flipcash/core-ui/src/main/kotlin/com/flipcash/app/core/ui/TokenBalanceRow.kt +++ b/apps/flipcash/core-ui/src/main/kotlin/com/flipcash/app/core/ui/TokenBalanceRow.kt @@ -11,6 +11,7 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.width import androidx.compose.foundation.layout.wrapContentWidth +import androidx.compose.foundation.selection.selectable import androidx.compose.foundation.shape.CircleShape import androidx.compose.material3.Icon import androidx.compose.material3.Text @@ -23,6 +24,9 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.painter.Painter import androidx.compose.ui.graphics.takeOrElse import androidx.compose.ui.res.painterResource +import androidx.compose.ui.semantics.Role +import androidx.compose.ui.semantics.selected +import androidx.compose.ui.semantics.semantics import androidx.compose.ui.text.TextStyle import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.Dp @@ -182,13 +186,25 @@ fun TokenBalanceRow( ) { val exchange = LocalExchange.current val backgroundColor = CodeTheme.colors.background + // The checkbox mark is drawn, not announced, so the row carries the selection instead. + val selection = isSelected.takeIf { styling.selectionStyle == TokenSelectionStyle.Checkbox } + val isClickable = onClick != null && isEnabled Row( modifier = Modifier - .addIf(onClick != null && isEnabled) { - Modifier.clickable { - onClick?.invoke() + .addIf(isClickable) { + if (selection != null) { + Modifier.selectable(selected = selection, role = Role.RadioButton) { + onClick?.invoke() + } + } else { + Modifier.clickable { + onClick?.invoke() + } } } + .addIf(!isClickable && selection != null) { + Modifier.semantics(mergeDescendants = true) { selected = selection == true } + } .then(modifier) .addIf(!isEnabled) { Modifier.drawWithContent { @@ -251,7 +267,7 @@ fun TokenBalanceRow( .width(styling.flagSize) .clip(CircleShape), painter = painterResource(it), - contentDescription = "" + contentDescription = null ) } } @@ -325,7 +341,7 @@ fun TokenBalanceRow( if (isSelected) R.drawable.ic_checked else R.drawable.ic_unchecked ), - contentDescription = "" + contentDescription = null ) } } diff --git a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/screens/GroupInviteSheet.kt b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/screens/GroupInviteSheet.kt index e5adf3cc0f..31fcbb8aea 100644 --- a/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/screens/GroupInviteSheet.kt +++ b/apps/flipcash/features/messenger/src/main/kotlin/com/flipcash/app/messenger/internal/screens/GroupInviteSheet.kt @@ -28,6 +28,7 @@ import androidx.compose.foundation.layout.size import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.rememberLazyListState +import androidx.compose.foundation.selection.toggleable import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.text.input.rememberTextFieldState @@ -389,7 +390,12 @@ private fun RecentChatRow( Row( modifier = Modifier .fillMaxWidth() - .clickable(enabled = enabled, role = Role.Checkbox, onClick = onClick) + .toggleable( + value = selected, + enabled = enabled, + role = Role.Checkbox, + onValueChange = { onClick() }, + ) .padding(horizontal = ListInset), verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(RowGap), diff --git a/apps/flipcash/features/tipping/src/main/kotlin/com/flipcash/app/tipping/internal/screens/SelectGroupCurrencySheet.kt b/apps/flipcash/features/tipping/src/main/kotlin/com/flipcash/app/tipping/internal/screens/SelectGroupCurrencySheet.kt index f84f9fed83..6fe6a57ef5 100644 --- a/apps/flipcash/features/tipping/src/main/kotlin/com/flipcash/app/tipping/internal/screens/SelectGroupCurrencySheet.kt +++ b/apps/flipcash/features/tipping/src/main/kotlin/com/flipcash/app/tipping/internal/screens/SelectGroupCurrencySheet.kt @@ -3,7 +3,6 @@ package com.flipcash.app.tipping.internal.screens import androidx.compose.foundation.Image import androidx.compose.foundation.background import androidx.compose.foundation.border -import androidx.compose.foundation.clickable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -11,6 +10,7 @@ import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size +import androidx.compose.foundation.selection.selectable import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material3.Icon @@ -23,6 +23,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.stringResource +import androidx.compose.ui.semantics.Role import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.text.style.TextOverflow import androidx.compose.ui.unit.Dp @@ -179,7 +180,7 @@ private fun AllCurrenciesCard( color = if (selected) White50 else CardOutline, shape = shape, ) - .clickable(onClick = onClick) + .selectable(selected = selected, role = Role.RadioButton, onClick = onClick) .padding( horizontal = CodeTheme.dimens.inset - CardMargin, vertical = CodeTheme.dimens.grid.x3, diff --git a/apps/flipcash/shared/region-selection/ui/src/main/kotlin/com/flipcash/app/currency/internal/components/ListRowItem.kt b/apps/flipcash/shared/region-selection/ui/src/main/kotlin/com/flipcash/app/currency/internal/components/ListRowItem.kt index 2d72bb4dee..74dac2af06 100644 --- a/apps/flipcash/shared/region-selection/ui/src/main/kotlin/com/flipcash/app/currency/internal/components/ListRowItem.kt +++ b/apps/flipcash/shared/region-selection/ui/src/main/kotlin/com/flipcash/app/currency/internal/components/ListRowItem.kt @@ -24,7 +24,8 @@ import com.flipcash.app.currency.internal.RegionListItem import com.flipcash.features.currency.R import com.getcode.theme.CodeTheme import com.getcode.ui.components.SwipeActionRow -import androidx.compose.foundation.clickable +import androidx.compose.foundation.selection.selectable +import androidx.compose.ui.semantics.Role @Composable internal fun ListRowItem( @@ -39,11 +40,12 @@ internal fun ListRowItem( modifier = Modifier .fillMaxSize() .background(CodeTheme.colors.background) - .let { - if (item.currency.rate > 0) { - it.clickable { onClick() } - } else it - } + .selectable( + selected = isSelected, + enabled = item.currency.rate > 0, + role = Role.RadioButton, + onClick = onClick, + ) ) { Box( modifier = Modifier.fillMaxSize() @@ -63,7 +65,7 @@ internal fun ListRowItem( .clip(CodeTheme.shapes.large) .align(Alignment.CenterVertically), painter = painterResource(resId), - contentDescription = "" + contentDescription = null ) } Column( @@ -88,7 +90,7 @@ internal fun ListRowItem( if (isSelected) R.drawable.ic_checked else R.drawable.ic_unchecked ), - contentDescription = "" + contentDescription = null ) } }