Use a Checkbox for the timeline selection indicator

This commit is contained in:
ganfra
2026-09-25 18:47:48 +02:00
parent cec42ae4e6
commit f4399a392b
@@ -7,44 +7,38 @@
package io.element.android.features.messages.impl.timeline.components
import androidx.compose.foundation.layout.size
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
import io.element.android.compound.theme.ElementTheme
import io.element.android.compound.tokens.generated.CompoundIcons
import io.element.android.libraries.designsystem.preview.ElementPreview
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
import io.element.android.libraries.designsystem.theme.components.Icon
import io.element.android.libraries.designsystem.theme.components.Checkbox
/**
* Compact selection indicator used in the timeline selection mode, in place of a Material
* [androidx.compose.material3.Checkbox] (which reserves a 48dp interactive area). It is purely
* visual: the tap is handled by the whole-row click target, so this only reflects [selected].
* Selection indicator used in the timeline selection mode. It renders the Compound [Checkbox], with the minimum
* interactive size enforcement disabled so that it fits the compact selection column. It is purely visual: the tap
* is handled by the whole-row click target, so this only reflects [selected].
*/
@Composable
internal fun SelectionIndicator(
selected: Boolean,
modifier: Modifier = Modifier,
) {
Icon(
modifier = modifier,
imageVector = if (selected) CompoundIcons.CheckCircleSolid() else CompoundIcons.Circle(),
contentDescription = null,
tint = if (selected) ElementTheme.colors.iconAccentPrimary else ElementTheme.colors.iconTertiary,
)
CompositionLocalProvider(LocalMinimumInteractiveComponentSize provides Dp.Unspecified) {
Checkbox(
modifier = modifier,
checked = selected,
onCheckedChange = null,
)
}
}
@PreviewsDayNight
@Composable
internal fun SelectionIndicatorPreview() = ElementPreview {
Icon(
modifier = Modifier.size(24.dp),
imageVector = CompoundIcons.Circle(),
contentDescription = null,
tint = ElementTheme.colors.iconTertiary,
)
SelectionIndicator(selected = false)
}
@PreviewsDayNight