From e34fa1050e90bb1b275c611c6485c57d7f5ea0d6 Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Sat, 31 Oct 2026 04:27:35 +0000 Subject: [PATCH] Close the chrome gaps: content behind bars on Templates, run detail, stage page and Schedules; Search field fills the bar - SegmentedBar.titleWidget (and ShellBar/ShellBarSpec titleWidget, backgroundColor): a bar's main pill can be an input in place of the title; Search uses it so the field fills the bar with Kind and info, capped at the result column width so field and results share edges on wide windows. - Templates page/frame drop the top SafeArea again (BelowTopBar gate, TopBarNotices banners); Cupertino uses the grouped background. - Settings on Cupertino in the shell publishes the grouped background so the bar scrim matches the page (no white band or seam). - TopGlassStrip: the run detail header (status, actions, decision, notices) and the Schedules search/filter toolbar float as glass under the bar; tabs and lists scroll behind both. - Stage page: stage title and Visit/Run subtitle in the bar, facts lead the Summary scroll, sections scroll behind the bar under floating tabs. - Tests for content-behind-bar on each page and the title-widget bar mode; notes/chrome-gaps-fixes.md. --- .../application/schedules_destination.dart | 10 +- .../application/templates_destination.dart | 42 +-- .../runs/ui/run_detail_cupertino.dart | 7 +- .../features/runs/ui/run_detail_material.dart | 7 +- app/lib/features/runs/ui/run_detail_tabs.dart | 122 +++++---- .../features/runs/ui/run_detail_visit.dart | 244 +++--------------- .../runs/ui/run_detail_visit_definition.dart | 3 +- .../runs/ui/run_detail_visit_facts_view.dart | 150 +++++++++++ .../runs/ui/run_detail_visit_sections.dart | 25 +- .../runs/ui/run_detail_visit_session.dart | 2 +- .../ui/list/schedule_list_toolbar.dart | 13 +- .../schedules/ui/list/schedule_list_view.dart | 61 +++-- app/lib/features/search/search_screen.dart | 18 +- .../search/ui/search_bar_controls.dart | 14 +- .../features/settings/settings_screen.dart | 14 +- app/lib/features/templates/screen.dart | 22 +- .../templates/ui/templates_frame.dart | 12 +- app/lib/shell/adaptive_shell.dart | 7 +- app/lib/shell/shell_bar.dart | 25 ++ app/lib/ui/adaptive/segmented_bar.dart | 38 ++- app/lib/ui/adaptive/top_glass_strip.dart | 56 ++++ app/notes/chrome-gaps-fixes.md | 192 ++++++++++++++ .../templates_behind_bar_test.dart | 92 +++++++ .../runs/ui/run_decision_wiring_test.dart | 16 +- .../runs/ui/run_detail_behind_bar_test.dart | 101 ++++++++ .../features/runs/ui/run_detail_finders.dart | 21 +- .../runs/ui/run_detail_visit_test.dart | 42 +-- .../ui/list/schedules_behind_bar_test.dart | 93 +++++++ .../search/search_bar_layout_test.dart | 50 ++++ .../settings_shell_background_test.dart | 99 +++++++ .../segmented_bar_title_widget_test.dart | 145 +++++++++++ 31 files changed, 1348 insertions(+), 395 deletions(-) create mode 100644 app/lib/features/runs/ui/run_detail_visit_facts_view.dart create mode 100644 app/lib/ui/adaptive/top_glass_strip.dart create mode 100644 app/notes/chrome-gaps-fixes.md create mode 100644 app/test/application/templates_behind_bar_test.dart create mode 100644 app/test/features/runs/ui/run_detail_behind_bar_test.dart create mode 100644 app/test/features/schedules/ui/list/schedules_behind_bar_test.dart create mode 100644 app/test/features/settings/settings_shell_background_test.dart create mode 100644 app/test/ui/adaptive/segmented_bar_title_widget_test.dart diff --git a/app/lib/application/schedules_destination.dart b/app/lib/application/schedules_destination.dart index d249102e..7a96cab0 100644 --- a/app/lib/application/schedules_destination.dart +++ b/app/lib/application/schedules_destination.dart @@ -124,17 +124,15 @@ class _SchedulesDestinationState extends State { ), ], ); + // The page reaches its top edge: the search strip floats under the bar + // and the list scrolls behind both. if (cupertino) { return CupertinoPageScaffold( navigationBar: bar, - child: SafeArea(child: body), + child: SafeArea(top: false, bottom: false, child: body), ); } - return Scaffold( - extendBodyBehindAppBar: true, - appBar: bar, - body: SafeArea(left: false, right: false, bottom: false, child: body), - ); + return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body); } Widget _body(bool cupertino) { diff --git a/app/lib/application/templates_destination.dart b/app/lib/application/templates_destination.dart index 736d6d54..e8569735 100644 --- a/app/lib/application/templates_destination.dart +++ b/app/lib/application/templates_destination.dart @@ -8,7 +8,10 @@ import '../features/templates/ui/template_detail.dart' import '../shell/destination.dart'; import '../shell/shell_bar.dart'; import '../ui/adaptive/host.dart'; +import '../ui/adaptive/floating_bar_layout.dart'; import '../ui/adaptive/segmented_bar.dart'; +import '../ui/adaptive/top_bar_notices.dart'; +import '../ui/theme/app_theme.dart'; import 'app_session.dart'; import 'connection_status.dart'; import 'server_endpoint.dart'; @@ -76,16 +79,22 @@ class _TemplatesDestinationState extends State { listenable: _bar, builder: (context, _) => _segmentedBar(cupertino), ); + // The page reaches its top edge: the gallery and an open template scroll + // behind the bar and pad their own content by its height. + final page = SafeArea(top: false, bottom: false, child: body); if (cupertino) { + // Inset-grouped rows on the grouped background, as in Settings; the + // bar's scrim takes the same colour. return CupertinoPageScaffold( + backgroundColor: AppColors.groupedBackground, navigationBar: _BarSlot(cupertino: true, child: bar), - child: SafeArea(child: body), + child: page, ); } return Scaffold( extendBodyBehindAppBar: true, appBar: _BarSlot(cupertino: false, child: bar), - body: SafeArea(child: body), + body: page, ); } @@ -113,25 +122,26 @@ class _TemplatesDestinationState extends State { Widget _body(bool cupertino) { final session = widget.session; if (!session.everConnected) { - return ConnectionGate( - session: session, - server: widget.server, - cupertino: cupertino, + return BelowTopBar( + child: ConnectionGate( + session: session, + server: widget.server, + cupertino: cupertino, + ), ); } - return Column( - children: [ + // A connection banner stays below the bar; the gallery keeps its place. + return TopBarNotices( + notices: [ if (!session.connected) ConnectionBanner(session: session, cupertino: cupertino), - Expanded( - child: TemplatesScreen( - gateway: session.gateway, - embedded: true, - onCreated: widget.onCreated, - initialKey: widget.initialKey, - ), - ), ], + child: TemplatesScreen( + gateway: session.gateway, + embedded: true, + onCreated: widget.onCreated, + initialKey: widget.initialKey, + ), ); } } diff --git a/app/lib/features/runs/ui/run_detail_cupertino.dart b/app/lib/features/runs/ui/run_detail_cupertino.dart index 6994716a..70a2ee41 100644 --- a/app/lib/features/runs/ui/run_detail_cupertino.dart +++ b/app/lib/features/runs/ui/run_detail_cupertino.dart @@ -36,11 +36,12 @@ Widget buildCupertinoRunDetail({ configuredEndpoint: configuredEndpoint, initialStageKey: initialStageKey, initialVisit: initialVisit, + // A glass strip under the top bar: as wide as its content. header: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsetsDirectional.fromSTEB(16, 4, 16, 0), + padding: const EdgeInsetsDirectional.fromSTEB(12, 4, 12, 4), child: Wrap( spacing: 12, runSpacing: 4, @@ -68,7 +69,7 @@ class _CupertinoNotice extends StatelessWidget { @override Widget build(BuildContext context) => Padding( - padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 0), + padding: const EdgeInsetsDirectional.fromSTEB(12, 0, 12, 8), child: Semantics(liveRegion: true, child: Text(text)), ); } diff --git a/app/lib/features/runs/ui/run_detail_material.dart b/app/lib/features/runs/ui/run_detail_material.dart index 4c6d65f2..dca0856d 100644 --- a/app/lib/features/runs/ui/run_detail_material.dart +++ b/app/lib/features/runs/ui/run_detail_material.dart @@ -37,11 +37,12 @@ Widget buildMaterialRunDetail({ configuredEndpoint: configuredEndpoint, initialStageKey: initialStageKey, initialVisit: initialVisit, + // A glass strip under the top bar: as wide as its content. header: Column( - crossAxisAlignment: CrossAxisAlignment.stretch, + crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.fromLTRB(16, 4, 16, 0), + padding: const EdgeInsets.fromLTRB(12, 4, 12, 4), child: Wrap( spacing: 12, runSpacing: 4, @@ -68,7 +69,7 @@ class _Notice extends StatelessWidget { @override Widget build(BuildContext context) => Padding( - padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), + padding: const EdgeInsets.fromLTRB(12, 0, 12, 8), child: Semantics(liveRegion: true, child: Text(text)), ); } diff --git a/app/lib/features/runs/ui/run_detail_tabs.dart b/app/lib/features/runs/ui/run_detail_tabs.dart index c0ed2e93..1daffb40 100644 --- a/app/lib/features/runs/ui/run_detail_tabs.dart +++ b/app/lib/features/runs/ui/run_detail_tabs.dart @@ -1,5 +1,6 @@ import '../../../ui/adaptive/floating_bar_layout.dart'; import '../../../ui/adaptive/segmented_bar.dart'; +import '../../../ui/adaptive/top_glass_strip.dart'; import 'dart:math' as math; import 'package:flutter/cupertino.dart'; @@ -29,8 +30,9 @@ import 'run_search_selection.dart'; /// reserve keeps its bounded canvas positive at 320px with 2x text. const double kRunDetailMinContentHeight = 240; -/// The run detail's tabbed body: the host-built header above the bounded -/// selected tab, with the floating tab bar over the bottom of the tab. +/// The run detail's tabbed body: the selected tab fills the detail and +/// scrolls behind the top bar, the host-built header (a glass strip just +/// under the bar) and the floating tab bar. /// /// The Graph tab fills its slot with [RunGraphView] from the run's own pinned /// graph and recorded steps. A visited stage click selects that stage's latest @@ -54,7 +56,7 @@ class RunDetailTabs extends StatefulWidget { final JsonMap run; - /// The host's own header: identity, status and the run actions. It stays + /// The host's own header: status, the run actions and notices. It floats /// outside the tab body, so switching tabs never drops an action. final Widget header; @@ -297,35 +299,25 @@ class _RunDetailTabsState extends State { onClose: () => Navigator.of(pageContext).pop(), ) : const Center(child: Text('This visit is no longer recorded.')); - // The pane names the visit; the bar names the run it belongs to. - final title = detailTitle(run); - if (cupertino) { - return CupertinoPageScaffold( - navigationBar: SegmentedBar( - cupertino: true, - leading: SegmentedBackButton( - key: const Key('run-visit-back'), - cupertino: true, - onPressed: () => Navigator.of(pageContext).pop(), - ), - title: title, - ), - child: SafeArea(child: pane), - ); - } - return Scaffold( - extendBodyBehindAppBar: true, - appBar: SegmentedBar( - cupertino: false, - leading: SegmentedBackButton( - key: const Key('run-visit-back'), - cupertino: false, - onPressed: () => Navigator.of(pageContext).pop(), - ), - title: title, + // The bar names the stage over its visit and run, so the body + // repeats neither; the sections scroll behind it. + final known = index < visits.length; + final bar = SegmentedBar( + cupertino: cupertino, + leading: SegmentedBackButton( + key: const Key('run-visit-back'), + cupertino: cupertino, + onPressed: () => Navigator.of(pageContext).pop(), ), - body: SafeArea(child: pane), + title: known ? visits[index].stage : detailTitle(run), + titleKey: const Key('run-visit-title'), + subtitle: known ? runVisitSubtitle(run, visits[index]) : null, ); + final body = SafeArea(top: false, bottom: false, child: pane); + if (cupertino) { + return CupertinoPageScaffold(navigationBar: bar, child: body); + } + return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body); }, ); final route = cupertino @@ -368,42 +360,41 @@ class _RunDetailTabsState extends State { return LayoutBuilder( builder: (context, constraints) { final headerLimit = _headerLimit(constraints); - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - // The header (status, actions, notices) starts below the floating - // top bar; the tab body below it no longer sees the bar's height. - ConstrainedBox( + // The header (status, actions, notices) is a glass strip floating + // just under the top bar, so every tab scrolls behind both and pads + // its first item clear of them at rest. Below it, the tabs float over + // the 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 too. Every + // tab gets the whole height: the scrolling tabs own their content and + // the Graph tab fills the slot, so its canvas is never asked for an + // unbounded extent. + return FloatingBarOverlay( + edge: FloatingBarEdge.top, + bar: TopGlassStrip( + key: const Key('run-detail-header'), + cupertino: widget.cupertino, + padding: const EdgeInsets.symmetric(vertical: 4), + child: ConstrainedBox( constraints: BoxConstraints(maxHeight: headerLimit), child: SingleChildScrollView( key: ValueKey('run-detail-header-${widget.run['id']}'), - padding: EdgeInsets.only(top: topBarInset(context)), child: widget.header, ), ), - // Every tab gets the bounded remaining height. The scrolling tabs - // own their content; the Graph tab fills the slot so its canvas is - // never asked for an unbounded extent. The tabs float over the - // tab, at its bottom on a page or at its top beside a list, and - // the tab learns their height as its padding on that edge. - Expanded( - key: ValueKey('run-detail-body-${widget.run['id']}'), - child: MediaQuery.removePadding( - context: context, - removeTop: true, - child: FloatingBarOverlay( - edge: edge, - bar: RunDetailTabStrip( - tabs: tabs, - edge: edge, - selected: shown, - onSelected: (tab) => setState(() => _tab = tab), - ), - child: _body(shown), - ), + ), + child: KeyedSubtree( + key: ValueKey('run-detail-body-${widget.run['id']}'), + child: FloatingBarOverlay( + edge: edge, + bar: RunDetailTabStrip( + tabs: tabs, + edge: edge, + selected: shown, + onSelected: (tab) => setState(() => _tab = tab), ), + child: _body(shown), ), - ], + ), ); }, ); @@ -429,12 +420,15 @@ class _RunDetailTabsState extends State { ), ); case RunDetailTab.graph: - return RunGraphView( - key: const Key('run-detail-graph'), - graph: detailGraph(widget.run), - run: widget.run, - selectedStage: _selectedStage, - onStageSelected: _openStage, + // A canvas with its own overlay controls starts below the header. + return BelowTopBar( + child: RunGraphView( + key: const Key('run-detail-graph'), + graph: detailGraph(widget.run), + run: widget.run, + selectedStage: _selectedStage, + onStageSelected: _openStage, + ), ); case RunDetailTab.input: return runDetailFieldTab( diff --git a/app/lib/features/runs/ui/run_detail_visit.dart b/app/lib/features/runs/ui/run_detail_visit.dart index 6043a3a1..49446124 100644 --- a/app/lib/features/runs/ui/run_detail_visit.dart +++ b/app/lib/features/runs/ui/run_detail_visit.dart @@ -1,20 +1,14 @@ -import '../../../ui/status/run_status_icon.dart'; -import '../../graph/widgets/graph_stage_node.dart' show graphStatusState; -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; import '../../../ui/adaptive/floating_bar_layout.dart'; -import '../../../ui/adaptive/host.dart'; import 'run_detail_content.dart'; -import 'run_detail_visit_facts.dart'; +import 'run_detail_visit_facts_view.dart'; import 'run_detail_visit_sections.dart'; -/// The selected recorded visit inside the Timeline tab. -/// -/// It leads with the visit's own headline facts, then native tabbed sections. -/// A fact the reply did not record is not drawn at all; a blank verdict or -/// diagnostic is not rendered as an empty decision. +/// The selected recorded visit's page body: its sections under floating +/// tabs. The page's bar carries the stage and its coordinates +/// ([runVisitSubtitle]); the Summary section leads with the visit's facts. class RunVisitPane extends StatefulWidget { const RunVisitPane({ super.key, @@ -68,208 +62,42 @@ class _RunVisitPaneState extends State { @override Widget build(BuildContext context) { - final style = _VisitStyle.of(context); - final facts = detailVisitFacts(widget.step); - final verdict = detailVisitVerdict(widget.step); - final diagnostic = detailVisitDiagnostic(widget.step); - // The facts take what they need, up to 40% of the height (then scroll); - // the section fills everything else, so the tabs always end at the - // bottom of the screen however short the facts or the section are. - return LayoutBuilder( - builder: (context, constraints) => Column( - key: const Key('run-visit-pane'), - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - ConstrainedBox( - constraints: BoxConstraints(maxHeight: constraints.maxHeight * 0.4), - child: SingleChildScrollView( - key: const Key('run-visit-facts'), - padding: const EdgeInsetsDirectional.fromSTEB(16, 0, 16, 8), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - _bar(style), - _FactGrid(facts: facts, style: style), - if (verdict != null) ...[ - const SizedBox(height: 8), - Text('Verdict', style: style.heading), - if (verdict.option != null) Text(verdict.option!), - if (verdict.reason != null) - Text(verdict.reason!, style: style.value), - ], - if (diagnostic != null) ...[ - const SizedBox(height: 8), - Text('Diagnostic', style: style.heading), - Text(diagnostic, style: style.value), - ], - ], - ), - ), - ), - // The sections are floating tabs over the bottom of what they - // show; the section learns their height as bottom padding. - Expanded( - child: FloatingBarOverlay( - bar: RunVisitSectionStrip( - selected: _section, - onSelected: (section) => setState(() => _section = section), - ), - child: runVisitSectionBody( - section: _section, - run: widget.run, - step: widget.step, - visitIndex: widget.visitIndex, - stageKey: widget.visit.stage, - runSteps: widget.runSteps, - gateway: widget.gateway, - onRunChanged: widget.onRunChanged, - configuredEndpoint: widget.configuredEndpoint, - cupertino: widget.cupertino, - ), - ), - ), - ], - ), - ); - } - - /// Keep stage identity visually distinct from the visit/run coordinates. - /// Back is the page bar's; this heading is the selected recorded stage. - Widget _bar(_VisitStyle style) { - final runId = '${widget.run['id'] ?? ''}'.trim(); - return Padding( - padding: const EdgeInsetsDirectional.fromSTEB(0, 8, 0, 12), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Semantics( - container: true, - header: true, - identifier: 'run-stage-heading', - child: Text( - widget.visit.stage, - key: const Key('run-visit-title'), - style: style.stageTitle, - softWrap: true, - ), - ), - const SizedBox(height: 4), - Wrap( - spacing: 12, - runSpacing: 4, - children: [ - if (widget.visit.sequence != null) - Text('Visit ${widget.visit.sequence}', style: style.muted), - if (runId.isNotEmpty) Text('Run $runId', style: style.muted), - ], - ), - ], - ), - ); - } -} - -/// The visit's facts several to a line: status and outcome as coloured -/// pills, a long value (the model) on a line of its own. -class _FactGrid extends StatelessWidget { - const _FactGrid({required this.facts, required this.style}); - - final List facts; - final _VisitStyle style; - - static String _stateOf(VisitFact fact) { - final value = fact.value.trim().toLowerCase(); - if (fact.label == 'Outcome') { - if (value == 'error' || value == 'failed' || value == 'blocked') { - return 'failed'; - } - if (value == 'success') return 'succeeded'; - return 'running'; - } - return graphStatusState(fact.value); - } - - @override - Widget build(BuildContext context) { - return Padding( - padding: const EdgeInsets.only(top: 4), - child: Wrap( - key: const Key('run-visit-facts-grid'), - spacing: 16, - runSpacing: 8, - children: [ - for (final fact in facts) - Column( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.min, - children: [ - Text(fact.label, style: style.muted), - const SizedBox(height: 2), - if (fact.label == 'Status' || fact.label == 'Outcome') - _pill(context, fact) - else - Text(fact.value, style: style.value), - ], - ), - ], - ), - ); - } - - Widget _pill(BuildContext context, VisitFact fact) { - final color = runStatusColor(_stateOf(fact)).resolveFrom(context); - return DecoratedBox( - decoration: ShapeDecoration( - color: color.withValues(alpha: 0.16), - shape: const StadiumBorder(), - ), - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), - child: Text( - fact.value, - style: style.value.copyWith( - color: color, - fontWeight: FontWeight.w700, - ), + // The section fills the page and scrolls behind the page's top bar (which + // names the stage and its visit) and the floating tabs, padding its + // content clear of both at rest. Summary leads with the visit's facts. + return KeyedSubtree( + key: const Key('run-visit-pane'), + child: FloatingBarOverlay( + bar: RunVisitSectionStrip( + selected: _section, + onSelected: (section) => setState(() => _section = section), + ), + child: runVisitSectionBody( + section: _section, + run: widget.run, + step: widget.step, + visitIndex: widget.visitIndex, + stageKey: widget.visit.stage, + runSteps: widget.runSteps, + gateway: widget.gateway, + onRunChanged: widget.onRunChanged, + configuredEndpoint: widget.configuredEndpoint, + cupertino: widget.cupertino, + facts: RunVisitFactsView(step: widget.step), ), ), ); } } -/// Host text roles only: no palette, font family or explicit size. -class _VisitStyle { - const _VisitStyle({ - required this.value, - required this.muted, - required this.heading, - required this.stageTitle, - }); - - factory _VisitStyle.of(BuildContext context) { - if (usesCupertinoHost(context)) { - final theme = CupertinoTheme.of(context); - final secondary = CupertinoColors.secondaryLabel.resolveFrom(context); - return _VisitStyle( - value: theme.textTheme.textStyle, - muted: theme.textTheme.textStyle.copyWith(color: secondary), - heading: theme.textTheme.navTitleTextStyle, - stageTitle: theme.textTheme.navLargeTitleTextStyle, - ); - } - final theme = Theme.of(context); - return _VisitStyle( - value: theme.textTheme.bodyMedium ?? const TextStyle(), - muted: (theme.textTheme.bodySmall ?? const TextStyle()).copyWith( - color: theme.colorScheme.onSurfaceVariant, - ), - heading: theme.textTheme.titleSmall ?? const TextStyle(), - stageTitle: theme.textTheme.headlineSmall ?? const TextStyle(), - ); - } - - final TextStyle value; - final TextStyle muted; - final TextStyle heading; - final TextStyle stageTitle; +/// The page bar's subtitle for a recorded visit: its sequence, then the run +/// it belongs to (`Visit 2 · Run 7 · Nightly report`). +String runVisitSubtitle(JsonMap run, DetailVisit visit) { + final runId = '${run['id'] ?? ''}'.trim(); + final title = detailTitle(run); + return [ + if (visit.sequence != null) 'Visit ${visit.sequence}', + if (runId.isNotEmpty) 'Run $runId', + if (title.isNotEmpty && title != 'Run $runId') title, + ].join(' · '); } diff --git a/app/lib/features/runs/ui/run_detail_visit_definition.dart b/app/lib/features/runs/ui/run_detail_visit_definition.dart index e5d93a4e..8743b46a 100644 --- a/app/lib/features/runs/ui/run_detail_visit_definition.dart +++ b/app/lib/features/runs/ui/run_detail_visit_definition.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../../../core/api_gateway.dart'; +import '../../../ui/adaptive/floating_bar_layout.dart'; import '../../graph/widgets/stage_definition_view.dart'; import 'run_detail_content.dart'; import 'run_detail_visit_facts.dart'; @@ -26,7 +27,7 @@ class RunVisitDefinition extends StatelessWidget { if (!detailVisitHasDefinition(graph, stageKey)) { return ListView( key: const Key('run-visit-body-definition'), - padding: const EdgeInsets.all(16), + padding: withBarClearance(context, const EdgeInsets.all(16)), children: const [Text(unknownStageDefinition)], ); } diff --git a/app/lib/features/runs/ui/run_detail_visit_facts_view.dart b/app/lib/features/runs/ui/run_detail_visit_facts_view.dart new file mode 100644 index 00000000..1c8d6b54 --- /dev/null +++ b/app/lib/features/runs/ui/run_detail_visit_facts_view.dart @@ -0,0 +1,150 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; + +import '../../../core/api_gateway.dart'; +import '../../../ui/adaptive/host.dart'; +import '../../../ui/status/run_status_icon.dart'; +import '../../graph/widgets/graph_stage_node.dart' show graphStatusState; +import 'run_detail_visit_facts.dart'; + +/// A recorded visit's facts, verdict and diagnostic: the head of the stage +/// page's Summary, scrolling with it behind the top bar. The stage and its +/// coordinates are the page bar's title and subtitle, so they are not +/// repeated here. A fact the reply did not record is not drawn at all; a +/// blank verdict or diagnostic is not rendered as an empty decision. +class RunVisitFactsView extends StatelessWidget { + const RunVisitFactsView({super.key, required this.step}); + + final JsonMap step; + + @override + Widget build(BuildContext context) { + final style = _VisitStyle.of(context); + final facts = detailVisitFacts(step); + final verdict = detailVisitVerdict(step); + final diagnostic = detailVisitDiagnostic(step); + return Padding( + key: const Key('run-visit-facts'), + padding: const EdgeInsetsDirectional.fromSTEB(16, 8, 16, 12), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + _FactGrid(facts: facts, style: style), + if (verdict != null) ...[ + const SizedBox(height: 8), + Text('Verdict', style: style.heading), + if (verdict.option != null) Text(verdict.option!), + if (verdict.reason != null) + Text(verdict.reason!, style: style.value), + ], + if (diagnostic != null) ...[ + const SizedBox(height: 8), + Text('Diagnostic', style: style.heading), + Text(diagnostic, style: style.value), + ], + ], + ), + ); + } +} + +/// The visit's facts several to a line: status and outcome as coloured +/// pills, a long value (the model) on a line of its own. +class _FactGrid extends StatelessWidget { + const _FactGrid({required this.facts, required this.style}); + + final List facts; + final _VisitStyle style; + + static String _stateOf(VisitFact fact) { + final value = fact.value.trim().toLowerCase(); + if (fact.label == 'Outcome') { + if (value == 'error' || value == 'failed' || value == 'blocked') { + return 'failed'; + } + if (value == 'success') return 'succeeded'; + return 'running'; + } + return graphStatusState(fact.value); + } + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.only(top: 4), + child: Wrap( + key: const Key('run-visit-facts-grid'), + spacing: 16, + runSpacing: 8, + children: [ + for (final fact in facts) + Column( + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.min, + children: [ + Text(fact.label, style: style.muted), + const SizedBox(height: 2), + if (fact.label == 'Status' || fact.label == 'Outcome') + _pill(context, fact) + else + Text(fact.value, style: style.value), + ], + ), + ], + ), + ); + } + + Widget _pill(BuildContext context, VisitFact fact) { + final color = runStatusColor(_stateOf(fact)).resolveFrom(context); + return DecoratedBox( + decoration: ShapeDecoration( + color: color.withValues(alpha: 0.16), + shape: const StadiumBorder(), + ), + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2), + child: Text( + fact.value, + style: style.value.copyWith( + color: color, + fontWeight: FontWeight.w700, + ), + ), + ), + ); + } +} + +/// Host text roles only: no palette, font family or explicit size. +class _VisitStyle { + const _VisitStyle({ + required this.value, + required this.muted, + required this.heading, + }); + + factory _VisitStyle.of(BuildContext context) { + if (usesCupertinoHost(context)) { + final theme = CupertinoTheme.of(context); + final secondary = CupertinoColors.secondaryLabel.resolveFrom(context); + return _VisitStyle( + value: theme.textTheme.textStyle, + muted: theme.textTheme.textStyle.copyWith(color: secondary), + heading: theme.textTheme.navTitleTextStyle, + ); + } + final theme = Theme.of(context); + return _VisitStyle( + value: theme.textTheme.bodyMedium ?? const TextStyle(), + muted: (theme.textTheme.bodySmall ?? const TextStyle()).copyWith( + color: theme.colorScheme.onSurfaceVariant, + ), + heading: theme.textTheme.titleSmall ?? const TextStyle(), + ); + } + + final TextStyle value; + final TextStyle muted; + final TextStyle heading; +} diff --git a/app/lib/features/runs/ui/run_detail_visit_sections.dart b/app/lib/features/runs/ui/run_detail_visit_sections.dart index cc19705d..b2ef6171 100644 --- a/app/lib/features/runs/ui/run_detail_visit_sections.dart +++ b/app/lib/features/runs/ui/run_detail_visit_sections.dart @@ -111,6 +111,7 @@ Widget runVisitSectionBody({ required ValueChanged onRunChanged, required String configuredEndpoint, required bool cupertino, + Widget? facts, }) { Widget body(RunVisitSection section) => runVisitSectionBody( section: section, @@ -132,6 +133,7 @@ Widget runVisitSectionBody({ input: step['input'], output: step['output'], cupertino: cupertino, + facts: facts, ); case RunVisitSection.more: return body(RunVisitSection.session); @@ -164,12 +166,15 @@ Widget runVisitSectionBody({ steps: [step], showSummary: false, ); - return cupertino - ? Builder( - builder: (context) => - Theme(data: hostTextTheme(context), child: viewer), - ) - : viewer; + // The viewer's own header leads it, so it starts below the bar. + return BelowTopBar( + child: cupertino + ? Builder( + builder: (context) => + Theme(data: hostTextTheme(context), child: viewer), + ) + : viewer, + ); case RunVisitSection.session: return RunVisitSession( run: run, @@ -189,12 +194,16 @@ class _VisitSummary extends StatefulWidget { required this.input, required this.output, required this.cupertino, + this.facts, }); final dynamic input; final dynamic output; final bool cupertino; + /// The visit's facts, leading the scroll below the top bar. + final Widget? facts; + @override State<_VisitSummary> createState() => _VisitSummaryState(); } @@ -251,6 +260,10 @@ class _VisitSummaryState extends State<_VisitSummary> { Widget build(BuildContext context) => CustomScrollView( key: const Key('run-visit-body-summary'), slivers: [ + // Starts below the page's bar and scrolls behind it; the sticky + // sections pin just below the bar. + const SliverTopBarClearance(), + if (widget.facts case final facts?) SliverToBoxAdapter(child: facts), _section('Input', widget.input, visitEmptyInput), _section('Output', widget.output, visitEmptyOutput), const SliverFloatingBarClearance(), diff --git a/app/lib/features/runs/ui/run_detail_visit_session.dart b/app/lib/features/runs/ui/run_detail_visit_session.dart index 67dfa19f..5a0d8a39 100644 --- a/app/lib/features/runs/ui/run_detail_visit_session.dart +++ b/app/lib/features/runs/ui/run_detail_visit_session.dart @@ -134,7 +134,7 @@ class _RunVisitSessionState extends State { } return ListView( key: const Key('run-visit-body-session'), - padding: withFloatingBarClearance(context, const EdgeInsets.all(16)), + padding: withBarClearance(context, const EdgeInsets.all(16)), children: _spaced(children), ); } diff --git a/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart b/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart index 50f1f1df..2a4e0d9b 100644 --- a/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart +++ b/app/lib/features/schedules/ui/list/schedule_list_toolbar.dart @@ -36,8 +36,9 @@ class ScheduleRefreshAction extends StatelessWidget { ); } -/// Search and the enabled filter; the refresh control too when no bar above -/// carries it ([onRefresh] null leaves it to the bar). +/// Search and the enabled filter, and the count; the refresh control too when +/// no bar above carries it ([onRefresh] null leaves it to the bar). The list +/// floats it as a glass strip under the page's bar. class ScheduleListToolbar extends StatelessWidget { const ScheduleListToolbar({ super.key, @@ -55,14 +56,15 @@ class ScheduleListToolbar extends StatelessWidget { @override Widget build(BuildContext context) { return Column( + mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ Padding( - padding: const EdgeInsets.fromLTRB(16, 12, 16, 8), + padding: const EdgeInsets.fromLTRB(12, 12, 12, 8), child: _search(context), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16), + padding: const EdgeInsets.symmetric(horizontal: 12), child: Row( children: [ Expanded( @@ -87,7 +89,7 @@ class ScheduleListToolbar extends StatelessWidget { ), if (controller.hasLoaded) Padding( - padding: const EdgeInsets.fromLTRB(16, 8, 16, 4), + padding: const EdgeInsets.fromLTRB(12, 8, 12, 0), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -99,6 +101,7 @@ class ScheduleListToolbar extends StatelessWidget { ], ), ), + const SizedBox(height: 12), ], ); } diff --git a/app/lib/features/schedules/ui/list/schedule_list_view.dart b/app/lib/features/schedules/ui/list/schedule_list_view.dart index e3b82cc5..c2369b6b 100644 --- a/app/lib/features/schedules/ui/list/schedule_list_view.dart +++ b/app/lib/features/schedules/ui/list/schedule_list_view.dart @@ -1,6 +1,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import '../../../../ui/adaptive/floating_bar_layout.dart'; +import '../../../../ui/adaptive/top_bar_notices.dart'; +import '../../../../ui/adaptive/top_glass_strip.dart'; import '../../domain/saved_schedule.dart'; import 'schedule_list_controller.dart'; import 'schedule_list_row.dart'; @@ -8,9 +11,18 @@ import 'schedule_list_toolbar.dart'; const scheduleListKey = ValueKey('schedule-list'); const scheduleRetryKey = ValueKey('schedule-retry'); +const scheduleToolbarKey = ValueKey('schedule-toolbar'); + +/// The widest the search and filter strip grows on a wide window. +const double kScheduleToolbarMaxWidth = 720; /// Platform-adaptive list body. It owns no navigation chrome; the shell frames /// it as the Schedules destination. +/// +/// Search, the filter and the count float as one glass strip just under the +/// page's top bar, and the list scrolls behind both: it pads its first row +/// clear of them at rest. The strip keeps its place whatever the list shows, +/// so typing a query that empties the list never drops the field's focus. class SchedulesListView extends StatelessWidget { const SchedulesListView({ super.key, @@ -35,42 +47,44 @@ class SchedulesListView extends StatelessWidget { @override Widget build(BuildContext context) { - return Column( - children: [ - ScheduleListToolbar( + return FloatingBarOverlay( + edge: FloatingBarEdge.top, + bar: TopGlassStrip( + key: scheduleToolbarKey, + cupertino: cupertino, + maxWidth: kScheduleToolbarMaxWidth, + padding: EdgeInsets.zero, + child: ScheduleListToolbar( controller: controller, searchController: searchController, cupertino: cupertino, onRefresh: refreshInToolbar ? onRefresh : null, ), - Expanded(child: _body(context)), - ], + ), + child: Builder(builder: _body), ); } Widget _body(BuildContext context) { final failure = controller.failure; if (failure != null && controller.schedules.isEmpty) { - return _failureState(context, failure); + return BelowTopBar(child: _failureState(context, failure)); + } + if (controller.isInitialLoading) { + return BelowTopBar(child: _loadingState(context)); } - if (controller.isInitialLoading) return _loadingState(context); if (controller.schedules.isEmpty) { - return _emptyState('No schedules yet.'); + return BelowTopBar(child: _emptyState('No schedules yet.')); } final content = controller.visibleSchedules.isEmpty - ? _emptyState(controller.emptyMessage) - : _list(context); - // The banner slot is always present so a failed or recovered refresh does - // not change the list's ancestors. Replacing the ListView would rebuild the - // Scrollable and drop the user's scroll offset. - return Column( - children: [ - if (failure != null) - _failureBanner(context, failure) - else - const SizedBox.shrink(), - Expanded(child: content), - ], + ? BelowTopBar(child: _emptyState(controller.emptyMessage)) + : Builder(builder: _list); + // A failed refresh shows under the strip without changing the list's + // ancestors: replacing the ListView would rebuild the Scrollable and drop + // the user's scroll offset. + return TopBarNotices( + notices: [if (failure != null) _failureBanner(context, failure)], + child: content, ); } @@ -79,7 +93,10 @@ class SchedulesListView extends StatelessWidget { return ListView.separated( key: scheduleListKey, controller: scrollController, - padding: const EdgeInsets.only(top: 4, bottom: 24), + padding: withBarClearance( + context, + const EdgeInsets.only(top: 4, bottom: 24), + ), itemCount: schedules.length, separatorBuilder: (context, index) => cupertino ? _cupertinoSeparator(context) : const Divider(height: 1), diff --git a/app/lib/features/search/search_screen.dart b/app/lib/features/search/search_screen.dart index 39295491..18a7d663 100644 --- a/app/lib/features/search/search_screen.dart +++ b/app/lib/features/search/search_screen.dart @@ -14,10 +14,10 @@ import 'ui/search_bounds_note.dart'; import 'ui/search_result_view.dart'; /// Native omni-search over the Pipelines server: the search field, a compact -/// kind menu and the syntax help in the top bar's actions pill, and a flat -/// result list whose rows open the server's own target through [onOpen]. The -/// screen never mutates server state and never guesses a route for an unknown -/// or targetless hit. +/// kind menu and the syntax help as the top bar's main pill (no title), and a +/// flat result list whose rows open the server's own target through [onOpen]. +/// The screen never mutates server state and never guesses a route for an +/// unknown or targetless hit. class SearchScreen extends StatefulWidget { const SearchScreen({ super.key, @@ -95,12 +95,18 @@ class _SearchScreenState extends State { if (!ShellBar.available(context)) { return _body(cupertino, controls: _controls(cupertino)); } - return ShellBar(actions: [_controls(cupertino)], child: _body(cupertino)); + // The field takes the title's place and fills the bar. + return ShellBar( + titleWidget: _controls(cupertino), + titleWidgetMaxWidth: kSearchPillMaxWidth, + child: _body(cupertino), + ); } final bar = SegmentedBar( cupertino: cupertino, title: 'Search', - actions: [_controls(cupertino)], + titleWidget: _controls(cupertino), + titleWidgetMaxWidth: kSearchPillMaxWidth, ); if (cupertino) { return CupertinoPageScaffold(navigationBar: bar, child: _body(cupertino)); diff --git a/app/lib/features/search/ui/search_bar_controls.dart b/app/lib/features/search/ui/search_bar_controls.dart index 2d805437..4f552d18 100644 --- a/app/lib/features/search/ui/search_bar_controls.dart +++ b/app/lib/features/search/ui/search_bar_controls.dart @@ -4,22 +4,25 @@ import 'package:flutter/material.dart'; import '../../../ui/input/app_search_field.dart'; import '../../../ui/navigation/bar_icon_button.dart'; import '../domain/search_models.dart'; +import 'search_layout.dart'; const searchFieldKey = ValueKey('search.field'); const searchKindKey = ValueKey('search.kind'); const searchHelpKey = ValueKey('search.help'); const searchBarControlsKey = ValueKey('search.bar'); -/// The widest the search pill grows on a wide window. -const double kSearchPillMaxWidth = 560; +/// The widest the search pill grows on a wide window: the result column's +/// width, so on a wide window the field and the results share both edges. +const double kSearchPillMaxWidth = kSearchContentMaxWidth; const searchTokenHint = 'Filter with t:pipeline or type:artifact (pipeline, run, step, field, ' 'artifact, version). Last type wins; choosing Kind replaces it. Quote ' 'tokens to search literally.'; -/// Search's controls as one piece of the top bar's actions pill: the search -/// field, a compact Kind menu and the query-syntax help behind an info button. +/// Search's controls as the top bar's main pill (in place of a title): the +/// search field filling the pill, a compact Kind menu and the query-syntax +/// help behind an info button. class SearchBarControls extends StatelessWidget { const SearchBarControls({ super.key, @@ -47,9 +50,8 @@ class SearchBarControls extends StatelessWidget { key: searchBarControlsKey, constraints: const BoxConstraints(maxWidth: kSearchPillMaxWidth), child: Row( - mainAxisSize: MainAxisSize.min, children: [ - Flexible( + Expanded( child: Padding( padding: const EdgeInsetsDirectional.only(start: 4), child: AppSearchField( diff --git a/app/lib/features/settings/settings_screen.dart b/app/lib/features/settings/settings_screen.dart index 9497598f..bbbf1a8a 100644 --- a/app/lib/features/settings/settings_screen.dart +++ b/app/lib/features/settings/settings_screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../core/transport/pipelines_client.dart' as transport; +import '../../shell/shell_bar.dart'; import '../attention/notify/notification_controller.dart'; import 'default_endpoint.dart'; import 'settings_controller.dart'; @@ -201,7 +202,18 @@ class _SettingsScreenState extends State { ), ], ); - if (widget.embedded) return content; + if (widget.embedded) { + // Under the shell's bar the Cupertino page is the grouped background + // right up to the top edge: the bar's scrim takes the same colour, so + // no white band or seam shows above the groups. + if (usesCupertinoControls(context) && ShellBar.available(context)) { + return ShellBar( + backgroundColor: settingsCupertinoBackground, + child: content, + ); + } + return content; + } if (usesCupertinoControls(context)) { return CupertinoPageScaffold( backgroundColor: settingsCupertinoBackground, diff --git a/app/lib/features/templates/screen.dart b/app/lib/features/templates/screen.dart index 566cb7c6..19fba08e 100644 --- a/app/lib/features/templates/screen.dart +++ b/app/lib/features/templates/screen.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; import '../../core/api_gateway.dart'; import '../../shell/shell_bar.dart'; import '../../ui/adaptive/host.dart'; +import '../../ui/adaptive/top_bar_notices.dart'; import 'data/template_repository.dart'; import 'domain/template_entry.dart'; import 'ui/template_create_dialog.dart'; @@ -209,17 +210,18 @@ class _TemplatesScreenState extends State { /// open template never hides a failed read. The rows and selection are kept. Widget _withFailure(BuildContext context, Widget body) { final error = _error; - if (error == null || !_loaded) return body; - return Column( - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - TemplatesFailureBanner( - message: error, - retrying: _loading, - onRetry: () => unawaited(_load()), - ), - Expanded(child: body), + // The banner stays put below the top bar; without it the body scrolls + // behind the bar. The body keeps its place either way. + return TopBarNotices( + notices: [ + if (error != null && _loaded) + TemplatesFailureBanner( + message: error, + retrying: _loading, + onRetry: () => unawaited(_load()), + ), ], + child: body, ); } } diff --git a/app/lib/features/templates/ui/templates_frame.dart b/app/lib/features/templates/ui/templates_frame.dart index 3e6d2250..2894dd40 100644 --- a/app/lib/features/templates/ui/templates_frame.dart +++ b/app/lib/features/templates/ui/templates_frame.dart @@ -5,6 +5,7 @@ import '../../../shell/shell_bar.dart'; import '../../../ui/adaptive/host.dart'; import '../../../ui/adaptive/segmented_bar.dart'; import '../../../ui/navigation/bar_icon_button.dart'; +import '../../../ui/theme/app_theme.dart'; const templatesRefreshKey = ValueKey('templates-refresh'); const templatesBackKey = ValueKey('templates-back'); @@ -72,17 +73,16 @@ class TemplatesFrame extends StatelessWidget { title: 'Templates', actions: [_refreshButton()], ); + // The body reaches the top edge and scrolls behind the bar. + final page = SafeArea(top: false, bottom: false, child: body); if (cupertino) { return CupertinoPageScaffold( + backgroundColor: AppColors.groupedBackground, navigationBar: bar, - child: SafeArea(child: body), + child: page, ); } - return Scaffold( - extendBodyBehindAppBar: true, - appBar: bar, - body: SafeArea(child: body), - ); + return Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: page); } Widget _refreshButton() => BarIconButton( diff --git a/app/lib/shell/adaptive_shell.dart b/app/lib/shell/adaptive_shell.dart index 4ef9dda1..eb03c8a7 100644 --- a/app/lib/shell/adaptive_shell.dart +++ b/app/lib/shell/adaptive_shell.dart @@ -211,6 +211,9 @@ class _AdaptiveShellState extends State { onPressed: onBack, ), title: spec?.title ?? label, + titleWidget: spec?.titleWidget, + titleWidgetMaxWidth: spec?.titleWidgetMaxWidth ?? double.infinity, + backgroundColor: spec?.backgroundColor, subtitle: spec?.subtitle, subtitleIcon: spec?.subtitleIcon, onTitlePressed: spec?.onTitlePressed, @@ -228,7 +231,9 @@ class _AdaptiveShellState extends State { ], ), ) - else if (onSearch != null) + // A screen whose main pill is its own field (Search) needs no + // separate Search action. + else if (onSearch != null && spec?.titleWidget == null) cupertino ? CupertinoButton( key: const ValueKey('shell.search'), diff --git a/app/lib/shell/shell_bar.dart b/app/lib/shell/shell_bar.dart index 0e8ecb60..f668067a 100644 --- a/app/lib/shell/shell_bar.dart +++ b/app/lib/shell/shell_bar.dart @@ -15,10 +15,22 @@ class ShellBarSpec { this.onBack, this.actions = const [], this.barless = false, + this.titleWidget, + this.titleWidgetMaxWidth = double.infinity, + this.backgroundColor, }); final String? title; + /// The bar's main pill in place of the title (a search field); see + /// `SegmentedBar.titleWidget`. + final Widget? titleWidget; + final double titleWidgetMaxWidth; + + /// The page's own background behind the bar (a grouped list's), so the + /// bar's scrim matches what scrolls under it; null keeps the shell's. + final Color? backgroundColor; + /// 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; @@ -130,9 +142,19 @@ class ShellBar extends StatefulWidget { this.actions = const [], this.active = true, this.barless = false, + this.titleWidget, + this.titleWidgetMaxWidth = double.infinity, + this.backgroundColor, required this.child, }); + /// See [ShellBarSpec.titleWidget]. + final Widget? titleWidget; + final double titleWidgetMaxWidth; + + /// See [ShellBarSpec.backgroundColor]. + final Color? backgroundColor; + /// See [ShellBarSpec.barless]. final bool barless; @@ -190,6 +212,9 @@ class _ShellBarState extends State { onBack: widget.onBack, actions: widget.actions, barless: widget.barless, + titleWidget: widget.titleWidget, + titleWidgetMaxWidth: widget.titleWidgetMaxWidth, + backgroundColor: widget.backgroundColor, ); // The bar is above this screen; update it after this frame's build. WidgetsBinding.instance.addPostFrameCallback((_) { diff --git a/app/lib/ui/adaptive/segmented_bar.dart b/app/lib/ui/adaptive/segmented_bar.dart index 1ff9f145..fd3556a9 100644 --- a/app/lib/ui/adaptive/segmented_bar.dart +++ b/app/lib/ui/adaptive/segmented_bar.dart @@ -18,6 +18,10 @@ export 'segmented_bar_pieces.dart' show SegmentedBackButton, SegmentedPill; /// shrinks; only when the title is down to [minTitleShare] of the bar does /// the first action ellipsise. /// +/// A page whose bar is mainly an input (Search) passes [titleWidget] instead: +/// it takes the title pill's place as one pill that fills the space beside +/// the leading piece (up to the widget's own width cap), with no title. +/// /// Only the pieces take taps: a tap between them reaches the content behind. /// It works as a [Scaffold.appBar] (with `extendBodyBehindAppBar`) and a /// [CupertinoPageScaffold.navigationBar], which inset the content by the @@ -30,6 +34,8 @@ class SegmentedBar extends StatelessWidget super.key, required this.cupertino, required this.title, + this.titleWidget, + this.titleWidgetMaxWidth = double.infinity, this.leading, this.automaticallyImplyLeading = true, this.subtitle, @@ -52,6 +58,16 @@ class SegmentedBar extends StatelessWidget /// The title; empty shows no title pill unless there is a [subtitle]. final String title; + /// The bar's main pill when it is not a title: a search field and its + /// filters. It replaces the title pill (so [title], [subtitle] and + /// [onTitlePressed] are not drawn) and fills the width beside the leading + /// piece and any [actions], up to [titleWidgetMaxWidth]. + final Widget? titleWidget; + + /// The widest the [titleWidget] pill grows on a wide window; it starts at + /// the leading edge, so content below can line up with it. + final double titleWidgetMaxWidth; + /// The leading control, normally a [SegmentedBackButton]. final Widget? leading; @@ -110,7 +126,10 @@ class SegmentedBar extends StatelessWidget bool shouldFullyObstruct(BuildContext context) => false; Color _background(BuildContext context) { - if (backgroundColor case final color?) return color; + if (backgroundColor case final color?) { + // A dynamic system colour (the grouped background) follows the theme. + return CupertinoDynamicColor.maybeResolve(color, context) ?? color; + } if (cupertino) { return context .dependOnInheritedWidgetOfExactType< @@ -148,7 +167,22 @@ class SegmentedBar extends StatelessWidget child: Align( alignment: AlignmentDirectional.centerStart, heightFactor: 1, - child: showTitle + child: titleWidget != null + // The main pill fills the row, up to its cap. + ? ConstrainedBox( + constraints: BoxConstraints( + maxWidth: titleWidgetMaxWidth, + ), + child: SegmentedPill( + cupertino: cupertino, + fill: pillColor, + child: SizedBox( + width: double.infinity, + child: titleWidget, + ), + ), + ) + : showTitle ? SegmentedTitlePill( cupertino: cupertino, title: title, diff --git a/app/lib/ui/adaptive/top_glass_strip.dart b/app/lib/ui/adaptive/top_glass_strip.dart new file mode 100644 index 00000000..892a296a --- /dev/null +++ b/app/lib/ui/adaptive/top_glass_strip.dart @@ -0,0 +1,56 @@ +import 'package:flutter/widgets.dart'; + +import 'glass_pill.dart'; + +/// The corner radius of a [TopGlassStrip]. +const double kTopGlassStripRadius = 22; + +/// A page's own controls as one frosted piece floating just under its top +/// bar (a run's status and actions, a list's search and filter), so content +/// scrolls behind it as it does behind the bar. +/// +/// Float it with `FloatingBarOverlay(edge: FloatingBarEdge.top)`: the strip +/// sits below the bar and the content's top padding grows by the strip's +/// height, so at rest nothing is hidden. It starts at the bar's 12px side +/// inset, is as wide as its content up to [maxWidth] (and the area), and is +/// only as tall as its content; the space beside it passes taps through. +class TopGlassStrip extends StatelessWidget { + const TopGlassStrip({ + super.key, + required this.cupertino, + required this.child, + this.maxWidth = double.infinity, + this.padding = const EdgeInsets.symmetric(horizontal: 12, vertical: 8), + }); + + final bool cupertino; + final Widget child; + + /// The widest the strip grows on a wide window. + final double maxWidth; + + /// Space between the strip's edge and [child]. + final EdgeInsetsGeometry padding; + + @override + Widget build(BuildContext context) { + final insets = MediaQuery.paddingOf(context); + return Padding( + padding: EdgeInsets.fromLTRB(12 + insets.left, 0, 12 + insets.right, 8), + child: Align( + alignment: AlignmentDirectional.topStart, + heightFactor: 1, + child: ConstrainedBox( + constraints: BoxConstraints(maxWidth: maxWidth), + child: GlassPill( + cupertino: cupertino, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(kTopGlassStripRadius), + ), + child: Padding(padding: padding, child: child), + ), + ), + ), + ); + } +} diff --git a/app/notes/chrome-gaps-fixes.md b/app/notes/chrome-gaps-fixes.md new file mode 100644 index 00000000..28229203 --- /dev/null +++ b/app/notes/chrome-gaps-fixes.md @@ -0,0 +1,192 @@ +# Chrome gaps after the segmented-bar waves + +Follow-up to `notes/segmented-bar.md`, `notes/floating-tab-bars.md`, +`notes/app-chrome-fixes.md`, `notes/pages-fixes.md` and +`notes/chat-chrome-fixes.md`: the gaps those batches left. List rows, the chat +thread/composer and the viewers (artifact viewer, diff/changes viewer, graph +canvases, image viewer) were out of scope and are untouched. + +## Shared pieces + +- `SegmentedBar.titleWidget` / `titleWidgetMaxWidth` + (`lib/ui/adaptive/segmented_bar.dart`). The bar's main pill is a widget + (a search field and its filters) in place of the title pill. It fills the + row beside the leading piece and any actions, up to the cap, and starts at + the leading edge. `title` is not drawn. A `backgroundColor` given as a + `CupertinoDynamicColor` is now resolved against the context, so the + scrim follows light/dark. +- `ShellBarSpec`/`ShellBar` (`lib/shell/shell_bar.dart`) carry `titleWidget`, + `titleWidgetMaxWidth` and `backgroundColor`, and the shell passes them to its + bar. When a screen publishes a `titleWidget`, the shell drops its own Search + action. +- `TopGlassStrip` (`lib/ui/adaptive/top_glass_strip.dart`): a page's own + controls as one frosted rounded piece under the top bar. It is placed with + `FloatingBarOverlay(edge: FloatingBarEdge.top)`, so the content's top + padding grows by the strip's height and the content scrolls behind it. It + starts at the bar's 12px inset and is as wide as its content (up to + `maxWidth`). Taps beside it pass through. + +## 1. Templates + +- `templates_destination.dart`, `templates_frame.dart` (standalone) and + `screen.dart` dropped the top `SafeArea` that a merge had brought back. + Instead: + - the page body is `SafeArea(top: false, bottom: false)`; + - the connection gate is `BelowTopBar`; + - the connection banner and the refused-refresh banner use + `TopBarNotices`. +- The gallery's `ListView`s use the default media padding, and the detail uses + `withBarClearance`. Both start below the bar and scroll behind it. +- There is still one bar: Back (`templates-page-back` / `template-detail-back`) + and Refresh in the actions pill. +- On Cupertino the page (and so the bar's scrim) is + `AppColors.groupedBackground`, under the existing inset-grouped section. + That gives inset-grouped rows on the grouped background, as in Settings, + instead of white rows in a grey band on a white page. + +## 2. Search field fills the bar + +- `SearchScreen` publishes `SearchBarControls` as the bar's `titleWidget` in + both cases: as the shell tab through `ShellBar`, and standalone through its + own `SegmentedBar`. There is no Search title pill and no actions pill. +- The field is `Expanded` inside the pill, with Kind and the info button at its + trailing end. +- `kSearchPillMaxWidth` is now `kSearchContentMaxWidth` (840). The pill starts + at x=12 and the result column at the same 12 inset with the same cap, so on a + wide window the field and the results share both edges. On a phone the pill + spans the bar. + +## 3. Settings on Cupertino in the shell + +Embedded Settings under the shell publishes +`ShellBar(backgroundColor: settingsCupertinoBackground)`. The shell's bar scrim +(the opaque status inset and its fade) is then the grouped background, the same +as the page's `ColoredBox` from the top edge down. This removes the white band +and the seam under the bar. Material is unchanged. + +## 4. Run detail header + +The slim header (status kicker, run actions, decision banner, +refreshing/error notices) is now a `TopGlassStrip` floating just under the +bar (key `run-detail-header`; the inner scroll keeps +`run-detail-header-`). + +- Every tab fills the whole detail from the top edge and scrolls behind both + the bar and the strip. Tab bodies already padded by the media top + (`SliverTopBarClearance` / `withBarClearance`), so they clear the strip at + rest. +- The strip is content-width, or full width when the decision banner is + shown. Its internal paddings went from 16 to 12. +- The 40%/240px header limit still applies: the strip scrolls internally past + it. +- Pane-top tabs on a wide split now float below the strip. The two overlays + nest. +- The Graph canvas is `BelowTopBar`, and Changes stays `BelowTopBar`: both are + viewers with fixed headers or controls. + +## 5. Stage (visit) page + +`run_detail_visit*.dart`: + +- **Bar.** The page bar's title is the stage (key `run-visit-title`) and its + subtitle is `Visit N · Run X · ` (`runVisitSubtitle`). The + pane's own stage heading and `Visit N` / `Run X` line are gone, so nothing + is duplicated. +- **Body.** The body is `SafeArea(top: false, bottom: false)`, and the + sections fill the page under the floating tabs (`FloatingBarOverlay`, keys + `run-visit-tabs`, `run-visit-tab-` unchanged). +- **Facts.** The facts, verdict and diagnostic (`run_detail_visit_facts_view.dart`, + `RunVisitFactsView`) lead the Summary's scroll after a + `SliverTopBarClearance`. They scroll behind the bar, and the Input/Output + sticky headers pin under it. The fixed 40% facts block is gone. +- **Other sections.** + - Session (Material) and Definition (missing) pad with `withBarClearance`. + - Cupertino Session and the field tabs already used the media padding. + - Artifacts uses the gallery's `SliverTopBarClearance`. + - Changes (a viewer) is `BelowTopBar`. + +## 6. Schedules + +The search/filter/count toolbar is now a `TopGlassStrip` (key +`schedule-toolbar`, at most 720 wide) floating under the bar, set inside +`SchedulesListView`. + +- The list (`schedule-list`, still a `ListView`) pads its first row by + `withBarClearance`. +- The loading, empty and failure states are `BelowTopBar`. +- The failed-refresh banner uses `TopBarNotices`, so the list keeps its + ancestors and its scroll offset. +- The strip keeps its place in every state, so a query that empties the list + keeps the field's focus. The destination dropped its top `SafeArea`. + +## Tests + +New: + +- `test/ui/adaptive/segmented_bar_title_widget_test.dart` (both hosts): + - no title pill; + - the pill fills a 390 bar at 12/378, and stops at its cap beside a Back with + actions trailing at 1200; + - a shell tab publishing a field gets it in place of the title, with no + `shell.search`. +- `test/features/search/search_bar_layout_test.dart`, new cases at 390 and + 1200: the field's pill is the bar's only piece, starts at 12 and is + `min(width − 24, 840)` wide, and the result row shares its left and right + edges. +- `test/application/templates_behind_bar_test.dart` (real app, both hosts): + - the gallery reaches y=0, its first row is below the bar, and dragging + moves it up; + - Cupertino has the grouped scaffold background and the inset section; + - the detail reaches y=0 with Create below the bar; + - Refresh is in the one bar. +- `test/features/settings/settings_shell_background_test.dart`: in the + Cupertino shell the bar's scrim and the page are both the grouped background + from y=0, with the groups below the bar. Material keeps the scaffold colour. +- `test/features/runs/ui/run_detail_behind_bar_test.dart` (both hosts): + - the header strip sits just under the bar at x=12, the tab body starts at + y=0 with padding past the strip, and the content scrolls behind the strip; + - the stage page's bar holds `run-visit-title` (the stage), Summary starts + at y=0 with the facts below the bar, and the tabs float at the bottom. +- `test/features/schedules/ui/list/schedules_behind_bar_test.dart` (both + hosts): + - the strip is under the bar and holds the field, the list starts at y=0 + with its first row below the strip, and a drag moves rows behind it; + - an emptying query keeps the field element and its focus. + +Updated for intentional changes: + +- `run_detail_finders.dart` `expectVisitHeading`: the stage and `Visit N` are + in the page bar. +- `run_detail_visit_test.dart`: heading in the bar with header semantics, the + facts below it; the long stage fits the bar's one line at 2x. +- `run_decision_wiring_test.dart`: the banner spans the header strip at its 12 + inset, and the strip sits 12 in from the pane. + +## Evidence + +Captures are in `/tmp/wave2-e-evidence/`, taken with headless Chrome via +`/tmp/wave2-e-scripts/shoot.mjs` (a copy of `/tmp/fix-c-tools/shoot.mjs` with +its fixture server). They come from a web build of +`tool/templates_wiring_probe_entry.dart` (the real app, `?host=material|cupertino`). +Spec: `/tmp/wave2-e-scripts/mkspec.py`. + +- Naming: `{m,c}-{search,settings,templates,template-detail,schedules,run1,run5,stage}-{560,1200}-{light,dark}` + and `{m,c}-{settings,templates,schedules,search,run1,stage}-{560,1200}-scrolled`. +- `run5` is the human-decision run (banner inside the strip). +- `stage` is `/runs/1/stage/build`. +- A second pass (`mkspec2.py`) gave the fixture copy 16 templates and 12 + schedules. Its captures are + `{m,c}-{templates,template-long,schedules}-{560,1200}-{light,dark}-scrolled` + (rows and source behind the bar or strip), `{m,c}-{templates,schedules}-*-rest`, + and `{m,c}-{run1,stage}-560-*-input-scrolled` (Input expanded, then + scrolled behind the header strip). +- `main-{run1,run5,stage,search,settings}-{560,1200}-{light,dark}` are the + `lib/main.dart` web build over the same fixture. That build is Material on + the web. + +## Not done / notes + +- A standalone `SearchScreen` with an implied Back (tests only; the app mounts + Search as a shell tab) starts its field after the Back. Its results still + start at the 12 inset. +- No device run: Android and iOS are unverified. diff --git a/app/test/application/templates_behind_bar_test.dart b/app/test/application/templates_behind_bar_test.dart new file mode 100644 index 00000000..b4e17817 --- /dev/null +++ b/app/test/application/templates_behind_bar_test.dart @@ -0,0 +1,92 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/application/templates_destination.dart'; +import 'package:pipelines_app/core/transport/pipelines_client.dart'; +import 'package:pipelines_app/features/templates/screen.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; +import 'package:pipelines_app/ui/theme/app_theme.dart'; + +import '../core/transport/pipelines_client_test.dart' show FakeChannel; +import '../features/pipelines/fixtures.dart'; +import 'pipelines_replies.dart'; +import 'templates_wiring_test.dart' show openSettings, openTemplates, pumpApp; + +/// The app-level Templates page: one bar (Back + Refresh), the gallery and an +/// open template reach the top edge, start below the bar at rest and scroll +/// behind it. Cupertino draws inset-grouped rows on the grouped background. +void main() { + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + + testWidgets('$host: the gallery and detail scroll behind the bar', ( + tester, + ) async { + final channel = FakeChannel()..readyCompleter.complete(); + final client = PipelinesClient(channelFactory: (_) => channel); + final provider = PlatformRouteInformationProvider( + initialRouteInformation: RouteInformation(uri: Uri.parse('/pipelines')), + ); + addTearDown(provider.dispose); + await pumpApp( + tester, + channel: channel, + client: client, + provider: provider, + cupertino: cupertino, + ); + await replyPipelines(tester, channel, PipelineFixture()); + await openSettings(tester, channel, provider); + await openTemplates(tester, channel, provider); + await tester.pumpAndSettle(); + + final bar = find.ancestor( + of: find.byKey(templatesPageBackKey), + matching: find.byType(SegmentedBar), + ); + final barBottom = tester.getRect(bar).bottom; + // One bar: Back and Refresh are its pieces. + expect( + find.descendant(of: bar, matching: find.byKey(templatesRefreshKey)), + findsOneWidget, + ); + + final gallery = find.byKey(templatesGalleryKey); + expect(tester.getTopLeft(gallery).dy, 0); + final row = find.byKey(templateRowKey('release')); + expect(tester.getTopLeft(row).dy, greaterThanOrEqualTo(barBottom - 8)); + // Scrolling moves the row up behind the bar. + final before = tester.getTopLeft(row).dy; + await tester.drag(gallery, const Offset(0, -40)); + await tester.pump(); + expect(tester.getTopLeft(row).dy, lessThanOrEqualTo(before)); + + if (cupertino) { + final scaffold = tester.widget( + find + .ancestor( + of: gallery, + matching: find.byType(CupertinoPageScaffold), + ) + .first, + ); + expect(scaffold.backgroundColor, AppColors.groupedBackground); + expect( + find.descendant( + of: gallery, + matching: find.byType(CupertinoListSection), + ), + findsOneWidget, + ); + } + + await tester.tap(row); + await tester.pumpAndSettle(); + final detail = find.byKey(templateDetailKey); + expect(tester.getTopLeft(detail).dy, 0); + expect( + tester.getTopLeft(find.byKey(templateCreateActionKey)).dy, + greaterThanOrEqualTo(barBottom - 8), + ); + }); + } +} diff --git a/app/test/features/runs/ui/run_decision_wiring_test.dart b/app/test/features/runs/ui/run_decision_wiring_test.dart index dce58f99..d4e27fbf 100644 --- a/app/test/features/runs/ui/run_decision_wiring_test.dart +++ b/app/test/features/runs/ui/run_decision_wiring_test.dart @@ -6,6 +6,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:pipelines_app/core/api_gateway.dart'; import 'package:pipelines_app/features/runs/actions/decision_wording.dart'; import 'package:pipelines_app/features/runs/screen.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; class _DecisionGateway implements ApiGateway { final events = StreamController.broadcast(); @@ -73,16 +74,25 @@ void main() { ); await tester.pumpAndSettle(); expect(find.text(decisionWaitingTitle), findsOneWidget); - // The web's decision banner spans the header at its 16px inset, with + // The web's decision banner spans the header's glass strip (under + // the top bar, 12 in from the pane) at the strip's 12px inset, with // Decide trailing. final banner = tester.getRect( find.byKey(const Key('run-decision-banner')), ); + final strip = tester.getRect( + find.descendant( + of: find.byKey(const Key('run-detail-header')), + matching: find.byType(GlassPill), + ), + ); final pane = tester.getRect( find.byKey(const ValueKey('list-detail-body')), ); - expect(banner.left, pane.left + 16); - expect(banner.right, pane.right - 16); + expect(strip.left, pane.left + 12); + expect(strip.right, pane.right - 12); + expect(banner.left, strip.left + 12); + expect(banner.right, strip.right - 12); expect( tester.getCenter(find.byKey(decisionActionKey)).dx, greaterThan(banner.center.dx), diff --git a/app/test/features/runs/ui/run_detail_behind_bar_test.dart b/app/test/features/runs/ui/run_detail_behind_bar_test.dart new file mode 100644 index 00000000..b4908aa3 --- /dev/null +++ b/app/test/features/runs/ui/run_detail_behind_bar_test.dart @@ -0,0 +1,101 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; + +import 'run_detail_graph_support.dart'; +import 'run_detail_visit_support.dart'; + +/// The run detail and the stage page scroll behind their top bars: the run's +/// status and actions are a glass strip under the bar (not a fixed block +/// above the tab), and the stage page's bar names the stage while its +/// sections, led by the facts, pass behind it. +void main() { + Rect pieceOf(WidgetTester tester, Finder owner) => tester.getRect( + find.descendant(of: owner, matching: find.byType(GlassPill)).first, + ); + + ScrollPosition positionIn(WidgetTester tester, Finder owner) => tester + .state( + find.descendant(of: owner, matching: find.byType(Scrollable)).first, + ) + .position; + + for (final platform in RunDetailTestPlatform.values) { + testWidgets('${platform.name} run header floats under the bar and the ' + 'tab scrolls behind both', (tester) async { + await pumpRunDetail(tester, platform, size: const Size(390, 520)); + + final bar = pieceOf(tester, find.byType(SegmentedBar)); + final header = find.byKey(const Key('run-detail-header')); + final strip = pieceOf(tester, header); + // A glass strip just under the bar, at the bar's side inset. + expect(strip.top, greaterThanOrEqualTo(bar.bottom)); + expect(strip.top - bar.bottom, lessThan(24)); + expect(strip.left, 12); + expect(find.byKey(const Key('run-status-kicker')), findsWidgets); + + // The tab fills the detail from the top edge; its content starts + // below the strip at rest. + final body = find.byKey(const Key('run-detail-tab-body-summary')); + expect(tester.getTopLeft(body).dy, 0); + final padding = MediaQuery.paddingOf(tester.element(body)).top; + expect(padding, greaterThanOrEqualTo(strip.bottom)); + + // Scrolled, the content passes behind the strip and the bar. + final position = positionIn(tester, body); + expect(position.maxScrollExtent, greaterThan(0)); + final firstChild = find + .descendant(of: body, matching: find.byType(Text)) + .first; + final before = tester.getTopLeft(firstChild).dy; + expect(before, greaterThanOrEqualTo(strip.bottom - 1)); + position.jumpTo(position.maxScrollExtent.clamp(0, 200).toDouble()); + await tester.pump(); + expect(tester.getTopLeft(firstChild).dy, lessThan(before)); + }); + + testWidgets('${platform.name} stage page names the stage in its bar and ' + 'its Summary scrolls behind it', (tester) async { + await openVisit(tester, platform, size: const Size(390, 844)); + + final bar = find.ancestor( + of: find.byKey(const Key('run-visit-back')), + matching: find.byType(SegmentedBar), + ); + final heading = find.byKey(const Key('run-visit-title')); + expect( + find.descendant(of: bar, matching: heading), + findsOneWidget, + reason: 'the stage is the bar title', + ); + expect( + find.descendant(of: heading, matching: find.text('plan')), + findsOneWidget, + ); + final barBottom = pieceOf(tester, bar).bottom; + + final summary = find.byKey(const Key('run-visit-body-summary')); + expect(tester.getTopLeft(summary).dy, 0); + final facts = find.byKey(const Key('run-visit-facts-grid')); + final rest = tester.getTopLeft(facts).dy; + expect(rest, greaterThanOrEqualTo(barBottom)); + // The tabs float at the bottom over the section. + final tabs = pieceOf(tester, find.byKey(const Key('run-visit-tabs'))); + expect(tabs.bottom, 844 - 16); + expect(tester.getRect(summary).bottom, 844); + + // Open Input so the section is long enough to scroll, then scroll: + // the facts pass behind the bar. + await tester.tap(find.text('Input').first); + await tester.pumpAndSettle(); + final position = positionIn(tester, summary); + if (position.maxScrollExtent > 0) { + position.jumpTo(position.maxScrollExtent.clamp(0, 60).toDouble()); + await tester.pump(); + expect(tester.getTopLeft(facts).dy, lessThan(rest)); + } + expect(tester.takeException(), isNull); + }); + } +} diff --git a/app/test/features/runs/ui/run_detail_finders.dart b/app/test/features/runs/ui/run_detail_finders.dart index 4824aa1a..a41a6066 100644 --- a/app/test/features/runs/ui/run_detail_finders.dart +++ b/app/test/features/runs/ui/run_detail_finders.dart @@ -13,17 +13,20 @@ Finder runDetailText(String text) => find.descendant( matching: find.text(text), ); -/// Stage identity and visit coordinates are separate rendered fields now. +/// The stage page's bar names the stage over its visit (and run): the title +/// is keyed `run-visit-title` and the subtitle starts `Visit `. void expectVisitHeading(WidgetTester tester, String stage, num sequence) { - final pane = find.byKey(const Key('run-visit-pane')); - expect(pane, findsOneWidget); - final title = find.descendant( - of: pane, - matching: find.byKey(const Key('run-visit-title')), - ); - expect(tester.widget(title).data, stage); + expect(find.byKey(const Key('run-visit-pane')), findsOneWidget); + final heading = find.byKey(const Key('run-visit-title')); expect( - find.descendant(of: pane, matching: find.text('Visit $sequence')), + find.descendant(of: heading, matching: find.text(stage)), + findsOneWidget, + ); + expect( + find.descendant( + of: heading, + matching: find.textContaining(RegExp('^Visit $sequence( ·|\$)')), + ), findsOneWidget, ); } diff --git a/app/test/features/runs/ui/run_detail_visit_test.dart b/app/test/features/runs/ui/run_detail_visit_test.dart index 1b9e0c3c..5ba115e6 100644 --- a/app/test/features/runs/ui/run_detail_visit_test.dart +++ b/app/test/features/runs/ui/run_detail_visit_test.dart @@ -16,9 +16,22 @@ void main() { await openVisit(tester, platform); expect(find.byKey(const Key('run-visit-pane')), findsOneWidget); + // The page bar names the stage over its visit and run; the body does + // not repeat them. + final heading = find.byKey(const Key('run-visit-title')); + expect( + find.descendant(of: heading, matching: find.text('plan')), + findsOneWidget, + ); + expect( + find.descendant( + of: heading, + matching: find.text('Visit 1 · Run 77 · Visit run'), + ), + findsOneWidget, + ); expect(find.text('plan'), findsOneWidget); - expect(find.text('Visit 1'), findsOneWidget); - expect(find.text('Run 77'), findsOneWidget); + expect(find.text('Visit 1'), findsNothing); // Each fact as its label over its value; several share a line. for (final (label, value) in [ ('Status', 'completed'), @@ -36,20 +49,16 @@ void main() { expect(find.text('Verdict'), findsOneWidget); expect(find.text('Diagnostic'), findsOneWidget); - // Stage identity is a distinct, prominent heading; coordinates are - // subordinate and the facts remain aligned with the heading. - final titleFinder = find.byKey(const Key('run-visit-title')); - final title = tester.getTopLeft(titleFinder).dx; - final titleStyle = tester.widget(titleFinder).style!; - expect(titleStyle.fontSize!, greaterThan(18)); + // The title is the bar's header; the facts lead the scrolled Summary + // below the bar at rest. expect( - tester.getTopLeft(find.text('Visit 1')).dy, - greaterThan(tester.getTopLeft(titleFinder).dy), + tester.getSemantics(find.text('plan')), + matchesSemantics(isHeader: true, label: 'plan'), ); - expect( - tester.getTopLeft(find.byKey(const Key('run-visit-facts-grid'))).dx, - title, + final facts = tester.getRect( + find.byKey(const Key('run-visit-facts-grid')), ); + expect(facts.top, greaterThanOrEqualTo(tester.getRect(heading).bottom)); // Status and duration share a line. expect( tester.getTopLeft(find.text('completed')).dy, @@ -109,7 +118,7 @@ void main() { expect(tester.takeException(), isNull); }); - testWidgets('${platform.name} long stage identity wraps at 2x', ( + testWidgets('${platform.name} long stage identity fits the bar at 2x', ( tester, ) async { final run = visitRunFixture(); @@ -123,12 +132,13 @@ void main() { scale: 2, ); + // The bar's one-line title ellipsises a long stage instead of + // overflowing. expect( find.text('review-generated-release-artifacts-and-verify-evidence'), findsOneWidget, ); - expect(find.text('Visit 1'), findsOneWidget); - expect(find.text('Run 77'), findsOneWidget); + expect(find.text('Visit 1 · Run 77 · Visit run'), findsOneWidget); expect(tester.takeException(), isNull); }); } diff --git a/app/test/features/schedules/ui/list/schedules_behind_bar_test.dart b/app/test/features/schedules/ui/list/schedules_behind_bar_test.dart new file mode 100644 index 00000000..71ca8abe --- /dev/null +++ b/app/test/features/schedules/ui/list/schedules_behind_bar_test.dart @@ -0,0 +1,93 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/features/schedules/screen.dart'; +import 'package:pipelines_app/features/schedules/ui/list/schedule_list_toolbar.dart'; +import 'package:pipelines_app/features/schedules/ui/list/schedule_list_view.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; + +import 'schedule_list_test_support.dart'; + +/// The schedule list under a floating bar: search, filter and count are a +/// glass strip under the bar, and the list scrolls behind both. +void main() { + Future pump(WidgetTester tester, {required bool cupertino}) async { + tester.view.physicalSize = const Size(390, 844); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + final gateway = FakeSchedulesGateway( + (type, fields) async => schedulesReply(longScheduleList(30)), + ); + final screen = SchedulesScreen(gateway: gateway, onOpen: (_) {}); + final bar = SegmentedBar(cupertino: cupertino, title: 'Schedules'); + await tester.pumpWidget( + cupertino + ? CupertinoApp( + home: CupertinoPageScaffold(navigationBar: bar, child: screen), + ) + : MaterialApp( + home: Scaffold( + extendBodyBehindAppBar: true, + appBar: bar, + body: screen, + ), + ), + ); + await tester.pumpAndSettle(); + } + + Rect pieceOf(WidgetTester tester, Finder owner) => tester.getRect( + find.descendant(of: owner, matching: find.byType(GlassPill)).first, + ); + + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + + testWidgets('$host: the toolbar floats under the bar and the list ' + 'scrolls behind it', (tester) async { + await pump(tester, cupertino: cupertino); + + final bar = pieceOf(tester, find.byType(SegmentedBar)); + final strip = pieceOf(tester, find.byKey(scheduleToolbarKey)); + expect(strip.top, greaterThanOrEqualTo(bar.bottom)); + expect(strip.top - bar.bottom, lessThan(24)); + expect( + find.descendant( + of: find.byKey(scheduleToolbarKey), + matching: find.byKey(scheduleSearchFieldKey), + ), + findsOneWidget, + ); + + final list = find.byKey(scheduleListKey); + expect(tester.getTopLeft(list).dy, 0); + final firstRow = find.byKey(const ValueKey('schedule-row-0-100')); + final rest = tester.getTopLeft(firstRow).dy; + expect(rest, greaterThanOrEqualTo(strip.bottom)); + + await tester.drag(list, const Offset(0, -120)); + await tester.pump(); + expect(tester.getTopLeft(firstRow).dy, lessThan(strip.bottom)); + }); + + testWidgets('$host: a query that empties the list keeps the field', ( + tester, + ) async { + await pump(tester, cupertino: cupertino); + final field = find.byKey(scheduleSearchFieldKey); + await tester.tap(field); + await tester.pump(); + final before = tester.element(field); + await tester.enterText(field, 'no schedule matches this'); + await tester.pump(); + + expect(find.text('No schedules match this search.'), findsOneWidget); + expect(tester.element(field), same(before)); + final editable = tester.state( + find.descendant(of: field, matching: find.byType(EditableText)), + ); + expect(editable.widget.focusNode.hasFocus, isTrue); + }); + } +} diff --git a/app/test/features/search/search_bar_layout_test.dart b/app/test/features/search/search_bar_layout_test.dart index 1755044a..439e8888 100644 --- a/app/test/features/search/search_bar_layout_test.dart +++ b/app/test/features/search/search_bar_layout_test.dart @@ -6,6 +6,7 @@ import 'package:pipelines_app/features/search/ui/search_bar_controls.dart'; import 'package:pipelines_app/features/search/ui/search_bounds_note.dart'; import 'package:pipelines_app/features/search/ui/search_layout.dart'; import 'package:pipelines_app/features/search/ui/search_result_view.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; import 'search_screen_test.dart' @@ -153,5 +154,54 @@ void main() { lessThanOrEqualTo(kSearchPillMaxWidth), ); }); + + for (final width in [390.0, 1200.0]) { + testWidgets('$host: at $width the field takes the title\'s place and ' + 'the results line up with it', (tester) async { + _size(tester, width); + final gateway = ImmediateGateway((_, _) => response([pipeline])); + await tester.pumpWidget( + _app( + cupertino, + SearchScreen( + gateway: gateway, + onOpen: (_) {}, + cupertino: cupertino, + ), + ), + ); + await _search(tester, 'release'); + + final bar = find.byType(SegmentedBar); + // No Search title pill: the field's pill is the bar's only piece. + expect( + find.descendant(of: bar, matching: find.text('Search')), + findsNothing, + ); + expect( + find.descendant(of: bar, matching: find.byType(GlassPill)), + findsOneWidget, + ); + final pill = tester.getRect( + find.descendant(of: bar, matching: find.byType(GlassPill)), + ); + expect(pill.left, kSearchContentInset); + expect( + pill.width, + width - 2 * kSearchContentInset < kSearchPillMaxWidth + ? width - 2 * kSearchContentInset + : kSearchPillMaxWidth, + ); + // The field fills the pill beside Kind and the help. + final field = tester.getRect(find.byKey(searchFieldKey)); + expect(field.width, greaterThan(pill.width * 0.6)); + // The result column shares the pill's edges. + final row = tester.getRect( + find.byKey(const ValueKey('search.result.pipeline:7')), + ); + expect(row.left, pill.left); + expect(row.right, pill.right); + }); + } } } diff --git a/app/test/features/settings/settings_shell_background_test.dart b/app/test/features/settings/settings_shell_background_test.dart new file mode 100644 index 00000000..7c7c3a0a --- /dev/null +++ b/app/test/features/settings/settings_shell_background_test.dart @@ -0,0 +1,99 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:pipelines_app/core/transport/pipelines_client.dart' + as transport; +import 'package:pipelines_app/features/settings/settings_group.dart'; +import 'package:pipelines_app/features/settings/settings_screen.dart'; +import 'package:pipelines_app/features/settings/settings_store.dart'; +import 'package:pipelines_app/shell/adaptive_shell.dart'; +import 'package:pipelines_app/shell/destination.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; +import 'package:pipelines_app/ui/theme/app_theme.dart'; + +import 'fake_channel.dart'; + +/// Settings as the shell's tab: the page runs behind the shell's bar, and on +/// Cupertino the grouped background reaches the top edge with the bar's +/// scrim in the same colour, so no white band or seam shows under the bar. +void main() { + Future pump(WidgetTester tester, {required bool cupertino}) async { + await tester.binding.setSurfaceSize(const Size(560, 1000)); + addTearDown(() => tester.binding.setSurfaceSize(null)); + final factory = FakeChannelFactory(); + final client = transport.PipelinesClient(channelFactory: factory.call); + addTearDown(client.dispose); + await tester.pumpWidget( + MaterialApp( + theme: ThemeData( + platform: cupertino ? TargetPlatform.iOS : TargetPlatform.android, + ), + home: AdaptiveShell( + cupertino: cupertino, + destination: AppDestination.settings, + destinationBodies: { + AppDestination.settings: (_) => SettingsScreen( + client: client, + store: MemorySettingsStore(), + embedded: true, + ), + }, + ), + ), + ); + await tester.pump(); + await tester.pump(); + } + + Color scrimOf(WidgetTester tester) => tester + .widget( + find + .descendant( + of: find.byType(SegmentedBar), + matching: find.byType(ColoredBox), + ) + .first, + ) + .color; + + testWidgets('Cupertino: the grouped background runs under the bar', ( + tester, + ) async { + await pump(tester, cupertino: true); + + final grouped = AppColors.groupedBackground.color.toARGB32(); + expect(scrimOf(tester).toARGB32(), grouped); + // The page's background starts at the top edge, behind the bar. + final page = find.ancestor( + of: find.byKey(const ValueKey('settings.scroll')), + matching: find.byWidgetPredicate( + (widget) => widget is ColoredBox && widget.color.toARGB32() == grouped, + ), + ); + expect(page, findsOneWidget); + expect(tester.getTopLeft(page).dy, 0); + // The groups start below the bar and scroll behind it. + final bar = tester.getRect(find.byType(SegmentedBar)); + expect( + tester.getTopLeft(find.byType(SettingsGroup).first).dy, + greaterThanOrEqualTo(bar.bottom - 8), + ); + }); + + testWidgets('Material: the bar keeps the shell page background', ( + tester, + ) async { + await pump(tester, cupertino: false); + + final context = tester.element(find.byType(SettingsGroup).first); + expect( + scrimOf(tester).toARGB32(), + Theme.of(context).scaffoldBackgroundColor.toARGB32(), + ); + expect( + tester + .getTopLeft(find.byKey(const ValueKey('settings.scroll'))) + .dy, + 0, + ); + }); +} diff --git a/app/test/ui/adaptive/segmented_bar_title_widget_test.dart b/app/test/ui/adaptive/segmented_bar_title_widget_test.dart new file mode 100644 index 00000000..f22226c0 --- /dev/null +++ b/app/test/ui/adaptive/segmented_bar_title_widget_test.dart @@ -0,0 +1,145 @@ +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/shell_bar.dart'; +import 'package:pipelines_app/ui/adaptive/glass_pill.dart'; +import 'package:pipelines_app/ui/adaptive/segmented_bar.dart'; + +/// A bar whose main pill is an input (Search): the widget takes the title +/// pill's place and fills the bar, up to its cap, from the leading edge. +void main() { + void setSize(WidgetTester tester, double width) { + tester.view.physicalSize = Size(width, 800); + tester.view.devicePixelRatio = 1; + addTearDown(tester.view.reset); + } + + const fieldKey = Key('field'); + + Widget field(bool cupertino) => cupertino + ? const CupertinoTextField(key: fieldKey, placeholder: 'Find') + : const TextField(key: fieldKey); + + Rect pillOf(WidgetTester tester, Finder child) => tester.getRect( + find.ancestor(of: child, matching: find.byType(GlassPill)).first, + ); + + Widget page(bool cupertino, SegmentedBar bar) => cupertino + ? CupertinoApp( + home: CupertinoPageScaffold( + navigationBar: bar, + child: const SizedBox.expand(), + ), + ) + : MaterialApp( + home: Scaffold( + extendBodyBehindAppBar: true, + appBar: bar, + body: const SizedBox.expand(), + ), + ); + + for (final cupertino in [false, true]) { + final host = cupertino ? 'Cupertino' : 'Material'; + + testWidgets('$host: the widget replaces the title and fills a phone bar', ( + tester, + ) async { + setSize(tester, 390); + await tester.pumpWidget( + page( + cupertino, + SegmentedBar( + cupertino: cupertino, + title: 'Search', + titleWidget: field(cupertino), + titleWidgetMaxWidth: 840, + ), + ), + ); + + expect(find.text('Search'), findsNothing, reason: 'no title pill'); + expect( + find.descendant( + of: find.byType(SegmentedBar), + matching: find.byType(GlassPill), + ), + findsOneWidget, + reason: 'one pill: the field', + ); + final pill = pillOf(tester, find.byKey(fieldKey)); + expect(pill.left, 12); + expect(pill.right, 390 - 12); + }); + + testWidgets('$host: on a wide bar the pill stops at its cap from the ' + 'leading edge, beside a Back and any actions', (tester) async { + setSize(tester, 1200); + await tester.pumpWidget( + page( + cupertino, + SegmentedBar( + cupertino: cupertino, + title: 'Search', + leading: SegmentedBackButton( + cupertino: cupertino, + onPressed: () {}, + ), + titleWidget: field(cupertino), + titleWidgetMaxWidth: 600, + actions: const [Icon(Icons.info_outline, key: Key('action'))], + ), + ), + ); + + final pill = pillOf(tester, find.byKey(fieldKey)); + final back = pillOf(tester, find.byType(SegmentedBackButton)); + expect(pill.width, 600); + expect(pill.left, back.right + 8); + // The actions keep to the trailing edge. + expect(pillOf(tester, find.byKey(const Key('action'))).right, 1200 - 12); + }); + + testWidgets('$host: a shell tab publishing a field gets it in place of ' + 'the title, without the Search action', (tester) async { + setSize(tester, 560); + await tester.pumpWidget( + _shellApp( + cupertino, + AdaptiveShell( + cupertino: cupertino, + destination: AppDestination.search, + onSearch: () {}, + destinationBodies: { + AppDestination.search: (_) => ShellBar( + titleWidget: field(cupertino), + titleWidgetMaxWidth: 840, + child: const SizedBox.expand(), + ), + }, + ), + ), + ); + await tester.pump(); + + final bar = find.byType(SegmentedBar); + expect( + find.descendant(of: bar, matching: find.byKey(fieldKey)), + findsOneWidget, + ); + expect( + find.descendant(of: bar, matching: find.text('Search')), + findsNothing, + ); + expect(find.byKey(const ValueKey('shell.search')), findsNothing); + final pill = pillOf(tester, find.byKey(fieldKey)); + expect(pill.left, 12); + expect(pill.right, 560 - 12); + }); + } +} + +Widget _shellApp(bool cupertino, Widget shell) => + cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell);