Run the preview plate the full row width (#163)

The plate now spans the same width as the option rows beneath it and takes
their outer radius, so preview and options read as one stack instead of a
card floating over a list.
This commit is contained in:
2026-08-08 22:04:37 +02:00
parent 3e68ed8068
commit 944365e5a1
4 changed files with 36 additions and 34 deletions

View File

@@ -26,6 +26,7 @@ import androidx.compose.ui.semantics.clearAndSetSemantics
import androidx.compose.ui.unit.Constraints import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import de.jeanlucmakiola.floret.components.GroupedListInset
import de.jeanlucmakiola.floret.identity.rememberReduceMotion import de.jeanlucmakiola.floret.identity.rememberReduceMotion
import kotlin.math.roundToInt import kotlin.math.roundToInt
@@ -97,13 +98,17 @@ internal fun ScaledViewPreview(
} }
/** /**
* The bezel every preview picker frames its preview with, cross-fading as * The stage every preview picker sets its preview on, cross-fading as [selected]
* [selected] changes. * changes.
* *
* A preview draws the app's own surface, so on a chooser screen — which draws the * A preview draws the app's own surface, so on a chooser screen — which draws the
* same surface — it had no edge of its own and dissolved into the page. The tonal * same surface — it had no edge of its own and dissolved into the page. A tonal
* ring gives it one: the preview reads as a screen being shown rather than as * plate gives it one: the preview reads as a screen being shown rather than as
* part of the screen showing it. * part of the screen showing it. The plate takes the width and the outer radius
* of the grouped rows underneath, so the two read as one stack.
*
* Only vertical spacing is the caller's to pass — the horizontal inset is the
* rows' own, and the alignment is the point.
*/ */
@Composable @Composable
internal fun <T> ViewPreviewFrame( internal fun <T> ViewPreviewFrame(
@@ -114,14 +119,13 @@ internal fun <T> ViewPreviewFrame(
) { ) {
val reduceMotion = rememberReduceMotion() val reduceMotion = rememberReduceMotion()
Box( Box(
modifier = modifier.fillMaxWidth(), modifier = modifier
contentAlignment = Alignment.Center, .fillMaxWidth()
) { .padding(horizontal = GroupedListInset)
Box(
modifier = Modifier
.clip(FRAME_SHAPE) .clip(FRAME_SHAPE)
.background(MaterialTheme.colorScheme.surfaceContainerHigh) .background(MaterialTheme.colorScheme.surfaceContainerHigh)
.padding(FRAME_INSET), .padding(FRAME_INSET),
contentAlignment = Alignment.Center,
) { ) {
Crossfade( Crossfade(
targetState = selected, targetState = selected,
@@ -129,7 +133,7 @@ internal fun <T> ViewPreviewFrame(
label = label, label = label,
) { shown -> ) { shown ->
// Each preview renders the real view at phone size and scales it // Each preview renders the real view at phone size and scales it
// down, so its own corners are square — the frame rounds them. // down, so its own corners are square — the plate rounds them.
Box( Box(
modifier = Modifier modifier = Modifier
.clip(PREVIEW_SHAPE) .clip(PREVIEW_SHAPE)
@@ -140,9 +144,10 @@ internal fun <T> ViewPreviewFrame(
} }
} }
} }
}
} }
private val FRAME_INSET = 8.dp private val FRAME_INSET = 8.dp
private val FRAME_SHAPE = RoundedCornerShape(20.dp)
/** The grouped rows' own outer radius, so the stack shares one silhouette. */
private val FRAME_SHAPE = RoundedCornerShape(22.dp)
private val PREVIEW_SHAPE = RoundedCornerShape(12.dp) private val PREVIEW_SHAPE = RoundedCornerShape(12.dp)

View File

@@ -197,10 +197,7 @@ private fun <T> StepPreview(selected: T, content: @Composable (T) -> Unit) {
ViewPreviewFrame( ViewPreviewFrame(
selected = selected, selected = selected,
label = "step-preview", label = "step-preview",
modifier = Modifier.padding( modifier = Modifier.padding(top = OnboardingSpace.xs, bottom = OnboardingSpace.md),
horizontal = 12.dp,
vertical = OnboardingSpace.xs,
).padding(bottom = OnboardingSpace.sm),
content = content, content = content,
) )
} }

View File

@@ -47,7 +47,7 @@ internal fun MonthViewStylePicker(
ViewPreviewFrame( ViewPreviewFrame(
selected = selected, selected = selected,
label = "month-style-preview", label = "month-style-preview",
modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp), modifier = Modifier.padding(vertical = 8.dp),
) { shown -> ) { shown ->
MonthStylePreview( MonthStylePreview(
style = shown, style = shown,

View File

@@ -43,7 +43,7 @@ internal fun WeekStartPicker(
ViewPreviewFrame( ViewPreviewFrame(
selected = resolved, selected = resolved,
label = "week-start-preview", label = "week-start-preview",
modifier = Modifier.padding(horizontal = 12.dp, vertical = 8.dp), modifier = Modifier.padding(vertical = 8.dp),
) { day -> ) { day ->
MonthStylePreview( MonthStylePreview(
style = monthStyle, style = monthStyle,