Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -251,7 +267,7 @@ fun TokenBalanceRow(
.width(styling.flagSize)
.clip(CircleShape),
painter = painterResource(it),
contentDescription = ""
contentDescription = null
)
}
}
Expand Down Expand Up @@ -325,7 +341,7 @@ fun TokenBalanceRow(
if (isSelected)
R.drawable.ic_checked else R.drawable.ic_unchecked
),
contentDescription = ""
contentDescription = null
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ 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
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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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()
Expand All @@ -63,7 +65,7 @@ internal fun ListRowItem(
.clip(CodeTheme.shapes.large)
.align(Alignment.CenterVertically),
painter = painterResource(resId),
contentDescription = ""
contentDescription = null
)
}
Column(
Expand All @@ -88,7 +90,7 @@ internal fun ListRowItem(
if (isSelected)
R.drawable.ic_checked else R.drawable.ic_unchecked
),
contentDescription = ""
contentDescription = null
)
}
}
Expand Down
Loading