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 '../features/chat/screen.dart';
import '../ui/adaptive/host.dart'; import '../ui/adaptive/host.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart'; import 'app_session.dart';
import 'connection_status.dart'; import 'connection_status.dart';
import 'server_endpoint.dart'; import 'server_endpoint.dart';
@@ -49,12 +50,15 @@ class ChatDestination extends StatelessWidget {
cupertino: cupertino, cupertino: cupertino,
); );
} }
return Column( // The banner stays below the top bar; without it the chat screen
children: [ // reaches the top edge (an open chat beside the list draws its own bar
// there).
return TopBarNotices(
notices: [
if (!session.connected) if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino), 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 '../features/pipelines/screen.dart';
import '../ui/adaptive/host.dart'; import '../ui/adaptive/host.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart'; import 'app_session.dart';
import 'connection_status.dart'; import 'connection_status.dart';
import 'server_endpoint.dart'; import 'server_endpoint.dart';
@@ -72,12 +73,14 @@ class PipelinesDestination extends StatelessWidget {
cupertino: cupertino, cupertino: cupertino,
); );
} }
return Column( // The banner stays below the top bar; without it the pipelines reach
children: [ // the top edge and scroll behind the bar.
return TopBarNotices(
notices: [
if (!session.connected) if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino), 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/screen.dart';
import '../features/runs/ui/run_pipeline_link.dart'; import '../features/runs/ui/run_pipeline_link.dart';
import '../ui/adaptive/host.dart'; import '../ui/adaptive/host.dart';
import '../ui/adaptive/top_bar_notices.dart';
import 'app_session.dart'; import 'app_session.dart';
import 'connection_status.dart'; import 'connection_status.dart';
import 'server_endpoint.dart'; import 'server_endpoint.dart';
@@ -85,13 +86,15 @@ class RunsDestination extends StatelessWidget {
cupertino: cupertino, cupertino: cupertino,
); );
} }
return Column( // The banner stays below the top bar; without it the runs reach the top
children: [ // edge and scroll behind the bar.
return TopBarNotices(
notices: [
if (!session.connected || if (!session.connected ||
session.subscription == RunSubscriptionState.refused) session.subscription == RunSubscriptionState.refused)
ConnectionBanner(session: session, cupertino: cupertino), 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 '../ui/adaptive/segmented_bar.dart';
import '../core/api_gateway.dart'; import '../core/api_gateway.dart';
import '../features/templates/screen.dart'; import '../features/templates/screen.dart';
import '../shell/destination.dart';
import '../shell/shell_bar.dart';
import '../ui/adaptive/host.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 'app_session.dart';
import 'connection_status.dart'; import 'connection_status.dart';
import 'server_endpoint.dart'; import 'server_endpoint.dart';
@@ -57,32 +61,33 @@ class TemplatesDestination extends StatelessWidget {
Widget _body(bool cupertino) { Widget _body(bool cupertino) {
if (!session.everConnected) { if (!session.everConnected) {
return ConnectionGate( return BelowTopBar(
session: session, child: ConnectionGate(
server: server, session: session,
cupertino: cupertino, server: server,
cupertino: cupertino,
),
); );
} }
return Column( return TopBarNotices(
children: [ notices: [
if (!session.connected) if (!session.connected)
ConnectionBanner(session: session, cupertino: cupertino), 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 /// The page's standard native bar. Back is named explicitly so it cannot be
/// confused with the gallery's own Back-to-gallery control. /// confused with the gallery's own Back-to-gallery control. The gallery puts
class _TemplatesPage extends StatelessWidget { /// Refresh in this bar ([ShellBar]); its content scrolls behind the bar.
class _TemplatesPage extends StatefulWidget {
const _TemplatesPage({ const _TemplatesPage({
required this.cupertino, required this.cupertino,
required this.onBack, required this.onBack,
@@ -93,39 +98,72 @@ class _TemplatesPage extends StatelessWidget {
final VoidCallback onBack; final VoidCallback onBack;
final Widget child; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (cupertino) { final cupertino = widget.cupertino;
return CupertinoPageScaffold( // The page reaches its top edge; the gallery pads its lists by the bar.
navigationBar: SegmentedBar( final body = SafeArea(
cupertino: true, top: false,
leading: CupertinoButton( bottom: false,
key: templatesPageBackKey, child: ShellBarScope(
padding: EdgeInsets.zero, registry: _bar,
onPressed: onBack, destination: AppDestination.settings,
child: const Icon( child: widget.child,
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',
), ),
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, cupertino: true,
title: artifactGalleryTitle, title: artifactGalleryTitle,
), ),
child: SafeArea(child: body), child: SafeArea(top: false, bottom: false, child: body),
); );
} }
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
appBar: const SegmentedBar(cupertino: false, title: artifactGalleryTitle), 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( 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/destination.dart';
import '../../shell/detail_page.dart'; import '../../shell/detail_page.dart';
import '../../shell/list_detail.dart'; import '../../shell/list_detail.dart';
import '../../ui/adaptive/floating_bar_layout.dart';
import '../../ui/adaptive/host.dart'; import '../../ui/adaptive/host.dart';
import 'dart:async'; import 'dart:async';
@@ -241,15 +242,19 @@ class _ChatScreenState extends State<ChatScreen> {
? const SizedBox.shrink() ? const SizedBox.shrink()
: _thread(selected, () => Navigator.of(context).maybePop()), : _thread(selected, () => Navigator.of(context).maybePop()),
); );
final list = ChatSessionsScreen( // The shell's body now reaches the top edge; until the session list pads
gateway: widget.gateway, // itself by the bar (owned by the chat lane), it keeps starting below it.
embedded: true, final list = BelowTopBar(
syncToken: widget.syncToken, child: ChatSessionsScreen(
controller: _sessions, gateway: widget.gateway,
onOpen: _open, embedded: true,
onSessions: _adoptRows, syncToken: widget.syncToken,
activeSessionId: selected, controller: _sessions,
publishShellBar: true, onOpen: _open,
onSessions: _adoptRows,
activeSessionId: selected,
publishShellBar: true,
),
); );
if (!beside) return list; if (!beside) return list;
return ListDetailPanes( return ListDetailPanes(
@@ -7,6 +7,7 @@ import 'package:flutter/material.dart';
import '../../../ui/text/markdown_source_view.dart'; import '../../../ui/text/markdown_source_view.dart';
import '../../chat/ui/transcript/chat_markdown_view.dart'; import '../../chat/ui/transcript/chat_markdown_view.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
import '../domain/graph_protocol.dart'; import '../domain/graph_protocol.dart';
import '../domain/stage_definition.dart'; import '../domain/stage_definition.dart';
@@ -42,6 +43,7 @@ class StageDefinitionView extends StatefulWidget {
required this.pipelineId, required this.pipelineId,
required this.pipelineName, required this.pipelineName,
required this.version, required this.version,
this.showIdentity = true,
}); });
final JsonMap graph; final JsonMap graph;
@@ -50,16 +52,24 @@ class StageDefinitionView extends StatefulWidget {
final String pipelineName; final String pipelineName;
final int version; 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 @override
State<StageDefinitionView> createState() => _StageDefinitionViewState(); 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> { class _StageDefinitionViewState extends State<StageDefinitionView> {
// One switch for every authored text block; raw is the exact text. // One switch for every authored text block; raw is the exact text.
bool _raw = true; bool _raw = true;
String get _identity => String get _identity =>
'${widget.pipelineName.isEmpty ? 'Pipeline' : widget.pipelineName} \u00b7 v${widget.version}'; stageDefinitionIdentity(widget.pipelineName, widget.version);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
@@ -74,11 +84,14 @@ class _StageDefinitionViewState extends State<StageDefinitionView> {
? terminalDefinitionFields(graph, stageKey) ? terminalDefinitionFields(graph, stageKey)
: const <StageDefinitionField>[]; : const <StageDefinitionField>[];
// Scrolls behind the page's floating top bar; at rest it starts below it.
return ListView( return ListView(
padding: const EdgeInsets.all(16), padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [ children: [
Text(_identity, style: style.muted), if (widget.showIdentity) ...[
const SizedBox(height: 16), Text(_identity, style: style.muted),
const SizedBox(height: 16),
],
if (fields.any((field) => field.block)) ...[ if (fields.any((field) => field.block)) ...[
MarkdownModeSwitch( MarkdownModeSwitch(
raw: _raw, raw: _raw,
@@ -131,7 +144,9 @@ Future<void> openStageDefinition(
pipelineId: pipelineId, pipelineId: pipelineId,
pipelineName: pipelineName, pipelineName: pipelineName,
version: version, version: version,
showIdentity: false,
); );
final identity = stageDefinitionIdentity(pipelineName, version);
final settings = RouteSettings( final settings = RouteSettings(
name: 'stage-definition/$pipelineId/$version/$stageKey', name: 'stage-definition/$pipelineId/$version/$stageKey',
); );
@@ -142,16 +157,24 @@ Future<void> openStageDefinition(
? CupertinoPageRoute<void>( ? CupertinoPageRoute<void>(
settings: settings, settings: settings,
builder: (_) => CupertinoPageScaffold( builder: (_) => CupertinoPageScaffold(
navigationBar: SegmentedBar(cupertino: true, title: title), navigationBar: SegmentedBar(
child: SafeArea(child: view), cupertino: true,
title: title,
subtitle: identity,
),
child: SafeArea(top: false, bottom: false, child: view),
), ),
) )
: MaterialPageRoute<void>( : MaterialPageRoute<void>(
settings: settings, settings: settings,
builder: (_) => Scaffold( builder: (_) => Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
appBar: SegmentedBar(cupertino: false, title: title), appBar: SegmentedBar(
body: SafeArea(child: view), cupertino: false,
title: title,
subtitle: identity,
),
body: SafeArea(top: false, bottom: false, child: view),
), ),
); );
return Navigator.of(context).push(route); return Navigator.of(context).push(route);
+25 -28
View File
@@ -217,7 +217,20 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
final body = LayoutBuilder( final body = LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final wide = showsListBesideDetail(context); 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( _page.sync(
context, context,
selected: _controller.hasSelection && !wide, selected: _controller.hasSelection && !wide,
@@ -225,20 +238,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
onClosed: _controller.clearSelection, onClosed: _controller.clearSelection,
builder: (context) => AnimatedBuilder( builder: (context) => AnimatedBuilder(
animation: _controller, animation: _controller,
builder: (context, _) => ShellBar( builder: (context, _) => detail(),
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,
),
),
), ),
); );
if (!wide) { if (!wide) {
@@ -250,17 +250,14 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
list: ContentWidth( list: ContentWidth(
child: PipelineListPanel(controller: _controller), child: PipelineListPanel(controller: _controller),
), ),
detail: PipelineDetailPanel( detail: _controller.hasSelection
controller: _controller, ? DetailPane(
gateway: widget.gateway, key: const ValueKey('pipeline-detail-pane'),
showBack: false, destination: AppDestination.pipelines,
onRunStarted: widget.onRunStarted, implyBack: false,
onViewPipelineRuns: widget.onViewPipelineRuns, builder: (_) => detail(),
stageKey: stageKey, )
stagePipelineId: widget.initialPipelineId, : detail(),
stageVersion: widget.initialVersion,
stageRequest: _stageRequest,
),
); );
}, },
); );
@@ -362,7 +359,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
_refreshButton(context), _refreshButton(context),
], ],
), ),
body: SafeArea(child: body), body: SafeArea(top: false, child: body),
); );
} }
@@ -377,7 +374,7 @@ class _PipelinesScreenState extends State<PipelinesScreen> {
_refreshButton(context), _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.detail,
required this.gateway, required this.gateway,
this.onRunStarted, this.onRunStarted,
this.fab = false, this.inBar = false,
}); });
/// A floating action button instead of an inline button. /// The compact icon-and-word button of a top bar's actions pill instead
final bool fab; /// of an inline button.
final bool inBar;
final PipelinesController controller; final PipelinesController controller;
final PipelineDetail detail; final PipelineDetail detail;
@@ -169,8 +170,8 @@ class _RunPipelineActionState extends State<RunPipelineAction> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final label = const Text(runPipelineActionLabel); final label = const Text(runPipelineActionLabel);
if (widget.fab) { if (widget.inBar) {
return pipelineFab( return pipelineBarAction(
context, context,
key: runPipelineActionKey, key: runPipelineActionKey,
primary: true, 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 pipeline action in its top bar's actions pill: the icon and word as one
/// a filled pill with the same icon and word and a soft shadow. /// compact button. The primary action (Run) is filled so it reads apart from
Widget pipelineFab( /// the plain ones around it.
Widget pipelineBarAction(
BuildContext context, { BuildContext context, {
required Key key, required Key key,
required bool primary, required bool primary,
@@ -212,45 +214,39 @@ Widget pipelineFab(
children: [ children: [
Icon(cupertinoIcon, size: 18), Icon(cupertinoIcon, size: 18),
const SizedBox(width: 6), const SizedBox(width: 6),
Text(label), Flexible(child: Text(label, maxLines: 1, softWrap: false)),
], ],
); );
return DecoratedBox( const padding = EdgeInsets.symmetric(horizontal: 12, vertical: 6);
decoration: BoxDecoration( return primary
borderRadius: BorderRadius.circular(28), ? CupertinoButton.filled(
boxShadow: const [ key: key,
BoxShadow( padding: padding,
color: Color(0x33000000), minimumSize: Size.zero,
blurRadius: 8, onPressed: onPressed,
offset: Offset(0, 2), child: content,
), )
], : CupertinoButton(
), key: key,
child: primary padding: padding,
? CupertinoButton.filled( minimumSize: Size.zero,
key: key, onPressed: onPressed,
borderRadius: BorderRadius.circular(28), child: content,
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,
),
);
} }
final scheme = Theme.of(context).colorScheme; final icon = Icon(materialIcon);
return FloatingActionButton.extended( final text = Text(label, maxLines: 1, softWrap: false);
key: key, return primary
heroTag: key, ? FilledButton.icon(
backgroundColor: primary ? null : scheme.secondaryContainer, key: key,
foregroundColor: primary ? null : scheme.onSecondaryContainer, onPressed: onPressed,
onPressed: onPressed, icon: icon,
icon: Icon(materialIcon), label: text,
label: Text(label), )
); : 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 'package:flutter/material.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../shell/shell_bar.dart';
import '../../../ui/adaptive/floating_bar_layout.dart'; import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../graph/domain/graph_definition.dart'; import '../../graph/domain/graph_definition.dart';
import '../../graph/widgets/stage_definition_view.dart'; import '../../graph/widgets/stage_definition_view.dart';
import '../pipeline_models.dart'; import '../pipeline_models.dart';
import '../pipeline_query.dart';
import '../pipelines_controller.dart'; import '../pipelines_controller.dart';
import '../ui/run_pipeline_action.dart'; import '../ui/run_pipeline_action.dart';
import 'pipeline_controls.dart'; import 'pipeline_controls.dart';
@@ -95,18 +97,47 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final detail = _controller.detail; 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); _retainGraphSelection(detail);
_applyStageRequest(context, 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( final panel = LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final headerLimit = _headerLimit(constraints); final headerLimit = _headerLimit(constraints);
// The tabs float over the bottom of the tab body, as in the run // The tabs float over the tab body: at the bottom on a phone page,
// detail: full width on a phone, at the right edge of a wide pane. // under the pane's top bar beside a list (never on the shell's bar).
final edge = PageTabsEdge.of(context);
final tabs = PipelineDetailTabs( final tabs = PipelineDetailTabs(
selected: _tab, selected: _tab,
edge: edge,
onSelected: (tab) => setState(() => _tab = tab), 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( return Column(
key: const Key('pipeline-detail'), key: const Key('pipeline-detail'),
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -114,23 +145,10 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
ConstrainedBox( ConstrainedBox(
constraints: BoxConstraints(maxHeight: headerLimit), constraints: BoxConstraints(maxHeight: headerLimit),
child: SingleChildScrollView( child: SingleChildScrollView(
padding: EdgeInsets.only(top: notices.isEmpty ? 0 : inset),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: notices,
_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,
),
],
), ),
), ),
), ),
@@ -138,36 +156,35 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
// scroll their own content; the graph fills the slot so its canvas // scroll their own content; the graph fills the slot so its canvas
// is never asked for an unbounded extent inside a scroll view. // is never asked for an unbounded extent inside a scroll view.
Expanded( Expanded(
child: FloatingBarOverlay( child: MediaQuery(
bar: tabs, data: media.copyWith(
child: Builder( padding: media.padding.copyWith(
builder: (context) => Stack( top: notices.isEmpty ? inset : 0,
children: [ ),
Positioned.fill( ),
child: switch (_tab) { child: FloatingBarOverlay(
PipelineDetailTab.summary => _scrolling( edge: edge,
PipelineSummaryView( bar: tabs,
controller: _controller, child: Builder(
detail: detail, builder: (context) => switch (_tab) {
gateway: widget.gateway, PipelineDetailTab.summary => _scrolling(
), PipelineSummaryView(
), controller: _controller,
PipelineDetailTab.graph => PipelineGraphTab( detail: detail,
detail: detail, gateway: widget.gateway,
selectedStage: _graphSelection, showIdentity: !inBar,
onSelected: (stageKey) => ),
_openGraphStage(context, detail, stageKey),
),
PipelineDetailTab.source => _source(context, detail),
},
), ),
// Run and Runs float over the content, above the tabs. PipelineDetailTab.graph => BelowTopBar(
PositionedDirectional( child: PipelineGraphTab(
end: 16, detail: detail,
bottom: 16 + MediaQuery.paddingOf(context).bottom, selectedStage: _graphSelection,
child: _fabs(context, detail), 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 /// The header keeps its natural height while at least
@@ -345,56 +367,62 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
: title; : title;
return Padding( return Padding(
key: const Key('pipeline-detail-header'), key: const Key('pipeline-detail-header'),
// The web detail head is a compact single identity line; the recorded // On its own (no top bar) the panel heads itself with the pipeline's
// id/version/stage facts live at the top of the Summary tab. // 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), padding: const EdgeInsets.fromLTRB(12, 6, 12, 4),
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, 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 /// Runs and the primary Run: the top bar's actions, never floating over
/// the edge. /// the content (where they used to cover the version history).
Widget _fabs(BuildContext context, PipelineDetail detail) => Column( List<Widget> _actions(BuildContext context, PipelineDetail detail) => [
key: const Key('pipeline-actions'), Semantics(
mainAxisSize: MainAxisSize.min, button: true,
crossAxisAlignment: CrossAxisAlignment.end, label: detail.name.trim().isEmpty
children: [ ? 'View runs of this pipeline'
Semantics( : 'View runs of ${detail.name}',
button: true, child: ExcludeSemantics(
label: detail.name.trim().isEmpty child: pipelineBarAction(
? 'View runs of this pipeline' context,
: 'View runs of ${detail.name}', key: const Key('pipeline-view-runs'),
child: ExcludeSemantics( primary: false,
child: pipelineFab( materialIcon: Icons.list_alt,
context, cupertinoIcon: CupertinoIcons.list_bullet,
key: const Key('pipeline-view-runs'), label: 'Runs',
primary: false, onPressed: widget.onViewPipelineRuns == null
materialIcon: Icons.list_alt, ? null
cupertinoIcon: CupertinoIcons.list_bullet, : () => widget.onViewPipelineRuns!(detail.id),
label: 'Runs',
onPressed: widget.onViewPipelineRuns == null
? null
: () => widget.onViewPipelineRuns!(detail.id),
),
), ),
), ),
const SizedBox(height: 12), ),
RunPipelineAction( RunPipelineAction(
controller: _controller, controller: _controller,
detail: detail, detail: detail,
gateway: widget.gateway, gateway: widget.gateway,
onRunStarted: widget.onRunStarted, onRunStarted: widget.onRunStarted,
fab: true, inBar: true,
), ),
], ];
);
Widget _source(BuildContext context, PipelineDetail detail) { Widget _source(BuildContext context, PipelineDetail detail) {
return ListView( return ListView(
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)), padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [ children: [
if (detail.source.isEmpty) if (detail.source.isEmpty)
Text('No source recorded.', style: pipelineMutedStyle(context)) Text('No source recorded.', style: pipelineMutedStyle(context))
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../pipeline_filter.dart'; import '../pipeline_filter.dart';
import 'pipeline_controls.dart'; import 'pipeline_controls.dart';
@@ -24,7 +25,7 @@ class PipelineFilterMaterialBody extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ListView( return ListView(
padding: const EdgeInsets.all(16), padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [ children: [
TextField( TextField(
controller: name, 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( return Scaffold(
@@ -121,7 +121,7 @@ class _PipelineFilterPageState extends State<PipelineFilterPage> {
title: 'Filter pipelines', title: 'Filter pipelines',
actions: [TextButton(onPressed: _apply, child: const Text('Done'))], 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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/status/run_status_icon.dart'; import '../../../ui/status/run_status_icon.dart';
import '../pipeline_format.dart'; import '../pipeline_format.dart';
import '../pipeline_models.dart'; import '../pipeline_models.dart';
@@ -28,32 +29,42 @@ class PipelineListPanel extends StatelessWidget {
(pipeline) => (pipeline) =>
pipeline.scheduleState == PipelineScheduleState.unclassified, 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, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
_scope(context, filters), ...header,
_toolbar(context, filters, hasUnclassified), Expanded(child: state),
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)),
], ],
); ),
} );
/// The web's compact toolbar: filter (whose page carries the name search), /// 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. /// 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) { if (controller.initialListLoading) {
return _centered(context, const ['Loading pipelines…']); return _withoutRows(
header,
_centered(context, const ['Loading pipelines…']),
);
} }
if (!controller.pipelinesLoaded) { if (!controller.pipelinesLoaded) {
if (controller.listError != null) return const SizedBox.shrink(); if (controller.listError != null) {
return _centered(context, const ['Loading pipelines…']); return _withoutRows(header, const SizedBox.shrink());
}
return _withoutRows(
header,
_centered(context, const ['Loading pipelines…']),
);
} }
final items = controller.visiblePipelines; final items = controller.visiblePipelines;
if (items.isEmpty) { if (items.isEmpty) {
final empty = controller.emptyState; final empty = controller.emptyState;
if (empty == null) return const SizedBox.shrink(); if (empty == null) return _withoutRows(header, const SizedBox.shrink());
return _empty(context, empty); return _withoutRows(header, _empty(context, empty));
} }
// A list pane beside a detail can be very narrow (a 640px window leaves // 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 // it ~130px): there the rows drop the identity icon and chevron so the
@@ -126,8 +145,8 @@ class PipelineListPanel extends StatelessWidget {
builder: (context, constraints) { builder: (context, constraints) {
final compact = constraints.maxWidth < _compactRowWidth; final compact = constraints.maxWidth < _compactRowWidth;
return useCupertinoControls(context) return useCupertinoControls(context)
? _cupertinoList(context, items, compact: compact) ? _cupertinoList(context, header, items, compact: compact)
: _materialList(context, items, compact: compact); : _materialList(context, header, items, compact: compact);
}, },
); );
} }
@@ -178,16 +197,22 @@ class PipelineListPanel extends StatelessWidget {
Widget _materialList( Widget _materialList(
BuildContext context, BuildContext context,
List<Widget> header,
List<PipelineSummary> items, { List<PipelineSummary> items, {
required bool compact, required bool compact,
}) { }) {
final now = DateTime.now(); 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( return ListView.separated(
key: const Key('pipeline-list'), key: const Key('pipeline-list'),
itemCount: items.length, itemCount: header.length + items.length,
separatorBuilder: (context, index) => const Divider(height: 1), separatorBuilder: (context, index) => index < header.length
? const SizedBox.shrink()
: const Divider(height: 1),
itemBuilder: (context, index) { itemBuilder: (context, index) {
final pipeline = items[index]; if (index < header.length) return header[index];
final pipeline = items[index - header.length];
return ListTile( return ListTile(
key: Key('pipeline-row-${pipeline.id}'), key: Key('pipeline-row-${pipeline.id}'),
selected: controller.selectedId == pipeline.id, selected: controller.selectedId == pipeline.id,
@@ -210,6 +235,7 @@ class PipelineListPanel extends StatelessWidget {
Widget _cupertinoList( Widget _cupertinoList(
BuildContext context, BuildContext context,
List<Widget> header,
List<PipelineSummary> items, { List<PipelineSummary> items, {
required bool compact, required bool compact,
}) { }) {
@@ -217,6 +243,7 @@ class PipelineListPanel extends StatelessWidget {
return ListView( return ListView(
key: const Key('pipeline-list'), key: const Key('pipeline-list'),
children: [ children: [
...header,
CupertinoListSection.insetGrouped( CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground, backgroundColor: AppColors.groupedBackground,
children: [ children: [
@@ -20,12 +20,17 @@ class PipelineSummaryView extends StatelessWidget {
required this.controller, required this.controller,
required this.detail, required this.detail,
required this.gateway, required this.gateway,
this.showIdentity = true,
}); });
final PipelinesController controller; final PipelinesController controller;
final PipelineDetail detail; final PipelineDetail detail;
final ApiGateway gateway; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final historical = detail.resolvedVersion != detail.latestVersion; final historical = detail.resolvedVersion != detail.latestVersion;
@@ -34,13 +39,14 @@ class PipelineSummaryView extends StatelessWidget {
children: [ children: [
// The web's Summary subtitle: the compact header names the pipeline, // The web's Summary subtitle: the compact header names the pipeline,
// this line carries its recorded identity. // this line carries its recorded identity.
Padding( if (showIdentity)
padding: const EdgeInsets.fromLTRB(16, 12, 16, 0), Padding(
child: Text( padding: const EdgeInsets.fromLTRB(16, 12, 16, 0),
pipelineSubtitle(detail), child: Text(
style: pipelineMutedStyle(context), pipelineSubtitle(detail),
style: pipelineMutedStyle(context),
),
), ),
),
if (historical) if (historical)
Padding( Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 4),
@@ -1,5 +1,6 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/floating_destination_bar.dart'; import '../../../ui/adaptive/floating_destination_bar.dart';
import 'pipeline_controls.dart'; import 'pipeline_controls.dart';
import 'pipeline_detail_tab.dart'; import 'pipeline_detail_tab.dart';
@@ -7,7 +8,7 @@ import 'pipeline_detail_tab.dart';
export 'pipeline_detail_tab.dart'; export 'pipeline_detail_tab.dart';
/// The pipeline detail's tabs: the app's floating glass tab bar, full width on /// 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 /// Float it over the tab body with `FloatingBarOverlay`. The whole bar is
/// keyed `pipeline-detail-tabs`, each tab `pipeline-detail-tab-<name>`. /// keyed `pipeline-detail-tabs`, each tab `pipeline-detail-tab-<name>`.
@@ -16,11 +17,16 @@ class PipelineDetailTabs extends StatelessWidget {
super.key, super.key,
required this.selected, required this.selected,
required this.onSelected, required this.onSelected,
this.edge = FloatingBarEdge.bottom,
}); });
final PipelineDetailTab selected; final PipelineDetailTab selected;
final ValueChanged<PipelineDetailTab> onSelected; 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 @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino = useCupertinoControls(context); final cupertino = useCupertinoControls(context);
@@ -30,6 +36,7 @@ class PipelineDetailTabs extends StatelessWidget {
child: FloatingDestinationBar( child: FloatingDestinationBar(
cupertino: cupertino, cupertino: cupertino,
currentIndex: tabs.indexOf(selected), currentIndex: tabs.indexOf(selected),
edge: edge,
onTap: (value) => onSelected(tabs[value]), onTap: (value) => onSelected(tabs[value]),
items: [ items: [
for (final tab in tabs) for (final tab in tabs)
@@ -31,6 +31,19 @@ String detailTitle(JsonMap run) {
return identity.label.trim().isEmpty ? 'Run ${run['id']}' : identity.label; 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) { String detailPipeline(JsonMap run) {
final name = '${run['name'] ?? ''}'.trim(); final name = '${run['name'] ?? ''}'.trim();
return name.isEmpty ? 'unavailable' : name; return name.isEmpty ? 'unavailable' : name;
@@ -3,27 +3,21 @@ import 'package:flutter/cupertino.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../ui/status/run_status_icon.dart'; import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart'; import '../domain/run_models.dart';
import 'run_detail_content.dart';
import 'run_detail_tabs.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 /// The runs detail with standard Cupertino controls. It has no Material
/// ancestor: the host header keeps native navigation, actions and notices, and /// ancestor: the top bar carries the run's identity, Back and the more menu;
/// the shared tab body uses native Cupertino expansion tiles and grouped list /// this header keeps the status in its colour beside the run actions, and the
/// sections. Copy feedback is an inline live-region status. /// notices. The shared tab body uses native Cupertino expansion tiles and
/// grouped list sections. Copy feedback is an inline live-region status.
Widget buildCupertinoRunDetail({ Widget buildCupertinoRunDetail({
required BuildContext context, required BuildContext context,
required JsonMap run, required JsonMap run,
required Widget headerActions, required Widget headerActions,
bool inShellBar = false,
ValueChanged<num>? onRunOpened,
OpenPipeline? onOpenPipeline,
required bool detailLoading, required bool detailLoading,
required String? error, required String? error,
required bool copying, required bool copying,
required String? copyStatus, required String? copyStatus,
required VoidCallback onBack,
required VoidCallback onCopy, required VoidCallback onCopy,
required ApiGateway gateway, required ApiGateway gateway,
required ValueChanged<JsonMap> onRunChanged, required ValueChanged<JsonMap> onRunChanged,
@@ -31,7 +25,6 @@ Widget buildCupertinoRunDetail({
String? initialStageKey, String? initialStageKey,
int? initialVisit, int? initialVisit,
}) { }) {
final theme = CupertinoTheme.of(context);
return RunDetailTabs( return RunDetailTabs(
run: run, run: run,
cupertino: true, cupertino: true,
@@ -46,82 +39,22 @@ Widget buildCupertinoRunDetail({
header: Column( header: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ 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(
padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0), padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 0),
child: Column( child: Wrap(
crossAxisAlignment: CrossAxisAlignment.start, spacing: 12,
runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center,
children: [ children: [
Wrap( RunStatusKicker(
spacing: 8, state: runStateOf(run['status']),
runSpacing: 4, label: runStatusLabel(run),
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,
),
],
), ),
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 (detailLoading) const _CupertinoNotice('Refreshing run details…'),
if (error != null) _CupertinoNotice(error), if (error != null) _CupertinoNotice(error),
], ],
@@ -3,27 +3,22 @@ import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../ui/status/run_status_icon.dart'; import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart'; import '../domain/run_models.dart';
import 'run_detail_content.dart';
import 'run_detail_tabs.dart'; import 'run_detail_tabs.dart';
import 'run_more_menu.dart';
import 'run_pipeline_link.dart';
/// The runs detail with standard Material controls. /// The runs detail with standard Material controls.
/// ///
/// The host header keeps the run identity, status and every action; the shared /// The top bar carries the run's identity (title, number, pipeline and
/// tab body supplies Summary, Graph, Input, Output and Timeline. /// 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({ Widget buildMaterialRunDetail({
required BuildContext context, required BuildContext context,
required JsonMap run, required JsonMap run,
required Widget headerActions, required Widget headerActions,
bool inShellBar = false,
ValueChanged<num>? onRunOpened,
OpenPipeline? onOpenPipeline,
required bool detailLoading, required bool detailLoading,
required String? error, required String? error,
required bool copying, required bool copying,
required String? copyStatus, required String? copyStatus,
required VoidCallback onBack,
required VoidCallback onCopy, required VoidCallback onCopy,
required ApiGateway gateway, required ApiGateway gateway,
required ValueChanged<JsonMap> onRunChanged, required ValueChanged<JsonMap> onRunChanged,
@@ -31,7 +26,6 @@ Widget buildMaterialRunDetail({
String? initialStageKey, String? initialStageKey,
int? initialVisit, int? initialVisit,
}) { }) {
final theme = Theme.of(context);
return RunDetailTabs( return RunDetailTabs(
run: run, run: run,
cupertino: false, cupertino: false,
@@ -46,76 +40,16 @@ Widget buildMaterialRunDetail({
header: Column( header: Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ 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(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), 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( child: Wrap(
spacing: 8, spacing: 12,
runSpacing: 4, runSpacing: 4,
crossAxisAlignment: WrapCrossAlignment.center, crossAxisAlignment: WrapCrossAlignment.center,
children: [ children: [
Text('Run ${run['id']}'), RunStatusKicker(
Wrap( state: runStateOf(run['status']),
crossAxisAlignment: WrapCrossAlignment.center, label: runStatusLabel(run),
children: [
const Text('Pipeline '),
RunPipelineLink(
run: run,
cupertino: false,
onOpenPipeline: onOpenPipeline,
),
],
), ),
headerActions, headerActions,
], ],
@@ -41,6 +41,9 @@ Widget runDetailSummaryTab({
return CustomScrollView( return CustomScrollView(
key: const Key('run-detail-tab-body-summary'), key: const Key('run-detail-tab-body-summary'),
slivers: [ 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), if (graphPreview != null) SliverToBoxAdapter(child: graphPreview),
SliverToBoxAdapter( SliverToBoxAdapter(
child: cupertino child: cupertino
@@ -212,7 +215,7 @@ Widget runDetailFieldTab({
return Builder( return Builder(
builder: (context) => ListView( builder: (context) => ListView(
key: Key('run-detail-tab-body-$tabKey'), key: Key('run-detail-tab-body-$tabKey'),
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)), padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [body], children: [body],
), ),
); );
@@ -1,5 +1,6 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/floating_destination_bar.dart'; import '../../../ui/adaptive/floating_destination_bar.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
import 'run_detail_tab.dart'; import 'run_detail_tab.dart';
@@ -16,23 +17,26 @@ const List<RunDetailTab> renderedRunDetailTabs = [
RunDetailTab.changes, RunDetailTab.changes,
]; ];
/// The run detail's tabs: the app's floating glass tab bar, full width on a /// The run detail's tabs: the app's floating glass tab bar, full width at the
/// phone and sized to its tabs at the right edge of a wide pane. /// 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 /// Float it over the tab body with `FloatingBarOverlay` at the same [edge];
/// visible, so a tab selected by the Graph is shown selected without /// every tab is always visible, so a tab selected by the Graph is shown
/// scrolling. The whole bar is keyed `run-detail-tabs`, each tab /// selected without scrolling. The whole bar is keyed `run-detail-tabs`, each
/// `run-detail-tab-<name>`. /// tab `run-detail-tab-<name>`.
class RunDetailTabStrip extends StatelessWidget { class RunDetailTabStrip extends StatelessWidget {
const RunDetailTabStrip({ const RunDetailTabStrip({
super.key, super.key,
required this.selected, required this.selected,
required this.onSelected, required this.onSelected,
this.tabs = renderedRunDetailTabs, this.tabs = renderedRunDetailTabs,
this.edge = FloatingBarEdge.bottom,
}); });
final RunDetailTab selected; final RunDetailTab selected;
final ValueChanged<RunDetailTab> onSelected; final ValueChanged<RunDetailTab> onSelected;
final FloatingBarEdge edge;
/// The tabs this run offers, in [renderedRunDetailTabs] order. /// The tabs this run offers, in [renderedRunDetailTabs] order.
final List<RunDetailTab> tabs; final List<RunDetailTab> tabs;
@@ -46,6 +50,7 @@ class RunDetailTabStrip extends StatelessWidget {
child: FloatingDestinationBar( child: FloatingDestinationBar(
cupertino: cupertino, cupertino: cupertino,
currentIndex: index < 0 ? 0 : index, currentIndex: index < 0 ? 0 : index,
edge: edge,
onTap: (value) => onSelected(tabs[value]), onTap: (value) => onSelected(tabs[value]),
items: [ items: [
for (final tab in tabs) 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) final shown = tabs.contains(_tab) || !renderedRunDetailTabs.contains(_tab)
? _tab ? _tab
: RunDetailTab.summary; : RunDetailTab.summary;
final edge = PageTabsEdge.of(context);
return LayoutBuilder( return LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final headerLimit = _headerLimit(constraints); final headerLimit = _headerLimit(constraints);
return Column( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ 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( ConstrainedBox(
constraints: BoxConstraints(maxHeight: headerLimit), constraints: BoxConstraints(maxHeight: headerLimit),
child: SingleChildScrollView( child: SingleChildScrollView(
key: ValueKey('run-detail-header-${widget.run['id']}'), key: ValueKey('run-detail-header-${widget.run['id']}'),
padding: EdgeInsets.only(top: topBarInset(context)),
child: widget.header, child: widget.header,
), ),
), ),
// Every tab gets the bounded remaining height. The scrolling tabs // Every tab gets the bounded remaining height. The scrolling tabs
// own their content; the Graph tab fills the slot so its canvas is // own their content; the Graph tab fills the slot so its canvas is
// never asked for an unbounded extent. The tabs float over the // 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( Expanded(
key: ValueKey('run-detail-body-${widget.run['id']}'), key: ValueKey('run-detail-body-${widget.run['id']}'),
child: FloatingBarOverlay( child: MediaQuery.removePadding(
bar: RunDetailTabStrip( context: context,
tabs: tabs, removeTop: true,
selected: shown, child: FloatingBarOverlay(
onSelected: (tab) => setState(() => _tab = tab), 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, finalOnly: true,
); );
// A CupertinoApp supplies no Material theme; follow the host so the // A CupertinoApp supplies no Material theme; follow the host so the
// viewer's section text stays readable. // viewer's section text stays readable. Its summary heads the tab, so
return widget.cupertino // the tab starts below a pane's top tabs.
? Theme(data: hostTextTheme(context), child: viewer) return BelowTopBar(
: viewer; child: widget.cupertino
? Theme(data: hostTextTheme(context), child: viewer)
: viewer,
);
case RunDetailTab.timeline: case RunDetailTab.timeline:
final visits = detailTimeline(widget.run['steps']); final visits = detailTimeline(widget.run['steps']);
final index = _selectedVisit; final index = _selectedVisit;
@@ -34,7 +34,7 @@ class RunTimelineList extends StatelessWidget {
if (visits.isEmpty) { if (visits.isEmpty) {
return ListView( return ListView(
key: const Key('run-detail-tab-body-timeline'), 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.')], children: const [Text('No visits recorded.')],
); );
} }
@@ -64,7 +64,7 @@ class RunTimelineList extends StatelessWidget {
} }
return ListView( return ListView(
key: const Key('run-detail-tab-body-timeline'), key: const Key('run-detail-tab-body-timeline'),
padding: withFloatingBarClearance( padding: withBarClearance(
context, context,
const EdgeInsets.symmetric(vertical: 8), 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 '../../../core/transport/pipelines_client.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
import '../../../shell/shell_bar.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_detail_actions.dart';
import 'run_more_menu.dart'; import 'run_more_menu.dart';
import 'run_pipeline_link.dart'; import 'run_pipeline_link.dart';
@@ -75,14 +77,10 @@ class _RunDetailViewState extends State<RunDetailView> {
context: context, context: context,
run: run, run: run,
headerActions: headerActions, headerActions: headerActions,
onRunOpened: widget.onRunOpened,
onOpenPipeline: widget.onOpenPipeline,
inShellBar: inShellBar,
detailLoading: widget.controller.detailLoading, detailLoading: widget.controller.detailLoading,
error: widget.controller.error, error: widget.controller.error,
copying: _copying, copying: _copying,
copyStatus: _copyStatus, copyStatus: _copyStatus,
onBack: widget.onBack,
onCopy: () => _copyPrompt(prompt ?? '', cupertino: true), onCopy: () => _copyPrompt(prompt ?? '', cupertino: true),
gateway: widget.gateway, gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail, onRunChanged: widget.controller.acceptRunDetail,
@@ -94,14 +92,10 @@ class _RunDetailViewState extends State<RunDetailView> {
context: context, context: context,
run: run, run: run,
headerActions: headerActions, headerActions: headerActions,
onRunOpened: widget.onRunOpened,
onOpenPipeline: widget.onOpenPipeline,
inShellBar: inShellBar,
detailLoading: widget.controller.detailLoading, detailLoading: widget.controller.detailLoading,
error: widget.controller.error, error: widget.controller.error,
copying: _copying, copying: _copying,
copyStatus: _copyStatus, copyStatus: _copyStatus,
onBack: widget.onBack,
onCopy: () => _copyPrompt(prompt ?? '', cupertino: false), onCopy: () => _copyPrompt(prompt ?? '', cupertino: false),
gateway: widget.gateway, gateway: widget.gateway,
onRunChanged: widget.controller.acceptRunDetail, onRunChanged: widget.controller.acceptRunDetail,
@@ -109,25 +103,68 @@ class _RunDetailViewState extends State<RunDetailView> {
initialStageKey: widget.initialStageKey, initialStageKey: widget.initialStageKey,
initialVisit: widget.initialVisit, initialVisit: widget.initialVisit,
); );
// The app bar becomes the run's: Back to the list, the run and its // The top bar becomes the run's: Back to the list, its title over its
// more menu. Search and the tab name return when the run closes. // number, pipeline and version (a link to that pipeline when the host
return ShellBar( // can open it) and its more menu, so the body repeats none of them.
title: 'Run ${run['id']}', // Search and the tab name return when the run closes.
onBack: widget.onBack, final title = detailTitle(run);
actions: [ final subtitle = detailSubtitle(run);
RunMoreMenu( final openPipeline = _openPipeline(run);
run: run, final pipelineName = detailPipeline(run);
gateway: widget.gateway, final more = RunMoreMenu(
onRunChanged: widget.controller.acceptRunDetail, 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, 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, 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}) { Widget _placeholder(BuildContext context, {required bool cupertino}) {
final loading = widget.controller.detailLoading; final loading = widget.controller.detailLoading;
final message = loading final message = loading
+38 -25
View File
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
import '../../../ui/status/run_status_icon.dart'; import '../../../ui/status/run_status_icon.dart';
import '../../attention/notify/notification_controller.dart'; import '../../attention/notify/notification_controller.dart';
@@ -112,30 +113,36 @@ class RunsList extends StatelessWidget {
if (controller.error != null && controller.runs.isEmpty) { if (controller.error != null && controller.runs.isEmpty) {
return _emptyError(context); return _emptyError(context);
} }
return Column( // The notice and the applied filters lead the list, so they scroll
crossAxisAlignment: CrossAxisAlignment.stretch, // behind the top bar with the runs and start below it at rest.
children: [ final header = [
if (controller.error != null) _inlineError(context), if (controller.error != null) _inlineError(context),
RunsFilters(controller: controller), RunsFilters(controller: controller),
Expanded( ];
child: controller.visibleRuns.isEmpty if (controller.visibleRuns.isNotEmpty) return _groupedRuns(context, header);
? _state( return BelowTopBar(
context, child: Column(
icon: Icon( crossAxisAlignment: CrossAxisAlignment.stretch,
usesCupertinoHost(context) children: [
? CupertinoIcons.tray ...header,
: Icons.inbox_outlined, Expanded(
), child: _state(
title: 'No runs found.', context,
subtitle: 'Try changing or clearing the filters.', icon: Icon(
) usesCupertinoHost(context)
: _groupedRuns(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 groups = groupRunsByDay(controller.visibleRuns, DateTime.now());
final entries = <({String? label, JsonMap? run})>[]; final entries = <({String? label, JsonMap? run})>[];
for (final group in groups) { 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. // Runs that start while the list is open enter with a short fade.
return ArrivalScope( return ArrivalScope(
ids: [for (final run in controller.visibleRuns) '${run['id']}'], 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( return ListView.builder(
itemCount: entries.length, itemCount: header.length + entries.length,
itemBuilder: (context, index) { 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?) { if (entry.label case final label?) {
// A day heading reads as a divider between groups of runs. // A day heading reads as a divider between groups of runs.
return Padding( return Padding(
@@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart'; import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
import '../../../ui/status/run_status_icon.dart'; import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart'; import '../domain/run_models.dart';
@@ -39,13 +40,13 @@ class RunsStatsPage extends StatelessWidget {
if (cupertino) { if (cupertino) {
return CupertinoPageScaffold( return CupertinoPageScaffold(
navigationBar: const SegmentedBar(cupertino: true, title: 'Usage'), navigationBar: const SegmentedBar(cupertino: true, title: 'Usage'),
child: SafeArea(child: body), child: SafeArea(top: false, bottom: false, child: body),
); );
} }
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
appBar: const SegmentedBar(cupertino: false, title: 'Usage'), 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; : Theme.of(context).colorScheme.onSurfaceVariant;
return ListView( return ListView(
key: const ValueKey('runs.stats.page'), key: const ValueKey('runs.stats.page'),
padding: const EdgeInsets.all(16), padding: withBarClearance(context, const EdgeInsets.all(16)),
children: [ children: [
Text('Usage', style: heading), Text('Usage', style: heading),
const SizedBox(height: 8), const SizedBox(height: 8),
+12 -10
View File
@@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../core/api_gateway.dart'; import '../../core/api_gateway.dart';
import '../../ui/adaptive/top_bar_notices.dart';
import '../../ui/adaptive/host.dart'; import '../../ui/adaptive/host.dart';
import 'data/template_repository.dart'; import 'data/template_repository.dart';
import 'domain/template_entry.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. /// open template never hides a failed read. The rows and selection are kept.
Widget _withFailure(BuildContext context, Widget body) { Widget _withFailure(BuildContext context, Widget body) {
final error = _error; final error = _error;
if (error == null || !_loaded) return body; // The banner stays put below the top bar; without it the body scrolls
return Column( // behind the bar.
crossAxisAlignment: CrossAxisAlignment.stretch, return TopBarNotices(
children: [ notices: [
TemplatesFailureBanner( if (error != null && _loaded)
message: error, TemplatesFailureBanner(
retrying: _loading, message: error,
onRetry: () => unawaited(_load()), retrying: _loading,
), onRetry: () => unawaited(_load()),
Expanded(child: body), ),
], ],
child: body,
); );
} }
} }
@@ -1,6 +1,7 @@
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
import '../domain/template_entry.dart'; import '../domain/template_entry.dart';
@@ -52,7 +53,7 @@ class TemplateDetail extends StatelessWidget {
final cupertino = usesCupertinoHost(context); final cupertino = usesCupertinoHost(context);
return ListView( return ListView(
key: templateDetailKey, key: templateDetailKey,
padding: const EdgeInsets.only(bottom: 24), padding: withBarClearance(context, const EdgeInsets.only(bottom: 24)),
children: [ children: [
if (showBack) _backRow(context, cupertino), if (showBack) _backRow(context, cupertino),
Padding( Padding(
@@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/adaptive/segmented_bar.dart'; import '../../../ui/adaptive/segmented_bar.dart';
import '../../../shell/shell_bar.dart';
import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/host.dart';
const templatesRefreshKey = ValueKey<String>('templates-refresh'); 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 /// 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 /// 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 { class TemplatesFrame extends StatelessWidget {
const TemplatesFrame({ const TemplatesFrame({
super.key, super.key,
@@ -39,6 +41,11 @@ class TemplatesFrame extends StatelessWidget {
} }
Widget _embedded(BuildContext context) { 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( return Column(
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
children: [ children: [
@@ -69,7 +76,7 @@ class TemplatesFrame extends StatelessWidget {
title: 'Templates', title: 'Templates',
actions: [_refreshButton(context)], actions: [_refreshButton(context)],
), ),
child: SafeArea(child: body), child: SafeArea(top: false, bottom: false, child: body),
); );
} }
@@ -84,7 +91,7 @@ class TemplatesFrame extends StatelessWidget {
: null, : null,
actions: [_refreshButton(context)], 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 '../ui/adaptive/floating_destination_bar.dart';
import 'attention_badge.dart'; import 'attention_badge.dart';
import 'destination.dart'; import 'destination.dart';
import 'list_detail.dart';
import 'shell_bar.dart'; import 'shell_bar.dart';
class AdaptiveShell extends StatefulWidget { class AdaptiveShell extends StatefulWidget {
@@ -95,19 +96,19 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
); );
} }
if (destination != AppDestination.runs) return icon; if (destination != AppDestination.runs) return icon;
// Runs in progress at the bottom, runs that need you at the top. // One indicator: runs that need you outrank runs in progress, so the
icon = ActivityBadge( // tab never wears two counts at once.
key: const ValueKey('shell.badge.runs.running'), final attention = widget.attentionCount > 0;
count: _bar.badge(destination, ShellBadgeKind.running),
label: 'runs in progress',
cupertino: widget.cupertino,
bottom: true,
child: icon,
);
return AttentionDestinationIcon( return AttentionDestinationIcon(
count: widget.attentionCount, count: widget.attentionCount,
cupertino: widget.cupertino, 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]), onTap: (value) => _select(AppDestination.values[value]),
items: _destinationItems(), 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) { if (widget.cupertino) {
return CupertinoPageScaffold( return CupertinoPageScaffold(
navigationBar: _segmentedBar(spec, details.label), navigationBar: topBar,
child: SafeArea( child: SafeArea(
top: false,
bottom: false, bottom: false,
child: FloatingBarOverlay( child: FloatingBarOverlay(
bar: bar, bar: bar,
@@ -162,14 +171,8 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
} }
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
appBar: _segmentedBar(spec, details.label), appBar: topBar,
// Destinations start below the floating top bar. body: _destinationStack(contents, index),
body: SafeArea(
left: false,
right: false,
bottom: false,
child: _destinationStack(contents, index),
),
extendBody: true, extendBody: true,
bottomNavigationBar: bar, bottomNavigationBar: bar,
); );
@@ -208,6 +211,11 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
onPressed: onBack, onPressed: onBack,
), ),
title: spec?.title ?? label, title: spec?.title ?? label,
subtitle: spec?.subtitle,
subtitleIcon: spec?.subtitleIcon,
onTitlePressed: spec?.onTitlePressed,
titleSemanticLabel: spec?.titleSemanticLabel,
titleKey: spec?.titleKey,
actions: [ actions: [
if (published.isNotEmpty) if (published.isNotEmpty)
// A screen taking the bar over cross-fades its actions in. // 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) => Widget _destinationStack(List<Widget> contents, int index) =>
IndexedStack(key: _destinationStackKey, index: index, children: contents); 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, cupertino: cupertino,
automaticallyImplyLeading: widget.implyBack, automaticallyImplyLeading: widget.implyBack,
title: title, title: title,
subtitle: spec?.subtitle,
subtitleIcon: spec?.subtitleIcon,
onTitlePressed: spec?.onTitlePressed,
titleSemanticLabel: spec?.titleSemanticLabel,
titleKey: spec?.titleKey,
actions: actions, actions: actions,
); );
// The bottom inset (the system's, or a floating tab bar's when the // Both insets pass through: the content scrolls behind the bar and
// pane sits beside a list) passes through: the open item's content // pads its lists by the bar's height (top) and by the system's or a
// floats its own tabs above it and pads its lists clear of it. // floating tab bar's (bottom), floating its own tabs clear of them.
final content = SafeArea(top: false, bottom: false, child: body);
if (cupertino) { if (cupertino) {
return CupertinoPageScaffold( return CupertinoPageScaffold(navigationBar: bar, child: content);
navigationBar: bar,
child: SafeArea(bottom: false, child: body),
);
} }
return Scaffold( return Scaffold(
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
appBar: bar, 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/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/host.dart'; import '../ui/adaptive/host.dart';
import 'shell_bar.dart';
/// At least this wide, a destination keeps its list beside the open item /// 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. /// (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) => bool showsListBesideDetail(BuildContext context) =>
MediaQuery.sizeOf(context).width >= kListDetailMinWidth; 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 /// One body-priority policy for all destinations, derived from the full window
/// and actual available space after navigation. No fixed pixel pane widths. /// 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 { class ListDetailPanes extends StatelessWidget {
const ListDetailPanes({super.key, required this.list, required this.detail}); const ListDetailPanes({super.key, required this.list, required this.detail});
@@ -32,50 +58,57 @@ class ListDetailPanes extends StatelessWidget {
color: CupertinoColors.separator.resolveFrom(context), color: CupertinoColors.separator.resolveFrom(context),
) )
: const VerticalDivider(width: 1); : const VerticalDivider(width: 1);
return LayoutBuilder( final media = MediaQuery.of(context);
builder: (context, constraints) { final split = ShellBar.available(context);
final window = MediaQuery.sizeOf(context).width; return ShellPaneSplit(
// Target 60% of the full window. Keep at least half for the body while child: LayoutBuilder(
// leaving a flexible share for native list controls on tighter windows. builder: (context, constraints) {
final requestedMinimum = window * _bodyWindowMinimum; final bodyWidth = listDetailBodyWidth(
final minimum = constraints.maxWidth > requestedMinimum media.size.width,
? requestedMinimum constraints.maxWidth,
: constraints.maxWidth * _bodyWindowMinimum; );
final maximum = math.max( Widget body = detail;
minimum, if (split) {
constraints.maxWidth * _bodyAvailableMaximum, // 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.
final bodyWidth = (window * _bodyWindowTarget).clamp(minimum, maximum); body = MediaQuery(
return Row( data: media.copyWith(
crossAxisAlignment: CrossAxisAlignment.stretch, padding: media.padding.copyWith(top: media.viewPadding.top),
children: [ ),
Expanded( child: PageTabsEdge(edge: FloatingBarEdge.top, child: body),
child: SizedBox.expand( );
key: const ValueKey('list-detail-list'), }
child: Semantics( return Row(
container: true, crossAxisAlignment: CrossAxisAlignment.stretch,
explicitChildNodes: true, children: [
identifier: 'list-detail-list', Expanded(
child: list, child: SizedBox.expand(
key: const ValueKey('list-detail-list'),
child: Semantics(
container: true,
explicitChildNodes: true,
identifier: 'list-detail-list',
child: list,
),
), ),
), ),
), divider,
divider, SizedBox(
SizedBox( width: bodyWidth,
width: bodyWidth, child: SizedBox.expand(
child: SizedBox.expand( key: const ValueKey('list-detail-body'),
key: const ValueKey('list-detail-body'), child: Semantics(
child: Semantics( container: true,
container: true, explicitChildNodes: true,
explicitChildNodes: true, identifier: 'list-detail-body',
identifier: 'list-detail-body', child: body,
child: detail, ),
), ),
), ),
), ],
], );
); },
}, ),
); );
} }
} }
+95
View File
@@ -7,12 +7,27 @@ import 'destination.dart';
class ShellBarSpec { class ShellBarSpec {
const ShellBarSpec({ const ShellBarSpec({
this.title, this.title,
this.subtitle,
this.subtitleIcon,
this.onTitlePressed,
this.titleSemanticLabel,
this.titleKey,
this.onBack, this.onBack,
this.actions = const [], this.actions = const [],
this.barless = false, this.barless = false,
}); });
final String? title; 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 VoidCallback? onBack;
final List<Widget> actions; final List<Widget> actions;
@@ -26,6 +41,20 @@ class ShellBarRegistry extends ChangeNotifier {
final Map<AppDestination, (Object, ShellBarSpec)> _specs = {}; final Map<AppDestination, (Object, ShellBarSpec)> _specs = {};
final Map<(AppDestination, ShellBadgeKind), int> _badges = {}; 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. /// The count a tab's screen published for [kind], 0 when none.
int badge(AppDestination destination, ShellBadgeKind kind) => int badge(AppDestination destination, ShellBadgeKind kind) =>
_badges[(destination, kind)] ?? 0; _badges[(destination, kind)] ?? 0;
@@ -92,6 +121,11 @@ class ShellBar extends StatefulWidget {
const ShellBar({ const ShellBar({
super.key, super.key,
this.title, this.title,
this.subtitle,
this.subtitleIcon,
this.onTitlePressed,
this.titleSemanticLabel,
this.titleKey,
this.onBack, this.onBack,
this.actions = const [], this.actions = const [],
this.active = true, this.active = true,
@@ -107,6 +141,13 @@ class ShellBar extends StatefulWidget {
final bool active; final bool active;
final String? title; 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 VoidCallback? onBack;
final List<Widget> actions; final List<Widget> actions;
final Widget child; final Widget child;
@@ -141,6 +182,11 @@ class _ShellBarState extends State<ShellBar> {
} }
final spec = ShellBarSpec( final spec = ShellBarSpec(
title: widget.title, title: widget.title,
subtitle: widget.subtitle,
subtitleIcon: widget.subtitleIcon,
onTitlePressed: widget.onTitlePressed,
titleSemanticLabel: widget.titleSemanticLabel,
titleKey: widget.titleKey,
onBack: widget.onBack, onBack: widget.onBack,
actions: widget.actions, actions: widget.actions,
barless: widget.barless, 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. /// What a tab badge counts.
enum ShellBadgeKind { enum ShellBadgeKind {
/// Runs still executing. /// Runs still executing.
+156 -37
View File
@@ -19,6 +19,77 @@ EdgeInsetsGeometry withFloatingBarClearance(
EdgeInsetsGeometry padding, EdgeInsetsGeometry padding,
) => padding.add(EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom)); ) => 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 /// Empty space as tall as the floating bar's clearance
/// ([MediaQuery.paddingOf] bottom), ending a scrolling column so its last item /// ([MediaQuery.paddingOf] bottom), ending a scrolling column so its last item
/// comes clear of the bar at rest. /// comes clear of the bar at rest.
@@ -39,49 +110,91 @@ class SliverFloatingBarClearance extends StatelessWidget {
const SliverToBoxAdapter(child: FloatingBarClearance()); const SliverToBoxAdapter(child: FloatingBarClearance());
} }
/// Floats [bar] over the bottom of [child], the way a scaffold with /// The edge a page's own floating tab bar sits at.
/// `extendBody` floats its bottom bar, for a bar that is not a scaffold's. 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 /// A detail pane beside a list says [FloatingBarEdge.top], so an open item's
/// bar's measured height (bottom safe area and margins included) as its /// tabs never stack on the shell's tab bar; everywhere else they float at the
/// [MediaQuery.paddingOf] bottom, so a list can pad its last item clear of the /// bottom.
/// bar at rest (see [withFloatingBarClearance]). Taps the bar does not take, class PageTabsEdge extends InheritedWidget {
/// such as beside a bar narrower than the area, reach [child]. 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 { 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 bar;
final Widget child; final Widget child;
final FloatingBarEdge edge;
@override @override
Widget build(BuildContext context) => CustomMultiChildLayout( Widget build(BuildContext context) {
delegate: _OverlayLayout(), final top = edge == FloatingBarEdge.top;
children: [ final inset = top ? MediaQuery.paddingOf(context).top : 0.0;
// Painted first, so the bar draws (and takes taps) above it. return CustomMultiChildLayout(
LayoutId( delegate: _OverlayLayout(top: top, inset: inset),
id: _Slot.content, children: [
child: LayoutBuilder( // Painted first, so the bar draws (and takes taps) above it.
builder: (context, constraints) { LayoutId(
final barHeight = constraints is _ContentConstraints id: _Slot.content,
? constraints.barHeight child: LayoutBuilder(
: 0.0; builder: (context, constraints) {
final media = MediaQuery.of(context); final barHeight = constraints is _ContentConstraints
return MediaQuery( ? constraints.barHeight
data: media.copyWith( : 0.0;
padding: media.padding.copyWith( final media = MediaQuery.of(context);
bottom: barHeight > media.padding.bottom final padding = top
? barHeight ? media.padding.copyWith(top: inset + barHeight)
: media.padding.bottom, : media.padding.copyWith(
), bottom: barHeight > media.padding.bottom
), ? barHeight
child: child, : 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 } enum _Slot { content, bar }
@@ -110,6 +223,11 @@ class _ContentConstraints extends BoxConstraints {
} }
class _OverlayLayout extends MultiChildLayoutDelegate { class _OverlayLayout extends MultiChildLayoutDelegate {
_OverlayLayout({required this.top, required this.inset});
final bool top;
final double inset;
@override @override
void performLayout(Size size) { void performLayout(Size size) {
final bar = layoutChild( final bar = layoutChild(
@@ -120,7 +238,7 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
maxHeight: size.height, maxHeight: size.height,
), ),
); );
positionChild(_Slot.bar, Offset(0, size.height - bar.height)); positionChild(_Slot.bar, Offset(0, top ? inset : size.height - bar.height));
layoutChild( layoutChild(
_Slot.content, _Slot.content,
_ContentConstraints(size, barHeight: bar.height), _ContentConstraints(size, barHeight: bar.height),
@@ -129,5 +247,6 @@ class _OverlayLayout extends MultiChildLayoutDelegate {
} }
@override @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.currentIndex,
required this.onTap, required this.onTap,
required this.items, required this.items,
this.edge = FloatingBarEdge.bottom,
}); });
final bool cupertino; 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 int currentIndex;
final ValueChanged<int> onTap; final ValueChanged<int> onTap;
final List<FloatingDestinationItem> items; 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). /// Height of the Cupertino bar inside the pill (the stock bar is 50).
static const double cupertinoHeight = 54; static const double cupertinoHeight = 54;
/// The side margin at [FloatingBarEdge.top], matching the top bar's own.
static const double topMargin = 12;
@override @override
Widget build(BuildContext context) { 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( return SafeArea(
top: false, top: false,
minimum: const EdgeInsets.fromLTRB( minimum: const EdgeInsets.fromLTRB(
@@ -51,35 +110,7 @@ class FloatingDestinationBar extends StatelessWidget {
kFloatingBarMargin, kFloatingBarMargin,
kFloatingBarMargin, kFloatingBarMargin,
), ),
child: LayoutBuilder( child: bar,
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),
),
),
);
},
),
); );
} }
+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,
),
),
],
);
}
}
+151
View File
@@ -0,0 +1,151 @@
# App chrome fixes (style review batch A: F1, F2, F3, F7, F15/F26, F19)
Follow-up to `notes/segmented-bar.md` and `notes/floating-tab-bars.md`, from
the independent review in `/tmp/app-style-review/report.md`.
## F1: content floats behind the top bar
Helpers (`lib/ui/adaptive/floating_bar_layout.dart`, next to
`withFloatingBarClearance`):
- `withTopBarClearance(context, padding)`, `withBarClearance` (top + bottom),
`TopBarClearance`, `topBarInset(context)`.
- `SliverTopBarClearance`: a *pinned*, empty, tap-through header, so the first
sliver starts below the bar and any later pinned header (sticky sections,
`StickyBar`) pins at the bar's inset instead of behind it.
- `BelowTopBar`: fixed content (a canvas, a header) starts below the bar and
its subtree no longer sees the bar's height.
- `lib/ui/adaptive/top_bar_notices.dart` `TopBarNotices(notices:, child:)`:
banners stay below the bar; without one the child reaches the top edge.
The child keeps its place, so a banner never remounts it.
Applied:
- Shell (`shell/adaptive_shell.dart`): no top `SafeArea` (Material body is the
destination stack directly; Cupertino `SafeArea(top: false, bottom: false)`).
Scaffold structure unchanged otherwise (the stack keeps its GlobalKey).
- `DetailPane` (`shell/detail_page.dart`): body `SafeArea(top: false, bottom:
false)`; passes the spec's subtitle / title press / title key to the bar.
- Runs list (`runs_list.dart`): the error notice and applied filters are the
first rows of the one `ListView` (default media padding), so they scroll
behind the bar; the empty state uses `BelowTopBar`.
- Pipelines list (`pipeline_list_panel.dart`): All/Scheduled, the clear-filter
button, banners and progress lead the list; empty/loading states keep them
below the bar.
- Pipeline detail: the tab body reaches the top edge; refresh/error notices
stay below the bar without remounting the tab. Source uses
`withBarClearance`; Graph is `BelowTopBar` (its overlay buttons).
- Run detail: the slim header (status + actions + notices) is padded by the
inset; tab bodies use `SliverTopBarClearance` / `withBarClearance` so they
also clear top tabs (below). Changes tab is `BelowTopBar` (fixed summary).
- Artifact gallery (`artifact_visit_list.dart`, page): `SliverTopBarClearance`
first, page `SafeArea(top: false, bottom: false)`.
- Stage definition page: list `withBarClearance`; the pipeline/version line
moved to the bar's subtitle (`StageDefinitionView(showIdentity: false)`).
- Templates (`templates_frame.dart`, `screen.dart`, `template_detail.dart`,
`application/templates_destination.dart`): page body floats; Refresh moves
into the page bar (the page hosts a `ShellBarScope`, the embedded frame
publishes through `ShellBar`); failure/connection banners use
`TopBarNotices`.
- Pipeline filter page, usage (`runs_stats_page.dart`): lists use
`withBarClearance`.
- Runs/Pipelines/Chat destinations: connection banner through `TopBarNotices`.
Left with a top inset (deliberately, with reason):
- Chat list (`features/chat/screen.dart` wraps it in `BelowTopBar`): the chat
lane owns its list padding; this keeps today's look until it pads itself.
Settings and Search keep their own `SafeArea`s (other lanes).
- `graph_expanded_view.dart`, `run_graph_preview.dart`: canvases with overlay
controls at their top and fit-to-viewport; floating them needs inset-aware
fit and controls (F12 lane).
- `file_diff_viewer.dart`, `run_changes_action.dart` (ChangesViewer),
`artifact_viewer_page.dart`: fixed headers/info strips above the scrolling
part; floating needs those headers inside the scroll (F13/F25 lanes touch
the same views).
- `application/schedules_destination.dart`: the search/refresh toolbar is a
pinned control row; the page keeps its top inset.
## F2/F3: one top row, no stacked bottom pills on wide windows
- `ListDetailPanes` (`shell/list_detail.dart`) publishes `ShellPaneSplit` to
the shell; the shell wraps its bar in `_ListPaneBar`, which narrows it to the
list pane width (`listDetailListWidth`, the same split math, now shared as
`listDetailBodyWidth`). The detail side gets only the system inset
(`viewPadding.top`) as its top padding, so its `DetailPane` bar sits on the
same row at the top edge.
- The detail side also gets `PageTabsEdge(edge: FloatingBarEdge.top)`. Run and
pipeline tabs read it: `FloatingBarOverlay(edge:)` and
`FloatingDestinationBar(edge:)` float the tabs just under the pane's bar /
header (sized to tabs, leading edge, 12 margins); the content's top padding
grows by the tabs' height. On phones and pushed pages nothing changes
(bottom).
- `FloatingDestinationBar` now strips leftover media padding inside the pill:
the host `NavigationBar` has its own `SafeArea` and swelled to ~130px when a
page's top padding (or the shell's bottom bar height) reached it.
- F3: wide pipeline detail is a `DetailPane` like runs and chat; the panel
itself publishes title, subtitle and actions through `ShellBar` (also on the
phone page, so `screen.dart` no longer wraps it).
## F7: pipeline detail
- Run/Runs FABs removed; they are the bar's actions (`pipelineBarAction`: a
`TextButton.icon` Runs and `FilledButton.icon` Run, Cupertino plain/filled
buttons; keys `pipeline-view-runs`, `run-pipeline-action` kept).
`RunPipelineAction(fab:)` became `inBar:`; `pipelineFab` is gone.
- No headline in the body: name in the title pill, `id · v · stages` as its
subtitle (Summary drops that line when in a bar,
`PipelineSummaryView(showIdentity:)`). A bare panel (no bar, tests) keeps a
header with the name and the actions row (`pipeline-detail-header`,
`pipeline-actions`).
## F15/F26: run detail title
- Title pill: the run's real title, subtitle `Run N · pipeline · vX`
(`detailSubtitle`). When the host can open pipelines the pill is the link
(`runPipelineLinkKey`, label `Open pipeline <name>`), replacing the body's
`Pipeline <name>` line.
- Body header: only the coloured status kicker beside the run actions, and the
notices. Title, `Run N`, pipeline line and the old `← Back to list` /
Cupertino Back row are gone; a run detail outside any bar draws the same
`SegmentedBar` (Back `run-detail-back`, title, subtitle, more menu) over
itself with `SegmentedBarOverlay`. (The loading/error placeholder keeps its
`Back to list` button: it has no bar content to show.)
## F19: one Runs badge
Attention outranks running: the running `ActivityBadge` count is 0 while the
attention count is positive; both stay in the tree (keys unchanged), so the
icon never remounts. The running badge moved to the same top corner.
## Tests
New: `test/ui/adaptive/top_bar_clearance_test.dart` (list reaches the top
edge, starts below the bar, scrolls behind it — Material and Cupertino; a
pinned header after `SliverTopBarClearance` pins at the inset;
`TopBarNotices` keeps the child mounted; top-edge tab bar position, height
and content padding), `test/shell/pane_bar_row_test.dart` (1200: shell bar
pieces stay within the list pane, pane bar on the same row, subtitle in the
pill, item tabs under the pane bar and far above the shell tabs, item list
below its tabs — both hosts; 390 page: tabs at bottom, content from the top
edge below the bar; one Runs badge).
Updated for intentional changes: `run_detail_finders.dart` (title is in the
pane/page bar), `runs_screen_test.dart` and `runs_destination_test.dart` (the
bar title arrives a frame later), `run_detail_widget_test.dart` (kicker below
the bar title), `run_detail_header_test.dart` (link label is the pill's),
`pipelines_screen_test.dart` (Run/Runs in the bar),
`pipeline_list_composition_test.dart` (no body headline), `widget_test.dart`
(a bare body is centred, bodies reach the top edge).
## Evidence
`/tmp/fix-a-evidence/` (headless Chrome via the reviewer's `shoot.mjs` with
its runs/pipelines loopback fixtures over a web build of `lib/main.dart`, and
static builds of `tool/floating_tabs_probe_entry.dart` and
`tool/run_detail_visit_probe.dart`): runs/run detail/pipelines/pipeline
detail at 560 and 1200 (light/dark, scrolled), chat list + thread at 1200,
settings/templates/schedules/search, floating-tabs probe (Cupertino; one
Runs badge), standalone run detail bar (`rv-standalone-*`).
Known gaps: no device run. A standalone `PipelinesScreen` (probe/tests only,
not the app) still shows its window-wide bar above the detail pane's bar.
+5 -4
View File
@@ -55,13 +55,14 @@ Cupertino sidebar are gone.
is `visitTabFor(section)`, so Input/Output highlight Summary. is `visitTabFor(section)`, so Input/Output highlight Summary.
- Pipeline detail (`features/pipelines/widgets/pipeline_tabs.dart`, - Pipeline detail (`features/pipelines/widgets/pipeline_tabs.dart`,
`pipeline_detail_panel.dart`): the same (it was a bottom bar on phones); `pipeline_detail_panel.dart`): the same (it was a bottom bar on phones);
`pipeline-detail-tabs`, new `pipeline-detail-tab-<name>`. Run/Runs FABs sit `pipeline-detail-tabs`, new `pipeline-detail-tab-<name>`. Run/Runs are now
16 above the bar (`bottom: 16 + MediaQuery.paddingOf(context).bottom`). the top bar's actions, not FABs (`notes/app-chrome-fixes.md`).
- `DetailPane` (`shell/detail_page.dart`) no longer consumes the bottom inset; - `DetailPane` (`shell/detail_page.dart`) no longer consumes the bottom inset;
its content (run detail, pipeline detail, chat thread with its own its content (run detail, pipeline detail, chat thread with its own
`SafeArea` composer) handles it. Beside a list on a wide window the open `SafeArea` composer) handles it. Beside a list on a wide window the open
item's tabs therefore float just above the shell's bar (two stacked pills item's tabs float at the top of the pane instead (`PageTabsEdge`,
at the right edge) and content scrolls behind both. `FloatingBarEdge.top`), so they never stack on the shell's bar; see
`notes/app-chrome-fixes.md`.
- Not converted (judged not bottom tabs): the segmented filters/toggles at the - Not converted (judged not bottom tabs): the segmented filters/toggles at the
top of lists and viewers (`SegmentedButton` / `CupertinoSlidingSegmentedControl` top of lists and viewers (`SegmentedButton` / `CupertinoSlidingSegmentedControl`
in markdown source view, artifact gallery mode, diff form, pipeline scope, in markdown source view, artifact gallery mode, diff form, pipeline scope,
+5 -5
View File
@@ -44,11 +44,11 @@ pill on the page's own background) is now the app's only top bar.
the transcript with `SegmentedBarOverlay`; the list pads its first item by the transcript with `SegmentedBarOverlay`; the list pads its first item by
the bar height, so at rest nothing is hidden and scrolled history passes the bar height, so at rest nothing is hidden and scrolled history passes
behind the glass pills. behind the glass pills.
- Other pages keep their content inset with `SafeArea` (bodies that used - The shell, `DetailPane` and most pages now float their content too (top
`SafeArea(top: false)` now use the full `SafeArea`; the shell, chat list and `SafeArea` dropped; lists pad by `withTopBarClearance` / `withBarClearance` /
schedules bodies gained a top-only `SafeArea`). They show the new bar but `SliverTopBarClearance`, fixed notices use `TopBarNotices` / `BelowTopBar`).
their content does not yet scroll behind it — each list has its own fixed See `notes/app-chrome-fixes.md` for what was converted and what still keeps
padding/headers and needs a per-screen change to consume the media padding. a top inset (chat list, settings, search, schedules toolbar, canvases).
- Bottom tab bars float too: see `notes/floating-tab-bars.md`. - Bottom tab bars float too: see `notes/floating-tab-bars.md`.
## Converted ## Converted
@@ -8,6 +8,7 @@ import 'package:pipelines_app/application/runs_destination.dart';
import 'package:pipelines_app/application/server_endpoint.dart'; import 'package:pipelines_app/application/server_endpoint.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart'; import 'package:pipelines_app/core/transport/pipelines_client.dart';
import 'package:pipelines_app/features/runs/screen.dart'; import 'package:pipelines_app/features/runs/screen.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import '../core/transport/pipelines_client_test.dart' show FakeChannel; import '../core/transport/pipelines_client_test.dart' show FakeChannel;
import '../features/runs/ui/run_detail_finders.dart'; import '../features/runs/ui/run_detail_finders.dart';
@@ -229,7 +230,8 @@ void main() {
}), }),
); );
await tester.pump(); await tester.pump();
expect(runDetailText('Open run'), findsOneWidget); // The detail is open; its title reaches the pane's bar a frame later.
expect(find.byType(RunDetailView), findsOneWidget);
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget); expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
first.incoming.addError(StateError('network drop')); first.incoming.addError(StateError('network drop'));
@@ -272,6 +274,7 @@ void main() {
}), }),
); );
await tester.pump(); await tester.pump();
await tester.pump();
expect(runDetailText('Open run'), findsOneWidget); expect(runDetailText('Open run'), findsOneWidget);
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget); expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
}, },
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart'; import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/shell/detail_page.dart';
import 'fixtures.dart'; import 'fixtures.dart';
import 'test_helpers.dart'; import 'test_helpers.dart';
@@ -44,38 +45,34 @@ void main() {
expect(find.text('no runs recorded'), findsNothing); expect(find.text('no runs recorded'), findsNothing);
}); });
testWidgets('the detail header is one identity line; Summary keeps facts', ( testWidgets('the pane bar names the pipeline and its identity; the body '
tester, 'repeats neither', (tester) async {
) async {
final fixture = PipelineFixture(); final fixture = PipelineFixture();
await pumpWide(tester, gatewayFor(fixture)); await pumpWide(tester, gatewayFor(fixture));
await tester.tap(find.byKey(const Key('pipeline-row-1'))); await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
final pane = find.byType(DetailPane);
final detail = find.byKey(const Key('pipeline-detail')); final detail = find.byKey(const Key('pipeline-detail'));
final header = find.byKey(const Key('pipeline-detail-header')); // No headline in the body: the title pill holds the name over the
expect(header, findsOneWidget); // recorded identity.
expect( expect(find.byKey(const Key('pipeline-detail-header')), findsNothing);
find.descendant(of: header, matching: find.text('Alpha review')), final title = find.descendant(
findsOneWidget, of: pane,
matching: find.text('Alpha review'),
); );
final identity = find.text('id 1 · v2 · 2 stages');
expect(title, findsOneWidget);
expect(identity, findsOneWidget);
expect( expect(
find.descendant(of: header, matching: find.text('id 1 · v2 · 2 stages')), find.descendant(of: detail, matching: find.text('Alpha review')),
findsNothing, findsNothing,
); );
// The recorded identity now sits at the top of the Summary tab. expect(find.descendant(of: detail, matching: identity), findsNothing);
expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget); // The identity is the pill's subtitle, under the name.
expect( expect(
tester tester.getTopLeft(identity).dy,
.getTopLeft( greaterThan(tester.getTopLeft(title).dy),
find.descendant(
of: header,
matching: find.text('Alpha review'),
),
)
.dx -
tester.getTopLeft(detail).dx,
12,
); );
}); });
@@ -106,14 +106,15 @@ void main() {
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.bySemanticsLabel('View runs of Alpha review'), findsOneWidget); expect(find.bySemanticsLabel('View runs of Alpha review'), findsOneWidget);
// Run and Runs share one action row, as the web's pipeline actions. // Run and Runs share the detail pane's actions pill at the top right,
// Run and Runs float at the bottom right, Runs above the primary Run. // Runs before the primary Run; nothing floats over the content.
final runs = tester.getRect(find.byKey(const Key('pipeline-view-runs'))); final runs = tester.getRect(find.byKey(const Key('pipeline-view-runs')));
final run = tester.getRect(find.byKey(runPipelineActionKey)); final run = tester.getRect(find.byKey(runPipelineActionKey));
final screen = tester.view.physicalSize / tester.view.devicePixelRatio; final screen = tester.view.physicalSize / tester.view.devicePixelRatio;
expect(runs.bottom, lessThanOrEqualTo(run.top)); expect(runs.right, lessThanOrEqualTo(run.left));
expect((runs.center.dy - run.center.dy).abs(), lessThan(1));
expect(run.right, greaterThan(screen.width - 40)); expect(run.right, greaterThan(screen.width - 40));
expect(run.bottom, greaterThan(screen.height - 120)); expect(run.bottom, lessThan(screen.height / 4));
await tester.tap(find.byKey(const Key('pipeline-view-runs'))); await tester.tap(find.byKey(const Key('pipeline-view-runs')));
expect(opened, [1]); expect(opened, [1]);
}); });
@@ -1,10 +1,17 @@
import 'package:flutter/widgets.dart'; import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart'; import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
import 'package:pipelines_app/shell/detail_page.dart';
/// Wide screens deliberately repeat the selected title in the visible list. /// Wide screens deliberately repeat the selected title in the visible list.
Finder runDetailText(String text) => /// The run's title is in its top bar: the detail pane's (or page's) when the
find.descendant(of: find.byType(RunDetailView), matching: find.text(text)); /// detail sits in one, else the run detail's own.
Finder runDetailText(String text) => find.descendant(
of: find.byWidgetPredicate(
(widget) => widget is RunDetailView || widget is DetailPane,
),
matching: find.text(text),
);
/// Stage identity and visit coordinates are separate rendered fields now. /// Stage identity and visit coordinates are separate rendered fields now.
void expectVisitHeading(WidgetTester tester, String stage, num sequence) { void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
@@ -89,7 +89,11 @@ void main() {
await tester.tap(find.byKey(runPipelineLinkKey)); await tester.tap(find.byKey(runPipelineLinkKey));
await tester.pump(); await tester.pump();
expect(opened, [(10, 3)]); expect(opened, [(10, 3)]);
expect(find.bySemanticsLabel('Open pipeline nightly'), findsOneWidget); // The run's title pill is the link, announced as opening the pipeline.
expect(
find.bySemanticsLabel(RegExp('Open pipeline nightly')),
findsOneWidget,
);
}); });
testWidgets('$host: a succeeded run offers no Retry', (tester) async { testWidgets('$host: a succeeded run offers no Retry', (tester) async {
@@ -147,11 +147,12 @@ void main() {
expect(tester.takeException(), isNull); expect(tester.takeException(), isNull);
expect(find.text('Nightly build'), findsOneWidget); expect(find.text('Nightly build'), findsOneWidget);
expect(find.textContaining('Original prompt'), findsNothing); expect(find.textContaining('Original prompt'), findsNothing);
// Both hosts lead with the web's status kicker above the title. // The title is the top bar's; the status kicker leads the body below
// it, and the body does not repeat the title.
expect(find.byKey(const Key('run-status-kicker')), findsOneWidget); expect(find.byKey(const Key('run-status-kicker')), findsOneWidget);
expect( expect(
tester.getTopLeft(find.byKey(const Key('run-status-kicker'))).dy, tester.getTopLeft(find.byKey(const Key('run-status-kicker'))).dy,
lessThan(tester.getTopLeft(find.text('Nightly build')).dy), greaterThan(tester.getBottomLeft(find.text('Nightly build')).dy),
); );
// Input and Output are sticky collapsibles on both hosts. // Input and Output are sticky collapsibles on both hosts.
expect( expect(
@@ -119,6 +119,7 @@ void main() {
'input': {'prompt': 'initial prompt'}, 'input': {'prompt': 'initial prompt'},
}); });
await tester.pump(); await tester.pump();
await tester.pump();
expect(runDetailText('Alpha run'), findsOneWidget); expect(runDetailText('Alpha run'), findsOneWidget);
expect(find.text('Input'), findsOneWidget); expect(find.text('Input'), findsOneWidget);
@@ -159,6 +160,7 @@ void main() {
expect(gateway.detailRequests[2], hasLength(1)); expect(gateway.detailRequests[2], hasLength(1));
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'}); gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
await tester.pump(); await tester.pump();
await tester.pump();
expect(runDetailText('Beta run'), findsOneWidget); expect(runDetailText('Beta run'), findsOneWidget);
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget); expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
}); });
@@ -251,6 +253,7 @@ void main() {
expect(gateway.detailRequests[2], hasLength(1)); expect(gateway.detailRequests[2], hasLength(1));
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'}); gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
await tester.pump(); await tester.pump();
await tester.pump();
expect(runDetailText('Beta run'), findsOneWidget); expect(runDetailText('Beta run'), findsOneWidget);
await tester.pumpWidget(_materialScreen(gateway, initialRunId: 1)); await tester.pumpWidget(_materialScreen(gateway, initialRunId: 1));
@@ -258,6 +261,7 @@ void main() {
expect(gateway.detailRequests[1], hasLength(1)); expect(gateway.detailRequests[1], hasLength(1));
gateway.replyDetail(1, 0, {'id': 1, 'title': 'Alpha run'}); gateway.replyDetail(1, 0, {'id': 1, 'title': 'Alpha run'});
await tester.pump(); await tester.pump();
await tester.pump();
expect(runDetailText('Alpha run'), findsOneWidget); expect(runDetailText('Alpha run'), findsOneWidget);
await tester.pumpWidget(_materialScreen(gateway)); await tester.pumpWidget(_materialScreen(gateway));
@@ -274,6 +278,7 @@ void main() {
await _mountList(tester, gateway); await _mountList(tester, gateway);
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'}); gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
await tester.pump(); await tester.pump();
await tester.pump();
expect(runDetailText('Beta run'), findsOneWidget); expect(runDetailText('Beta run'), findsOneWidget);
await tester.pumpWidget( await tester.pumpWidget(
@@ -291,6 +296,7 @@ void main() {
'status': 'succeeded', 'status': 'succeeded',
}); });
await tester.pump(); await tester.pump();
await tester.pump();
expect(runDetailText('Beta run'), findsOneWidget); expect(runDetailText('Beta run'), findsOneWidget);
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget); expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
}); });
+231
View File
@@ -0,0 +1,231 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/detail_page.dart';
import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
/// Beside a list each pane owns its bar on one shared top row, and an open
/// item's tabs never stack on the shell's tab bar at the bottom.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
Rect rectOf(Element element) {
final box = element.renderObject! as RenderBox;
return box.localToGlobal(Offset.zero) & box.size;
}
/// An open item: its title published to the pane's bar, its own tabs
/// floating where the pane says, and a list padded clear of both bars.
Widget item({bool cupertino = false}) => ShellBar(
title: 'Open item',
subtitle: 'Its context',
actions: const [Icon(Icons.more_vert, semanticLabel: 'More')],
child: Builder(
builder: (context) {
final edge = PageTabsEdge.of(context);
return FloatingBarOverlay(
edge: edge,
bar: KeyedSubtree(
key: const Key('item-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
edge: edge,
currentIndex: 0,
onTap: (_) {},
items: const [
FloatingDestinationItem(icon: Icon(Icons.notes), label: 'One'),
FloatingDestinationItem(
icon: Icon(Icons.timeline),
label: 'Two',
),
],
),
),
child: Builder(
builder: (context) => ListView(
key: const Key('item-list'),
padding: withBarClearance(context, EdgeInsets.zero),
children: [
for (var index = 0; index < 30; index++)
SizedBox(height: 40, child: Text('item row $index')),
],
),
),
);
},
),
);
Widget shell({bool cupertino = false, int attention = 0}) {
final app = AdaptiveShell(
cupertino: cupertino,
attentionCount: attention,
destinationBodies: {
AppDestination.runs: (_) => ShellBadge(
kind: ShellBadgeKind.running,
count: 4,
child: ListDetailPanes(
list: ShellBar(
actions: [const Icon(Icons.sort, semanticLabel: 'Sort')],
child: ListView(
children: [
for (var index = 0; index < 30; index++)
SizedBox(height: 40, child: Text('list row $index')),
],
),
),
detail: DetailPane(
destination: AppDestination.runs,
implyBack: false,
builder: (_) => item(cupertino: cupertino),
),
),
),
},
destination: AppDestination.runs,
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
}
Finder shellBar() => find.byWidgetPredicate(
(widget) => widget is SegmentedBar && widget.title == 'Runs',
);
Finder paneBar() => find.descendant(
of: find.byType(DetailPane),
matching: find.byType(SegmentedBar),
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host 1200: the shell bar covers the list pane and the '
'item\'s bar shares its row', (tester) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
await tester.pump();
final list = tester.getRect(
find.byKey(const ValueKey('list-detail-list')),
);
final body = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
final shellPills = find.descendant(
of: shellBar(),
matching: find.byType(GlassPill),
);
for (final element in shellPills.evaluate()) {
expect(
rectOf(element).right,
lessThanOrEqualTo(list.right),
reason: 'no shell piece sits over the open item',
);
}
// Both titles on the same top row.
final shellTitle = tester.getRect(
find.descendant(of: shellBar(), matching: find.text('Runs')),
);
final paneTitle = tester.getRect(find.text('Open item'));
expect(paneTitle.left, greaterThanOrEqualTo(body.left));
final paneTop = tester.getRect(
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
);
final shellTop = tester.getRect(shellPills.first);
expect(paneTop.top, shellTop.top);
expect(paneTitle.top, lessThan(shellTitle.bottom));
// The title pill carries the item's context too.
expect(find.text('Its context'), findsOneWidget);
});
testWidgets('$host 1200: the item\'s tabs float under its bar, not on '
'the shell\'s tab bar', (tester) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
await tester.pump();
final shellTabs = tester.getRect(
find.descendant(
of: find.byKey(const ValueKey('shell.destination.runs')).first,
matching: find.byType(Icon),
),
);
final itemTabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('item-tabs')),
matching: find.byType(GlassPill),
),
);
final paneBarPill = tester.getRect(
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
);
expect(itemTabs.top, greaterThanOrEqualTo(paneBarPill.bottom));
expect(itemTabs.top, lessThan(200));
expect(itemTabs.bottom, lessThan(shellTabs.top - 100));
// The item's list starts below its tabs at rest.
expect(
tester.getTopLeft(find.text('item row 0')).dy,
greaterThanOrEqualTo(itemTabs.bottom),
);
});
}
testWidgets('390: an open item is its own page with its tabs at the bottom', (
tester,
) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(
MaterialApp(
home: DetailPane(
destination: AppDestination.runs,
builder: (_) => item(),
),
),
);
await tester.pump();
final tabs = tester.getRect(
find.descendant(
of: find.byKey(const Key('item-tabs')),
matching: find.byType(GlassPill),
),
);
expect(tabs.bottom, greaterThan(844 - 40));
// Content reaches the top edge and starts below the page's bar.
final bar = tester.getRect(
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
);
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
expect(
tester.getTopLeft(find.text('item row 0')).dy,
greaterThanOrEqualTo(bar.bottom),
);
});
testWidgets('the Runs tab shows one indicator: attention outranks running', (
tester,
) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(attention: 2));
await tester.pump();
await tester.pump();
expect(find.text('2'), findsOneWidget);
expect(find.text('4'), findsNothing);
await tester.pumpWidget(shell());
await tester.pump();
await tester.pump();
expect(find.text('4'), findsOneWidget);
});
}
@@ -0,0 +1,213 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/adaptive/top_bar_notices.dart';
/// Content floats behind the top bar: lists reach the top edge, start below
/// the bar at rest and scroll behind it; pinned headers pin under it.
void main() {
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
Rect barRect(WidgetTester tester) => tester.getRect(
find.descendant(
of: find.byType(SegmentedBar),
matching: find.byType(GlassPill),
),
);
Widget page(Widget body, {bool cupertino = false}) {
final bar = SegmentedBar(cupertino: cupertino, title: 'Page');
if (cupertino) {
return CupertinoApp(
home: CupertinoPageScaffold(navigationBar: bar, child: body),
);
}
return MaterialApp(
home: Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body),
);
}
Widget rows() => Builder(
builder: (context) => ListView(
key: const Key('list'),
padding: withTopBarClearance(context, const EdgeInsets.all(16)),
children: [
for (var index = 0; index < 40; index++)
SizedBox(height: 48, child: Text('row $index')),
],
),
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: a list reaches the top edge, starts below the bar at '
'rest and scrolls behind it', (tester) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(page(rows(), cupertino: cupertino));
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
final bar = barRect(tester);
expect(
tester.getTopLeft(find.text('row 0')).dy,
greaterThanOrEqualTo(bar.bottom),
);
await tester.drag(find.byKey(const Key('list')), const Offset(0, -120));
await tester.pump();
// A row now passes behind the glass title pill.
final behind = find.byWidgetPredicate((widget) {
if (widget is! Text || !(widget.data ?? '').startsWith('row ')) {
return false;
}
return true;
});
final rects = behind.evaluate().map(
(element) => tester.getRect(find.byWidget(element.widget)),
);
expect(rects.any((rect) => rect.overlaps(bar)), isTrue);
});
}
testWidgets('a pinned header after SliverTopBarClearance pins below the '
'bar', (tester) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(
page(
CustomScrollView(
key: const Key('list'),
slivers: [
const SliverTopBarClearance(),
const SliverToBoxAdapter(child: SizedBox(height: 200)),
const PinnedHeaderSliver(
child: SizedBox(height: 40, child: Text('pinned')),
),
SliverList.list(
children: [
for (var index = 0; index < 40; index++)
SizedBox(height: 48, child: Text('row $index')),
],
),
],
),
),
);
final inset = barRect(tester).bottom;
await tester.drag(find.byKey(const Key('list')), const Offset(0, -600));
await tester.pump();
// The header pins at the bar's inset, not behind the bar.
expect(
tester.getTopLeft(find.text('pinned')).dy,
greaterThanOrEqualTo(inset),
);
expect(tester.getTopLeft(find.text('pinned')).dy, lessThan(inset + 16));
});
testWidgets('BelowTopBar and TopBarNotices keep fixed content below the bar '
'without remounting it', (tester) async {
await setSize(tester, const Size(390, 844));
var notice = false;
late StateSetter update;
await tester.pumpWidget(
page(
StatefulBuilder(
builder: (context, setState) {
update = setState;
return TopBarNotices(
notices: [if (notice) const Text('Offline')],
child: const _Probe(),
);
},
),
),
);
final bar = barRect(tester);
final probe = tester.state<_ProbeState>(find.byType(_Probe));
expect(probe.topPadding, greaterThanOrEqualTo(bar.bottom));
expect(tester.getTopLeft(find.byType(_Probe)).dy, 0);
update(() => notice = true);
await tester.pump();
expect(tester.state<_ProbeState>(find.byType(_Probe)), same(probe));
expect(
tester.getTopLeft(find.text('Offline')).dy,
greaterThanOrEqualTo(bar.bottom),
);
expect(probe.topPadding, 0);
expect(
tester.getTopLeft(find.byType(_Probe)).dy,
greaterThanOrEqualTo(tester.getBottomLeft(find.text('Offline')).dy),
);
});
testWidgets('a top-edge tab bar sits under the inset and pads the content '
'by both, without swelling over leftover padding', (tester) async {
await setSize(tester, const Size(800, 600));
late double contentTop;
await tester.pumpWidget(
MaterialApp(
home: MediaQuery(
data: const MediaQueryData(
size: Size(800, 600),
padding: EdgeInsets.only(top: 64, bottom: 96),
),
child: FloatingBarOverlay(
edge: FloatingBarEdge.top,
bar: FloatingDestinationBar(
cupertino: false,
edge: FloatingBarEdge.top,
currentIndex: 0,
onTap: (_) {},
items: const [
FloatingDestinationItem(icon: Icon(Icons.notes), label: 'One'),
FloatingDestinationItem(
icon: Icon(Icons.timeline),
label: 'Two',
),
],
),
child: Builder(
builder: (context) {
contentTop = MediaQuery.paddingOf(context).top;
return const SizedBox.expand();
},
),
),
),
),
);
final pill = tester.getRect(find.byType(GlassPill));
expect(pill.top, 64);
// The pill is the bar's own height: leftover media padding is not added.
expect(pill.height, FloatingDestinationBar.materialHeight);
// Wide: sized to its tabs at the leading edge, under the title.
expect(pill.left, FloatingDestinationBar.topMargin);
expect(pill.width, lessThan(400));
expect(contentTop, pill.bottom + 8);
});
}
class _Probe extends StatefulWidget {
const _Probe();
@override
State<_Probe> createState() => _ProbeState();
}
class _ProbeState extends State<_Probe> {
double topPadding = -1;
@override
Widget build(BuildContext context) {
topPadding = MediaQuery.paddingOf(context).top;
return const SizedBox.expand();
}
}
+8 -4
View File
@@ -87,10 +87,14 @@ void main() {
MaterialApp( MaterialApp(
home: AdaptiveShell( home: AdaptiveShell(
destinationBodies: { destinationBodies: {
AppDestination.pipelines: (_) => StatefulBuilder( // Bodies reach the top edge under the floating bar; this one
builder: (context, setState) => TextButton( // keeps its button clear of it.
onPressed: () => setState(() => builds++), AppDestination.pipelines: (_) => Center(
child: Text('Builds: $builds'), child: StatefulBuilder(
builder: (context, setState) => TextButton(
onPressed: () => setState(() => builds++),
child: Text('Builds: $builds'),
),
), ),
), ),
AppDestination.runs: (_) => const Text('Runs screen'), AppDestination.runs: (_) => const Text('Runs screen'),