feat: move attention access to action bars
This commit is contained in:
@@ -31,6 +31,8 @@ internal fun PipelineDestination(
|
||||
onSelectionChange: (PaneSelection) -> Unit,
|
||||
listState: LazyListState,
|
||||
onOpenRun: (Long) -> Unit,
|
||||
attention: List<AttentionEntry>,
|
||||
onOpenAttention: () -> Unit,
|
||||
) {
|
||||
val depth = selection.depth
|
||||
val onBack: () -> Unit = { onSelectionChange(backFrom(selection)) }
|
||||
@@ -70,6 +72,8 @@ internal fun PipelineDestination(
|
||||
covered = covered,
|
||||
wide = wide,
|
||||
listState = listState,
|
||||
attention = attention,
|
||||
onOpenAttention = onOpenAttention,
|
||||
)
|
||||
1 -> rememberPaneContent(
|
||||
selection.itemId.takeIf { it != 0L }?.let {
|
||||
@@ -92,6 +96,8 @@ internal fun PipelineDestination(
|
||||
)
|
||||
},
|
||||
covered = covered,
|
||||
attention = attention,
|
||||
onOpenAttention = onOpenAttention,
|
||||
)
|
||||
}
|
||||
2 -> rememberPaneContent(
|
||||
|
||||
@@ -58,7 +58,6 @@ import net.awan.pipelines.data.transport.ConnectionState
|
||||
import net.awan.pipelines.notify.NOTIFICATION_RATIONALE
|
||||
import net.awan.pipelines.notify.alertPermissionPrompt
|
||||
import net.awan.pipelines.ui.chat.ChatScreen
|
||||
import net.awan.pipelines.ui.components.AttentionIndicator
|
||||
import net.awan.pipelines.ui.components.AttentionSheet
|
||||
import net.awan.pipelines.ui.components.BottomStripInset
|
||||
import net.awan.pipelines.ui.components.ConnectionBanner
|
||||
@@ -67,10 +66,8 @@ import net.awan.pipelines.ui.components.LocalPillBottomInset
|
||||
import net.awan.pipelines.ui.components.MotionStandard
|
||||
import net.awan.pipelines.ui.components.paneSafeArea
|
||||
import net.awan.pipelines.ui.components.spec
|
||||
import net.awan.pipelines.ui.theme.ATTENTION_CHIP_RESERVE
|
||||
import net.awan.pipelines.ui.theme.DESTINATION_PILL_RESERVE
|
||||
import net.awan.pipelines.ui.theme.SPACING_L
|
||||
import net.awan.pipelines.ui.theme.SPACING_S
|
||||
|
||||
/** One destination the floating pill holds: its nav [route], the accessible [label] and its glyph. */
|
||||
internal data class TopDestination(val route: String, val label: String, val icon: ImageVector)
|
||||
@@ -339,6 +336,8 @@ fun PipelinesApp(
|
||||
selection = pipelineSelection,
|
||||
onSelectionChange = { pipelineSelection = it },
|
||||
listState = pipelineListState,
|
||||
attention = attention,
|
||||
onOpenAttention = { attentionOpen = true },
|
||||
onOpenRun = { runId ->
|
||||
runSelection = PaneSelection(
|
||||
pane = MasterPane.Detail,
|
||||
@@ -359,6 +358,8 @@ fun PipelinesApp(
|
||||
listState = runListState,
|
||||
decisionRequest = decisionRequest,
|
||||
onDecisionRequestHandled = { decisionRequest = null },
|
||||
attention = attention,
|
||||
onOpenAttention = { attentionOpen = true },
|
||||
)
|
||||
}
|
||||
composable("chat") {
|
||||
@@ -389,7 +390,7 @@ fun PipelinesApp(
|
||||
// Composed after the NavHost, so while the field is open Back (button
|
||||
// or gesture) dismisses the morph before any pane's own Back handler.
|
||||
BackHandler(enabled = searchState.open) { dismissSearch() }
|
||||
// The results panel, the attention chip and the destination bar share
|
||||
// The results panel and destination bar share
|
||||
// one bottom-anchored, inset-clearing column — the overlay layer, drawn
|
||||
// above the content and never part of its layout. `paneSafeArea`
|
||||
// (WindowInsets.safeDrawing) is applied once here, so the pill clears the
|
||||
@@ -403,8 +404,7 @@ fun PipelinesApp(
|
||||
// The overlay's resting place is the window width's in [destinationPillAlignment]:
|
||||
// horizontally centred on a narrow window, anchored to the bottom-right
|
||||
// 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
|
||||
// attention chip above it keeps its own bottom-right place at every width.
|
||||
// corner placement adds no new number.
|
||||
// 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(
|
||||
@@ -432,15 +432,6 @@ fun PipelinesApp(
|
||||
.padding(bottom = SPACING_L),
|
||||
)
|
||||
}
|
||||
// The attention chip is not part of the pill's placement rule: it
|
||||
// keeps its own bottom-right resting place at every width (as it
|
||||
// had before the pill became width-dependent), so only the pill
|
||||
// follows [destinationPillAlignment].
|
||||
AttentionIndicator(
|
||||
entries = attention,
|
||||
onClick = { attentionOpen = true },
|
||||
modifier = Modifier.align(Alignment.End).padding(bottom = SPACING_S),
|
||||
)
|
||||
// The pill stands down while a conversation or run detail is open;
|
||||
// the search field it morphs into is unreachable there anyway (the
|
||||
// field opens from the pill), so nothing is stranded by not drawing it.
|
||||
@@ -528,8 +519,8 @@ internal fun destinationPillVisible(
|
||||
): Boolean = !(currentRoute == CHAT_ROUTE && conversationOpen) && !runDetailOpen
|
||||
|
||||
/**
|
||||
* Where the bottom overlay — the destination pill and the attention chip above it
|
||||
* — rests in the window: horizontally centred on a **narrow** window and anchored
|
||||
* Where the bottom destination pill rests in the window: horizontally centred on a
|
||||
* **narrow** window and anchored
|
||||
* to the bottom-right **corner** on a **wide** one. The overlay is drawn above the
|
||||
* content and never takes layout space either way, so this is purely where it
|
||||
* sits. A pure function of the window width, so the one arrangement rule is
|
||||
@@ -552,8 +543,7 @@ internal fun contentPillPadding(pillVisible: Boolean): Dp = 0.dp
|
||||
|
||||
/**
|
||||
* The trailing bottom space a scrollable screen keeps so its last row scrolls clear
|
||||
* of the floating bottom stack — the destination pill and the attention chip above
|
||||
* it — built from the named [DESTINATION_PILL_RESERVE] and [ATTENTION_CHIP_RESERVE]
|
||||
* of the floating destination pill, built from the named [DESTINATION_PILL_RESERVE]
|
||||
* while the pill is drawn, and none while it is hidden (an open conversation or a
|
||||
* run detail, see [destinationPillVisible]) so a hidden pill
|
||||
* leaves no empty band at the end of a list. Published to the content through
|
||||
@@ -565,7 +555,7 @@ internal fun contentPillPadding(pillVisible: Boolean): Dp = 0.dp
|
||||
* the pill appears and disappears.
|
||||
*/
|
||||
internal fun pillScrollInset(pillVisible: Boolean): Dp =
|
||||
if (pillVisible) DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE else 0.dp
|
||||
if (pillVisible) DESTINATION_PILL_RESERVE else 0.dp
|
||||
|
||||
/**
|
||||
* How far above the window's bottom the floating pill rests: its own [SPACING_L]
|
||||
|
||||
@@ -34,6 +34,8 @@ internal fun RunsDestination(
|
||||
listState: LazyListState,
|
||||
decisionRequest: Long? = null,
|
||||
onDecisionRequestHandled: () -> Unit = {},
|
||||
attention: List<AttentionEntry>,
|
||||
onOpenAttention: () -> Unit,
|
||||
) {
|
||||
val depth = selection.depth
|
||||
val onBack: () -> Unit = { onSelectionChange(backFrom(selection)) }
|
||||
@@ -83,6 +85,8 @@ internal fun RunsDestination(
|
||||
covered = covered,
|
||||
wide = wide,
|
||||
listState = listState,
|
||||
attention = attention,
|
||||
onOpenAttention = onOpenAttention,
|
||||
)
|
||||
1 -> rememberPaneContent(
|
||||
selection.itemId.takeIf { it != 0L }?.let { it to selection.sectionIndex },
|
||||
@@ -103,6 +107,8 @@ internal fun RunsDestination(
|
||||
covered = covered,
|
||||
requestDecision = decisionRequest == itemId,
|
||||
onDecisionRequestHandled = onDecisionRequestHandled,
|
||||
attention = attention,
|
||||
onOpenAttention = onOpenAttention,
|
||||
)
|
||||
}
|
||||
2 -> rememberPaneContent(
|
||||
|
||||
@@ -6,10 +6,11 @@ import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Close
|
||||
import androidx.compose.material.icons.filled.NotificationsActive
|
||||
import androidx.compose.material3.Badge
|
||||
import androidx.compose.material3.BadgedBox
|
||||
import androidx.compose.material3.ExperimentalMaterial3Api
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
@@ -23,10 +24,8 @@ import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import net.awan.pipelines.ui.AttentionEntry
|
||||
import net.awan.pipelines.ui.AttentionKind
|
||||
import net.awan.pipelines.ui.attentionHeadline
|
||||
import net.awan.pipelines.ui.theme.ICON_INLINE_DP
|
||||
import net.awan.pipelines.ui.theme.SPACING_L
|
||||
import net.awan.pipelines.ui.theme.SPACING_M
|
||||
@@ -49,43 +48,22 @@ internal fun attentionRunState(kind: AttentionKind): RunState = when (kind) {
|
||||
AttentionKind.Failed -> RunState.Failed
|
||||
}
|
||||
|
||||
/**
|
||||
* The floating indicator: the count and the most important item, tappable to open
|
||||
* the list. Hidden (draws nothing) when [entries] is empty, so it never becomes a
|
||||
* permanent chrome element.
|
||||
*/
|
||||
/** The notifications action shared by the main and detail app bars. */
|
||||
@Composable
|
||||
fun AttentionIndicator(
|
||||
fun AttentionAction(
|
||||
entries: List<AttentionEntry>,
|
||||
onClick: () -> Unit,
|
||||
modifier: Modifier = Modifier,
|
||||
) {
|
||||
if (entries.isEmpty()) return
|
||||
val scheme = MaterialTheme.colorScheme
|
||||
Surface(
|
||||
onClick = onClick,
|
||||
modifier = modifier,
|
||||
shape = RoundedCornerShape(50),
|
||||
color = scheme.errorContainer,
|
||||
contentColor = scheme.onErrorContainer,
|
||||
shadowElevation = 6.dp,
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier.padding(horizontal = SPACING_M, vertical = SPACING_S),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(SPACING_S),
|
||||
) {
|
||||
IconButton(onClick = onClick) {
|
||||
BadgedBox(badge = {
|
||||
if (entries.isNotEmpty()) Badge { Text(entries.size.toString()) }
|
||||
}) {
|
||||
Icon(
|
||||
imageVector = Icons.Default.NotificationsActive,
|
||||
contentDescription = null,
|
||||
contentDescription = if (entries.isEmpty()) "Notifications" else
|
||||
"Notifications, ${entries.size} needing attention",
|
||||
modifier = Modifier.size(ICON_INLINE_DP),
|
||||
)
|
||||
Text(
|
||||
text = attentionHeadline(entries),
|
||||
style = MaterialTheme.typography.labelLarge,
|
||||
maxLines = 1,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,8 @@ import net.awan.pipelines.ui.theme.SPACING_L
|
||||
import net.awan.pipelines.ui.theme.SPACING_M
|
||||
import net.awan.pipelines.ui.theme.SPACING_S
|
||||
import net.awan.pipelines.ui.theme.SPACING_XS
|
||||
import net.awan.pipelines.ui.AttentionEntry
|
||||
import net.awan.pipelines.ui.components.AttentionAction
|
||||
import net.awan.pipelines.ui.theme.pipelinesText
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -79,6 +81,8 @@ fun PipelineDetailScreen(
|
||||
modifier: Modifier = Modifier,
|
||||
wide: Boolean = false,
|
||||
covered: Boolean = false,
|
||||
attention: List<AttentionEntry> = emptyList(),
|
||||
onOpenAttention: () -> Unit = {},
|
||||
) {
|
||||
val state by vm.pipelineDetail.collectAsStateWithLifecycle()
|
||||
val runsState by vm.runs.collectAsStateWithLifecycle()
|
||||
@@ -124,6 +128,7 @@ fun PipelineDetailScreen(
|
||||
},
|
||||
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||
actions = {
|
||||
AttentionAction(attention, onOpenAttention)
|
||||
IconButton(onClick = { vm.loadPipeline(pipelineId, version) }) {
|
||||
Icon(Icons.Default.Refresh, contentDescription = "Refresh pipeline")
|
||||
}
|
||||
|
||||
@@ -37,6 +37,8 @@ import java.time.OffsetDateTime
|
||||
import java.time.ZoneId
|
||||
import net.awan.pipelines.data.protocol.PipelineSummary
|
||||
import net.awan.pipelines.ui.AppViewModel
|
||||
import net.awan.pipelines.ui.AttentionEntry
|
||||
import net.awan.pipelines.ui.components.AttentionAction
|
||||
import net.awan.pipelines.ui.components.DetailTabBody
|
||||
import net.awan.pipelines.ui.components.EmptyState
|
||||
import net.awan.pipelines.ui.components.ErrorState
|
||||
@@ -74,6 +76,8 @@ fun PipelineListScreen(
|
||||
covered: Boolean = false,
|
||||
wide: Boolean = false,
|
||||
listState: LazyListState,
|
||||
attention: List<AttentionEntry> = emptyList(),
|
||||
onOpenAttention: () -> Unit = {},
|
||||
) {
|
||||
val state by vm.pipelines.collectAsStateWithLifecycle()
|
||||
val runsState by vm.runs.collectAsStateWithLifecycle()
|
||||
@@ -151,6 +155,7 @@ fun PipelineListScreen(
|
||||
title = { Text("Pipelines") },
|
||||
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||
actions = {
|
||||
AttentionAction(attention, onOpenAttention)
|
||||
PipelineFilterControl(
|
||||
filters = filters,
|
||||
onName = { vm.setPipelineFilterName(it) },
|
||||
|
||||
@@ -53,6 +53,8 @@ import net.awan.pipelines.ui.runIdentity
|
||||
import net.awan.pipelines.ui.runLabel
|
||||
import net.awan.pipelines.ui.theme.SPACING_L
|
||||
import net.awan.pipelines.ui.theme.SPACING_S
|
||||
import net.awan.pipelines.ui.AttentionEntry
|
||||
import net.awan.pipelines.ui.components.AttentionAction
|
||||
import net.awan.pipelines.ui.theme.pipelinesText
|
||||
|
||||
@OptIn(ExperimentalMaterial3Api::class)
|
||||
@@ -69,6 +71,8 @@ fun RunDetailScreen(
|
||||
covered: Boolean = false,
|
||||
requestDecision: Boolean = false,
|
||||
onDecisionRequestHandled: () -> Unit = {},
|
||||
attention: List<AttentionEntry> = emptyList(),
|
||||
onOpenAttention: () -> Unit = {},
|
||||
) {
|
||||
val state by vm.runDetail.collectAsStateWithLifecycle()
|
||||
val runsState by vm.runs.collectAsStateWithLifecycle()
|
||||
@@ -183,6 +187,7 @@ fun RunDetailScreen(
|
||||
},
|
||||
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||
actions = {
|
||||
AttentionAction(attention, onOpenAttention)
|
||||
LiveBadge(runStream, Modifier.padding(end = SPACING_S))
|
||||
IconButton(onClick = { vm.loadRun(runId) }) {
|
||||
Icon(Icons.Default.Refresh, contentDescription = "Refresh run")
|
||||
|
||||
@@ -48,6 +48,8 @@ import java.time.format.DateTimeFormatter
|
||||
import net.awan.pipelines.data.protocol.RunSummary
|
||||
import net.awan.pipelines.data.protocol.UsageStats
|
||||
import net.awan.pipelines.ui.AppViewModel
|
||||
import net.awan.pipelines.ui.AttentionEntry
|
||||
import net.awan.pipelines.ui.components.AttentionAction
|
||||
import net.awan.pipelines.ui.components.DetailTabBody
|
||||
import net.awan.pipelines.ui.components.EmptyState
|
||||
import net.awan.pipelines.ui.components.ErrorState
|
||||
@@ -98,6 +100,8 @@ fun RunHistoryScreen(
|
||||
covered: Boolean = false,
|
||||
wide: Boolean = false,
|
||||
listState: LazyListState,
|
||||
attention: List<AttentionEntry> = emptyList(),
|
||||
onOpenAttention: () -> Unit = {},
|
||||
) {
|
||||
val state by vm.runs.collectAsStateWithLifecycle()
|
||||
val runStream by vm.runStream.collectAsStateWithLifecycle()
|
||||
@@ -153,6 +157,7 @@ fun RunHistoryScreen(
|
||||
title = { Text(if (filterPipelineId == null) "Runs" else "Runs for this pipeline") },
|
||||
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
|
||||
actions = {
|
||||
AttentionAction(attention, onOpenAttention)
|
||||
RunFilterControl(
|
||||
filters = filters,
|
||||
pipelines = pipelineOptions,
|
||||
|
||||
@@ -84,16 +84,6 @@ internal val MIN_COVERED_PANE_WIDTH_DP = 112.dp
|
||||
*/
|
||||
internal val DESTINATION_PILL_RESERVE = 88.dp
|
||||
|
||||
/**
|
||||
* Bottom space the floating attention chip occupies above the destination pill:
|
||||
* the chip's own height (its single label line plus its vertical padding) plus the
|
||||
* gap below it. Added to a scrollable's trailing space alongside
|
||||
* [DESTINATION_PILL_RESERVE] while the pill is drawn, so the chip can never be laid
|
||||
* out over a row, a field or a button and the content does not jump as it appears
|
||||
* and clears.
|
||||
*/
|
||||
internal val ATTENTION_CHIP_RESERVE = SPACING_XXL + SPACING_M
|
||||
|
||||
// ---- Detail rail and max content width (ui/components/DetailTabs.kt) -------
|
||||
|
||||
/** The always-visible wide section rail's width (icons with labels). */
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.awan.pipelines.ui
|
||||
import androidx.compose.ui.Alignment
|
||||
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.DESTINATION_PILL_RESERVE
|
||||
import net.awan.pipelines.ui.theme.SPACING_L
|
||||
import org.junit.Assert.assertEquals
|
||||
@@ -133,11 +132,11 @@ class PipelinesNavTest {
|
||||
|
||||
@Test
|
||||
fun theScrollInsetTracksTheDrawnPillSoAListNeitherJumpsNorHidesItsLastRow() {
|
||||
// Drawn: a scrollable keeps the named pill + attention-chip space at the
|
||||
// end of its own scroll content and its last row scrolls clear of the whole
|
||||
// floating bottom stack. Hidden: no clearance, so there is no empty band
|
||||
// Drawn: a scrollable keeps the named pill space at the end of its own
|
||||
// scroll content and its last row scrolls clear of the floating pill. Hidden: no clearance,
|
||||
// so there is no empty band
|
||||
// where the pill used to be.
|
||||
val drawnInset = DESTINATION_PILL_RESERVE + ATTENTION_CHIP_RESERVE
|
||||
val drawnInset = DESTINATION_PILL_RESERVE
|
||||
assertDp(drawnInset.value, pillScrollInset(pillVisible = true))
|
||||
assertDp(0f, pillScrollInset(pillVisible = false))
|
||||
// One predicate drives both the drawing and the clearance, so the space can
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Action-bar notification access
|
||||
|
||||
The in-app attention entry point moved from the floating bottom indicator into the
|
||||
existing main/detail app bars. The action remains present when the destination pill
|
||||
is hidden, and its badge uses the existing attention list count; the attention sheet
|
||||
and permission behavior are unchanged.
|
||||
|
||||
The packaged OpenCode skill references that describe the old floating attention
|
||||
indicator may be stale. The manual `docs-fold` pipeline should fold this note into
|
||||
the shared documentation and references; this item does not edit those shared files.
|
||||
Reference in New Issue
Block a user