Merge bottom-strip: move the detail and visit selectors to a bottom strip on narrow windows
The narrow detail and visit selectors are now the shared bottom strip in the thumb zone (content above it), while a wide window keeps the left rail and the pinned visit top row; the floating destinations pill lifts clear of the strip. android/ only, no new dependency.
This commit is contained in:
@@ -60,7 +60,9 @@ import net.awan.pipelines.notify.alertPermissionPrompt
|
|||||||
import net.awan.pipelines.ui.chat.ChatScreen
|
import net.awan.pipelines.ui.chat.ChatScreen
|
||||||
import net.awan.pipelines.ui.components.AttentionIndicator
|
import net.awan.pipelines.ui.components.AttentionIndicator
|
||||||
import net.awan.pipelines.ui.components.AttentionSheet
|
import net.awan.pipelines.ui.components.AttentionSheet
|
||||||
|
import net.awan.pipelines.ui.components.BottomStripInset
|
||||||
import net.awan.pipelines.ui.components.ConnectionBanner
|
import net.awan.pipelines.ui.components.ConnectionBanner
|
||||||
|
import net.awan.pipelines.ui.components.LocalBottomStripInset
|
||||||
import net.awan.pipelines.ui.components.LocalPillBottomInset
|
import net.awan.pipelines.ui.components.LocalPillBottomInset
|
||||||
import net.awan.pipelines.ui.components.MotionStandard
|
import net.awan.pipelines.ui.components.MotionStandard
|
||||||
import net.awan.pipelines.ui.components.paneSafeArea
|
import net.awan.pipelines.ui.components.paneSafeArea
|
||||||
@@ -292,9 +294,16 @@ fun PipelinesApp(
|
|||||||
// (an open conversation, see [destinationPillVisible]) that clearance is zero
|
// (an open conversation, see [destinationPillVisible]) that clearance is zero
|
||||||
// so a hidden pill leaves no empty band. See [contentPillPadding].
|
// so a hidden pill leaves no empty band. See [contentPillPadding].
|
||||||
val bannerVisible = connectionState !is ConnectionState.Connected
|
val bannerVisible = connectionState !is ConnectionState.Connected
|
||||||
|
// The live height of any bottom selector strip the current pane is showing. The
|
||||||
|
// strip publishes it while it is shown and the pill below reads it, so the two
|
||||||
|
// never overlap: the pill is lifted clear of the strip (see [pillBottomOffset]).
|
||||||
|
val bottomStripInset = remember { BottomStripInset() }
|
||||||
Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0)) { padding ->
|
Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0)) { padding ->
|
||||||
Box(Modifier.fillMaxSize().padding(padding)) {
|
Box(Modifier.fillMaxSize().padding(padding)) {
|
||||||
CompositionLocalProvider(LocalPillBottomInset provides pillScrollInset(pillVisible)) {
|
CompositionLocalProvider(
|
||||||
|
LocalPillBottomInset provides pillScrollInset(pillVisible),
|
||||||
|
LocalBottomStripInset provides bottomStripInset,
|
||||||
|
) {
|
||||||
Column(Modifier.fillMaxSize().padding(bottom = contentPillPadding(pillVisible))) {
|
Column(Modifier.fillMaxSize().padding(bottom = contentPillPadding(pillVisible))) {
|
||||||
ConnectionBanner(
|
ConnectionBanner(
|
||||||
state = connectionState,
|
state = connectionState,
|
||||||
@@ -391,11 +400,16 @@ fun PipelinesApp(
|
|||||||
// corner on a wide one. Its margin comes from the named [SPACING_L], so the
|
// corner on a wide one. Its margin comes from the named [SPACING_L], so the
|
||||||
// corner placement adds no new number. That rule positions the pill; the
|
// corner placement adds no new number. That rule positions the pill; the
|
||||||
// attention chip above it keeps its own bottom-right place at every width.
|
// attention chip above it keeps its own bottom-right place at every width.
|
||||||
|
// While a bottom selector strip is up, the whole overlay is lifted by that
|
||||||
|
// strip's measured height ([pillBottomOffset]), so the pill never overlaps it.
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize()
|
.fillMaxSize()
|
||||||
.windowInsetsPadding(paneSafeArea())
|
.windowInsetsPadding(paneSafeArea())
|
||||||
.padding(end = if (wide) SPACING_L else 0.dp, bottom = SPACING_L),
|
.padding(
|
||||||
|
end = if (wide) SPACING_L else 0.dp,
|
||||||
|
bottom = pillBottomOffset(bottomStripInset.height),
|
||||||
|
),
|
||||||
verticalArrangement = Arrangement.Bottom,
|
verticalArrangement = Arrangement.Bottom,
|
||||||
horizontalAlignment = destinationPillAlignment(wide),
|
horizontalAlignment = destinationPillAlignment(wide),
|
||||||
) {
|
) {
|
||||||
@@ -531,3 +545,13 @@ internal fun contentPillPadding(pillVisible: Boolean): Dp = 0.dp
|
|||||||
*/
|
*/
|
||||||
internal fun pillScrollInset(pillVisible: Boolean): Dp =
|
internal fun pillScrollInset(pillVisible: Boolean): Dp =
|
||||||
if (pillVisible) DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE else 0.dp
|
if (pillVisible) DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE else 0.dp
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How far above the window's bottom the floating pill rests: its own [SPACING_L]
|
||||||
|
* margin, lifted by exactly the height of any bottom selector strip the current pane
|
||||||
|
* is showing ([stripHeight], published by the strip and zero when none is up). The
|
||||||
|
* pill therefore never overlaps the strip — while the strip is up the two are stacked
|
||||||
|
* with the pill clear above it — and it keeps its resting margin when no strip is up.
|
||||||
|
* Pure, so the one clearance rule is unit-testable without a device.
|
||||||
|
*/
|
||||||
|
internal fun pillBottomOffset(stripHeight: Dp): Dp = SPACING_L + stripHeight
|
||||||
|
|||||||
@@ -23,11 +23,8 @@ import androidx.compose.material.icons.automirrored.filled.Send
|
|||||||
import androidx.compose.material.icons.filled.Code
|
import androidx.compose.material.icons.filled.Code
|
||||||
import androidx.compose.material.icons.filled.Hub
|
import androidx.compose.material.icons.filled.Hub
|
||||||
import androidx.compose.material.icons.filled.Info
|
import androidx.compose.material.icons.filled.Info
|
||||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
|
||||||
import androidx.compose.material3.Icon
|
import androidx.compose.material3.Icon
|
||||||
import androidx.compose.material3.MaterialTheme
|
import androidx.compose.material3.MaterialTheme
|
||||||
import androidx.compose.material3.PrimaryScrollableTabRow
|
|
||||||
import androidx.compose.material3.Tab
|
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.VerticalDivider
|
import androidx.compose.material3.VerticalDivider
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
@@ -85,9 +82,10 @@ fun clampTabIndex(index: Int, tabCount: Int): Int =
|
|||||||
if (tabCount <= 0) 0 else index.coerceIn(0, tabCount - 1)
|
if (tabCount <= 0) 0 else index.coerceIn(0, tabCount - 1)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The section index + its panel. On narrow windows the index is a horizontally
|
* The section index + its panel. On narrow windows the index is the shared
|
||||||
* scrolling Material 3 [PrimaryScrollableTabRow]; on wide windows it is an
|
* [SelectorStrip] pinned to the bottom of the surface, in the thumb zone, with the
|
||||||
* always-visible selectable rail. Both stay fixed and visible while the selected
|
* panel filling the area above it; on wide windows it is an always-visible
|
||||||
|
* selectable rail on the left. Both stay fixed and visible while the selected
|
||||||
* section's panel swaps in place behind a short [Crossfade]: selecting a section
|
* section's panel swaps in place behind a short [Crossfade]: selecting a section
|
||||||
* is an ordinary tab change with no lateral motion and no swipe, because the
|
* is an ordinary tab change with no lateral motion and no swipe, because the
|
||||||
* sections are not a left-to-right pager. Only navigation between levels
|
* sections are not a left-to-right pager. Only navigation between levels
|
||||||
@@ -99,7 +97,6 @@ fun clampTabIndex(index: Int, tabCount: Int): Int =
|
|||||||
* position) is keyed by its stable tab key, so returning to a section restores
|
* position) is keyed by its stable tab key, so returning to a section restores
|
||||||
* where the operator left off instead of resetting it.
|
* where the operator left off instead of resetting it.
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
|
||||||
@Composable
|
@Composable
|
||||||
fun DetailTabs(
|
fun DetailTabs(
|
||||||
tabs: List<DetailTab>,
|
tabs: List<DetailTab>,
|
||||||
@@ -164,16 +161,15 @@ fun DetailTabs(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Column(modifier.fillMaxSize()) {
|
Column(modifier.fillMaxSize()) {
|
||||||
PrimaryScrollableTabRow(selectedTabIndex = selected, edgePadding = 0.dp) {
|
// The content fills the area above the strip; the selector sits after it,
|
||||||
tabs.forEachIndexed { index, tab ->
|
// pinned to the bottom where a thumb reaches, instead of scrolling away
|
||||||
Tab(
|
// at the top of a tall screen.
|
||||||
selected = index == selected,
|
|
||||||
onClick = { onSelect(index) },
|
|
||||||
text = { Text(tab.title, maxLines = 1) },
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
swap(Modifier.weight(1f).fillMaxWidth())
|
swap(Modifier.weight(1f).fillMaxWidth())
|
||||||
|
SelectorStrip(
|
||||||
|
entries = detailSelectorEntries(tabs),
|
||||||
|
selectedIndex = selected,
|
||||||
|
onSelect = onSelect,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,246 @@
|
|||||||
|
package net.awan.pipelines.ui.components
|
||||||
|
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
import androidx.compose.foundation.horizontalScroll
|
||||||
|
import androidx.compose.foundation.layout.Arrangement
|
||||||
|
import androidx.compose.foundation.layout.Column
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.size
|
||||||
|
import androidx.compose.foundation.rememberScrollState
|
||||||
|
import androidx.compose.foundation.selection.selectable
|
||||||
|
import androidx.compose.foundation.selection.selectableGroup
|
||||||
|
import androidx.compose.material3.HorizontalDivider
|
||||||
|
import androidx.compose.material3.Icon
|
||||||
|
import androidx.compose.material3.LocalMinimumInteractiveComponentSize
|
||||||
|
import androidx.compose.material3.MaterialTheme
|
||||||
|
import androidx.compose.material3.Surface
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.runtime.DisposableEffect
|
||||||
|
import androidx.compose.runtime.compositionLocalOf
|
||||||
|
import androidx.compose.runtime.getValue
|
||||||
|
import androidx.compose.runtime.mutableStateOf
|
||||||
|
import androidx.compose.runtime.setValue
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.graphics.vector.ImageVector
|
||||||
|
import androidx.compose.ui.layout.onSizeChanged
|
||||||
|
import androidx.compose.ui.platform.LocalDensity
|
||||||
|
import androidx.compose.ui.semantics.Role
|
||||||
|
import androidx.compose.ui.text.style.TextOverflow
|
||||||
|
import androidx.compose.ui.unit.Dp
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import net.awan.pipelines.data.protocol.RunStep
|
||||||
|
import net.awan.pipelines.ui.theme.HAIRLINE_DP
|
||||||
|
import net.awan.pipelines.ui.theme.ICON_RAIL_DP
|
||||||
|
import net.awan.pipelines.ui.theme.ICON_STATUS_DP
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_L
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_S
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_XS
|
||||||
|
import net.awan.pipelines.ui.theme.pipelinesText
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One entry of a bottom selector strip: its stable [key] (a selector's per-entry
|
||||||
|
* saved state — a section's list scroll position, say — is kept under it), the
|
||||||
|
* [label] it shows, an optional leading [icon] and an optional per-entry state
|
||||||
|
* [marker]. A [marker] is only ever set from state the model actually carries (a
|
||||||
|
* visit's recorded status or outcome); an entry whose model has no such state
|
||||||
|
* shows no marker rather than a stand-in for data that is not there.
|
||||||
|
*/
|
||||||
|
data class SelectorEntry(
|
||||||
|
val key: String,
|
||||||
|
val label: String,
|
||||||
|
val icon: ImageVector? = null,
|
||||||
|
val marker: RunState? = null,
|
||||||
|
)
|
||||||
|
|
||||||
|
/** Where a surface's selector sits: the wide left rail, the wide pinned top row, or the narrow bottom strip. */
|
||||||
|
enum class SelectorPlacement { Rail, TopRow, BottomStrip }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where the shared detail selector sits: the always-visible left rail on a wide
|
||||||
|
* window (unchanged), the bottom strip on a narrow one. Pure, so the one
|
||||||
|
* arrangement rule is unit-testable without a device.
|
||||||
|
*/
|
||||||
|
internal fun detailSelectorPlacement(wide: Boolean): SelectorPlacement =
|
||||||
|
if (wide) SelectorPlacement.Rail else SelectorPlacement.BottomStrip
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where the visit selector sits: the pinned top row on a wide window (unchanged),
|
||||||
|
* the bottom strip on a narrow one — the same thumb-reachable treatment the detail
|
||||||
|
* selector gets, so both selectors read the same on a phone.
|
||||||
|
*/
|
||||||
|
internal fun visitSelectorPlacement(wide: Boolean): SelectorPlacement =
|
||||||
|
if (wide) SelectorPlacement.TopRow else SelectorPlacement.BottomStrip
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a selector with [entryCount] entries needs a strip at all: one entry has
|
||||||
|
* nothing to select between, so a single-entry surface shows no pointless strip and
|
||||||
|
* its content fills the whole area.
|
||||||
|
*/
|
||||||
|
internal fun selectorStripShown(entryCount: Int): Boolean = entryCount > 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The strip entries for a detail tab list: each tab's stable key and its own title,
|
||||||
|
* with the rail's glyph. No marker is invented — a detail tab's model carries no
|
||||||
|
* per-entry state. Keeping the tab [DetailTab.key] as the entry key is what keeps a
|
||||||
|
* section's saved state keyed the same whether the selector is the rail or the strip.
|
||||||
|
*/
|
||||||
|
internal fun detailSelectorEntries(tabs: List<DetailTab>): List<SelectorEntry> =
|
||||||
|
tabs.map { SelectorEntry(key = it.key, label = it.title, icon = it.icon) }
|
||||||
|
|
||||||
|
/** The stable per-visit key, so a visit's saved state is keyed the same everywhere. */
|
||||||
|
internal fun visitSelectorKey(index: Int): String = "visit-${index + 1}"
|
||||||
|
|
||||||
|
/** The one wording a visit's entry carries, shared by the strip and the wide top row. */
|
||||||
|
internal fun visitSelectorLabel(index: Int): String = "visit ${index + 1}"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The marker for one visit: the state of the status (or, absent that, the outcome)
|
||||||
|
* the visit actually recorded. A visit that recorded neither shows no marker, so the
|
||||||
|
* strip never invents a state for it.
|
||||||
|
*/
|
||||||
|
internal fun visitMarker(step: RunStep): RunState? {
|
||||||
|
val word = step.status.ifBlank { step.outcome }
|
||||||
|
return if (word.isBlank()) null else runStateOf(word)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The visit strip entries: `visit N` with the marker of that visit's own recorded
|
||||||
|
* state, in recorded order, so the selected visit and every other visit's state are
|
||||||
|
* both readable at a glance.
|
||||||
|
*/
|
||||||
|
internal fun visitSelectorEntries(runSteps: List<RunStep>): List<SelectorEntry> =
|
||||||
|
runSteps.mapIndexed { index, step ->
|
||||||
|
SelectorEntry(
|
||||||
|
key = visitSelectorKey(index),
|
||||||
|
label = visitSelectorLabel(index),
|
||||||
|
marker = visitMarker(step),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* How tall the bottom selector strip currently is in the composition it is shown in.
|
||||||
|
* The strip publishes its own measured height here while it is shown and resets it
|
||||||
|
* to zero when it goes away; the app shell reads it to lift the floating destination
|
||||||
|
* pill clear of the strip, so the two never overlap. It is a small mutable cell
|
||||||
|
* rather than a plain value because the strip measures itself and the shell reacts
|
||||||
|
* to that measurement, and it defaults to a fresh zero cell, so a strip composed
|
||||||
|
* outside the shell (a preview, a test) lifts nothing.
|
||||||
|
*/
|
||||||
|
class BottomStripInset {
|
||||||
|
var height: Dp by mutableStateOf(0.dp)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The live bottom-strip height, published by the app shell and written by the strip. */
|
||||||
|
internal val LocalBottomStripInset = compositionLocalOf { BottomStripInset() }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The one bottom selector strip: a full-width bar pinned to the bottom of the
|
||||||
|
* surface, in the thumb zone the caller already placed it above the system gesture
|
||||||
|
* inset, with its entries in a single horizontally scrolling row and the content
|
||||||
|
* filling the area above it. Each entry keeps at least the platform's minimum touch
|
||||||
|
* target and shows its whole label (never squeezed); the selected entry is
|
||||||
|
* unmistakable through the tab semantics and the container colour, not colour alone.
|
||||||
|
* A single entry (or none) draws no strip at all.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
internal fun SelectorStrip(
|
||||||
|
entries: List<SelectorEntry>,
|
||||||
|
selectedIndex: Int,
|
||||||
|
onSelect: (Int) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
if (!selectorStripShown(entries.size)) return
|
||||||
|
val selected = selectedIndex.coerceIn(0, entries.size - 1)
|
||||||
|
val inset = LocalBottomStripInset.current
|
||||||
|
val density = LocalDensity.current
|
||||||
|
Surface(
|
||||||
|
modifier = modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.onSizeChanged { inset.height = with(density) { it.height.toDp() } },
|
||||||
|
color = MaterialTheme.colorScheme.surfaceContainer,
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
HorizontalDivider(
|
||||||
|
thickness = HAIRLINE_DP,
|
||||||
|
color = MaterialTheme.colorScheme.outlineVariant,
|
||||||
|
)
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.fillMaxWidth()
|
||||||
|
.horizontalScroll(rememberScrollState())
|
||||||
|
.selectableGroup()
|
||||||
|
.padding(horizontal = SPACING_S, vertical = SPACING_S),
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
entries.forEachIndexed { index, entry ->
|
||||||
|
StripTab(
|
||||||
|
entry = entry,
|
||||||
|
selected = index == selected,
|
||||||
|
onClick = { onSelect(index) },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Leaving the strip (a section with a single entry, or the pane going away)
|
||||||
|
// withdraws the clearance, so the pill drops back to its resting place.
|
||||||
|
DisposableEffect(inset) {
|
||||||
|
onDispose { inset.height = 0.dp }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One strip entry: its glyph (when it has one), its full label and its state marker
|
||||||
|
* (when the model carries one). It keeps at least the platform minimum touch target,
|
||||||
|
* and selection is conveyed by its tab semantics and container colour — the glyph
|
||||||
|
* and label are the same in both states, so nothing is conveyed by colour alone.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
private fun StripTab(entry: SelectorEntry, selected: Boolean, onClick: () -> Unit) {
|
||||||
|
val text = pipelinesText()
|
||||||
|
val minTouch = LocalMinimumInteractiveComponentSize.current
|
||||||
|
val contentColor = if (selected) {
|
||||||
|
MaterialTheme.colorScheme.onSecondaryContainer
|
||||||
|
} else {
|
||||||
|
MaterialTheme.colorScheme.onSurfaceVariant
|
||||||
|
}
|
||||||
|
Row(
|
||||||
|
modifier = Modifier
|
||||||
|
.heightIn(min = minTouch)
|
||||||
|
.selectable(selected = selected, role = Role.Tab, onClick = onClick)
|
||||||
|
.background(
|
||||||
|
color = if (selected) MaterialTheme.colorScheme.secondaryContainer else Color.Transparent,
|
||||||
|
shape = MaterialTheme.shapes.small,
|
||||||
|
)
|
||||||
|
.padding(horizontal = SPACING_L, vertical = SPACING_S),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
|
) {
|
||||||
|
entry.icon?.let { icon ->
|
||||||
|
Icon(
|
||||||
|
imageVector = icon,
|
||||||
|
// The label names the entry, so the glyph is decorative here.
|
||||||
|
contentDescription = null,
|
||||||
|
tint = contentColor,
|
||||||
|
modifier = Modifier.size(ICON_RAIL_DP),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Text(
|
||||||
|
text = entry.label,
|
||||||
|
style = text.cardTitle,
|
||||||
|
color = contentColor,
|
||||||
|
maxLines = 1,
|
||||||
|
overflow = TextOverflow.Ellipsis,
|
||||||
|
)
|
||||||
|
entry.marker?.let { state ->
|
||||||
|
RunStatusIcon(state = state, modifier = Modifier.size(ICON_STATUS_DP))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -128,8 +128,10 @@ internal fun decodeSessionFile(bytes: ByteArray, markdown: Boolean): SessionLoad
|
|||||||
* so a session of several hundred kilobytes scrolls without composing every block.
|
* so a session of several hundred kilobytes scrolls without composing every block.
|
||||||
* When both files were exported the section offers an "HTML view" toggle that
|
* When both files were exported the section offers an "HTML view" toggle that
|
||||||
* swaps in the html document in a WebView for fidelity, and switches back. The
|
* swaps in the html document in a WebView for fidelity, and switches back. The
|
||||||
* context line and the visit tabs stay pinned above the scroll, exactly as the
|
* context line stays pinned above the scroll, exactly as the other section panes
|
||||||
* other section panes keep their chrome.
|
* keep their chrome. On a wide window [visitTabs] renders the pinned visit row in
|
||||||
|
* that header; on a narrow one the caller owns the visit strip below instead, so the
|
||||||
|
* header must not double it.
|
||||||
*
|
*
|
||||||
* The file is fetched once per url through the app's shared artifact byte cache and
|
* The file is fetched once per url through the app's shared artifact byte cache and
|
||||||
* the fetch/parse run off the main thread, so switching views or reopening the pane
|
* the fetch/parse run off the main thread, so switching views or reopening the pane
|
||||||
@@ -146,13 +148,14 @@ internal fun SessionExportSection(
|
|||||||
onVisitIndexChange: (Int) -> Unit,
|
onVisitIndexChange: (Int) -> Unit,
|
||||||
configuredServerUrl: String,
|
configuredServerUrl: String,
|
||||||
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
fetchArtifactBytes: suspend (String) -> ByteArray?,
|
||||||
|
visitTabs: Boolean = true,
|
||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val text = pipelinesText()
|
val text = pipelinesText()
|
||||||
val files = remember(step) { sessionExportFiles(step) }
|
val files = remember(step) { sessionExportFiles(step) }
|
||||||
Column(modifier.fillMaxSize()) {
|
Column(modifier.fillMaxSize()) {
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
SessionHeader(stageKey, runSteps, visitIndex, onVisitIndexChange) {
|
SessionHeader(stageKey, runSteps, visitIndex, onVisitIndexChange, visitTabs) {
|
||||||
Text("No session was exported for this visit.", style = text.meta)
|
Text("No session was exported for this visit.", style = text.meta)
|
||||||
}
|
}
|
||||||
return@Column
|
return@Column
|
||||||
@@ -163,7 +166,7 @@ internal fun SessionExportSection(
|
|||||||
val toggle = sessionViewToggle(files)
|
val toggle = sessionViewToggle(files)
|
||||||
val artifact = sessionArtifact(files, view)
|
val artifact = sessionArtifact(files, view)
|
||||||
val url = artifact?.let { resolvedArtifactUrl(it, configuredServerUrl) }
|
val url = artifact?.let { resolvedArtifactUrl(it, configuredServerUrl) }
|
||||||
SessionHeader(stageKey, runSteps, visitIndex, onVisitIndexChange) {
|
SessionHeader(stageKey, runSteps, visitIndex, onVisitIndexChange, visitTabs) {
|
||||||
Row(
|
Row(
|
||||||
modifier = Modifier.fillMaxWidth(),
|
modifier = Modifier.fillMaxWidth(),
|
||||||
verticalAlignment = Alignment.CenterVertically,
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
@@ -194,10 +197,12 @@ internal fun SessionExportSection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The session pane's pinned header: the context line naming the stage and the
|
* The session pane's pinned header: the context line naming the stage and — on a
|
||||||
* visit tabs, followed by the caller's [content] (the view toggle, or the
|
* wide window — the visit row, followed by the caller's [content] (the view toggle,
|
||||||
* missing-export notice). It stays above the session's own scroll, exactly as the
|
* or the missing-export notice). It stays above the session's own scroll, exactly as
|
||||||
* other section panes keep their chrome.
|
* the other section panes keep their chrome. On a narrow window [visitTabs] is false
|
||||||
|
* and the visit selector is the caller's bottom strip instead, so the header does not
|
||||||
|
* show it twice.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun SessionHeader(
|
private fun SessionHeader(
|
||||||
@@ -205,6 +210,7 @@ private fun SessionHeader(
|
|||||||
runSteps: List<RunStep>,
|
runSteps: List<RunStep>,
|
||||||
visitIndex: Int,
|
visitIndex: Int,
|
||||||
onVisitIndexChange: (Int) -> Unit,
|
onVisitIndexChange: (Int) -> Unit,
|
||||||
|
visitTabs: Boolean,
|
||||||
content: @Composable () -> Unit,
|
content: @Composable () -> Unit,
|
||||||
) {
|
) {
|
||||||
val text = pipelinesText()
|
val text = pipelinesText()
|
||||||
@@ -215,7 +221,7 @@ private fun SessionHeader(
|
|||||||
verticalArrangement = Arrangement.spacedBy(SPACING_S),
|
verticalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||||
) {
|
) {
|
||||||
Text(GraphSemantics.nodeLabel(stageKey), style = text.meta)
|
Text(GraphSemantics.nodeLabel(stageKey), style = text.meta)
|
||||||
StageVisitTabs(runSteps.size, visitIndex, onVisitIndexChange)
|
if (visitTabs) StageVisitTabs(runSteps.size, visitIndex, onVisitIndexChange)
|
||||||
content()
|
content()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,8 +47,11 @@ import net.awan.pipelines.ui.components.DetailTabBody
|
|||||||
import net.awan.pipelines.ui.components.KeyValueRow
|
import net.awan.pipelines.ui.components.KeyValueRow
|
||||||
import net.awan.pipelines.ui.components.PaneIdentity
|
import net.awan.pipelines.ui.components.PaneIdentity
|
||||||
import net.awan.pipelines.ui.components.SectionHeader
|
import net.awan.pipelines.ui.components.SectionHeader
|
||||||
|
import net.awan.pipelines.ui.components.SelectorStrip
|
||||||
import net.awan.pipelines.ui.components.paneSafeArea
|
import net.awan.pipelines.ui.components.paneSafeArea
|
||||||
import net.awan.pipelines.ui.components.pillBottomPadding
|
import net.awan.pipelines.ui.components.pillBottomPadding
|
||||||
|
import net.awan.pipelines.ui.components.visitSelectorEntries
|
||||||
|
import net.awan.pipelines.ui.components.visitSelectorLabel
|
||||||
import net.awan.pipelines.ui.STAGE_RUN_LABEL_LINES
|
import net.awan.pipelines.ui.STAGE_RUN_LABEL_LINES
|
||||||
import net.awan.pipelines.ui.displayMap
|
import net.awan.pipelines.ui.displayMap
|
||||||
import net.awan.pipelines.ui.fileChangeLine
|
import net.awan.pipelines.ui.fileChangeLine
|
||||||
@@ -518,64 +521,74 @@ private fun StageDetailBody(
|
|||||||
}
|
}
|
||||||
|
|
||||||
DetailTabBody(wide, modifier) { columnModifier ->
|
DetailTabBody(wide, modifier) { columnModifier ->
|
||||||
Column(
|
Column(columnModifier) {
|
||||||
modifier = columnModifier
|
Column(
|
||||||
.verticalScroll(rememberScrollState())
|
modifier = Modifier
|
||||||
.padding(horizontal = SPACING_L, vertical = SPACING_S)
|
.weight(1f)
|
||||||
.pillBottomPadding(),
|
.fillMaxWidth()
|
||||||
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
.padding(horizontal = SPACING_L, vertical = SPACING_S)
|
||||||
// A run parked on this stage surfaces its decision here, at the top of
|
.pillBottomPadding(),
|
||||||
// the stage screen: reaching the stage is enough. Rendered
|
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||||
// unconditionally so the open sheet survives a refusal (which clears the
|
) {
|
||||||
// decision) and can report the server's reason.
|
// A run parked on this stage surfaces its decision here, at the top of
|
||||||
DecisionPrompt(decision = decision, onSend = onDecide)
|
// the stage screen: reaching the stage is enough. Rendered
|
||||||
// The stage's own name is the app bar's title, so the body does not
|
// unconditionally so the open sheet survives a refusal (which clears the
|
||||||
// repeat it: the pane leads with the stage's type and facts instead of
|
// decision) and can report the server's reason.
|
||||||
// a duplicated heading.
|
DecisionPrompt(decision = decision, onSend = onDecide)
|
||||||
StageTypeChip(typeLabel)
|
// The stage's own name is the app bar's title, so the body does not
|
||||||
StageVisitTabs(runSteps.size, clampedVisit, onVisitIndexChange)
|
// repeat it: the pane leads with the stage's type and facts instead of
|
||||||
|
// a duplicated heading.
|
||||||
|
StageTypeChip(typeLabel)
|
||||||
|
// A wide window keeps the visit row where it was, pinned with the
|
||||||
|
// content it belongs to; a narrow one moves it to the strip below,
|
||||||
|
// where a thumb reaches.
|
||||||
|
if (wide) StageVisitTabs(runSteps.size, clampedVisit, onVisitIndexChange)
|
||||||
|
|
||||||
// The verdict leads the run pane, above the facts: the chosen option,
|
// The verdict leads the run pane, above the facts: the chosen option,
|
||||||
// the concise reason and the artifacts it names. Absent when the server
|
// the concise reason and the artifacts it names. Absent when the server
|
||||||
// reported none, so no empty heading is ever drawn.
|
// reported none, so no empty heading is ever drawn.
|
||||||
if (runContext && selectedStep != null) {
|
if (runContext && selectedStep != null) {
|
||||||
StageVerdictBlock(
|
StageVerdictBlock(
|
||||||
verdict = selectedStep.verdict,
|
verdict = selectedStep.verdict,
|
||||||
outcome = selectedStep.outcome,
|
outcome = selectedStep.outcome,
|
||||||
status = selectedStep.status,
|
status = selectedStep.status,
|
||||||
artifacts = selectedStep.artifacts.orEmpty(),
|
artifacts = selectedStep.artifacts.orEmpty(),
|
||||||
configuredServerUrl = configuredServerUrl,
|
configuredServerUrl = configuredServerUrl,
|
||||||
fetchArtifactBytes = fetchArtifactBytes,
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
headline.forEach { field -> StageFieldRow(field) }
|
headline.forEach { field -> StageFieldRow(field) }
|
||||||
if (headline.isEmpty() && selectedStep == null && stage == null && sections.isEmpty()) {
|
if (headline.isEmpty() && selectedStep == null && stage == null && sections.isEmpty()) {
|
||||||
Text("No details recorded for this node.", style = text.meta)
|
Text("No details recorded for this node.", style = text.meta)
|
||||||
}
|
}
|
||||||
|
|
||||||
// The compact list of sections: each row opens that section as its own
|
// The compact list of sections: each row opens that section as its own
|
||||||
// pane instead of growing this screen inline (which stacked a section's
|
// pane instead of growing this screen inline (which stacked a section's
|
||||||
// several rows at the top of its header). The row is a navigation row,
|
// several rows at the top of its header). The row is a navigation row,
|
||||||
// so it reads as "Open Artifacts" with a forward chevron rather than an
|
// so it reads as "Open Artifacts" with a forward chevron rather than an
|
||||||
// in-place "Expand Artifacts"/collapsed disclosure.
|
// in-place "Expand Artifacts"/collapsed disclosure.
|
||||||
sections.forEach { section ->
|
sections.forEach { section ->
|
||||||
SectionHeader(
|
SectionHeader(
|
||||||
title = section.title,
|
title = section.title,
|
||||||
expanded = false,
|
expanded = false,
|
||||||
onToggle = { onOpenSection(section.key) },
|
onToggle = { onOpenSection(section.key) },
|
||||||
containerColor = paneContainerColor(),
|
containerColor = paneContainerColor(),
|
||||||
navigation = true,
|
navigation = true,
|
||||||
)
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!wide) StageVisitStrip(runSteps, clampedVisit, onVisitIndexChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The shared visit tab row: rendered only when [visitCount] is more than one, so
|
* The wide visit selector: the pinned top row, rendered only when [visitCount] is
|
||||||
* a single-visit stage never shows a pointless one-tab row. Both the stage screen
|
* more than one, so a single-visit stage never shows a pointless one-tab row. Both
|
||||||
* and a run-section pane use it, so a visit always reads the same way.
|
* the stage screen and a run-section pane use it on a **wide** window; on a narrow
|
||||||
|
* one they use the thumb-reachable [StageVisitStrip] instead, and both label a visit
|
||||||
|
* the same way ([visitSelectorLabel]).
|
||||||
*/
|
*/
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@Composable
|
@Composable
|
||||||
@@ -596,12 +609,34 @@ internal fun StageVisitTabs(
|
|||||||
Tab(
|
Tab(
|
||||||
selected = index == selectedIndex,
|
selected = index == selectedIndex,
|
||||||
onClick = { onSelect(index) },
|
onClick = { onSelect(index) },
|
||||||
text = { Text("visit ${index + 1}", maxLines = 1) },
|
text = { Text(visitSelectorLabel(index), maxLines = 1) },
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The narrow visit selector: the shared bottom strip, with each visit's own label and
|
||||||
|
* the marker of the state that visit actually recorded (its status, or its outcome
|
||||||
|
* when no status was recorded). A stage visited once — or not at all — shows no strip.
|
||||||
|
* The labels and markers come from [visitSelectorEntries], so the strip and the wide
|
||||||
|
* row never spell a visit differently.
|
||||||
|
*/
|
||||||
|
@Composable
|
||||||
|
internal fun StageVisitStrip(
|
||||||
|
runSteps: List<RunStep>,
|
||||||
|
selectedIndex: Int,
|
||||||
|
onSelect: (Int) -> Unit,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
) {
|
||||||
|
SelectorStrip(
|
||||||
|
entries = visitSelectorEntries(runSteps),
|
||||||
|
selectedIndex = selectedIndex,
|
||||||
|
onSelect = onSelect,
|
||||||
|
modifier = modifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One stage section opened as its own pane: its own Scaffold/[TopAppBar] titled
|
* One stage section opened as its own pane: its own Scaffold/[TopAppBar] titled
|
||||||
* with the section's own name, its own scroll and its own top spacing, so the
|
* with the section's own name, its own scroll and its own top spacing, so the
|
||||||
@@ -715,12 +750,14 @@ fun StageSectionPane(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* One section's content: its own single scroll, a context line naming the stage,
|
* One section's content: its own single scroll, a context line naming the stage,
|
||||||
* its own top spacing, and — for a visit's result section — the visit tab row,
|
* its own top spacing, and — for a visit's result section — the visit selector, so
|
||||||
* so the operator can switch visits in place. The stage definition skips the tab
|
* the operator can switch visits in place. The stage definition skips the selector
|
||||||
* row (it does not change per visit). Plain sections render their rows; the
|
* (it does not change per visit). A wide window keeps the pinned top row inside the
|
||||||
* artifacts section renders the shared [ArtifactsSection] gallery; the session
|
* scroll; a narrow one pins the shared bottom strip below the scroll, so a visit is
|
||||||
* section renders [SessionExportSection], which owns its own lazy/large-content
|
* switchable from the thumb zone. Plain sections render their rows; the artifacts
|
||||||
* scroll instead of the eager one below.
|
* section renders the shared [ArtifactsSection] gallery; the session section renders
|
||||||
|
* [SessionExportSection], which owns its own lazy/large-content scroll instead of the
|
||||||
|
* eager one below.
|
||||||
*/
|
*/
|
||||||
@Composable
|
@Composable
|
||||||
private fun StageSectionBody(
|
private fun StageSectionBody(
|
||||||
@@ -738,46 +775,56 @@ private fun StageSectionBody(
|
|||||||
modifier: Modifier = Modifier,
|
modifier: Modifier = Modifier,
|
||||||
) {
|
) {
|
||||||
val text = pipelinesText()
|
val text = pipelinesText()
|
||||||
|
val visitSelector = spec != null && spec.key != STAGE_DEFINITION_KEY
|
||||||
if (spec?.session == true && step != null) {
|
if (spec?.session == true && step != null) {
|
||||||
DetailTabBody(wide, modifier) { columnModifier ->
|
Column(modifier.fillMaxSize()) {
|
||||||
SessionExportSection(
|
DetailTabBody(wide, Modifier.weight(1f)) { columnModifier ->
|
||||||
stageKey = stageKey,
|
SessionExportSection(
|
||||||
step = step,
|
stageKey = stageKey,
|
||||||
runSteps = runSteps,
|
step = step,
|
||||||
visitIndex = visitIndex,
|
runSteps = runSteps,
|
||||||
onVisitIndexChange = onVisitIndexChange,
|
visitIndex = visitIndex,
|
||||||
configuredServerUrl = configuredServerUrl,
|
onVisitIndexChange = onVisitIndexChange,
|
||||||
fetchArtifactBytes = fetchArtifactBytes,
|
configuredServerUrl = configuredServerUrl,
|
||||||
modifier = columnModifier,
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
)
|
visitTabs = wide,
|
||||||
|
modifier = columnModifier,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
if (!wide) StageVisitStrip(runSteps, visitIndex, onVisitIndexChange)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
DetailTabBody(wide, modifier) { columnModifier ->
|
DetailTabBody(wide, modifier) { columnModifier ->
|
||||||
Column(
|
Column(columnModifier) {
|
||||||
modifier = columnModifier
|
Column(
|
||||||
.verticalScroll(rememberScrollState())
|
modifier = Modifier
|
||||||
.padding(horizontal = SPACING_L, vertical = SPACING_L)
|
.weight(1f)
|
||||||
.pillBottomPadding(),
|
.fillMaxWidth()
|
||||||
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
.verticalScroll(rememberScrollState())
|
||||||
) {
|
.padding(horizontal = SPACING_L, vertical = SPACING_L)
|
||||||
KeyValueRow("Stage", GraphSemantics.nodeLabel(stageKey))
|
.pillBottomPadding(),
|
||||||
if (spec != null && spec.key != STAGE_DEFINITION_KEY) {
|
verticalArrangement = Arrangement.spacedBy(SPACING_XS),
|
||||||
StageVisitTabs(runSteps.size, visitIndex, onVisitIndexChange)
|
) {
|
||||||
}
|
KeyValueRow("Stage", GraphSemantics.nodeLabel(stageKey))
|
||||||
when {
|
if (wide && visitSelector) {
|
||||||
spec == null -> Text("This section is not recorded for this stage.", style = text.meta)
|
StageVisitTabs(runSteps.size, visitIndex, onVisitIndexChange)
|
||||||
spec.artifacts -> if (step != null) {
|
}
|
||||||
ArtifactsSection(
|
when {
|
||||||
step = step,
|
spec == null -> Text("This section is not recorded for this stage.", style = text.meta)
|
||||||
configuredServerUrl = configuredServerUrl,
|
spec.artifacts -> if (step != null) {
|
||||||
fetchArtifactBytes = fetchArtifactBytes,
|
ArtifactsSection(
|
||||||
selection = selection,
|
step = step,
|
||||||
onSelectionChange = onSelectionChange,
|
configuredServerUrl = configuredServerUrl,
|
||||||
)
|
fetchArtifactBytes = fetchArtifactBytes,
|
||||||
|
selection = selection,
|
||||||
|
onSelectionChange = onSelectionChange,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else -> spec.fields.forEach { field -> StageFieldRow(field) }
|
||||||
}
|
}
|
||||||
else -> spec.fields.forEach { field -> StageFieldRow(field) }
|
|
||||||
}
|
}
|
||||||
|
if (!wide && visitSelector) StageVisitStrip(runSteps, visitIndex, onVisitIndexChange)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,10 @@ package net.awan.pipelines.ui
|
|||||||
|
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
import androidx.compose.ui.unit.Dp
|
import androidx.compose.ui.unit.Dp
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE
|
import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE
|
||||||
import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE
|
import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE
|
||||||
|
import net.awan.pipelines.ui.theme.SPACING_L
|
||||||
import org.junit.Assert.assertEquals
|
import org.junit.Assert.assertEquals
|
||||||
import org.junit.Assert.assertFalse
|
import org.junit.Assert.assertFalse
|
||||||
import org.junit.Assert.assertTrue
|
import org.junit.Assert.assertTrue
|
||||||
@@ -132,6 +134,15 @@ class PipelinesNavTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun thePillLiftsClearOfAnyBottomSelectorStrip() {
|
||||||
|
// With no strip up the pill keeps its own resting margin; with a strip up it
|
||||||
|
// is lifted by exactly that strip's measured height, so the two stack with
|
||||||
|
// the pill clear above the strip instead of overlapping it.
|
||||||
|
assertDp(SPACING_L.value, pillBottomOffset(0.dp))
|
||||||
|
assertDp((SPACING_L + 72.dp).value, pillBottomOffset(72.dp))
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertDp(expected: Float, actual: Dp) =
|
private fun assertDp(expected: Float, actual: Dp) =
|
||||||
assertEquals(expected, actual.value, 0.01f)
|
assertEquals(expected, actual.value, 0.01f)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
package net.awan.pipelines.ui.components
|
||||||
|
|
||||||
|
import net.awan.pipelines.data.protocol.RunStep
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Assert.assertNull
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
class SelectorStripTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun theNarrowDetailSelectorIsTheBottomStripAndTheWideOneKeepsTheRail() {
|
||||||
|
// The narrow arrangement puts the selector after the content, pinned to the
|
||||||
|
// bottom; the wide arrangement keeps the always-visible left rail, unmoved.
|
||||||
|
assertEquals(SelectorPlacement.BottomStrip, detailSelectorPlacement(wide = false))
|
||||||
|
assertEquals(SelectorPlacement.Rail, detailSelectorPlacement(wide = true))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun theNarrowVisitSelectorIsTheBottomStripAndTheWideOneKeepsThePinnedRow() {
|
||||||
|
assertEquals(SelectorPlacement.BottomStrip, visitSelectorPlacement(wide = false))
|
||||||
|
assertEquals(SelectorPlacement.TopRow, visitSelectorPlacement(wide = true))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aSingleEntryShowsNoPointlessStrip() {
|
||||||
|
assertTrue(!selectorStripShown(0))
|
||||||
|
assertTrue(!selectorStripShown(1))
|
||||||
|
assertTrue(selectorStripShown(2))
|
||||||
|
assertTrue(selectorStripShown(6))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun detailEntriesCarryTheTabKeysAndTitlesInOrderSoSavedStateIsKeyedTheSame() {
|
||||||
|
// Each entry keeps its tab's stable key, which is what a section's own saved
|
||||||
|
// state (its scroll position) is keyed by through the saveable state holder;
|
||||||
|
// the strip and the rail therefore preserve exactly the same per-entry state.
|
||||||
|
listOf(runDetailTabs, pipelineDetailTabs).forEach { tabs ->
|
||||||
|
val entries = detailSelectorEntries(tabs)
|
||||||
|
assertEquals(tabs.map { it.key }, entries.map { it.key })
|
||||||
|
assertEquals(tabs.map { it.title }, entries.map { it.label })
|
||||||
|
assertEquals(tabs.map { it.icon }, entries.map { it.icon })
|
||||||
|
// No marker is invented: a detail tab's model carries no per-entry state.
|
||||||
|
assertTrue(entries.all { it.marker == null })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun visitEntriesAreTheVisitLabelsWithEachVisitsOwnRecordedMarker() {
|
||||||
|
val steps = listOf(
|
||||||
|
RunStep(status = "succeeded", outcome = "success"),
|
||||||
|
RunStep(status = "failed"),
|
||||||
|
RunStep(status = "running"),
|
||||||
|
RunStep(outcome = "success"),
|
||||||
|
)
|
||||||
|
val entries = visitSelectorEntries(steps)
|
||||||
|
assertEquals(listOf("visit 1", "visit 2", "visit 3", "visit 4"), entries.map { it.label })
|
||||||
|
// The marker is the state the visit actually recorded, never invented.
|
||||||
|
assertEquals(
|
||||||
|
listOf(RunState.Succeeded, RunState.Failed, RunState.Running, RunState.Succeeded),
|
||||||
|
entries.map { it.marker },
|
||||||
|
)
|
||||||
|
// A visit's strip entry and the wide row spell the visit the same way.
|
||||||
|
assertEquals("visit 1", visitSelectorLabel(0))
|
||||||
|
assertEquals("visit 3", visitSelectorLabel(2))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aVisitThatRecordedNoStateShowsNoMarker() {
|
||||||
|
assertEquals(null, visitMarker(RunStep()))
|
||||||
|
assertEquals(null, visitMarker(RunStep(status = " ", outcome = "")))
|
||||||
|
// A status wins over the outcome when both are recorded.
|
||||||
|
assertEquals(RunState.Failed, visitMarker(RunStep(status = "failed", outcome = "success")))
|
||||||
|
assertNull(visitSelectorEntries(listOf(RunStep(), RunStep())).first().marker)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun visitKeysAreStableAndDistinct() {
|
||||||
|
// Two stages' strips must never share a visit's saved state, so each visit
|
||||||
|
// has its own stable key derived from its index.
|
||||||
|
assertEquals(listOf("visit-1", "visit-2", "visit-3"), (0..2).map { visitSelectorKey(it) })
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
# The detail and visit selectors: a bottom strip narrow, the rail wide
|
||||||
|
|
||||||
|
## What this item changed
|
||||||
|
|
||||||
|
`android/` only, the two selectors that used to be a horizontally scrolling Material 3
|
||||||
|
tab row at the top of a surface.
|
||||||
|
|
||||||
|
- `ui/components/SelectorStrip.kt` (new) — the one bottom selector strip, plus its pure
|
||||||
|
model. `SelectorEntry(key, label, icon, marker)`, `SelectorPlacement` (`Rail` / `TopRow`
|
||||||
|
/ `BottomStrip`), `detailSelectorPlacement(wide)`, `visitSelectorPlacement(wide)`,
|
||||||
|
`selectorStripShown(entryCount)`, `detailSelectorEntries(tabs)`,
|
||||||
|
`visitSelectorKey/Label(index)`, `visitMarker(step)`, `visitSelectorEntries(runSteps)`;
|
||||||
|
the `BottomStripInset` cell and `LocalBottomStripInset` the strip publishes its measured
|
||||||
|
height through; and the `SelectorStrip` composable (a full-width `Surface`, a hairline
|
||||||
|
top divider, one horizontally scrolling row of entries, each entry at least the platform
|
||||||
|
minimum touch target, the selected one carried by `Role.Tab` + selected state and the
|
||||||
|
container colour, a visit's recorded state shown as a small `RunStatusIcon` marker, and
|
||||||
|
a single entry drawing no strip at all).
|
||||||
|
- `ui/components/DetailTabs.kt` — the narrow branch's `PrimaryScrollableTabRow` is replaced
|
||||||
|
by `SelectorStrip(detailSelectorEntries(tabs), …)` **after** the panel in a `Column`, so
|
||||||
|
the content fills the area above the strip and the selector sits in the thumb zone. The
|
||||||
|
wide branch is unchanged (the left `RailTab` rail). The `@OptIn(ExperimentalMaterial3Api)`
|
||||||
|
and the `PrimaryScrollableTabRow`/`Tab` imports are gone.
|
||||||
|
- `ui/graph/StageDetailPane.kt` — `StageVisitTabs` stays the pinned **wide** visit row (now
|
||||||
|
labelling each visit through `visitSelectorLabel`); new `StageVisitStrip` is the narrow
|
||||||
|
form, the shared `SelectorStrip` fed by `visitSelectorEntries(runSteps)` (labels `visit N`
|
||||||
|
plus each visit's recorded status/outcome marker). `StageDetailBody` and `StageSectionBody`
|
||||||
|
put the strip below a `weight(1f)` scroll on a narrow window and keep the top row on a wide
|
||||||
|
one; a section that does not change per visit (`Stage definition`) still shows no strip.
|
||||||
|
The session branch composes `DetailTabBody` with `weight(1f)` above the strip.
|
||||||
|
- `ui/graph/SessionExport.kt` — `SessionExportSection` gains `visitTabs: Boolean` (passed as
|
||||||
|
`wide`), and `SessionHeader` renders the pinned visit row only when it is true, so the
|
||||||
|
narrow pane does not show the visit selector twice.
|
||||||
|
- `ui/PipelinesApp.kt` — the bottom strip's measured height is published to the content
|
||||||
|
through `LocalBottomStripInset` (a `BottomStripInset` cell created in the shell), and the
|
||||||
|
floating pill's overlay `Column` lifts by it: `pillBottomOffset(stripHeight) = SPACING_L +
|
||||||
|
stripHeight` (pure, new). So the pill moves clear of the strip while it is shown — the
|
||||||
|
chosen of the brief's two options — implemented once, and zero when no strip is up.
|
||||||
|
- Tests — `ui/components/SelectorStripTest.kt` (new: the placements, one-entry shows no
|
||||||
|
strip, the detail entries keep every tab key/title/icon so per-entry saved state is keyed
|
||||||
|
the same, the visit labels with their recorded markers, no marker for a visit with no
|
||||||
|
recorded state, the stable per-visit key) and `PipelinesNavTest` (the pill lifts by
|
||||||
|
exactly the strip height and keeps its margin with none). The existing `DetailTabsTest`
|
||||||
|
clamping/state tests and `StageDetailSheetTest` visit tests are unchanged and still pass.
|
||||||
|
|
||||||
|
## Shared documents this change makes stale
|
||||||
|
|
||||||
|
`android/README.md` documents the app's selector presentation and is written here rather
|
||||||
|
than edited in place; the `docs-fold` writer should update it.
|
||||||
|
|
||||||
|
- `android/README.md:182-184` — the bullet ending "Narrow windows show a horizontally
|
||||||
|
scrolling `PrimaryScrollableTabRow`; wide windows show an always-visible selectable rail
|
||||||
|
(icon + label, no collapse control)." should read "Narrow windows show the shared
|
||||||
|
`SelectorStrip` pinned to the bottom of the surface, in the thumb zone, with the panel
|
||||||
|
filling the area above it; wide windows show an always-visible selectable rail on the
|
||||||
|
left (icon + label, no collapse control)." The rest of the bullet (the in-place
|
||||||
|
`Crossfade`, no lateral motion, the per-section `rememberSaveableStateHolder` keyed by
|
||||||
|
the tab key, `clampTabIndex`) is still true.
|
||||||
|
- `android/README.md:233-235` — "The section index presentation does follow the window
|
||||||
|
width: a narrow window shows the tab row across the top, a wide window the always-visible
|
||||||
|
side rail…" should read "…a narrow window shows the bottom selector strip, a wide window
|
||||||
|
the always-visible side rail…".
|
||||||
|
- `android/README.md:487-488` — the Timeline + visit tabs bullet's "shows a `visit 1..N`
|
||||||
|
tab row only when there is more than one visit" should read "shows a `visit 1..N` row
|
||||||
|
(the pinned top row on a wide window, the bottom strip on a narrow one, each visit's
|
||||||
|
recorded state as a small marker) only when there is more than one visit".
|
||||||
|
- Append the dated section below at the end of `android/README.md`, after the last record.
|
||||||
|
|
||||||
|
```markdown
|
||||||
|
## The detail and visit selectors: a bottom strip narrow, the rail wide (18 Oct 2026)
|
||||||
|
|
||||||
|
Both selectors that were a horizontally scrolling Material 3 tab row at the top of a
|
||||||
|
surface are now one deliberate treatment: the shared detail selector (`DetailTabs`, the
|
||||||
|
pipeline and the run detail) and the visit selector (`StageVisitTabs`). On a **narrow**
|
||||||
|
window the selector is the shared `SelectorStrip` pinned to the bottom of the surface, in
|
||||||
|
the thumb zone above the system gesture inset, with the content filling the area above it;
|
||||||
|
on a **wide** one the detail selector keeps its existing left rail and the visit selector
|
||||||
|
its pinned top row. `android/` only; no new dependency (still only the declared
|
||||||
|
`material-icons-extended`), no Pipelines server/Go/installer/Docker file touched and no run
|
||||||
|
started from the app; the build and unit tests only, no device command run.
|
||||||
|
|
||||||
|
- **One shared strip.** `ui/components/SelectorStrip.kt` holds the strip and its pure
|
||||||
|
model: `SelectorEntry(key, label, icon, marker)`, `SelectorPlacement` (`Rail` / `TopRow` /
|
||||||
|
`BottomStrip`), `detailSelectorPlacement(wide)` / `visitSelectorPlacement(wide)`,
|
||||||
|
`selectorStripShown(entryCount)`, `detailSelectorEntries(tabs)`, `visitSelectorKey/Label`,
|
||||||
|
`visitMarker(step)` and `visitSelectorEntries(runSteps)`. A single entry (or none) draws
|
||||||
|
no strip, so a single-visit stage and a one-section surface stay strip-free.
|
||||||
|
- **Legible, unmistakable, token-driven.** Each entry keeps at least the platform minimum
|
||||||
|
touch target and shows its whole label (an ellipsis only if the row is scrolled), carries
|
||||||
|
the rail's glyph where the model has one, and shows a visit's recorded status/outcome as a
|
||||||
|
small marker (`RunStatusIcon`) — never a stand-in for data the model does not carry. The
|
||||||
|
selected entry is conveyed by `Role.Tab` + selected state and the container colour, not
|
||||||
|
colour alone. Every dimension is an existing `Dimens` token or the layout; no new
|
||||||
|
hardcoded value.
|
||||||
|
- **The pill moves clear of the strip.** The strip publishes its measured height through the
|
||||||
|
new `LocalBottomStripInset` (`BottomStripInset`), and the floating pill's overlay lifts by
|
||||||
|
`pillBottomOffset(stripHeight) = SPACING_L + stripHeight` — the one of the brief's two
|
||||||
|
options, implemented once and zero when no strip is up (a unit test pins both). The pane
|
||||||
|
stack's Back gesture and the in-place `Crossfade` swap are untouched, and each section's
|
||||||
|
own saved state is still keyed by its tab key.
|
||||||
|
- **Evidence.** `<gradle> --offline --no-daemon :app:assembleDebug :app:testDebugUnitTest`
|
||||||
|
→ `BUILD SUCCESSFUL`; the 69 result XMLs aggregate to **654 tests, 0 failures, 0 errors,
|
||||||
|
0 skipped**. New `SelectorStripTest` (7 tests) and one new `PipelinesNavTest` case.
|
||||||
|
`app-debug.apk` 18,700,429 bytes, sha256
|
||||||
|
`5b5bb9e0d67586c0a964853097be89842fc99053f428d4d24905fda1aaa71af3`, published as
|
||||||
|
`pipelines-debug-wip-d9619ea.apk` (`HTTP/1.1 200 OK`, the published bytes
|
||||||
|
Content-Length-matching the local file). Built in a worktree at `d9619ea`, which is
|
||||||
|
`main`'s tip, so no feature of `main` is missing from it.
|
||||||
|
|
||||||
|
Not verified in this pass: how the strip and the lifted pill actually render, and the
|
||||||
|
screenshots the brief names (the pipeline and run detail on a narrow window, a stage detail
|
||||||
|
with more than one visit, the single-entry case, and the wide rail) — that needs the device,
|
||||||
|
which this build-and-unit-test pass did not use; visual review owns the operator's Pixel 9
|
||||||
|
Pro XL.
|
||||||
|
```
|
||||||
|
|
||||||
|
## Not stale
|
||||||
|
|
||||||
|
- No packaged OpenCode skill reference (`internal/author/skill/references/`) documents the
|
||||||
|
app's detail/visit selectors; they describe the server, the CLI and the pipeline authoring
|
||||||
|
model. No packaged template (`examples/*.md`) and no `internal/author/` managed file names
|
||||||
|
them, so `internal/author/install.go`'s inventory needs no change.
|
||||||
|
- `android/AGENTS.md` lists `ui/components/` and `ui/graph/` generically and needs no change.
|
||||||
Reference in New Issue
Block a user