From fd1f283b775825b7e9060263f8e3513d30e63876 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Sat, 8 Aug 2026 16:24:39 +0200 Subject: [PATCH] feat(components): let a grouped row carry styled text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GroupedRow took plain Strings, so a caller that needs emphasis inside the title or summary — a search hit marking what it matched — had no way in short of rebuilding the row. Adds an AnnotatedString overload and delegates the String one to it. --- CHANGELOG.md | 5 +++ .../floret/components/GroupedList.kt | 39 ++++++++++++++++++- 2 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d39ab26..21f6261 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,11 @@ are no binary releases; "version" tracks the shared `version` in the root build ### Added +- **`components`** — `GroupedRow` takes an `AnnotatedString` title and summary + as well as plain `String`s, so a row can carry its own emphasis: marking the + run a search matched, without every caller having to rebuild the row. The + `String` overload delegates to it, so existing callers are unchanged. + - **`components`** — `SnackChip`, the family's compact confirmation: a content-sized pill sliding up from the bottom with an optional trailing action, for the case where the surface behind the confirmation *is* the confirmation diff --git a/components/src/main/kotlin/de/jeanlucmakiola/floret/components/GroupedList.kt b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/GroupedList.kt index 1897556..62f206d 100644 --- a/components/src/main/kotlin/de/jeanlucmakiola/floret/components/GroupedList.kt +++ b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/GroupedList.kt @@ -24,6 +24,7 @@ import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Shape import androidx.compose.ui.hapticfeedback.HapticFeedbackType import androidx.compose.ui.platform.LocalHapticFeedback +import androidx.compose.ui.text.AnnotatedString import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.dp @@ -130,7 +131,6 @@ fun GroupedSurface( * gap for a caller that owns its own uniform spacing, e.g. [ReorderableColumn]. * [onLongClick] (see [GroupedSurface]) adds a long-press to the row. */ -@OptIn(ExperimentalMaterial3Api::class) @Composable fun GroupedRow( title: String, @@ -146,6 +146,43 @@ fun GroupedRow( trailing: @Composable (() -> Unit)? = null, onClick: (() -> Unit)? = null, onLongClick: (() -> Unit)? = null, +) = GroupedRow( + title = AnnotatedString(title), + position = position, + modifier = modifier, + summary = summary?.let { AnnotatedString(it) }, + selected = selected, + dimmed = dimmed, + container = container, + minHeight = minHeight, + gapBelow = gapBelow, + leading = leading, + trailing = trailing, + onClick = onClick, + onLongClick = onLongClick, +) + +/** + * [GroupedRow] with styled text, for a row whose title or summary carries its own + * emphasis — a search hit marking the run that matched, say. Identical otherwise; + * the plain-[String] overload delegates here. + */ +@OptIn(ExperimentalMaterial3Api::class) +@Composable +fun GroupedRow( + title: AnnotatedString, + position: Position, + modifier: Modifier = Modifier, + summary: AnnotatedString? = null, + selected: Boolean = false, + dimmed: Boolean = false, + container: Color? = null, + minHeight: Dp = 72.dp, + gapBelow: Boolean = true, + leading: @Composable (() -> Unit)? = null, + trailing: @Composable (() -> Unit)? = null, + onClick: (() -> Unit)? = null, + onLongClick: (() -> Unit)? = null, ) { val itemColors = if (selected) { ListItemDefaults.colors(