Merge branch 'main' into lane-go
This commit is contained in:
@@ -2169,3 +2169,82 @@ Evidence (macOS, JDK 17 from Homebrew `openjdk@17`, Gradle 9.7.1,
|
||||
Not verified in this pass: a narrow-window frame (the fold inner display is
|
||||
851dp wide); the error state's fade-in from loading (the disconnected load failed
|
||||
before a loading frame could be drawn, only its fade-out was captured).
|
||||
|
||||
### Animated selection and state changes (16 Oct 2026, run 109/1)
|
||||
|
||||
Selection and live state changes animate instead of cutting, and every resting
|
||||
state is unchanged. All of it reuses the one `Motion.kt` token file; no new
|
||||
dependency, geometry or literal.
|
||||
|
||||
- **The destination pill's indicator travels.** `DestinationPill`
|
||||
(`PipelinesApp.kt`) now draws one selection indicator behind the three icons
|
||||
and animates its offset between them (`animateDpAsState`, `MotionStandard`), so
|
||||
picking another destination slides the highlight across rather than each icon
|
||||
swapping its own background; the glyph tint cross-fades in step
|
||||
(`animateColorAsState`). The geometry comes from two named tokens,
|
||||
`DESTINATION_ITEM_SIZE`/`DESTINATION_ITEM_GAP` (the existing 48dp target and
|
||||
4dp gap, named once), through the pure `destinationIndicatorOffsetDp`, which is
|
||||
unit-tested. The icons own the taps, so a tap registers while the indicator is
|
||||
still travelling, and a rapid run of taps only retargets the one animator.
|
||||
- **A selected row's highlight fades in.** The shared `ListRow` animates its
|
||||
tonal container and content colour under `MotionQuick` instead of switching, so
|
||||
selecting a pipeline/run row fades the `secondaryContainer` highlight in and
|
||||
out; the settled row is exactly the old one.
|
||||
- **Section bodies animate with their chevron.** A new shared
|
||||
`CollapsibleSectionBody` (`Sections.kt`) wraps a section's body in
|
||||
`AnimatedVisibility` with `expandVertically`/`shrinkVertically` + fade under
|
||||
`MotionQuick` — the same token the `SectionHeader` chevron turns with — so the
|
||||
content and the chevron move together. Both `collapsibleSection` (the lazy
|
||||
variant) and the stage pane's `StageSection` use it; collapsed, the body is not
|
||||
composed, so a resting section is unchanged. (The section *switch* was already
|
||||
an in-place `Crossfade` with no lateral motion and is unchanged.)
|
||||
- **A live run's status change animates.** `StatusChip` eases its container and
|
||||
label colour under `MotionQuick` and `RunStatusIcon` eases its glyph tint, so a
|
||||
run whose status changes while the 1s poll is running visibly transitions the
|
||||
chip and the row's leading accent instead of silently swapping a colour.
|
||||
- **Taps, pause and the animator scale.** These are ordinary Compose animators,
|
||||
so the platform animator duration scale applies unchanged (disabled = instant),
|
||||
the recomposer pauses them while the screen is not resumed, and the
|
||||
selectable/clickable nodes are independent of the animators, so taps register
|
||||
mid-animation.
|
||||
|
||||
Verified on `emulator-5554` only (fold layout, 2076x2152 / 390dpi; never the
|
||||
attached Pixel, never `emulator-5556`), against the live server; each frame
|
||||
captured and validated with `scripts/capture_png.sh -s emulator-5554`:
|
||||
|
||||
- `gradle :app:assembleDebug :app:testDebugUnitTest --offline --console=plain` →
|
||||
`BUILD SUCCESSFUL`; `gradle :app:testDebugUnitTest --rerun-tasks --offline`
|
||||
re-ran every result XML to **186 tests across 23 classes, 0 failures, 0 errors,
|
||||
0 skipped**. The new `PipelinesNavTest` cases check the indicator offset lines
|
||||
up with each slot and pins to slot 0 when nothing is selected.
|
||||
- **Pill selection moving** at `animator_duration_scale 6`
|
||||
(`pill_0/1/5.png`): with Pipelines selected, tapping Runs leaves `pill_0` on
|
||||
Pipelines, `pill_1` freezes the highlight between the two icons, and `pill_5`
|
||||
settles under Runs.
|
||||
- **Section collapsing** at `animator_duration_scale 15`
|
||||
(`sec2_expand_3.png`, `sec2_collapse_2.png`): the Input tab's `prompt` section
|
||||
expands with the code block revealing under a down chevron, and collapses with
|
||||
the block clipped and the following `pwd` header rising as the chevron returns.
|
||||
- **Live status change** (`status3_post_01/02/03.png`): run 112 was started
|
||||
out-of-band with `pipelines run … --pipeline 1 --prompt "… sleep 45 …"` (**not**
|
||||
from the app) and watched in its open detail; its summary chip goes from
|
||||
`running` (`status3_post_01`) through the mid-transition tint
|
||||
(`status3_post_02`) to `succeeded` (`status3_post_03`).
|
||||
- **Taps mid-animation**: at scale 15, tapping Runs and then Settings 0.2s later
|
||||
(while the indicator was still travelling) landed on the Settings screen, so
|
||||
the second tap registered.
|
||||
- `adb -s emulator-5554 logcat -d` held 0 `FATAL EXCEPTION` / 0
|
||||
`E AndroidRuntime` lines; `animator_duration_scale` was left at 1.
|
||||
- **APK publish.** `app-debug.apk` (18,133,184 bytes, sha256 `567c437d…`) copied
|
||||
to `~/.local/share/pipelines/data/artifacts/109/1/pipelines-debug-wip-b89ad29.apk`
|
||||
(`b89ad29` = `git rev-parse --short HEAD`); `curl -I
|
||||
http://10.0.0.249:8080/artifacts/109/1/pipelines-debug-wip-b89ad29.apk` returned
|
||||
`HTTP/1.1 200 OK`, `Content-Type: application/vnd.android.package-archive`,
|
||||
`Content-Length: 18133184`, and a streamed `curl | shasum -a 256` returned the
|
||||
same `567c437d…`.
|
||||
|
||||
Not verified in this pass: a clean *settled* frame of the selected-row highlight
|
||||
(it fades in while the wide layout then covers the list with the opened pane, so
|
||||
only a transient mid-fade frame was captured); resume-after-pause of an
|
||||
in-flight animation on device (the pause is Compose's own recomposer behaviour,
|
||||
not code here).
|
||||
|
||||
@@ -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