Keep every pane inside the Android safe area

The stage detail pane covered the status bar. Introduce one shared
paneSafeArea() (WindowInsets.safeDrawing: status bar, display cutout,
navigation bar, gesture area and IME) and apply it from the live window
insets across the pane stack:

- SlidingPaneStack uses it (unioned with systemGestures) for the covered
  peeks' strip geometry.
- Each pane's Scaffold reserves it once via contentWindowInsets, and its
  TopAppBar reserves the top/horizontal part, so no pane sits under the
  status bar, a cutout, the navigation bar or the IME. Applied to the five
  stacked panes and SettingsScreen.
- The connection banner owns the top inset and the NavHost consumes it
  (paneSafeArea().only(Top), was statusBars) so the inset is never doubled.
- The floating destinations pill clears the same safe area, so the keyboard
  no longer hides it.

Scrollable content stays inside the remaining space rather than clipping.
android/README.md records the design and emulator-5554 verification.
This commit is contained in:
2026-10-16 05:08:46 +01:00
parent 5ad4b58770
commit 6229fc9db5
10 changed files with 132 additions and 19 deletions
@@ -7,12 +7,12 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
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.navigationBars
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.foundation.selection.selectable
import androidx.compose.foundation.shape.CircleShape
@@ -48,6 +48,7 @@ import net.awan.pipelines.data.transport.ConnectionState
import net.awan.pipelines.ui.components.ConnectionBanner
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
@@ -116,11 +117,11 @@ fun PipelinesApp(vm: AppViewModel) {
//
// Exactly one layer owns the top inset. The outer Scaffold's content insets
// are zeroed so it no longer reserves the status bar on top of the inner
// screens' app bars (a Material 3 TopAppBar already applies the status-bar
// inset), which removed the duplicate top band. The bottom is owned by each
// screen's Scaffold, and the floating pill explicitly clears the navigation
// bar/gesture area via windowInsetsPadding. The Column reserves
// DESTINATION_PILL_RESERVE at the bottom so no scrollable content is
// screens' app bars (a Material 3 TopAppBar applies the top safe-area inset),
// which removed the duplicate top band. The bottom is owned by each screen's
// Scaffold, and the floating pill explicitly clears the safe area (system
// bars, cutout, gesture area and IME) via windowInsetsPadding. The Column
// reserves DESTINATION_PILL_RESERVE at the bottom so no scrollable content is
// permanently hidden behind the pill.
val bannerVisible = connectionState !is ConnectionState.Connected
Scaffold(contentWindowInsets = WindowInsets(0, 0, 0, 0)) { padding ->
@@ -140,7 +141,9 @@ fun PipelinesApp(vm: AppViewModel) {
.weight(1f)
.then(
if (bannerVisible) {
Modifier.consumeWindowInsets(WindowInsets.statusBars)
Modifier.consumeWindowInsets(
paneSafeArea().only(WindowInsetsSides.Top),
)
} else {
Modifier
},
@@ -178,7 +181,7 @@ fun PipelinesApp(vm: AppViewModel) {
onSelect = onNavigate,
modifier = Modifier
.align(Alignment.BottomEnd)
.windowInsetsPadding(WindowInsets.navigationBars)
.windowInsetsPadding(paneSafeArea())
.padding(end = 16.dp, bottom = 16.dp),
)
}
@@ -342,8 +345,8 @@ private fun RunsDestination(
/**
* 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 navigation bar/gesture area via windowInsetsPadding),
* each a 48dp touch
* 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.
@@ -2,10 +2,10 @@ package net.awan.pipelines.ui.components
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.statusBars
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
@@ -75,10 +75,12 @@ private fun Banner(
Surface(color = container, contentColor = contentColor, modifier = modifier.fillMaxWidth()) {
Row(
// The banner sits directly under the status bar (the outer Scaffold
// zeroes its content insets), so it owns the status-bar inset: the
// padding is inside the Surface so the banner colour covers the bar.
// zeroes its content insets), so it owns the top safe-area inset: the
// padding is inside the Surface so the banner colour covers the bar
// and any cutout, and the pane stack below consumes it so it is not
// applied a second time.
modifier = Modifier
.windowInsetsPadding(WindowInsets.statusBars)
.windowInsetsPadding(paneSafeArea().only(WindowInsetsSides.Top))
.padding(horizontal = 16.dp, vertical = 8.dp),
verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.spacedBy(12.dp),
@@ -14,7 +14,7 @@ import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.systemBars
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.systemGestures
import androidx.compose.foundation.layout.union
import androidx.compose.foundation.layout.width
@@ -176,6 +176,22 @@ internal fun peekStripsDp(
return strips
}
/**
* The one set of system insets every pane — and every overlay laid over a pane,
* such as the search field and its results panel — must clear: the status bar
* and any display cutout, the navigation bar and the IME
* ([WindowInsets.safeDrawing], read live from the window, never a fixed
* padding). A pane's [androidx.compose.material3.Scaffold] applies it to its
* content and its app bar applies its top/horizontal part, so a pane can never
* sit under the status bar, a cutout, the navigation bar or the keyboard.
*
* It is reserved exactly once: a parent that has already owned an inset (the
* connection banner owns the status bar while it is shown) consumes it, so the
* pane below it applies it once, never twice.
*/
@Composable
internal fun paneSafeArea(): WindowInsets = WindowInsets.safeDrawing
/**
* The one shared sliding pane stack, adaptive to the window width. Both the
* Pipelines and Runs destinations use it, so the motion and geometry live in
@@ -230,7 +246,7 @@ fun SlidingPaneStack(
// the strip node's geometry (not via a padding modifier, which would
// shrink the pointer node to nothing once the gesture insets are wide).
val hostWidth = maxWidth
val insetPadding = WindowInsets.systemBars.union(WindowInsets.systemGestures)
val insetPadding = paneSafeArea().union(WindowInsets.systemGestures)
.asPaddingValues()
val direction = LocalLayoutDirection.current
val startInset = insetPadding.calculateLeftPadding(direction)
@@ -2,8 +2,10 @@ package net.awan.pipelines.ui.graph
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
@@ -46,6 +48,7 @@ import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.SectionExpansionState
import net.awan.pipelines.ui.components.SectionHeader
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.rememberSectionExpansion
import net.awan.pipelines.ui.displayMap
import net.awan.pipelines.ui.fileChangeLine
@@ -334,6 +337,7 @@ fun StageDetailPane(
Scaffold(
modifier = modifier,
containerColor = paneContainerColor(),
contentWindowInsets = paneSafeArea(),
topBar = {
TopAppBar(
title = { Text(GraphSemantics.nodeLabel(stageKey)) },
@@ -342,6 +346,7 @@ fun StageDetailPane(
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
}
},
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
colors = TopAppBarDefaults.topAppBarColors(containerColor = paneContainerColor()),
)
},
@@ -5,8 +5,10 @@ import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
@@ -54,6 +56,7 @@ import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.collapsibleSection
import net.awan.pipelines.ui.components.pipelineDetailTabs
import net.awan.pipelines.ui.components.rememberSectionExpansion
@@ -98,6 +101,7 @@ fun PipelineDetailScreen(
Scaffold(
modifier = modifier,
contentWindowInsets = paneSafeArea(),
topBar = {
TopAppBar(
title = { Text(detail?.name ?: "Pipeline") },
@@ -106,6 +110,7 @@ fun PipelineDetailScreen(
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
}
},
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
actions = {
IconButton(onClick = { vm.loadPipeline(pipelineId, version) }) {
Icon(Icons.Default.Refresh, contentDescription = "Refresh pipeline")
@@ -2,8 +2,10 @@ package net.awan.pipelines.ui.screens
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
@@ -36,6 +38,7 @@ import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.ListRow
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.theme.pipelinesText
@OptIn(ExperimentalMaterial3Api::class)
@@ -66,9 +69,11 @@ fun PipelineListScreen(
Scaffold(
modifier = modifier,
contentWindowInsets = paneSafeArea(),
topBar = {
TopAppBar(
title = { Text("Pipelines") },
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
actions = {
IconButton(onClick = vm::refreshPipelines) {
Icon(Icons.Default.Refresh, contentDescription = "Refresh pipelines")
@@ -6,8 +6,10 @@ import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
@@ -57,6 +59,7 @@ import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.KeyValueRow
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.RunStatusIcon
import net.awan.pipelines.ui.components.StatusChip
import net.awan.pipelines.ui.components.collapsibleSection
@@ -126,6 +129,7 @@ fun RunDetailScreen(
Scaffold(
modifier = modifier,
contentWindowInsets = paneSafeArea(),
topBar = {
TopAppBar(
title = { Text(run?.let { "Run ${it.id}" } ?: "Run") },
@@ -134,6 +138,7 @@ fun RunDetailScreen(
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = "Back")
}
},
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
actions = {
IconButton(onClick = { vm.loadRun(runId) }) {
Icon(Icons.Default.Refresh, contentDescription = "Refresh run")
@@ -8,8 +8,10 @@ import androidx.compose.foundation.layout.ExperimentalLayoutApi
import androidx.compose.foundation.layout.FlowRow
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.lazy.LazyColumn
@@ -51,6 +53,7 @@ import net.awan.pipelines.ui.components.ErrorState
import net.awan.pipelines.ui.components.ListRow
import net.awan.pipelines.ui.components.LoadingState
import net.awan.pipelines.ui.components.PaneIdentity
import net.awan.pipelines.ui.components.paneSafeArea
import net.awan.pipelines.ui.components.runStateColor
import net.awan.pipelines.ui.components.runStateOf
import net.awan.pipelines.ui.formatDuration
@@ -85,9 +88,11 @@ fun RunHistoryScreen(
Scaffold(
modifier = modifier,
contentWindowInsets = paneSafeArea(),
topBar = {
TopAppBar(
title = { Text(if (filterPipelineId == null) "Runs" else "Runs for this pipeline") },
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
actions = {
IconButton(onClick = vm::refreshRuns) {
Icon(Icons.Default.Refresh, contentDescription = "Refresh runs")
@@ -3,8 +3,10 @@ package net.awan.pipelines.ui.screens
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.only
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.text.KeyboardOptions
@@ -28,6 +30,7 @@ import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import net.awan.pipelines.data.transport.ConnectionState
import net.awan.pipelines.ui.AppViewModel
import net.awan.pipelines.ui.components.paneSafeArea
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@@ -43,7 +46,13 @@ fun SettingsScreen(vm: AppViewModel, modifier: Modifier = Modifier) {
Scaffold(
modifier = modifier,
topBar = { TopAppBar(title = { Text("Settings") }) },
contentWindowInsets = paneSafeArea(),
topBar = {
TopAppBar(
title = { Text("Settings") },
windowInsets = paneSafeArea().only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
)
},
) { padding ->
SettingsContent(
padding = Modifier.padding(padding),