fix(app): float content behind top bars and give each wide pane its own bar row

- Top-bar clearance helpers (withTopBarClearance, withBarClearance,
  SliverTopBarClearance, BelowTopBar, TopBarNotices); shell, DetailPane and
  the runs/pipelines/templates/artifacts/stage definition/filter/usage pages
  drop their top SafeArea and pad their own lists, pinned headers pin at the
  inset.
- Wide windows: the shell bar narrows to the list pane (ShellPaneSplit) and
  the open item's bar shares its row; item tabs float at the pane's top
  (PageTabsEdge) instead of stacking on the shell's tab bar; the floating
  tab pill no longer swells over leftover media padding.
- Pipeline detail is a DetailPane on wide too; Run/Runs move from FABs into
  the bar's actions; name and identity live in the title pill.
- Run detail title pill shows the real title with Run N, pipeline and
  version (the pill links to the pipeline); the body keeps only status,
  actions and notices; standalone detail draws the same segmented bar.
- One Runs tab badge: attention outranks running.
- Tests for content-behind-bar padding and the no-stacking wide layout;
  notes/app-chrome-fixes.md.
This commit is contained in:
2026-10-31 03:36:22 +00:00
parent ea0f22dfc7
commit c6c6dcfe18
49 changed files with 1791 additions and 693 deletions
+7 -3
View File
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import '../features/chat/screen.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'server_endpoint.dart';
@@ -49,12 +50,15 @@ class ChatDestination extends StatelessWidget {
cupertino: cupertino,
);
}
return Column(
children: [
// The banner stays below the top bar; without it the chat screen
// reaches the top edge (an open chat beside the list draws its own bar
// there).
return TopBarNotices(
notices: [
if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino),
Expanded(child: _chatScreen()),
],
child: _chatScreen(),
);
},
);
@@ -3,6 +3,7 @@ import '../core/servers/server_scope.dart';
import '../features/pipelines/screen.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'server_endpoint.dart';
@@ -72,12 +73,14 @@ class PipelinesDestination extends StatelessWidget {
cupertino: cupertino,
);
}
return Column(
children: [
// The banner stays below the top bar; without it the pipelines reach
// the top edge and scroll behind the bar.
return TopBarNotices(
notices: [
if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino),
Expanded(child: _pipelinesScreen()),
],
child: _pipelinesScreen(),
);
},
);
+6 -3
View File
@@ -5,6 +5,7 @@ import '../features/attention/runtime/attention_controller.dart';
import '../features/runs/screen.dart';
import '../features/runs/ui/run_pipeline_link.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'server_endpoint.dart';
@@ -85,13 +86,15 @@ class RunsDestination extends StatelessWidget {
cupertino: cupertino,
);
}
return Column(
children: [
// The banner stays below the top bar; without it the runs reach the top
// edge and scroll behind the bar.
return TopBarNotices(
notices: [
if (!session.connected ||
session.subscription == RunSubscriptionState.refused)
ConnectionBanner(session: session, cupertino: cupertino),
Expanded(child: _runsScreen()),
],
child: _runsScreen(),
);
},
);
+84 -46
View File
@@ -4,7 +4,11 @@ import 'package:flutter/material.dart';
import '../ui/adaptive/segmented_bar.dart';
import '../core/api_gateway.dart';
import '../features/templates/screen.dart';
import '../shell/destination.dart';
import '../shell/shell_bar.dart';
import '../ui/adaptive/host.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart';
import 'connection_status.dart';
import 'server_endpoint.dart';
@@ -57,32 +61,33 @@ class TemplatesDestination extends StatelessWidget {
Widget _body(bool cupertino) {
if (!session.everConnected) {
return ConnectionGate(
session: session,
server: server,
cupertino: cupertino,
return BelowTopBar(
child: ConnectionGate(
session: session,
server: server,
cupertino: cupertino,
),
);
}
return Column(
children: [
return TopBarNotices(
notices: [
if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino),
Expanded(
child: TemplatesScreen(
gateway: session.gateway,
embedded: true,
onCreated: onCreated,
initialKey: initialKey,
),
),
],
child: TemplatesScreen(
gateway: session.gateway,
embedded: true,
onCreated: onCreated,
initialKey: initialKey,
),
);
}
}
/// The page's standard native bar. Back is named explicitly so it cannot be
/// confused with the gallery's own Back-to-gallery control.
class _TemplatesPage extends StatelessWidget {
/// confused with the gallery's own Back-to-gallery control. The gallery puts
/// Refresh in this bar ([ShellBar]); its content scrolls behind the bar.
class _TemplatesPage extends StatefulWidget {
const _TemplatesPage({
required this.cupertino,
required this.onBack,
@@ -93,39 +98,72 @@ class _TemplatesPage extends StatelessWidget {
final VoidCallback onBack;
final Widget child;
@override
State<_TemplatesPage> createState() => _TemplatesPageState();
}
class _TemplatesPageState extends State<_TemplatesPage> {
final ShellBarRegistry _bar = ShellBarRegistry();
@override
void dispose() {
_bar.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
leading: CupertinoButton(
key: templatesPageBackKey,
padding: EdgeInsets.zero,
onPressed: onBack,
child: const Icon(
CupertinoIcons.back,
semanticLabel: 'Back to Settings',
),
),
title: 'Templates',
),
child: SafeArea(child: child),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
cupertino: false,
leading: IconButton(
key: templatesPageBackKey,
tooltip: 'Back to Settings',
onPressed: onBack,
icon: const Icon(Icons.arrow_back),
),
title: 'Templates',
final cupertino = widget.cupertino;
// The page reaches its top edge; the gallery pads its lists by the bar.
final body = SafeArea(
top: false,
bottom: false,
child: ShellBarScope(
registry: _bar,
destination: AppDestination.settings,
child: widget.child,
),
body: SafeArea(child: child),
);
return ListenableBuilder(
listenable: _bar,
builder: (context, _) {
final actions =
_bar.specFor(AppDestination.settings)?.actions ?? const <Widget>[];
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: SegmentedBar(
cupertino: true,
leading: CupertinoButton(
key: templatesPageBackKey,
padding: EdgeInsets.zero,
onPressed: widget.onBack,
child: const Icon(
CupertinoIcons.back,
semanticLabel: 'Back to Settings',
),
),
title: 'Templates',
actions: actions,
),
child: body,
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(
cupertino: false,
leading: IconButton(
key: templatesPageBackKey,
tooltip: 'Back to Settings',
onPressed: widget.onBack,
icon: const Icon(Icons.arrow_back),
),
title: 'Templates',
actions: actions,
),
body: body,
);
},
);
}
}
@@ -403,13 +403,13 @@ class _ArtifactGalleryPageState extends State<ArtifactGalleryPage> {
cupertino: true,
title: artifactGalleryTitle,
),
child: SafeArea(child: body),
child: SafeArea(top: false, bottom: false, child: body),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: const SegmentedBar(cupertino: false, title: artifactGalleryTitle),
body: SafeArea(child: body),
body: SafeArea(top: false, bottom: false, child: body),
);
}
}
@@ -142,9 +142,15 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
);
}
}
// Clear of a floating tab bar when the gallery is a tab.
// Below the top bar (or a pane's top tabs) at rest and behind it when
// scrolled; pinned headers pin under it. Clear of a floating tab bar at
// the end.
return CustomScrollView(
slivers: [...slivers, const SliverFloatingBarClearance()],
slivers: [
const SliverTopBarClearance(),
...slivers,
const SliverFloatingBarClearance(),
],
);
}
+14 -9
View File
@@ -1,6 +1,7 @@
import '../../shell/destination.dart';
import '../../shell/detail_page.dart';
import '../../shell/list_detail.dart';
import '../../ui/adaptive/floating_bar_layout.dart';
import '../../ui/adaptive/host.dart';
import 'dart:async';
@@ -241,15 +242,19 @@ class _ChatScreenState extends State<ChatScreen> {
? const SizedBox.shrink()
: _thread(selected, () => Navigator.of(context).maybePop()),
);
final list = ChatSessionsScreen(
gateway: widget.gateway,
embedded: true,
syncToken: widget.syncToken,
controller: _sessions,
onOpen: _open,
onSessions: _adoptRows,
activeSessionId: selected,
publishShellBar: true,
// The shell's body now reaches the top edge; until the session list pads
// itself by the bar (owned by the chat lane), it keeps starting below it.
final list = BelowTopBar(
child: ChatSessionsScreen(
gateway: widget.gateway,
embedded: true,
syncToken: widget.syncToken,
controller: _sessions,
onOpen: _open,
onSessions: _adoptRows,
activeSessionId: selected,
publishShellBar: true,
),
);
if (!beside) return list;
return ListDetailPanes(
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import '../../../ui/text/markdown_source_view.dart';
import '../../chat/ui/transcript/chat_markdown_view.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/graph_protocol.dart';
import '../domain/stage_definition.dart';
@@ -42,6 +43,7 @@ class StageDefinitionView extends StatefulWidget {
required this.pipelineId,
required this.pipelineName,
required this.version,
this.showIdentity = true,
});
final JsonMap graph;
@@ -50,16 +52,24 @@ class StageDefinitionView extends StatefulWidget {
final String pipelineName;
final int version;
/// Whether the view starts with its pipeline and version. The page leaves
/// it out: its top bar shows them under the title.
final bool showIdentity;
@override
State<StageDefinitionView> createState() => _StageDefinitionViewState();
}
/// The pinned pipeline a definition belongs to (`Demo pipeline \u00b7 v7`).
String stageDefinitionIdentity(String pipelineName, int version) =>
'${pipelineName.isEmpty ? 'Pipeline' : pipelineName} \u00b7 v$version';
class _StageDefinitionViewState extends State<StageDefinitionView> {
// One switch for every authored text block; raw is the exact text.
bool _raw = true;
String get _identity =>
'${widget.pipelineName.isEmpty ? 'Pipeline' : widget.pipelineName} \u00b7 v${widget.version}';
stageDefinitionIdentity(widget.pipelineName, widget.version);
@override
Widget build(BuildContext context) {
@@ -74,11 +84,14 @@ class _StageDefinitionViewState extends State<StageDefinitionView> {
? terminalDefinitionFields(graph, stageKey)
: const <StageDefinitionField>[];
// Scrolls behind the page's floating top bar; at rest it starts below it.
return ListView(
padding: const EdgeInsets.all(16),
padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [
Text(_identity, style: style.muted),
const SizedBox(height: 16),
if (widget.showIdentity) ...[
Text(_identity, style: style.muted),
const SizedBox(height: 16),
],
if (fields.any((field) => field.block)) ...[
MarkdownModeSwitch(
raw: _raw,
@@ -131,7 +144,9 @@ Future<void> openStageDefinition(
pipelineId: pipelineId,
pipelineName: pipelineName,
version: version,
showIdentity: false,
);
final identity = stageDefinitionIdentity(pipelineName, version);
final settings = RouteSettings(
name: 'stage-definition/$pipelineId/$version/$stageKey',
);
@@ -142,16 +157,24 @@ Future<void> openStageDefinition(
? CupertinoPageRoute<void>(
settings: settings,
builder: (_) => CupertinoPageScaffold(
navigationBar: SegmentedBar(cupertino: true, title: title),
child: SafeArea(child: view),
navigationBar: SegmentedBar(
cupertino: true,
title: title,
subtitle: identity,
),
child: SafeArea(top: false, bottom: false, child: view),
),
)
: MaterialPageRoute<void>(
settings: settings,
builder: (_) => Scaffold(
extendBodyBehindAppBar: true,
appBar: SegmentedBar(cupertino: false, title: title),
body: SafeArea(child: view),
appBar: SegmentedBar(
cupertino: false,
title: title,
subtitle: identity,
),
body: SafeArea(top: false, bottom: false, child: view),
),
);
return Navigator.of(context).push(route);
+25 -28
View File
@@ -217,7 +217,20 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
final body = LayoutBuilder(
builder: (context, constraints) {
final wide = showsListBesideDetail(context);
// On a phone an open pipeline is its own page over the tabs.
// The open pipeline publishes its name, identity and Run/Runs to
// its own bar: a page over the tabs on a phone, a pane beside the
// list (on the shell bar's row) when wide.
Widget detail() => PipelineDetailPanel(
controller: _controller,
gateway: widget.gateway,
showBack: false,
onRunStarted: widget.onRunStarted,
onViewPipelineRuns: widget.onViewPipelineRuns,
stageKey: stageKey,
stagePipelineId: widget.initialPipelineId,
stageVersion: widget.initialVersion,
stageRequest: _stageRequest,
);
_page.sync(
context,
selected: _controller.hasSelection && !wide,
@@ -225,20 +238,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
onClosed: _controller.clearSelection,
builder: (context) => AnimatedBuilder(
animation: _controller,
builder: (context, _) => ShellBar(
title: _controller.detail?.displayName,
child: PipelineDetailPanel(
controller: _controller,
gateway: widget.gateway,
showBack: false,
onRunStarted: widget.onRunStarted,
onViewPipelineRuns: widget.onViewPipelineRuns,
stageKey: stageKey,
stagePipelineId: widget.initialPipelineId,
stageVersion: widget.initialVersion,
stageRequest: _stageRequest,
),
),
builder: (context, _) => detail(),
),
);
if (!wide) {
@@ -250,17 +250,14 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
list: ContentWidth(
child: PipelineListPanel(controller: _controller),
),
detail: PipelineDetailPanel(
controller: _controller,
gateway: widget.gateway,
showBack: false,
onRunStarted: widget.onRunStarted,
onViewPipelineRuns: widget.onViewPipelineRuns,
stageKey: stageKey,
stagePipelineId: widget.initialPipelineId,
stageVersion: widget.initialVersion,
stageRequest: _stageRequest,
),
detail: _controller.hasSelection
? DetailPane(
key: const ValueKey('pipeline-detail-pane'),
destination: AppDestination.pipelines,
implyBack: false,
builder: (_) => detail(),
)
: detail(),
);
},
);
@@ -362,7 +359,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
_refreshButton(context),
],
),
body: SafeArea(child: body),
body: SafeArea(top: false, child: body),
);
}
@@ -377,7 +374,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
_refreshButton(context),
],
),
child: SafeArea(child: body),
child: SafeArea(top: false, child: body),
);
}
}
@@ -24,11 +24,12 @@ class RunPipelineAction extends StatefulWidget {
required this.detail,
required this.gateway,
this.onRunStarted,
this.fab = false,
this.inBar = false,
});
/// A floating action button instead of an inline button.
final bool fab;
/// The compact icon-and-word button of a top bar's actions pill instead
/// of an inline button.
final bool inBar;
final PipelinesController controller;
final PipelineDetail detail;
@@ -169,8 +170,8 @@ class _RunPipelineActionState extends State<RunPipelineAction> {
@override
Widget build(BuildContext context) {
final label = const Text(runPipelineActionLabel);
if (widget.fab) {
return pipelineFab(
if (widget.inBar) {
return pipelineBarAction(
context,
key: runPipelineActionKey,
primary: true,
@@ -195,9 +196,10 @@ class _RunPipelineActionState extends State<RunPipelineAction> {
}
}
/// A floating action for a pipeline: Material's extended FAB, or on Cupertino
/// a filled pill with the same icon and word and a soft shadow.
Widget pipelineFab(
/// A pipeline action in its top bar's actions pill: the icon and word as one
/// compact button. The primary action (Run) is filled so it reads apart from
/// the plain ones around it.
Widget pipelineBarAction(
BuildContext context, {
required Key key,
required bool primary,
@@ -212,45 +214,39 @@ Widget pipelineFab(
children: [
Icon(cupertinoIcon, size: 18),
const SizedBox(width: 6),
Text(label),
Flexible(child: Text(label, maxLines: 1, softWrap: false)),
],
);
return DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(28),
boxShadow: const [
BoxShadow(
color: Color(0x33000000),
blurRadius: 8,
offset: Offset(0, 2),
),
],
),
child: primary
? CupertinoButton.filled(
key: key,
borderRadius: BorderRadius.circular(28),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
onPressed: onPressed,
child: content,
)
: CupertinoButton.tinted(
key: key,
borderRadius: BorderRadius.circular(28),
padding: const EdgeInsets.symmetric(horizontal: 20, vertical: 14),
onPressed: onPressed,
child: content,
),
);
const padding = EdgeInsets.symmetric(horizontal: 12, vertical: 6);
return primary
? CupertinoButton.filled(
key: key,
padding: padding,
minimumSize: Size.zero,
onPressed: onPressed,
child: content,
)
: CupertinoButton(
key: key,
padding: padding,
minimumSize: Size.zero,
onPressed: onPressed,
child: content,
);
}
final scheme = Theme.of(context).colorScheme;
return FloatingActionButton.extended(
key: key,
heroTag: key,
backgroundColor: primary ? null : scheme.secondaryContainer,
foregroundColor: primary ? null : scheme.onSecondaryContainer,
onPressed: onPressed,
icon: Icon(materialIcon),
label: Text(label),
);
final icon = Icon(materialIcon);
final text = Text(label, maxLines: 1, softWrap: false);
return primary
? FilledButton.icon(
key: key,
onPressed: onPressed,
icon: icon,
label: text,
)
: TextButton.icon(
key: key,
onPressed: onPressed,
icon: icon,
label: text,
);
}
@@ -4,10 +4,12 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../shell/shell_bar.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../graph/domain/graph_definition.dart';
import '../../graph/widgets/stage_definition_view.dart';
import '../pipeline_models.dart';
import '../pipeline_query.dart';
import '../pipelines_controller.dart';
import '../ui/run_pipeline_action.dart';
import 'pipeline_controls.dart';
@@ -95,18 +97,47 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
@override
Widget build(BuildContext context) {
final detail = _controller.detail;
if (detail == null) return _withoutDetail(context);
// In a page or pane the pipeline's name, identity and actions are its top
// bar's; on its own the panel heads itself.
final inBar = ShellBar.available(context);
if (detail == null) {
// Nothing selected is the bare placeholder beside the list; it must
// not take a bar over.
if (!_controller.hasSelection) return _withoutDetail(context);
return ShellBar(child: _withoutDetail(context));
}
_retainGraphSelection(detail);
_applyStageRequest(context, detail);
final notices = [
if (!inBar) _header(context, detail),
if (_controller.detailLoading)
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: PipelineProgress(label: 'Refreshing pipeline detail'),
),
if (_controller.detailError != null)
PipelineErrorBanner(
message: _controller.detailError!,
onRetry: _controller.retryDetail,
),
];
final panel = LayoutBuilder(
builder: (context, constraints) {
final headerLimit = _headerLimit(constraints);
// The tabs float over the bottom of the tab body, as in the run
// detail: full width on a phone, at the right edge of a wide pane.
// The tabs float over the tab body: at the bottom on a phone page,
// under the pane's top bar beside a list (never on the shell's bar).
final edge = PageTabsEdge.of(context);
final tabs = PipelineDetailTabs(
selected: _tab,
edge: edge,
onSelected: (tab) => setState(() => _tab = tab),
);
// With nothing above it the tab body reaches the top edge and scrolls
// behind the bar; notices stay below the bar and the body below them.
// The structure is the same either way, so a refresh never remounts
// the open tab.
final media = MediaQuery.of(context);
final inset = media.padding.top;
return Column(
key: const Key('pipeline-detail'),
crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -114,23 +145,10 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
ConstrainedBox(
constraints: BoxConstraints(maxHeight: headerLimit),
child: SingleChildScrollView(
padding: EdgeInsets.only(top: notices.isEmpty ? 0 : inset),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_header(context, detail),
if (_controller.detailLoading)
const Padding(
padding: EdgeInsets.symmetric(horizontal: 16),
child: PipelineProgress(
label: 'Refreshing pipeline detail',
),
),
if (_controller.detailError != null)
PipelineErrorBanner(
message: _controller.detailError!,
onRetry: _controller.retryDetail,
),
],
children: notices,
),
),
),
@@ -138,36 +156,35 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
// scroll their own content; the graph fills the slot so its canvas
// is never asked for an unbounded extent inside a scroll view.
Expanded(
child: FloatingBarOverlay(
bar: tabs,
child: Builder(
builder: (context) => Stack(
children: [
Positioned.fill(
child: switch (_tab) {
PipelineDetailTab.summary => _scrolling(
PipelineSummaryView(
controller: _controller,
detail: detail,
gateway: widget.gateway,
),
),
PipelineDetailTab.graph => PipelineGraphTab(
detail: detail,
selectedStage: _graphSelection,
onSelected: (stageKey) =>
_openGraphStage(context, detail, stageKey),
),
PipelineDetailTab.source => _source(context, detail),
},
child: MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(
top: notices.isEmpty ? inset : 0,
),
),
child: FloatingBarOverlay(
edge: edge,
bar: tabs,
child: Builder(
builder: (context) => switch (_tab) {
PipelineDetailTab.summary => _scrolling(
PipelineSummaryView(
controller: _controller,
detail: detail,
gateway: widget.gateway,
showIdentity: !inBar,
),
),
// Run and Runs float over the content, above the tabs.
PositionedDirectional(
end: 16,
bottom: 16 + MediaQuery.paddingOf(context).bottom,
child: _fabs(context, detail),
PipelineDetailTab.graph => BelowTopBar(
child: PipelineGraphTab(
detail: detail,
selectedStage: _graphSelection,
onSelected: (stageKey) =>
_openGraphStage(context, detail, stageKey),
),
),
],
PipelineDetailTab.source => _source(context, detail),
},
),
),
),
@@ -176,7 +193,12 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
);
},
);
return panel;
return ShellBar(
title: detail.displayName,
subtitle: pipelineSubtitle(detail),
actions: _actions(context, detail),
child: panel,
);
}
/// The header keeps its natural height while at least
@@ -345,56 +367,62 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
: title;
return Padding(
key: const Key('pipeline-detail-header'),
// The web detail head is a compact single identity line; the recorded
// id/version/stage facts live at the top of the Summary tab.
// On its own (no top bar) the panel heads itself with the pipeline's
// name and its actions; the recorded id/version/stage facts live at the
// top of the Summary tab.
padding: const EdgeInsets.fromLTRB(12, 6, 12, 4),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [heading],
children: [
heading,
Align(
alignment: AlignmentDirectional.centerEnd,
child: Wrap(
key: const Key('pipeline-actions'),
spacing: 8,
runSpacing: 4,
children: _actions(context, detail),
),
),
],
),
);
}
/// Run and Runs float at the bottom right: Runs above, the primary Run at
/// the edge.
Widget _fabs(BuildContext context, PipelineDetail detail) => Column(
key: const Key('pipeline-actions'),
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Semantics(
button: true,
label: detail.name.trim().isEmpty
? 'View runs of this pipeline'
: 'View runs of ${detail.name}',
child: ExcludeSemantics(
child: pipelineFab(
context,
key: const Key('pipeline-view-runs'),
primary: false,
materialIcon: Icons.list_alt,
cupertinoIcon: CupertinoIcons.list_bullet,
label: 'Runs',
onPressed: widget.onViewPipelineRuns == null
? null
: () => widget.onViewPipelineRuns!(detail.id),
),
/// Runs and the primary Run: the top bar's actions, never floating over
/// the content (where they used to cover the version history).
List<Widget> _actions(BuildContext context, PipelineDetail detail) => [
Semantics(
button: true,
label: detail.name.trim().isEmpty
? 'View runs of this pipeline'
: 'View runs of ${detail.name}',
child: ExcludeSemantics(
child: pipelineBarAction(
context,
key: const Key('pipeline-view-runs'),
primary: false,
materialIcon: Icons.list_alt,
cupertinoIcon: CupertinoIcons.list_bullet,
label: 'Runs',
onPressed: widget.onViewPipelineRuns == null
? null
: () => widget.onViewPipelineRuns!(detail.id),
),
),
const SizedBox(height: 12),
RunPipelineAction(
controller: _controller,
detail: detail,
gateway: widget.gateway,
onRunStarted: widget.onRunStarted,
fab: true,
),
],
);
),
RunPipelineAction(
controller: _controller,
detail: detail,
gateway: widget.gateway,
onRunStarted: widget.onRunStarted,
inBar: true,
),
];
Widget _source(BuildContext context, PipelineDetail detail) {
return ListView(
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [
if (detail.source.isEmpty)
Text('No source recorded.', style: pipelineMutedStyle(context))
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../pipeline_filter.dart';
import 'pipeline_controls.dart';
@@ -24,7 +25,7 @@ class PipelineFilterMaterialBody extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView(
padding: const EdgeInsets.all(16),
padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [
TextField(
controller: name,
@@ -111,7 +111,7 @@ class _PipelineFilterPageState extends State<PipelineFilterPage> {
),
],
),
child: SafeArea(child: body),
child: SafeArea(top: false, bottom: false, child: body),
);
}
return Scaffold(
@@ -121,7 +121,7 @@ class _PipelineFilterPageState extends State<PipelineFilterPage> {
title: 'Filter pipelines',
actions: [TextButton(onPressed: _apply, child: const Text('Done'))],
),
body: SafeArea(child: body),
body: SafeArea(top: false, bottom: false, child: body),
);
}
}
@@ -2,6 +2,7 @@ import '../../../ui/theme/app_theme.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/status/run_status_icon.dart';
import '../pipeline_format.dart';
import '../pipeline_models.dart';
@@ -28,32 +29,42 @@ class PipelineListPanel extends StatelessWidget {
(pipeline) =>
pipeline.scheduleState == PipelineScheduleState.unclassified,
);
return Column(
// The controls and notices lead the list, so they scroll behind the top
// bar with the rows and start below it at rest.
final header = [
_scope(context, filters),
_toolbar(context, filters, hasUnclassified),
if (controller.listError != null)
PipelineErrorBanner(
message: controller.listError!,
onRetry: controller.load,
),
if (controller.runsError != null)
PipelineErrorBanner(
message:
'${controller.runsLoaded ? 'Last runs could not be refreshed' : 'Last runs unavailable'}: '
'${controller.runsError}',
onRetry: controller.load,
),
if (controller.listLoading && controller.pipelinesLoaded)
const Padding(
padding: EdgeInsets.symmetric(horizontal: kPipelineListInset),
child: PipelineProgress(label: 'Refreshing pipelines'),
),
];
return _content(context, header);
}
/// A state without rows: the controls stay at the top, below the bar.
Widget _withoutRows(List<Widget> header, Widget state) => BelowTopBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_scope(context, filters),
_toolbar(context, filters, hasUnclassified),
if (controller.listError != null)
PipelineErrorBanner(
message: controller.listError!,
onRetry: controller.load,
),
if (controller.runsError != null)
PipelineErrorBanner(
message:
'${controller.runsLoaded ? 'Last runs could not be refreshed' : 'Last runs unavailable'}: '
'${controller.runsError}',
onRetry: controller.load,
),
if (controller.listLoading && controller.pipelinesLoaded)
const Padding(
padding: EdgeInsets.symmetric(horizontal: kPipelineListInset),
child: PipelineProgress(label: 'Refreshing pipelines'),
),
Expanded(child: _content(context)),
...header,
Expanded(child: state),
],
);
}
),
);
/// The web's compact toolbar: filter (whose page carries the name search),
/// sort and clear, on the list's 12px inset with a separator underneath.
@@ -105,19 +116,27 @@ class PipelineListPanel extends StatelessWidget {
);
}
Widget _content(BuildContext context) {
Widget _content(BuildContext context, List<Widget> header) {
if (controller.initialListLoading) {
return _centered(context, const ['Loading pipelines…']);
return _withoutRows(
header,
_centered(context, const ['Loading pipelines…']),
);
}
if (!controller.pipelinesLoaded) {
if (controller.listError != null) return const SizedBox.shrink();
return _centered(context, const ['Loading pipelines…']);
if (controller.listError != null) {
return _withoutRows(header, const SizedBox.shrink());
}
return _withoutRows(
header,
_centered(context, const ['Loading pipelines…']),
);
}
final items = controller.visiblePipelines;
if (items.isEmpty) {
final empty = controller.emptyState;
if (empty == null) return const SizedBox.shrink();
return _empty(context, empty);
if (empty == null) return _withoutRows(header, const SizedBox.shrink());
return _withoutRows(header, _empty(context, empty));
}
// A list pane beside a detail can be very narrow (a 640px window leaves
// it ~130px): there the rows drop the identity icon and chevron so the
@@ -126,8 +145,8 @@ class PipelineListPanel extends StatelessWidget {
builder: (context, constraints) {
final compact = constraints.maxWidth < _compactRowWidth;
return useCupertinoControls(context)
? _cupertinoList(context, items, compact: compact)
: _materialList(context, items, compact: compact);
? _cupertinoList(context, header, items, compact: compact)
: _materialList(context, header, items, compact: compact);
},
);
}
@@ -178,16 +197,22 @@ class PipelineListPanel extends StatelessWidget {
Widget _materialList(
BuildContext context,
List<Widget> header,
List<PipelineSummary> items, {
required bool compact,
}) {
final now = DateTime.now();
// The default padding is the media padding: the controls start below the
// top bar and the last row clears the floating tab bar.
return ListView.separated(
key: const Key('pipeline-list'),
itemCount: items.length,
separatorBuilder: (context, index) => const Divider(height: 1),
itemCount: header.length + items.length,
separatorBuilder: (context, index) => index < header.length
? const SizedBox.shrink()
: const Divider(height: 1),
itemBuilder: (context, index) {
final pipeline = items[index];
if (index < header.length) return header[index];
final pipeline = items[index - header.length];
return ListTile(
key: Key('pipeline-row-${pipeline.id}'),
selected: controller.selectedId == pipeline.id,
@@ -210,6 +235,7 @@ class PipelineListPanel extends StatelessWidget {
Widget _cupertinoList(
BuildContext context,
List<Widget> header,
List<PipelineSummary> items, {
required bool compact,
}) {
@@ -217,6 +243,7 @@ class PipelineListPanel extends StatelessWidget {
return ListView(
key: const Key('pipeline-list'),
children: [
...header,
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
children: [
@@ -20,12 +20,17 @@ class PipelineSummaryView extends StatelessWidget {
required this.controller,
required this.detail,
required this.gateway,
this.showIdentity = true,
});
final PipelinesController controller;
final PipelineDetail detail;
final ApiGateway gateway;
/// Whether to start with the recorded identity line (`id · version ·
/// stages`). False when the top bar's title pill already carries it.
final bool showIdentity;
@override
Widget build(BuildContext context) {
final historical = detail.resolvedVersion != detail.latestVersion;
@@ -34,13 +39,14 @@ class PipelineSummaryView extends StatelessWidget {
children: [
// The web's Summary subtitle: the compact header names the pipeline,
// this line carries its recorded identity.
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Text(
pipelineSubtitle(detail),
style: pipelineMutedStyle(context),
if (showIdentity)
Padding(
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
child: Text(
pipelineSubtitle(detail),
style: pipelineMutedStyle(context),
),
),
),
if (historical)
Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
@@ -1,5 +1,6 @@
import 'package:flutter/widgets.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import 'pipeline_controls.dart';
import 'pipeline_detail_tab.dart';
@@ -7,7 +8,7 @@ import 'pipeline_detail_tab.dart';
export 'pipeline_detail_tab.dart';
/// The pipeline detail's tabs: the app's floating glass tab bar, full width on
/// a phone and sized to its tabs at the right edge of a wide pane.
/// a phone page; beside a list, sized to its tabs under the pane's top bar.
///
/// Float it over the tab body with `FloatingBarOverlay`. The whole bar is
/// keyed `pipeline-detail-tabs`, each tab `pipeline-detail-tab-<name>`.
@@ -16,11 +17,16 @@ class PipelineDetailTabs extends StatelessWidget {
super.key,
required this.selected,
required this.onSelected,
this.edge = FloatingBarEdge.bottom,
});
final PipelineDetailTab selected;
final ValueChanged<PipelineDetailTab> onSelected;
/// Where the bar floats: the bottom of a page, or the top of a pane beside
/// a list (see `PageTabsEdge`).
final FloatingBarEdge edge;
@override
Widget build(BuildContext context) {
final cupertino = useCupertinoControls(context);
@@ -30,6 +36,7 @@ class PipelineDetailTabs extends StatelessWidget {
child: FloatingDestinationBar(
cupertino: cupertino,
currentIndex: tabs.indexOf(selected),
edge: edge,
onTap: (value) => onSelected(tabs[value]),
items: [
for (final tab in tabs)
@@ -31,6 +31,19 @@ String detailTitle(JsonMap run) {
return identity.label.trim().isEmpty ? 'Run ${run['id']}' : identity.label;
}
/// The run's context under its title in the top bar: its number, then the
/// pipeline it ran and the pinned version when recorded
/// (`Run 7 · Demo pipeline · v3`).
String detailSubtitle(JsonMap run) {
final name = '${run['name'] ?? ''}'.trim();
final version = run['version'];
return [
'Run ${run['id']}',
if (name.isNotEmpty) name,
if (version is num && version > 0) 'v${version.toInt()}',
].join(' · ');
}
String detailPipeline(JsonMap run) {
final name = '${run['name'] ?? ''}'.trim();
return name.isEmpty ? 'unavailable' : name;
@@ -3,27 +3,21 @@ import 'package:flutter/cupertino.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart';
import 'run_detail_content.dart';
import 'run_detail_tabs.dart';
import 'run_more_menu.dart';
import 'run_pipeline_link.dart';
/// The runs detail with standard Cupertino controls. It has no Material
/// ancestor: the host header keeps native navigation, actions and notices, and
/// the shared tab body uses native Cupertino expansion tiles and grouped list
/// sections. Copy feedback is an inline live-region status.
/// ancestor: the top bar carries the run's identity, Back and the more menu;
/// this header keeps the status in its colour beside the run actions, and the
/// notices. The shared tab body uses native Cupertino expansion tiles and
/// grouped list sections. Copy feedback is an inline live-region status.
Widget buildCupertinoRunDetail({
required BuildContext context,
required JsonMap run,
required Widget headerActions,
bool inShellBar = false,
ValueChanged<num>? onRunOpened,
OpenPipeline? onOpenPipeline,
required bool detailLoading,
required String? error,
required bool copying,
required String? copyStatus,
required VoidCallback onBack,
required VoidCallback onCopy,
required ApiGateway gateway,
required ValueChanged<JsonMap> onRunChanged,
@@ -31,7 +25,6 @@ Widget buildCupertinoRunDetail({
String? initialStageKey,
int? initialVisit,
}) {
final theme = CupertinoTheme.of(context);
return RunDetailTabs(
run: run,
cupertino: true,
@@ -46,82 +39,22 @@ Widget buildCupertinoRunDetail({
header: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Inside the app shell, Back and the more menu are in its bar.
if (!inShellBar)
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
child: Wrap(
alignment: WrapAlignment.spaceBetween,
crossAxisAlignment: WrapCrossAlignment.center,
spacing: 8,
runSpacing: 4,
children: [
CupertinoButton(
padding: EdgeInsets.zero,
onPressed: onBack,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
const Icon(CupertinoIcons.back),
const SizedBox(width: 4),
const Text('Back'),
],
),
),
if (copying) const CupertinoActivityIndicator(),
RunMoreMenu(
run: run,
gateway: gateway,
onRunChanged: onRunChanged,
cupertino: true,
onRunOpened: onRunOpened,
),
],
),
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 0),
child: Wrap(
spacing: 12,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Wrap(
spacing: 8,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
],
),
const SizedBox(height: 4),
Text(
detailTitle(run),
style: theme.textTheme.navLargeTitleTextStyle,
),
const SizedBox(height: 4),
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text('Run ${run['id']} · Pipeline '),
RunPipelineLink(
run: run,
cupertino: true,
onOpenPipeline: onOpenPipeline,
),
],
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
if (copying) const CupertinoActivityIndicator(),
headerActions,
],
),
),
Padding(
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: headerActions,
),
),
if (detailLoading) const _CupertinoNotice('Refreshing run details…'),
if (error != null) _CupertinoNotice(error),
],
@@ -3,27 +3,22 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart';
import 'run_detail_content.dart';
import 'run_detail_tabs.dart';
import 'run_more_menu.dart';
import 'run_pipeline_link.dart';
/// The runs detail with standard Material controls.
///
/// The host header keeps the run identity, status and every action; the shared
/// tab body supplies Summary, Graph, Input, Output and Timeline.
/// The top bar carries the run's identity (title, number, pipeline and
/// version), Back and the more menu; this header keeps only what the bar does
/// not: the status in its colour beside the run actions, and the notices.
/// The shared tab body supplies Summary, Timeline, Artifacts and Changes.
Widget buildMaterialRunDetail({
required BuildContext context,
required JsonMap run,
required Widget headerActions,
bool inShellBar = false,
ValueChanged<num>? onRunOpened,
OpenPipeline? onOpenPipeline,
required bool detailLoading,
required String? error,
required bool copying,
required String? copyStatus,
required VoidCallback onBack,
required VoidCallback onCopy,
required ApiGateway gateway,
required ValueChanged<JsonMap> onRunChanged,
@@ -31,7 +26,6 @@ Widget buildMaterialRunDetail({
String? initialStageKey,
int? initialVisit,
}) {
final theme = Theme.of(context);
return RunDetailTabs(
run: run,
cupertino: false,
@@ -46,76 +40,16 @@ Widget buildMaterialRunDetail({
header: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// Inside the app shell, Back and the more menu are in its bar.
if (!inShellBar)
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: Wrap(
spacing: 8,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
TextButton.icon(
onPressed: onBack,
icon: const Icon(Icons.arrow_back),
label: const Text('Back to list'),
),
],
),
),
RunMoreMenu(
run: run,
gateway: gateway,
onRunChanged: onRunChanged,
cupertino: false,
onRunOpened: onRunOpened,
),
],
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: Align(
alignment: AlignmentDirectional.centerStart,
child: Wrap(
spacing: 8,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
],
),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 0),
child: Text(detailTitle(run), style: theme.textTheme.headlineSmall),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 0),
child: Wrap(
spacing: 8,
spacing: 12,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [
Text('Run ${run['id']}'),
Wrap(
crossAxisAlignment: WrapCrossAlignment.center,
children: [
const Text('Pipeline '),
RunPipelineLink(
run: run,
cupertino: false,
onOpenPipeline: onOpenPipeline,
),
],
RunStatusKicker(
state: runStateOf(run['status']),
label: runStatusLabel(run),
),
headerActions,
],
@@ -41,6 +41,9 @@ Widget runDetailSummaryTab({
return CustomScrollView(
key: const Key('run-detail-tab-body-summary'),
slivers: [
// Below the pane's top tabs at rest (nothing on a phone page); the
// sticky sections pin under them.
const SliverTopBarClearance(),
if (graphPreview != null) SliverToBoxAdapter(child: graphPreview),
SliverToBoxAdapter(
child: cupertino
@@ -212,7 +215,7 @@ Widget runDetailFieldTab({
return Builder(
builder: (context) => ListView(
key: Key('run-detail-tab-body-$tabKey'),
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [body],
),
);
@@ -1,5 +1,6 @@
import 'package:flutter/widgets.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import '../../../ui/adaptive/host.dart';
import 'run_detail_tab.dart';
@@ -16,23 +17,26 @@ const List<RunDetailTab> renderedRunDetailTabs = [
RunDetailTab.changes,
];
/// The run detail's tabs: the app's floating glass tab bar, full width on a
/// phone and sized to its tabs at the right edge of a wide pane.
/// The run detail's tabs: the app's floating glass tab bar, full width at the
/// bottom of a phone page; beside a list, under the pane's top bar (sized to
/// its tabs) so it never stacks on the shell's own tab bar.
///
/// Float it over the tab body with `FloatingBarOverlay`; every tab is always
/// visible, so a tab selected by the Graph is shown selected without
/// scrolling. The whole bar is keyed `run-detail-tabs`, each tab
/// `run-detail-tab-<name>`.
/// Float it over the tab body with `FloatingBarOverlay` at the same [edge];
/// every tab is always visible, so a tab selected by the Graph is shown
/// selected without scrolling. The whole bar is keyed `run-detail-tabs`, each
/// tab `run-detail-tab-<name>`.
class RunDetailTabStrip extends StatelessWidget {
const RunDetailTabStrip({
super.key,
required this.selected,
required this.onSelected,
this.tabs = renderedRunDetailTabs,
this.edge = FloatingBarEdge.bottom,
});
final RunDetailTab selected;
final ValueChanged<RunDetailTab> onSelected;
final FloatingBarEdge edge;
/// The tabs this run offers, in [renderedRunDetailTabs] order.
final List<RunDetailTab> tabs;
@@ -46,6 +50,7 @@ class RunDetailTabStrip extends StatelessWidget {
child: FloatingDestinationBar(
cupertino: cupertino,
currentIndex: index < 0 ? 0 : index,
edge: edge,
onTap: (value) => onSelected(tabs[value]),
items: [
for (final tab in tabs)
+25 -11
View File
@@ -364,32 +364,43 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
final shown = tabs.contains(_tab) || !renderedRunDetailTabs.contains(_tab)
? _tab
: RunDetailTab.summary;
final edge = PageTabsEdge.of(context);
return LayoutBuilder(
builder: (context, constraints) {
final headerLimit = _headerLimit(constraints);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// The header (status, actions, notices) starts below the floating
// top bar; the tab body below it no longer sees the bar's height.
ConstrainedBox(
constraints: BoxConstraints(maxHeight: headerLimit),
child: SingleChildScrollView(
key: ValueKey('run-detail-header-${widget.run['id']}'),
padding: EdgeInsets.only(top: topBarInset(context)),
child: widget.header,
),
),
// Every tab gets the bounded remaining height. The scrolling tabs
// own their content; the Graph tab fills the slot so its canvas is
// never asked for an unbounded extent. The tabs float over the
// bottom of it, and the tab learns their height as bottom padding.
// tab, at its bottom on a page or at its top beside a list, and
// the tab learns their height as its padding on that edge.
Expanded(
key: ValueKey('run-detail-body-${widget.run['id']}'),
child: FloatingBarOverlay(
bar: RunDetailTabStrip(
tabs: tabs,
selected: shown,
onSelected: (tab) => setState(() => _tab = tab),
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: FloatingBarOverlay(
edge: edge,
bar: RunDetailTabStrip(
tabs: tabs,
edge: edge,
selected: shown,
onSelected: (tab) => setState(() => _tab = tab),
),
child: _body(shown),
),
child: _body(shown),
),
),
],
@@ -458,10 +469,13 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
finalOnly: true,
);
// A CupertinoApp supplies no Material theme; follow the host so the
// viewer's section text stays readable.
return widget.cupertino
? Theme(data: hostTextTheme(context), child: viewer)
: viewer;
// viewer's section text stays readable. Its summary heads the tab, so
// the tab starts below a pane's top tabs.
return BelowTopBar(
child: widget.cupertino
? Theme(data: hostTextTheme(context), child: viewer)
: viewer,
);
case RunDetailTab.timeline:
final visits = detailTimeline(widget.run['steps']);
final index = _selectedVisit;
@@ -34,7 +34,7 @@ class RunTimelineList extends StatelessWidget {
if (visits.isEmpty) {
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
padding: withBarClearance(context, const EdgeInsets.all(16)),
children: const [Text('No visits recorded.')],
);
}
@@ -64,7 +64,7 @@ class RunTimelineList extends StatelessWidget {
}
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: withFloatingBarClearance(
padding: withBarClearance(
context,
const EdgeInsets.symmetric(vertical: 8),
),
+57 -20
View File
@@ -6,6 +6,8 @@ import '../../../core/api_gateway.dart';
import '../../../core/transport/pipelines_client.dart';
import '../../../ui/adaptive/host.dart';
import '../../../shell/shell_bar.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../ui/adaptive/segmented_bar_overlay.dart';
import 'run_detail_actions.dart';
import 'run_more_menu.dart';
import 'run_pipeline_link.dart';
@@ -75,14 +77,10 @@ class _RunDetailViewState extends State<RunDetailView> {
context: context,
run: run,
headerActions: headerActions,
onRunOpened: widget.onRunOpened,
onOpenPipeline: widget.onOpenPipeline,
inShellBar: inShellBar,
detailLoading: widget.controller.detailLoading,
error: widget.controller.error,
copying: _copying,
copyStatus: _copyStatus,
onBack: widget.onBack,
onCopy: () => _copyPrompt(prompt ?? '', cupertino: true),
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
@@ -94,14 +92,10 @@ class _RunDetailViewState extends State<RunDetailView> {
context: context,
run: run,
headerActions: headerActions,
onRunOpened: widget.onRunOpened,
onOpenPipeline: widget.onOpenPipeline,
inShellBar: inShellBar,
detailLoading: widget.controller.detailLoading,
error: widget.controller.error,
copying: _copying,
copyStatus: _copyStatus,
onBack: widget.onBack,
onCopy: () => _copyPrompt(prompt ?? '', cupertino: false),
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
@@ -109,25 +103,68 @@ class _RunDetailViewState extends State<RunDetailView> {
initialStageKey: widget.initialStageKey,
initialVisit: widget.initialVisit,
);
// The app bar becomes the run's: Back to the list, the run and its
// more menu. Search and the tab name return when the run closes.
return ShellBar(
title: 'Run ${run['id']}',
onBack: widget.onBack,
actions: [
RunMoreMenu(
run: run,
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
// The top bar becomes the run's: Back to the list, its title over its
// number, pipeline and version (a link to that pipeline when the host
// can open it) and its more menu, so the body repeats none of them.
// Search and the tab name return when the run closes.
final title = detailTitle(run);
final subtitle = detailSubtitle(run);
final openPipeline = _openPipeline(run);
final pipelineName = detailPipeline(run);
final more = RunMoreMenu(
run: run,
gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail,
cupertino: cupertino,
onRunOpened: widget.onRunOpened,
);
if (inShellBar) {
return ShellBar(
title: title,
subtitle: subtitle,
onTitlePressed: openPipeline,
titleSemanticLabel: openPipeline == null
? null
: 'Open pipeline $pipelineName',
titleKey: openPipeline == null ? null : runPipelineLinkKey,
onBack: widget.onBack,
actions: [more],
child: detail,
);
}
// On its own the run draws the same bar over its content.
return SegmentedBarOverlay(
bar: SegmentedBar(
cupertino: cupertino,
leading: SegmentedBackButton(
key: const Key('run-detail-back'),
cupertino: cupertino,
onRunOpened: widget.onRunOpened,
onPressed: widget.onBack,
),
],
title: title,
subtitle: subtitle,
onTitlePressed: openPipeline,
titleSemanticLabel: openPipeline == null
? null
: 'Open pipeline $pipelineName',
titleKey: openPipeline == null ? null : runPipelineLinkKey,
actions: [more],
),
child: detail,
);
},
);
/// Opens the run's pipeline at its pinned version, or null when the run
/// names none or the host cannot navigate.
VoidCallback? _openPipeline(JsonMap run) {
final id = runPipelineId(run);
final open = widget.onOpenPipeline;
if (id == null || open == null) return null;
final version = run['version'];
return () => open(id, version is num ? version.toInt() : 0);
}
Widget _placeholder(BuildContext context, {required bool cupertino}) {
final loading = widget.controller.detailLoading;
final message = loading
+38 -25
View File
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/status/run_status_icon.dart';
import '../../attention/notify/notification_controller.dart';
@@ -112,30 +113,36 @@ class RunsList extends StatelessWidget {
if (controller.error != null && controller.runs.isEmpty) {
return _emptyError(context);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
if (controller.error != null) _inlineError(context),
RunsFilters(controller: controller),
Expanded(
child: controller.visibleRuns.isEmpty
? _state(
context,
icon: Icon(
usesCupertinoHost(context)
? CupertinoIcons.tray
: Icons.inbox_outlined,
),
title: 'No runs found.',
subtitle: 'Try changing or clearing the filters.',
)
: _groupedRuns(context),
),
],
// The notice and the applied filters lead the list, so they scroll
// behind the top bar with the runs and start below it at rest.
final header = [
if (controller.error != null) _inlineError(context),
RunsFilters(controller: controller),
];
if (controller.visibleRuns.isNotEmpty) return _groupedRuns(context, header);
return BelowTopBar(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
...header,
Expanded(
child: _state(
context,
icon: Icon(
usesCupertinoHost(context)
? CupertinoIcons.tray
: Icons.inbox_outlined,
),
title: 'No runs found.',
subtitle: 'Try changing or clearing the filters.',
),
),
],
),
);
}
Widget _groupedRuns(BuildContext context) {
Widget _groupedRuns(BuildContext context, List<Widget> header) {
final groups = groupRunsByDay(controller.visibleRuns, DateTime.now());
final entries = <({String? label, JsonMap? run})>[];
for (final group in groups) {
@@ -145,15 +152,21 @@ class RunsList extends StatelessWidget {
// Runs that start while the list is open enter with a short fade.
return ArrivalScope(
ids: [for (final run in controller.visibleRuns) '${run['id']}'],
child: _entriesList(entries),
child: _entriesList(entries, header),
);
}
Widget _entriesList(List<({String? label, JsonMap? run})> entries) {
Widget _entriesList(
List<({String? label, JsonMap? run})> entries,
List<Widget> header,
) {
// The default padding is the media padding: the first row starts below
// the top bar and the last clears the floating tab bar.
return ListView.builder(
itemCount: entries.length,
itemCount: header.length + entries.length,
itemBuilder: (context, index) {
final entry = entries[index];
if (index < header.length) return header[index];
final entry = entries[index - header.length];
if (entry.label case final label?) {
// A day heading reads as a divider between groups of runs.
return Padding(
@@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart';
@@ -39,13 +40,13 @@ class RunsStatsPage extends StatelessWidget {
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: const SegmentedBar(cupertino: true, title: 'Usage'),
child: SafeArea(child: body),
child: SafeArea(top: false, bottom: false, child: body),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: const SegmentedBar(cupertino: false, title: 'Usage'),
body: SafeArea(child: body),
body: SafeArea(top: false, bottom: false, child: body),
);
}
@@ -69,7 +70,7 @@ class RunsStatsPage extends StatelessWidget {
: Theme.of(context).colorScheme.onSurfaceVariant;
return ListView(
key: const ValueKey('runs.stats.page'),
padding: const EdgeInsets.all(16),
padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [
Text('Usage', style: heading),
const SizedBox(height: 8),
+12 -10
View File
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import '../../core/api_gateway.dart';
import '../../ui/adaptive/top_bar_notices.dart';
import '../../ui/adaptive/host.dart';
import 'data/template_repository.dart';
import 'domain/template_entry.dart';
@@ -208,17 +209,18 @@ class _TemplatesScreenState extends State<TemplatesScreen> {
/// open template never hides a failed read. The rows and selection are kept.
Widget _withFailure(BuildContext context, Widget body) {
final error = _error;
if (error == null || !_loaded) return body;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
TemplatesFailureBanner(
message: error,
retrying: _loading,
onRetry: () => unawaited(_load()),
),
Expanded(child: body),
// The banner stays put below the top bar; without it the body scrolls
// behind the bar.
return TopBarNotices(
notices: [
if (error != null && _loaded)
TemplatesFailureBanner(
message: error,
retrying: _loading,
onRetry: () => unawaited(_load()),
),
],
child: body,
);
}
}
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import '../domain/template_entry.dart';
@@ -52,7 +53,7 @@ class TemplateDetail extends StatelessWidget {
final cupertino = usesCupertinoHost(context);
return ListView(
key: templateDetailKey,
padding: const EdgeInsets.only(bottom: 24),
padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
children: [
if (showBack) _backRow(context, cupertino),
Padding(
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import '../../../shell/shell_bar.dart';
import '../../../ui/adaptive/host.dart';
const templatesRefreshKey = ValueKey<String>('templates-refresh');
@@ -11,7 +12,8 @@ const templatesBackKey = ValueKey<String>('templates-back');
///
/// Standalone use keeps the host's own app bar with Back and Refresh. A shell
/// that already owns navigation passes [embedded], which drops the bar and
/// keeps Refresh at the top of the body.
/// puts Refresh in the host's bar through `ShellBar` (or, without one,
/// keeps it at the top of the body).
class TemplatesFrame extends StatelessWidget {
const TemplatesFrame({
super.key,
@@ -39,6 +41,11 @@ class TemplatesFrame extends StatelessWidget {
}
Widget _embedded(BuildContext context) {
// A host page with a bar takes Refresh into it; the body then reaches
// its top edge and scrolls behind that bar.
if (ShellBar.available(context)) {
return ShellBar(actions: [_refreshButton(context)], child: body);
}
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -69,7 +76,7 @@ class TemplatesFrame extends StatelessWidget {
title: 'Templates',
actions: [_refreshButton(context)],
),
child: SafeArea(child: body),
child: SafeArea(top: false, bottom: false, child: body),
);
}
@@ -84,7 +91,7 @@ class TemplatesFrame extends StatelessWidget {
: null,
actions: [_refreshButton(context)],
),
body: SafeArea(child: body),
body: SafeArea(top: false, bottom: false, child: body),
);
}
+63 -19
View File
@@ -7,6 +7,7 @@ import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/floating_destination_bar.dart';
import 'attention_badge.dart';
import 'destination.dart';
import 'list_detail.dart';
import 'shell_bar.dart';
class AdaptiveShell extends StatefulWidget {
@@ -95,19 +96,19 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
);
}
if (destination != AppDestination.runs) return icon;
// Runs in progress at the bottom, runs that need you at the top.
icon = ActivityBadge(
key: const ValueKey('shell.badge.runs.running'),
count: _bar.badge(destination, ShellBadgeKind.running),
label: 'runs in progress',
cupertino: widget.cupertino,
bottom: true,
child: icon,
);
// One indicator: runs that need you outrank runs in progress, so the
// tab never wears two counts at once.
final attention = widget.attentionCount > 0;
return AttentionDestinationIcon(
count: widget.attentionCount,
cupertino: widget.cupertino,
child: icon,
child: ActivityBadge(
key: const ValueKey('shell.badge.runs.running'),
count: attention ? 0 : _bar.badge(destination, ShellBadgeKind.running),
label: 'runs in progress',
cupertino: widget.cupertino,
child: icon,
),
);
}
@@ -148,10 +149,18 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
onTap: (value) => _select(AppDestination.values[value]),
items: _destinationItems(),
);
// Destinations reach the top edge and scroll behind the floating top
// bar too: each learns the bar's height as its top media padding and
// pads its own lists by it (see withTopBarClearance).
final topBar = _ListPaneBar(
split: _bar.split(_selected),
bar: _segmentedBar(spec, details.label),
);
if (widget.cupertino) {
return CupertinoPageScaffold(
navigationBar: _segmentedBar(spec, details.label),
navigationBar: topBar,
child: SafeArea(
top: false,
bottom: false,
child: FloatingBarOverlay(
bar: bar,
@@ -162,14 +171,8 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: _segmentedBar(spec, details.label),
// Destinations start below the floating top bar.
body: SafeArea(
left: false,
right: false,
bottom: false,
child: _destinationStack(contents, index),
),
appBar: topBar,
body: _destinationStack(contents, index),
extendBody: true,
bottomNavigationBar: bar,
);
@@ -208,6 +211,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
onPressed: onBack,
),
title: spec?.title ?? label,
subtitle: spec?.subtitle,
subtitleIcon: spec?.subtitleIcon,
onTitlePressed: spec?.onTitlePressed,
titleSemanticLabel: spec?.titleSemanticLabel,
titleKey: spec?.titleKey,
actions: [
if (published.isNotEmpty)
// A screen taking the bar over cross-fades its actions in.
@@ -244,3 +252,39 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
Widget _destinationStack(List<Widget> contents, int index) =>
IndexedStack(key: _destinationStackKey, index: index, children: contents);
}
/// The shell's top bar, over the list pane only while the tab shows a list
/// beside an open item ([ShellPaneSplit]); the item's own bar takes the rest
/// of the same row. The bar keeps its place in the scaffold either way, so a
/// split never remounts it.
class _ListPaneBar extends StatelessWidget
implements ObstructingPreferredSizeWidget {
const _ListPaneBar({required this.split, required this.bar});
final bool split;
final SegmentedBar bar;
@override
Size get preferredSize => bar.preferredSize;
@override
bool shouldFullyObstruct(BuildContext context) =>
bar.shouldFullyObstruct(context);
@override
Widget build(BuildContext context) => LayoutBuilder(
builder: (context, constraints) {
final width = split
? listDetailListWidth(
MediaQuery.sizeOf(context).width,
constraints.maxWidth,
)
: constraints.maxWidth;
return Align(
alignment: AlignmentDirectional.topStart,
heightFactor: 1,
child: SizedBox(width: width, child: bar),
);
},
);
}
+11 -8
View File
@@ -141,21 +141,24 @@ class _DetailPaneState extends State<DetailPane> {
cupertino: cupertino,
automaticallyImplyLeading: widget.implyBack,
title: title,
subtitle: spec?.subtitle,
subtitleIcon: spec?.subtitleIcon,
onTitlePressed: spec?.onTitlePressed,
titleSemanticLabel: spec?.titleSemanticLabel,
titleKey: spec?.titleKey,
actions: actions,
);
// The bottom inset (the system's, or a floating tab bar's when the
// pane sits beside a list) passes through: the open item's content
// floats its own tabs above it and pads its lists clear of it.
// Both insets pass through: the content scrolls behind the bar and
// pads its lists by the bar's height (top) and by the system's or a
// floating tab bar's (bottom), floating its own tabs clear of them.
final content = SafeArea(top: false, bottom: false, child: body);
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: bar,
child: SafeArea(bottom: false, child: body),
);
return CupertinoPageScaffold(navigationBar: bar, child: content);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: SafeArea(bottom: false, child: body),
body: content,
);
},
);
+73 -40
View File
@@ -3,7 +3,9 @@ import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/host.dart';
import 'shell_bar.dart';
/// At least this wide, a destination keeps its list beside the open item
/// (with the destination rail) instead of pushing the item as its own page.
@@ -16,8 +18,32 @@ const double _bodyAvailableMaximum = 0.75;
bool showsListBesideDetail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kListDetailMinWidth;
/// The open item's width beside a list, for a [window] this wide and
/// [available] width for both panes and their divider.
double listDetailBodyWidth(double window, double available) {
// Target 60% of the full window. Keep at least half for the body while
// leaving a flexible share for native list controls on tighter windows.
final requestedMinimum = window * _bodyWindowMinimum;
final minimum = available > requestedMinimum
? requestedMinimum
: available * _bodyWindowMinimum;
final maximum = math.max(minimum, available * _bodyAvailableMaximum);
return (window * _bodyWindowTarget).clamp(minimum, maximum);
}
/// The list pane's width beside an open item (see [listDetailBodyWidth]),
/// one divider excluded.
double listDetailListWidth(double window, double available) =>
math.max(0, available - 1 - listDetailBodyWidth(window, available));
/// One body-priority policy for all destinations, derived from the full window
/// and actual available space after navigation. No fixed pixel pane widths.
///
/// Under the shell, the list keeps the shell's bar (narrowed to the list pane
/// through [ShellPaneSplit]) and the open item owns the rest of the top row:
/// the detail starts at the top edge with only the system inset as its top
/// padding, and its own tabs float at its top ([PageTabsEdge]) so they never
/// stack on the shell's tab bar at the bottom.
class ListDetailPanes extends StatelessWidget {
const ListDetailPanes({super.key, required this.list, required this.detail});
@@ -32,50 +58,57 @@ class ListDetailPanes extends StatelessWidget {
color: CupertinoColors.separator.resolveFrom(context),
)
: const VerticalDivider(width: 1);
return LayoutBuilder(
builder: (context, constraints) {
final window = MediaQuery.sizeOf(context).width;
// Target 60% of the full window. Keep at least half for the body while
// leaving a flexible share for native list controls on tighter windows.
final requestedMinimum = window * _bodyWindowMinimum;
final minimum = constraints.maxWidth > requestedMinimum
? requestedMinimum
: constraints.maxWidth * _bodyWindowMinimum;
final maximum = math.max(
minimum,
constraints.maxWidth * _bodyAvailableMaximum,
);
final bodyWidth = (window * _bodyWindowTarget).clamp(minimum, maximum);
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: SizedBox.expand(
key: const ValueKey('list-detail-list'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-list',
child: list,
final media = MediaQuery.of(context);
final split = ShellBar.available(context);
return ShellPaneSplit(
child: LayoutBuilder(
builder: (context, constraints) {
final bodyWidth = listDetailBodyWidth(
media.size.width,
constraints.maxWidth,
);
Widget body = detail;
if (split) {
// Beside the list the item is not under the shell's bar: it keeps
// only the system's own inset and draws its bar at the top edge.
body = MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(top: media.viewPadding.top),
),
child: PageTabsEdge(edge: FloatingBarEdge.top, child: body),
);
}
return Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Expanded(
child: SizedBox.expand(
key: const ValueKey('list-detail-list'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-list',
child: list,
),
),
),
),
divider,
SizedBox(
width: bodyWidth,
child: SizedBox.expand(
key: const ValueKey('list-detail-body'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-body',
child: detail,
divider,
SizedBox(
width: bodyWidth,
child: SizedBox.expand(
key: const ValueKey('list-detail-body'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-body',
child: body,
),
),
),
),
],
);
},
],
);
},
),
);
}
}
+95
View File
@@ -7,12 +7,27 @@ import 'destination.dart';
class ShellBarSpec {
const ShellBarSpec({
this.title,
this.subtitle,
this.subtitleIcon,
this.onTitlePressed,
this.titleSemanticLabel,
this.titleKey,
this.onBack,
this.actions = const [],
this.barless = false,
});
final String? title;
/// A one-line subtitle in the title pill (the item's context: its
/// pipeline and version), so the body need not repeat it.
final String? subtitle;
final IconData? subtitleIcon;
/// Makes the title pill a button; see `SegmentedBar.onTitlePressed`.
final VoidCallback? onTitlePressed;
final String? titleSemanticLabel;
final Key? titleKey;
final VoidCallback? onBack;
final List<Widget> actions;
@@ -26,6 +41,20 @@ class ShellBarRegistry extends ChangeNotifier {
final Map<AppDestination, (Object, ShellBarSpec)> _specs = {};
final Map<(AppDestination, ShellBadgeKind), int> _badges = {};
final Map<AppDestination, int> _splits = {};
/// Whether a tab's screen shows a list beside an open item right now
/// ([ShellPaneSplit]): the shell's bar then covers the list pane only, so
/// the item's own bar shares its top row.
bool split(AppDestination destination) => (_splits[destination] ?? 0) > 0;
void _setSplit(AppDestination destination, bool value) {
if (_disposed) return;
final before = split(destination);
_splits[destination] = (_splits[destination] ?? 0) + (value ? 1 : -1);
if (split(destination) != before) notifyListeners();
}
/// The count a tab's screen published for [kind], 0 when none.
int badge(AppDestination destination, ShellBadgeKind kind) =>
_badges[(destination, kind)] ?? 0;
@@ -92,6 +121,11 @@ class ShellBar extends StatefulWidget {
const ShellBar({
super.key,
this.title,
this.subtitle,
this.subtitleIcon,
this.onTitlePressed,
this.titleSemanticLabel,
this.titleKey,
this.onBack,
this.actions = const [],
this.active = true,
@@ -107,6 +141,13 @@ class ShellBar extends StatefulWidget {
final bool active;
final String? title;
/// See [ShellBarSpec.subtitle].
final String? subtitle;
final IconData? subtitleIcon;
final VoidCallback? onTitlePressed;
final String? titleSemanticLabel;
final Key? titleKey;
final VoidCallback? onBack;
final List<Widget> actions;
final Widget child;
@@ -141,6 +182,11 @@ class _ShellBarState extends State<ShellBar> {
}
final spec = ShellBarSpec(
title: widget.title,
subtitle: widget.subtitle,
subtitleIcon: widget.subtitleIcon,
onTitlePressed: widget.onTitlePressed,
titleSemanticLabel: widget.titleSemanticLabel,
titleKey: widget.titleKey,
onBack: widget.onBack,
actions: widget.actions,
barless: widget.barless,
@@ -169,6 +215,55 @@ class _ShellBarState extends State<ShellBar> {
}
}
/// Tells the shell, while mounted, that its tab shows a list beside an open
/// item (`ListDetailPanes`). The shell then narrows its own bar to the list
/// pane, so each pane owns its bar on one shared top row. Outside a shell it
/// does nothing.
class ShellPaneSplit extends StatefulWidget {
const ShellPaneSplit({super.key, required this.child});
final Widget child;
@override
State<ShellPaneSplit> createState() => _ShellPaneSplitState();
}
class _ShellPaneSplitState extends State<ShellPaneSplit> {
ShellBarScope? _scope;
@override
void didChangeDependencies() {
super.didChangeDependencies();
final scope = ShellBarScope.maybeOf(context);
if (scope == _scope) return;
_release();
_scope = scope;
if (scope != null) {
// The bar is above this screen; update it after this frame's build.
WidgetsBinding.instance.addPostFrameCallback(
(_) => scope.registry._setSplit(scope.destination, true),
);
}
}
void _release() {
final scope = _scope;
if (scope == null) return;
WidgetsBinding.instance.addPostFrameCallback(
(_) => scope.registry._setSplit(scope.destination, false),
);
}
@override
void dispose() {
_release();
super.dispose();
}
@override
Widget build(BuildContext context) => widget.child;
}
/// What a tab badge counts.
enum ShellBadgeKind {
/// Runs still executing.
+156 -37
View File
@@ -19,6 +19,77 @@ EdgeInsetsGeometry withFloatingBarClearance(
EdgeInsetsGeometry padding,
) => padding.add(EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom));
/// [padding] with the top bar's clearance added at the top.
///
/// A page whose top bar floats over its content (a `SegmentedBar` in a
/// scaffold with `extendBodyBehindAppBar`, a `SegmentedBarOverlay`, the
/// shell's bar) reads the bar's height as [MediaQuery.paddingOf] top. Adding
/// it to a list's own padding starts the first item below the bar at rest
/// while scrolled content passes behind the glass pieces. Lists without
/// explicit padding (`ListView`'s default) already do this themselves.
EdgeInsetsGeometry withTopBarClearance(
BuildContext context,
EdgeInsetsGeometry padding,
) => padding.add(EdgeInsets.only(top: MediaQuery.paddingOf(context).top));
/// [padding] with both the top bar's and the floating tab bar's clearance:
/// for a list that scrolls behind a bar at each edge.
EdgeInsetsGeometry withBarClearance(
BuildContext context,
EdgeInsetsGeometry padding,
) {
final media = MediaQuery.paddingOf(context);
return padding.add(EdgeInsets.only(top: media.top, bottom: media.bottom));
}
/// Empty space as tall as the top bar's clearance ([MediaQuery.paddingOf]
/// top), starting a scrolling column so its first item sits below the bar at
/// rest and scrolls behind it.
class TopBarClearance extends StatelessWidget {
const TopBarClearance({super.key});
@override
Widget build(BuildContext context) =>
SizedBox(height: MediaQuery.paddingOf(context).top);
}
/// [TopBarClearance] as the first sliver of a [CustomScrollView]: the first
/// item starts below the bar at rest and scrolls behind it.
///
/// The clearance stays pinned (it paints nothing and takes no taps), so a
/// pinned header further down (`PinnedHeaderSliver`, a sticky section title)
/// pins just below the bar rather than behind it.
class SliverTopBarClearance extends StatelessWidget {
const SliverTopBarClearance({super.key});
@override
Widget build(BuildContext context) =>
const PinnedHeaderSliver(child: TopBarClearance());
}
/// The top bar's height over the content at [context]: where a pinned
/// header must stop so it stays below the bar.
double topBarInset(BuildContext context) => MediaQuery.paddingOf(context).top;
/// Content that cannot scroll behind the top bar (a fixed header, a canvas
/// with its own overlay controls): it starts below the bar, and its subtree no
/// longer sees the bar's height as padding.
class BelowTopBar extends StatelessWidget {
const BelowTopBar({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) => Padding(
padding: EdgeInsets.only(top: MediaQuery.paddingOf(context).top),
child: MediaQuery.removePadding(
context: context,
removeTop: true,
child: child,
),
);
}
/// Empty space as tall as the floating bar's clearance
/// ([MediaQuery.paddingOf] bottom), ending a scrolling column so its last item
/// comes clear of the bar at rest.
@@ -39,49 +110,91 @@ class SliverFloatingBarClearance extends StatelessWidget {
const SliverToBoxAdapter(child: FloatingBarClearance());
}
/// Floats [bar] over the bottom of [child], the way a scaffold with
/// `extendBody` floats its bottom bar, for a bar that is not a scaffold's.
/// The edge a page's own floating tab bar sits at.
enum FloatingBarEdge {
/// Above the bottom safe area: a phone page, or a page covering the shell.
bottom,
/// Just below the page's top bar: a detail pane beside a list, where the
/// shell's own tab bar already floats at the bottom.
top,
}
/// Where the pages' own tab bars float in this subtree ([FloatingBarEdge]).
///
/// [child] fills the whole area and scrolls behind the bar; it learns the
/// bar's measured height (bottom safe area and margins included) as its
/// [MediaQuery.paddingOf] bottom, so a list can pad its last item clear of the
/// bar at rest (see [withFloatingBarClearance]). Taps the bar does not take,
/// such as beside a bar narrower than the area, reach [child].
/// A detail pane beside a list says [FloatingBarEdge.top], so an open item's
/// tabs never stack on the shell's tab bar; everywhere else they float at the
/// bottom.
class PageTabsEdge extends InheritedWidget {
const PageTabsEdge({super.key, required this.edge, required super.child});
final FloatingBarEdge edge;
static FloatingBarEdge of(BuildContext context) =>
context.dependOnInheritedWidgetOfExactType<PageTabsEdge>()?.edge ??
FloatingBarEdge.bottom;
@override
bool updateShouldNotify(PageTabsEdge oldWidget) => edge != oldWidget.edge;
}
/// Floats [bar] over [child] at [edge], the way a scaffold with `extendBody`
/// floats its bottom bar, for a bar that is not a scaffold's.
///
/// [child] fills the whole area and scrolls behind the bar. At the bottom it
/// learns the bar's measured height (bottom safe area and margins included)
/// as its [MediaQuery.paddingOf] bottom, so a list can pad its last item clear
/// of the bar at rest (see [withFloatingBarClearance]). At the top the bar
/// sits below the area's own top inset (the page's top bar) and the content's
/// top padding grows by the bar's height (see [withTopBarClearance]). Taps the
/// bar does not take, such as beside a bar narrower than the area, reach
/// [child].
class FloatingBarOverlay extends StatelessWidget {
const FloatingBarOverlay({super.key, required this.bar, required this.child});
const FloatingBarOverlay({
super.key,
required this.bar,
required this.child,
this.edge = FloatingBarEdge.bottom,
});
final Widget bar;
final Widget child;
final FloatingBarEdge edge;
@override
Widget build(BuildContext context) => CustomMultiChildLayout(
delegate: _OverlayLayout(),
children: [
// Painted first, so the bar draws (and takes taps) above it.
LayoutId(
id: _Slot.content,
child: LayoutBuilder(
builder: (context, constraints) {
final barHeight = constraints is _ContentConstraints
? constraints.barHeight
: 0.0;
final media = MediaQuery.of(context);
return MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(
bottom: barHeight > media.padding.bottom
? barHeight
: media.padding.bottom,
),
),
child: child,
);
},
Widget build(BuildContext context) {
final top = edge == FloatingBarEdge.top;
final inset = top ? MediaQuery.paddingOf(context).top : 0.0;
return CustomMultiChildLayout(
delegate: _OverlayLayout(top: top, inset: inset),
children: [
// Painted first, so the bar draws (and takes taps) above it.
LayoutId(
id: _Slot.content,
child: LayoutBuilder(
builder: (context, constraints) {
final barHeight = constraints is _ContentConstraints
? constraints.barHeight
: 0.0;
final media = MediaQuery.of(context);
final padding = top
? media.padding.copyWith(top: inset + barHeight)
: media.padding.copyWith(
bottom: barHeight > media.padding.bottom
? barHeight
: media.padding.bottom,
);
return MediaQuery(
data: media.copyWith(padding: padding),
child: child,
);
},
),
),
),
LayoutId(id: _Slot.bar, child: bar),
],
);
LayoutId(id: _Slot.bar, child: bar),
],
);
}
}
enum _Slot { content, bar }
@@ -110,6 +223,11 @@ class _ContentConstraints extends BoxConstraints {
}
class _OverlayLayout extends MultiChildLayoutDelegate {
_OverlayLayout({required this.top, required this.inset});
final bool top;
final double inset;
@override
void performLayout(Size size) {
final bar = layoutChild(
@@ -120,7 +238,7 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
maxHeight: size.height,
),
);
positionChild(_Slot.bar, Offset(0, size.height - bar.height));
positionChild(_Slot.bar, Offset(0, top ? inset : size.height - bar.height));
layoutChild(
_Slot.content,
_ContentConstraints(size, barHeight: bar.height),
@@ -129,5 +247,6 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
}
@override
bool shouldRelayout(_OverlayLayout oldDelegate) => false;
bool shouldRelayout(_OverlayLayout oldDelegate) =>
oldDelegate.top != top || oldDelegate.inset != inset;
}
@@ -28,9 +28,15 @@ class FloatingDestinationBar extends StatelessWidget {
required this.currentIndex,
required this.onTap,
required this.items,
this.edge = FloatingBarEdge.bottom,
});
final bool cupertino;
/// The edge the bar floats at. At [FloatingBarEdge.top] (an open item's
/// tabs under its pane's top bar) a wide bar sits at the leading edge, in
/// line with the bar's title, and keeps no bottom safe area.
final FloatingBarEdge edge;
final int currentIndex;
final ValueChanged<int> onTap;
final List<FloatingDestinationItem> items;
@@ -41,8 +47,61 @@ class FloatingDestinationBar extends StatelessWidget {
/// Height of the Cupertino bar inside the pill (the stock bar is 50).
static const double cupertinoHeight = 54;
/// The side margin at [FloatingBarEdge.top], matching the top bar's own.
static const double topMargin = 12;
@override
Widget build(BuildContext context) {
final top = edge == FloatingBarEdge.top;
final margins = 2 * (top ? topMargin : kFloatingBarMargin);
final bar = LayoutBuilder(
builder: (context, constraints) {
// Wide is judged on the space the bar is given, margins included,
// the way the shell and the pages judge their own layouts.
final available = constraints.maxWidth;
final wide = available + margins >= kFloatingBarWideWidth;
final width = wide
? math.min(available, _tabsWidth(context))
: available;
return Align(
// As tall as the pill, so a scaffold or overlay measures the bar
// and not the whole area it may grow into.
heightFactor: 1,
alignment: !wide
? Alignment.bottomCenter
: top
? AlignmentDirectional.topStart
: AlignmentDirectional.bottomEnd,
child: SizedBox(
width: math.max(0, width),
// The insets are handled around the pill. The host bars pad
// themselves by any media padding left over (a page's top bar,
// another floating bar below a pane), which would swell the pill.
child: MediaQuery.removePadding(
context: context,
removeTop: true,
removeBottom: true,
removeLeft: true,
removeRight: true,
child: GlassPill(
cupertino: cupertino,
child: cupertino
? _cupertinoBar(context)
: _materialBar(context),
),
),
),
);
},
);
if (top) {
// Under a top bar: no safe area to keep clear of, only the gap to the
// content below.
return Padding(
padding: const EdgeInsets.fromLTRB(topMargin, 0, topMargin, 8),
child: bar,
);
}
return SafeArea(
top: false,
minimum: const EdgeInsets.fromLTRB(
@@ -51,35 +110,7 @@ class FloatingDestinationBar extends StatelessWidget {
kFloatingBarMargin,
kFloatingBarMargin,
),
child: LayoutBuilder(
builder: (context, constraints) {
// Wide is judged on the space the bar is given, margins included,
// the way the shell and the pages judge their own layouts.
final available = constraints.maxWidth;
final wide =
available + 2 * kFloatingBarMargin >= kFloatingBarWideWidth;
final width = wide
? math.min(available, _tabsWidth(context))
: available;
return Align(
// As tall as the pill, so a scaffold or overlay measures the bar
// and not the whole area it may grow into.
heightFactor: 1,
alignment: wide
? AlignmentDirectional.bottomEnd
: Alignment.bottomCenter,
child: SizedBox(
width: math.max(0, width),
child: GlassPill(
cupertino: cupertino,
child: cupertino
? _cupertinoBar(context)
: _materialBar(context),
),
),
);
},
),
child: bar,
);
}
+47
View File
@@ -0,0 +1,47 @@
import 'package:flutter/widgets.dart';
/// Content that scrolls behind a floating top bar, with optional [notices]
/// (a connection banner, a refused refresh) that stay put above it.
///
/// Without notices [child] reaches the top edge and keeps the bar's height as
/// its [MediaQuery.paddingOf] top, so its list starts below the bar at rest
/// and scrolls behind it. With notices they sit below the bar and [child]
/// below them, no longer seeing the bar's height. [child] keeps its place in
/// the tree either way, so a banner coming or going never remounts it.
class TopBarNotices extends StatelessWidget {
const TopBarNotices({
super.key,
this.notices = const [],
required this.child,
});
final List<Widget> notices;
final Widget child;
@override
Widget build(BuildContext context) {
final media = MediaQuery.of(context);
final inset = media.padding.top;
final shown = notices.isNotEmpty;
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: EdgeInsets.only(top: shown ? inset : 0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: notices,
),
),
Expanded(
child: MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(top: shown ? 0 : inset),
),
child: child,
),
),
],
);
}
}