Animate selection and live state changes
Animate selection and status changes across the Android UI using the existing Motion tokens, leaving every resting state unchanged. - DestinationPill draws one selection indicator and animates its offset between the three slots (animateDpAsState, MotionStandard), with the glyph tint cross-fading in step; geometry comes from named DESTINATION_ITEM_SIZE/GAP tokens via the unit-tested destinationIndicatorOffsetDp helper. - The shared ListRow fades its tonal container and content colour under MotionQuick instead of switching. - New shared CollapsibleSectionBody wraps section bodies in AnimatedVisibility (expand/shrink + fade) under MotionQuick, used by both the lazy collapsibleSection and the stage pane's StageSection, so body and chevron move together. - StatusChip eases container and label colour and RunStatusIcon eases its glyph tint, so a live run's status transition is visible rather than a silent colour swap. Verified: assembleDebug + testDebugUnitTest BUILD SUCCESSFUL, 186 tests across 23 classes with 0 failures/errors/skips; frames captured on emulator-5554 for the travelling pill, section collapse and a live status change; APK published to the run artifact directory. README documents the change and its evidence.
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import androidx.activity.compose.PredictiveBackHandler
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.animation.core.animateDpAsState
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@@ -10,6 +12,7 @@ import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.WindowInsetsSides
|
||||
import androidx.compose.foundation.layout.consumeWindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.offset
|
||||
import androidx.compose.foundation.layout.only
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
@@ -33,10 +36,10 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.platform.LocalConfiguration
|
||||
import androidx.compose.ui.semantics.Role
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.navigation.compose.NavHost
|
||||
@@ -46,12 +49,14 @@ import androidx.navigation.compose.rememberNavController
|
||||
import kotlinx.coroutines.flow.collect
|
||||
import net.awan.pipelines.data.transport.ConnectionState
|
||||
import net.awan.pipelines.ui.components.ConnectionBanner
|
||||
import net.awan.pipelines.ui.components.MotionStandard
|
||||
import net.awan.pipelines.ui.components.SlidingPaneStack
|
||||
import net.awan.pipelines.ui.components.clampTabIndex
|
||||
import net.awan.pipelines.ui.components.paneSafeArea
|
||||
import net.awan.pipelines.ui.components.pipelineDetailTabs
|
||||
import net.awan.pipelines.ui.components.rememberPaneContent
|
||||
import net.awan.pipelines.ui.components.runDetailTabs
|
||||
import net.awan.pipelines.ui.components.spec
|
||||
import net.awan.pipelines.ui.graph.PipelineStagePane
|
||||
import net.awan.pipelines.ui.graph.RunStagePane
|
||||
import net.awan.pipelines.ui.screens.PipelineDetailScreen
|
||||
@@ -342,14 +347,27 @@ private fun RunsDestination(
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* The horizontal offset of the pill's travelling selection indicator for the
|
||||
* destination at [index]: the pill's inner padding plus [index] item slots
|
||||
* ([itemSize] + [gap]). Pure and in one place, so the indicator lines up exactly
|
||||
* with the icon it selects and the geometry is unit-testable without a device.
|
||||
* A missing selection (-1) pins to the first slot and the caller draws nothing.
|
||||
*/
|
||||
internal fun destinationIndicatorOffsetDp(index: Int, itemSize: Dp, gap: Dp): Dp =
|
||||
gap + (itemSize + gap) * index.coerceAtLeast(0)
|
||||
|
||||
/**
|
||||
* The Pipelines/Runs/Settings destinations as a floating rounded pill at the
|
||||
* bottom right: the three destinations as icons, inset from the bottom/right
|
||||
* edges (it clears the safe area — system bars, cutout, gesture area and IME —
|
||||
* via windowInsetsPadding), each a 48dp touch
|
||||
* target. Selection is a tonal container plus the `Role.Tab` selected
|
||||
* accessibility state — never colour alone — and tapping switches destination
|
||||
* through the caller's existing navigate/popUpTo logic.
|
||||
* via windowInsetsPadding), each a [DESTINATION_ITEM_SIZE] touch target.
|
||||
* Selection is one tonal indicator that travels between the icons
|
||||
* ([MotionStandard], so it slides rather than jumping) plus the icon's fading
|
||||
* tint, while the `Role.Tab` selected accessibility state is never conveyed by
|
||||
* colour alone. Tapping switches destination through the caller's existing
|
||||
* navigate/popUpTo logic; the icons own the taps, so a tap registers even while
|
||||
* the indicator is still travelling, and the settled pill equals the old one.
|
||||
*/
|
||||
@Composable
|
||||
private fun DestinationPill(
|
||||
@@ -358,53 +376,81 @@ private fun DestinationPill(
|
||||
onSelect: (TopDestination) -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val scheme = MaterialTheme.colorScheme
|
||||
val selectedIndex = destinations.indexOfFirst { destinationSelected(currentRoute, it.route) }
|
||||
// One long-lived animator, so a rapid run of taps only retargets it (never
|
||||
// half-way) and the first composition starts already settled at the target.
|
||||
val indicatorOffset by animateDpAsState(
|
||||
targetValue = destinationIndicatorOffsetDp(
|
||||
selectedIndex,
|
||||
DESTINATION_ITEM_SIZE,
|
||||
DESTINATION_ITEM_GAP,
|
||||
),
|
||||
animationSpec = MotionStandard.spec(),
|
||||
label = "destination-indicator",
|
||||
)
|
||||
Surface(
|
||||
modifier = modifier,
|
||||
shape = RoundedCornerShape(50),
|
||||
color = MaterialTheme.colorScheme.surfaceContainerHigh,
|
||||
color = scheme.surfaceContainerHigh,
|
||||
tonalElevation = 3.dp,
|
||||
shadowElevation = 6.dp,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(4.dp),
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
destinations.forEach { destination ->
|
||||
val selected = destinationSelected(currentRoute, destination.route)
|
||||
Box {
|
||||
// Drawn behind the icons, so the highlight slides under whichever is
|
||||
// selected; before the nav graph settles there is no selection and
|
||||
// nothing is drawn.
|
||||
if (selectedIndex >= 0) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(48.dp)
|
||||
Modifier
|
||||
.offset(x = indicatorOffset, y = DESTINATION_ITEM_GAP)
|
||||
.size(DESTINATION_ITEM_SIZE)
|
||||
.clip(CircleShape)
|
||||
.background(
|
||||
if (selected) {
|
||||
MaterialTheme.colorScheme.secondaryContainer
|
||||
} else {
|
||||
Color.Transparent
|
||||
},
|
||||
)
|
||||
.selectable(
|
||||
selected = selected,
|
||||
role = Role.Tab,
|
||||
onClick = { onSelect(destination) },
|
||||
),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = destination.icon,
|
||||
contentDescription = destination.label,
|
||||
tint = if (selected) {
|
||||
MaterialTheme.colorScheme.onSecondaryContainer
|
||||
} else {
|
||||
MaterialTheme.colorScheme.onSurfaceVariant
|
||||
},
|
||||
.background(scheme.secondaryContainer),
|
||||
)
|
||||
}
|
||||
Row(
|
||||
modifier = Modifier.padding(DESTINATION_ITEM_GAP),
|
||||
horizontalArrangement = Arrangement.spacedBy(DESTINATION_ITEM_GAP),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
) {
|
||||
destinations.forEach { destination ->
|
||||
val selected = destinationSelected(currentRoute, destination.route)
|
||||
// The glyph tint fades in step with the travelling indicator.
|
||||
val iconColor by animateColorAsState(
|
||||
targetValue = if (selected) scheme.onSecondaryContainer else scheme.onSurfaceVariant,
|
||||
animationSpec = MotionStandard.spec(),
|
||||
label = "destination-icon",
|
||||
)
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.size(DESTINATION_ITEM_SIZE)
|
||||
.clip(CircleShape)
|
||||
.selectable(
|
||||
selected = selected,
|
||||
role = Role.Tab,
|
||||
onClick = { onSelect(destination) },
|
||||
),
|
||||
contentAlignment = Alignment.Center,
|
||||
) {
|
||||
Icon(
|
||||
imageVector = destination.icon,
|
||||
contentDescription = destination.label,
|
||||
tint = iconColor,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** The destination pill's icon touch target and the size of its selection indicator. */
|
||||
internal val DESTINATION_ITEM_SIZE = 48.dp
|
||||
|
||||
/** The gap between destinations, also the pill's inner padding. */
|
||||
internal val DESTINATION_ITEM_GAP = 4.dp
|
||||
|
||||
/** Bottom space reserved for the floating destination pill, so content is never
|
||||
* permanently hidden behind it (pill height + its margins + a small gap). */
|
||||
private val DESTINATION_PILL_RESERVE = 88.dp
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.awan.pipelines.ui.components
|
||||
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.ColumnScope
|
||||
@@ -13,6 +14,7 @@ import androidx.compose.material3.LocalContentColor
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
@@ -31,7 +33,9 @@ import androidx.compose.ui.unit.dp
|
||||
* the bottom destinations ([MaterialTheme.colorScheme.secondaryContainer] with
|
||||
* `onSecondaryContainer` content) and exposes its selection through
|
||||
* `selectable`'s accessibility selected state, so selection is never conveyed by
|
||||
* colour alone.
|
||||
* colour alone. The highlight fades in and out under [MotionQuick] rather than
|
||||
* appearing at once; the settled row is exactly the selected/unselected row, so
|
||||
* the resting appearance is unchanged.
|
||||
*/
|
||||
@Composable
|
||||
fun ListRow(
|
||||
@@ -43,8 +47,16 @@ fun ListRow(
|
||||
content: @Composable ColumnScope.() -> Unit,
|
||||
) {
|
||||
val scheme = MaterialTheme.colorScheme
|
||||
val container = if (selected) scheme.secondaryContainer else Color.Transparent
|
||||
val contentColor = if (selected) scheme.onSecondaryContainer else LocalContentColor.current
|
||||
val container by animateColorAsState(
|
||||
targetValue = if (selected) scheme.secondaryContainer else Color.Transparent,
|
||||
animationSpec = MotionQuick.spec(),
|
||||
label = "row-selection-container",
|
||||
)
|
||||
val contentColor by animateColorAsState(
|
||||
targetValue = if (selected) scheme.onSecondaryContainer else LocalContentColor.current,
|
||||
animationSpec = MotionQuick.spec(),
|
||||
label = "row-selection-content",
|
||||
)
|
||||
Surface(
|
||||
color = container,
|
||||
contentColor = contentColor,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.awan.pipelines.ui.components
|
||||
|
||||
import androidx.compose.animation.animateColorAsState
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Row
|
||||
@@ -19,6 +20,7 @@ import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
@@ -89,7 +91,8 @@ fun runStateIcon(state: RunState): ImageVector = when (state) {
|
||||
* A state glyph with an accurate [contentDescription]. Every glyph comes from the
|
||||
* standard filled material icon set (the extended pack is declared as a
|
||||
* dependency), all the same weight/family, so state is never conveyed by colour
|
||||
* alone.
|
||||
* alone. The tint eases under [MotionQuick], so a live run's status change fades
|
||||
* the accent colour rather than swapping it.
|
||||
*/
|
||||
@Composable
|
||||
fun RunStatusIcon(
|
||||
@@ -98,22 +101,37 @@ fun RunStatusIcon(
|
||||
modifier: Modifier = Modifier,
|
||||
tint: Color = runStateColor(state),
|
||||
) {
|
||||
val animatedTint by animateColorAsState(
|
||||
targetValue = tint,
|
||||
animationSpec = MotionQuick.spec(),
|
||||
label = "run-status-tint",
|
||||
)
|
||||
Icon(
|
||||
imageVector = runStateIcon(state),
|
||||
contentDescription = contentDescription,
|
||||
tint = tint,
|
||||
tint = animatedTint,
|
||||
modifier = modifier,
|
||||
)
|
||||
}
|
||||
|
||||
/** A colour-coded chip pairing a state glyph with its text label. */
|
||||
/**
|
||||
* A colour-coded chip pairing a state glyph with its text label. Its container,
|
||||
* label and glyph all ease to the new state's colour under [MotionQuick] (the
|
||||
* glyph's own tint animates in [RunStatusIcon], in step), so a run whose status
|
||||
* changes while the screen is open visibly transitions instead of silently
|
||||
* swapping a colour; the chip is identical to the old one once settled.
|
||||
*/
|
||||
@Composable
|
||||
fun StatusChip(
|
||||
label: String,
|
||||
state: RunState,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
val color = runStateColor(state)
|
||||
val color by animateColorAsState(
|
||||
targetValue = runStateColor(state),
|
||||
animationSpec = MotionQuick.spec(),
|
||||
label = "status-chip-color",
|
||||
)
|
||||
Row(
|
||||
modifier = modifier
|
||||
.clip(RoundedCornerShape(50))
|
||||
@@ -122,7 +140,7 @@ fun StatusChip(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
RunStatusIcon(state, contentDescription = label, modifier = Modifier.size(14.dp), tint = color)
|
||||
RunStatusIcon(state, contentDescription = label, modifier = Modifier.size(14.dp))
|
||||
Text(
|
||||
text = label,
|
||||
color = color,
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
package net.awan.pipelines.ui.components
|
||||
|
||||
import androidx.compose.animation.AnimatedVisibility
|
||||
import androidx.compose.animation.core.animateFloatAsState
|
||||
import androidx.compose.animation.expandVertically
|
||||
import androidx.compose.animation.fadeIn
|
||||
import androidx.compose.animation.fadeOut
|
||||
import androidx.compose.animation.shrinkVertically
|
||||
import androidx.compose.foundation.ExperimentalFoundationApi
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
@@ -100,10 +105,38 @@ fun SectionHeader(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The one animated collapsible body: [content] expands and shrinks with a fade
|
||||
* under [MotionQuick], the same token the section chevron turns with, so the
|
||||
* body and the chevron move together instead of the content popping in after the
|
||||
* chevron has already turned. Collapsed, [content] is not composed, so a closed
|
||||
* section does no work and the resting layout is the collapsed header alone.
|
||||
* With animations disabled Compose maps the platform animator duration scale
|
||||
* onto the specs, so the body is at its final state at once.
|
||||
*/
|
||||
@Composable
|
||||
fun CollapsibleSectionBody(
|
||||
expanded: Boolean,
|
||||
modifier: Modifier = Modifier,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
AnimatedVisibility(
|
||||
visible = expanded,
|
||||
enter = expandVertically(animationSpec = MotionQuick.spec()) +
|
||||
fadeIn(animationSpec = MotionQuick.spec()),
|
||||
exit = shrinkVertically(animationSpec = MotionQuick.spec()) +
|
||||
fadeOut(animationSpec = MotionQuick.spec()),
|
||||
modifier = modifier,
|
||||
) {
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Emits a collapsible [section] into a [LazyListScope]: a sticky header for the
|
||||
* title and, only while [expanded], the content as items of the *same* outer
|
||||
* list. Nothing ever nests a scrollable, so real laziness is preserved.
|
||||
* title and one body item after it, wrapped in [CollapsibleSectionBody] so the
|
||||
* whole section animates as a unit. Nothing ever nests a scrollable, so the
|
||||
* outer list keeps its own scroll and laziness.
|
||||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
fun LazyListScope.collapsibleSection(
|
||||
@@ -111,12 +144,12 @@ fun LazyListScope.collapsibleSection(
|
||||
key: Any,
|
||||
expanded: Boolean,
|
||||
onToggle: () -> Unit,
|
||||
content: LazyListScope.() -> Unit,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
stickyHeader(key = "section-$key") {
|
||||
SectionHeader(title = title, expanded = expanded, onToggle = onToggle)
|
||||
}
|
||||
if (expanded) {
|
||||
content()
|
||||
item(key = "section-$key-body") {
|
||||
CollapsibleSectionBody(expanded) { content() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ import net.awan.pipelines.data.protocol.Stage
|
||||
import net.awan.pipelines.data.protocol.edges
|
||||
import net.awan.pipelines.ui.AppViewModel
|
||||
import net.awan.pipelines.ui.components.CodeBlock
|
||||
import net.awan.pipelines.ui.components.CollapsibleSectionBody
|
||||
import net.awan.pipelines.ui.components.DetailTabBody
|
||||
import net.awan.pipelines.ui.components.KeyValueRow
|
||||
import net.awan.pipelines.ui.components.PaneIdentity
|
||||
@@ -518,9 +519,10 @@ private fun StageDetailBody(
|
||||
|
||||
/**
|
||||
* One collapsible section of the stage pane: its header toggles [expansion]
|
||||
* under [key] and, while it is expanded, [content] is rendered. The title
|
||||
* defaults to the capitalised key (e.g. `artifacts` → `Artifacts`), so the pane
|
||||
* names every section the same way.
|
||||
* under [key] and its body animates open/closed with the shared
|
||||
* [CollapsibleSectionBody], so the content and the chevron move together. The
|
||||
* title defaults to the capitalised key (e.g. `artifacts` → `Artifacts`), so the
|
||||
* pane names every section the same way.
|
||||
*/
|
||||
@Composable
|
||||
private fun StageSection(
|
||||
@@ -529,13 +531,14 @@ private fun StageSection(
|
||||
title: String = key.capitalized(),
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
val expanded = expansion.isExpanded(key)
|
||||
SectionHeader(
|
||||
title,
|
||||
expansion.isExpanded(key),
|
||||
expanded,
|
||||
{ expansion.toggle(key) },
|
||||
containerColor = paneContainerColor(),
|
||||
)
|
||||
if (expansion.isExpanded(key)) content()
|
||||
CollapsibleSectionBody(expanded) { content() }
|
||||
}
|
||||
|
||||
/** The stage pane hosted directly by the run destination, reading the run detail. */
|
||||
|
||||
@@ -13,7 +13,6 @@ import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.automirrored.filled.ArrowBack
|
||||
import androidx.compose.material.icons.filled.ContentCopy
|
||||
@@ -57,7 +56,6 @@ import net.awan.pipelines.ui.components.LoadPhase
|
||||
import net.awan.pipelines.ui.components.LoadingState
|
||||
import net.awan.pipelines.ui.components.PaneIdentity
|
||||
import net.awan.pipelines.ui.components.StateCrossfade
|
||||
import net.awan.pipelines.ui.components.animateListItem
|
||||
import net.awan.pipelines.ui.components.paneSafeArea
|
||||
import net.awan.pipelines.ui.components.collapsibleSection
|
||||
import net.awan.pipelines.ui.components.copyText
|
||||
@@ -222,16 +220,18 @@ private fun PipelineSummaryTab(detail: PipelineDetail, wide: Boolean, modifier:
|
||||
onToggle = { versionsExpanded = !versionsExpanded },
|
||||
) {
|
||||
if (detail.versions.isEmpty()) {
|
||||
item(key = "versions-empty") {
|
||||
Text(
|
||||
"No versions recorded.",
|
||||
style = text.meta,
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
)
|
||||
}
|
||||
Text(
|
||||
"No versions recorded.",
|
||||
style = text.meta,
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
)
|
||||
} else {
|
||||
items(detail.versions, key = { "version-${it.version}" }) { v ->
|
||||
VersionRow(v, animateListItem(Modifier.padding(horizontal = 16.dp, vertical = 4.dp)))
|
||||
// The version list is bounded and small, so it renders in the
|
||||
// section's single animated body item; the rows are not lazy.
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
detail.versions.forEach { v ->
|
||||
VersionRow(v, Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,15 +342,13 @@ private fun PipelineSourceTab(detail: PipelineDetail, modifier: Modifier) {
|
||||
expanded = expansion.isExpanded(sectionKey),
|
||||
onToggle = { expansion.toggle(sectionKey) },
|
||||
) {
|
||||
item(key = "$sectionKey-body") {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
fields.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 16.dp, vertical = 8.dp),
|
||||
verticalArrangement = Arrangement.spacedBy(4.dp),
|
||||
) {
|
||||
fields.forEach { field -> StageFieldRow(field) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,6 @@ import net.awan.pipelines.ui.components.LoadPhase
|
||||
import net.awan.pipelines.ui.components.LoadingState
|
||||
import net.awan.pipelines.ui.components.PaneIdentity
|
||||
import net.awan.pipelines.ui.components.StateCrossfade
|
||||
import net.awan.pipelines.ui.components.animateListItem
|
||||
import net.awan.pipelines.ui.components.paneSafeArea
|
||||
import net.awan.pipelines.ui.components.RunStatusIcon
|
||||
import net.awan.pipelines.ui.components.StatusChip
|
||||
@@ -493,13 +492,11 @@ private fun RunFieldSectionsTab(
|
||||
expanded = expansion.isExpanded(sectionKey),
|
||||
onToggle = { expansion.toggle(sectionKey) },
|
||||
) {
|
||||
item(key = "$sectionKey-body") {
|
||||
CodeBlock(
|
||||
label = label,
|
||||
text = value.displayText(),
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp),
|
||||
)
|
||||
}
|
||||
CodeBlock(
|
||||
label = label,
|
||||
text = value.displayText(),
|
||||
modifier = Modifier.padding(horizontal = 16.dp, vertical = 4.dp),
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -569,12 +566,7 @@ private fun RunEvidenceTab(
|
||||
expanded = expansion.isExpanded(sectionKey),
|
||||
onToggle = { expansion.toggle(sectionKey) },
|
||||
) {
|
||||
item(key = "$sectionKey-body") {
|
||||
EvidenceDetails(
|
||||
record,
|
||||
animateListItem(Modifier.padding(horizontal = 16.dp, vertical = 4.dp)),
|
||||
)
|
||||
}
|
||||
EvidenceDetails(record, Modifier.padding(horizontal = 16.dp, vertical = 4.dp))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.awan.pipelines.ui
|
||||
|
||||
import androidx.compose.ui.unit.Dp
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
@@ -29,4 +31,27 @@ class PipelinesNavTest {
|
||||
assertFalse(destinationSelected(null, "runs"))
|
||||
assertFalse(destinationSelected(null, "settings"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun destinationIndicatorLinesUpWithItsSlot() {
|
||||
// The travelling indicator sits at the pill's inner padding plus one slot
|
||||
// (item + gap) per destination, so it rests exactly over the icon it
|
||||
// selects.
|
||||
assertDp(4f, destinationIndicatorOffsetDp(0, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP))
|
||||
assertDp(56f, destinationIndicatorOffsetDp(1, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP))
|
||||
assertDp(108f, destinationIndicatorOffsetDp(2, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun destinationIndicatorPinsWhenNothingIsSelected() {
|
||||
// A missing selection (-1) must not index a negative offset; it pins to
|
||||
// the first slot while the caller draws no indicator at all.
|
||||
assertEquals(
|
||||
destinationIndicatorOffsetDp(0, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP),
|
||||
destinationIndicatorOffsetDp(-1, DESTINATION_ITEM_SIZE, DESTINATION_ITEM_GAP),
|
||||
)
|
||||
}
|
||||
|
||||
private fun assertDp(expected: Float, actual: Dp) =
|
||||
assertEquals(expected, actual.value, 0.01f)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user