From d5f5ad7b9df73a9dff4b7b82d8f338eec71423b7 Mon Sep 17 00:00:00 2001 From: Jean-Luc Makiola Date: Wed, 23 Sep 2026 16:51:55 +0200 Subject: [PATCH] components: ReorderableColumn row height parameter --- .../floret/components/ReorderableColumn.kt | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/components/src/main/kotlin/de/jeanlucmakiola/floret/components/ReorderableColumn.kt b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/ReorderableColumn.kt index d63ff1f..e99eb0b 100644 --- a/components/src/main/kotlin/de/jeanlucmakiola/floret/components/ReorderableColumn.kt +++ b/components/src/main/kotlin/de/jeanlucmakiola/floret/components/ReorderableColumn.kt @@ -31,7 +31,7 @@ import kotlinx.coroutines.Job import kotlinx.coroutines.launch import kotlin.math.roundToInt -/** Uniform row height for [ReorderableColumn]; a fixed pitch keeps drag maths exact. */ +/** Default uniform row height for [ReorderableColumn]; a fixed pitch keeps drag maths exact. */ val ReorderableRowHeight: Dp = 64.dp private val RowGap: Dp = 2.dp @@ -41,7 +41,7 @@ private val RowGap: Dp = 2.dp * Built for the short, fixed grouped-card lists in Settings — no external * dependency and no [androidx.compose.foundation.lazy.LazyColumn] (the settings * screens are a single [androidx.compose.foundation.verticalScroll] column, which - * can't nest a scrolling list). Rows are a fixed [ReorderableRowHeight] with a + * can't nest a scrolling list). Rows are a fixed [rowHeight] with a * uniform gap, so a row's target slot is simply how many whole pitches it has * been dragged. The held row follows the finger while the others slide out of * its way (animated); on release the order is committed immediately with a @@ -52,6 +52,8 @@ private val RowGap: Dp = 2.dp * [rowContent] receives the [Position] for the row's place in the order (to reuse * [GroupedRow]'s card shaping — pass `gapBelow = false` there, this owns spacing) * and a `dragHandle` [Modifier] to attach to the element that starts a drag. + * Pass [rowHeight] matching the rows' non-reorder `minHeight`, so they keep their + * size when a screen switches into reordering. */ @Composable fun ReorderableColumn( @@ -59,9 +61,10 @@ fun ReorderableColumn( keyOf: (T) -> Any, onReorder: (List) -> Unit, modifier: Modifier = Modifier, + rowHeight: Dp = ReorderableRowHeight, rowContent: @Composable (item: T, position: Position, dragHandle: Modifier, isDragging: Boolean) -> Unit, ) { - val pitchPx = with(LocalDensity.current) { (ReorderableRowHeight + RowGap).toPx() } + val pitchPx = with(LocalDensity.current) { (rowHeight + RowGap).toPx() } val scope = rememberCoroutineScope() // Local working copy; re-seeded when the incoming list changes (including the @@ -163,7 +166,7 @@ fun ReorderableColumn( Box( Modifier - .height(ReorderableRowHeight) + .height(rowHeight) .zIndex(if (isDragged) 1f else 0f) .graphicsLayer { translationY = if (isDragged) dragOffset else animatedShift