Merge branch 'worktree-agent-a99db48531c8c963c' into integrate/floating-tabs

This commit is contained in:
2026-10-31 01:51:13 +00:00
35 changed files with 1197 additions and 702 deletions
@@ -9,6 +9,7 @@ import 'artifact_record_row.dart';
import 'artifact_tile.dart';
import 'artifact_viewer_fetch.dart';
import 'artifact_row_labels.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
export 'artifact_row_labels.dart'
show
@@ -141,7 +142,10 @@ class _ArtifactVisitListState extends State<ArtifactVisitList> {
);
}
}
return CustomScrollView(slivers: slivers);
// Clear of a floating tab bar when the gallery is a tab.
return CustomScrollView(
slivers: [...slivers, const SliverFloatingBarClearance()],
);
}
/// One collapsible section: its title stays pinned at the top while its
@@ -9,6 +9,7 @@ import 'capture_section.dart';
import 'change_style.dart';
import 'file_diff_viewer.dart';
import 'visit_pager.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The run's Changes surface: an honest final-state summary followed by the
/// recorded stage/visit captures, with changed-filename filtering and the
@@ -148,7 +149,10 @@ class _ChangesViewerState extends State<ChangesViewer> {
Expanded(
child: run.files.isEmpty
? SingleChildScrollView(
padding: const EdgeInsets.all(16),
padding: withFloatingBarClearance(
context,
const EdgeInsets.all(16),
),
child: Text(noChangeDetail(run)),
)
: ListView(
@@ -171,7 +175,10 @@ class _ChangesViewerState extends State<ChangesViewer> {
Expanded(
child: visit == null
? SingleChildScrollView(
padding: const EdgeInsets.all(16),
padding: withFloatingBarClearance(
context,
const EdgeInsets.all(16),
),
child: Text(noChangeDetail(run)),
)
: SingleChildScrollView(
@@ -180,6 +187,7 @@ class _ChangesViewerState extends State<ChangesViewer> {
key: ValueKey<String>(
'changes-visit-${visit.stage}-${visit.sequence}',
),
padding: withFloatingBarClearance(context, EdgeInsets.zero),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -9,6 +9,7 @@ import 'chat_sessions_body.dart';
import 'session_actions.dart';
import 'session_row_content.dart';
import 'session_row_style.dart';
import '../../../../ui/adaptive/floating_bar_layout.dart';
class CupertinoSessionList extends StatelessWidget {
const CupertinoSessionList({
@@ -47,7 +48,10 @@ class CupertinoSessionList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView(
padding: const EdgeInsets.only(bottom: 24),
padding: withFloatingBarClearance(
context,
const EdgeInsets.only(bottom: 24),
),
children: [
for (final section in sections) ..._section(section),
if (emptyMessage != null)
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../graph/domain/graph_definition.dart';
import '../../graph/widgets/stage_definition_view.dart';
import '../pipeline_models.dart';
@@ -100,11 +101,10 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
final panel = LayoutBuilder(
builder: (context, constraints) {
final headerLimit = _headerLimit(constraints);
// On a phone the tabs are a bottom bar, as in the run detail.
final bottomTabs = constraints.maxWidth < 600;
// The tabs float over the bottom of the tab body, as in the run
// detail: full width on a phone, at the right edge of a wide pane.
final tabs = PipelineDetailTabs(
selected: _tab,
bottom: bottomTabs,
onSelected: (tab) => setState(() => _tab = tab),
);
return Column(
@@ -130,7 +130,6 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
message: _controller.detailError!,
onRetry: _controller.retryDetail,
),
if (!bottomTabs) tabs,
],
),
),
@@ -139,36 +138,40 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
// scroll their own content; the graph fills the slot so its canvas
// is never asked for an unbounded extent inside a scroll view.
Expanded(
child: Stack(
children: [
Positioned.fill(
child: switch (_tab) {
PipelineDetailTab.summary => _scrolling(
PipelineSummaryView(
controller: _controller,
detail: detail,
gateway: widget.gateway,
),
child: FloatingBarOverlay(
bar: tabs,
child: Builder(
builder: (context) => Stack(
children: [
Positioned.fill(
child: switch (_tab) {
PipelineDetailTab.summary => _scrolling(
PipelineSummaryView(
controller: _controller,
detail: detail,
gateway: widget.gateway,
),
),
PipelineDetailTab.graph => PipelineGraphTab(
detail: detail,
selectedStage: _graphSelection,
onSelected: (stageKey) =>
_openGraphStage(context, detail, stageKey),
),
PipelineDetailTab.source => _source(context, detail),
},
),
PipelineDetailTab.graph => PipelineGraphTab(
detail: detail,
selectedStage: _graphSelection,
onSelected: (stageKey) =>
_openGraphStage(context, detail, stageKey),
// Run and Runs float over the content, above the tabs.
PositionedDirectional(
end: 16,
bottom: 16 + MediaQuery.paddingOf(context).bottom,
child: _fabs(context, detail),
),
PipelineDetailTab.source => _source(context, detail),
},
],
),
// Run and Runs float over the content, above the tabs.
PositionedDirectional(
end: 16,
bottom: 16,
child: _fabs(context, detail),
),
],
),
),
),
if (bottomTabs) SafeArea(top: false, child: tabs),
],
);
},
@@ -391,7 +394,7 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
Widget _source(BuildContext context, PipelineDetail detail) {
return ListView(
padding: const EdgeInsets.all(16),
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
children: [
if (detail.source.isEmpty)
Text('No source recorded.', style: pipelineMutedStyle(context))
@@ -1,150 +1,45 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import 'pipeline_controls.dart';
import 'pipeline_detail_tab.dart';
export 'pipeline_detail_tab.dart';
/// Platform tabs: a Material segmented button or a Cupertino segmented control.
/// 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.
///
/// Keep the native control at every width. Horizontal scrolling gives scaled
/// labels their intrinsic width instead of squeezing or replacing the control.
/// Float it over the tab body with `FloatingBarOverlay`. The whole bar is
/// keyed `pipeline-detail-tabs`, each tab `pipeline-detail-tab-<name>`.
class PipelineDetailTabs extends StatelessWidget {
const PipelineDetailTabs({
super.key,
required this.selected,
required this.onSelected,
this.bottom = false,
});
/// The phone layout: a full-width bar under the content, with icons.
final bool bottom;
final PipelineDetailTab selected;
final ValueChanged<PipelineDetailTab> onSelected;
@override
Widget build(BuildContext context) {
final cupertino = useCupertinoControls(context);
if (bottom) {
final divider = cupertino
? CupertinoColors.separator.resolveFrom(context)
: Theme.of(context).colorScheme.outlineVariant;
return DecoratedBox(
decoration: BoxDecoration(
border: Border(top: BorderSide(color: divider, width: 0.5)),
),
child: Padding(
padding: const EdgeInsets.all(8),
child: SizedBox(
width: double.infinity,
child: KeyedSubtree(
key: const Key('pipeline-detail-tabs'),
child: cupertino ? _cupertinoControl() : _materialControl(),
const tabs = PipelineDetailTab.values;
return KeyedSubtree(
key: const Key('pipeline-detail-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
currentIndex: tabs.indexOf(selected),
onTap: (value) => onSelected(tabs[value]),
items: [
for (final tab in tabs)
FloatingDestinationItem(
key: ValueKey('pipeline-detail-tab-${tab.name}'),
icon: Icon(cupertino ? tab.cupertinoIcon : tab.icon),
label: tab.label,
),
),
),
);
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: _ScrollWhenOverflowing(
child: KeyedSubtree(
key: const Key('pipeline-detail-tabs'),
child: cupertino ? _cupertinoControl() : _materialControl(),
),
),
);
}
Widget _materialControl() {
return SegmentedButton<PipelineDetailTab>(
segments: [
for (final tab in PipelineDetailTab.values)
ButtonSegment(value: tab, label: _label(tab)),
],
selected: {selected},
showSelectedIcon: false,
expandedInsets: bottom ? EdgeInsets.zero : null,
onSelectionChanged: (selection) => onSelected(selection.single),
);
}
Widget _cupertinoControl() {
return CupertinoSegmentedControl<PipelineDetailTab>(
// The strip already insets 16; the control's default inset would push
// the tabs out of line with the content.
padding: EdgeInsets.zero,
groupValue: selected,
onValueChanged: onSelected,
children: {
for (final tab in PipelineDetailTab.values)
tab: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: _label(tab),
),
},
);
}
Widget _label(PipelineDetailTab tab) {
// One line, and let the control size the segment to the whole word rather
// than wrapping inside it when scaled text is wider than the pane.
final text = Text(tab.label, maxLines: 1, softWrap: false);
if (!bottom) return text;
return FittedBox(
fit: BoxFit.scaleDown,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Builder(
builder: (context) => Icon(
useCupertinoControls(context) ? tab.cupertinoIcon : tab.icon,
size: 18,
),
),
text,
],
),
);
}
}
/// Gives [child] the full available width as a minimum, then scrolls instead of
/// squeezing it below its content width.
class _ScrollWhenOverflowing extends StatelessWidget {
const _ScrollWhenOverflowing({required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
if (!constraints.hasBoundedWidth) return child;
return ScrollConfiguration(
// Desktop pointer scrolling is vertical only, so allow dragging the
// tab row with a mouse as well as touch and trackpad.
behavior: ScrollConfiguration.of(context).copyWith(
dragDevices: const {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
PointerDeviceKind.stylus,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.trackpad,
},
),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ConstrainedBox(
constraints: BoxConstraints(minWidth: constraints.maxWidth),
child: child,
),
),
);
},
);
}
}
@@ -10,6 +10,7 @@ import 'run_field_body.dart';
import '../../../ui/adaptive/host.dart';
import '../../../ui/layout/sticky_section.dart';
import '../../../ui/text/monospace.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The Summary tab: the run's identity, the recorded facts as key/value rows,
/// the stored original prompt with its copy control and the collapsible Input
@@ -99,6 +100,7 @@ Widget runDetailSummaryTab({
),
),
const SliverToBoxAdapter(child: SizedBox(height: 16)),
const SliverFloatingBarClearance(),
],
);
}
@@ -198,6 +200,7 @@ Widget runDetailFieldTab({
if (cupertino) {
return ListView(
key: Key('run-detail-tab-body-$tabKey'),
// Clear of a floating tab bar (the list pads its media insets itself).
children: [
CupertinoListSection.insetGrouped(
backgroundColor: AppColors.groupedBackground,
@@ -206,10 +209,12 @@ Widget runDetailFieldTab({
],
);
}
return ListView(
key: Key('run-detail-tab-body-$tabKey'),
padding: const EdgeInsets.all(16),
children: [body],
return Builder(
builder: (context) => ListView(
key: Key('run-detail-tab-body-$tabKey'),
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
children: [body],
),
);
}
@@ -1,16 +1,14 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import '../../../ui/adaptive/host.dart';
import 'run_detail_tab.dart';
/// The tabs the strip renders, in the web's order: Summary first so it is the
/// default, then the run Graph and the Timeline. Input and Output are
/// collapsible Summary sections now, so their stable enum keys stay available
/// for old routes but they are not separate tabs.
/// The graph is a preview on Summary that opens full screen, so it has no tab
/// of its own; the run's artifacts and changes do.
/// default, then the Timeline, the run's Artifacts and its Changes. Input and
/// Output are collapsible Summary sections now, so their stable enum keys stay
/// available for old routes but they are not separate tabs. The graph is a
/// preview on Summary that opens full screen, so it has no tab of its own.
const List<RunDetailTab> renderedRunDetailTabs = [
RunDetailTab.summary,
RunDetailTab.timeline,
@@ -18,20 +16,19 @@ const List<RunDetailTab> renderedRunDetailTabs = [
RunDetailTab.changes,
];
/// The run detail's platform tab strip: a Material segmented button or a
/// Cupertino segmented control, in the web's Summary/Graph/Timeline order.
/// The run detail's tabs: the app's floating glass tab bar, full width on a
/// phone and sized to its tabs at the right edge of a wide pane.
///
/// The native control keeps every label at its intrinsic width: a narrow pane
/// or scaled text scrolls the strip horizontally instead of squeezing or
/// wrapping the words. A tab selected by the Graph (not tapped in the strip)
/// is scrolled into view, so the operator can see which section is selected.
class RunDetailTabStrip extends StatefulWidget {
/// Float it over the tab body with `FloatingBarOverlay`; every tab is always
/// visible, so a tab selected by the Graph is shown selected without
/// scrolling. The whole bar is keyed `run-detail-tabs`, each tab
/// `run-detail-tab-<name>`.
class RunDetailTabStrip extends StatelessWidget {
const RunDetailTabStrip({
super.key,
required this.selected,
required this.onSelected,
this.tabs = renderedRunDetailTabs,
this.bottom = false,
});
final RunDetailTab selected;
@@ -40,162 +37,25 @@ class RunDetailTabStrip extends StatefulWidget {
/// The tabs this run offers, in [renderedRunDetailTabs] order.
final List<RunDetailTab> tabs;
/// The phone layout: a full-width bar under the content instead of a compact
/// strip under the header.
final bool bottom;
@override
State<RunDetailTabStrip> createState() => _RunDetailTabStripState();
}
class _RunDetailTabStripState extends State<RunDetailTabStrip> {
final Map<RunDetailTab, GlobalKey> _labels = {
for (final tab in renderedRunDetailTabs) tab: GlobalKey(),
};
@override
void didUpdateWidget(covariant RunDetailTabStrip oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.selected == widget.selected) return;
// The Graph can select Timeline without a strip tap. Wait for the new
// segment to be laid out, then reveal it inside the strip's own scroll.
WidgetsBinding.instance.addPostFrameCallback((_) {
if (!mounted) return;
final context = _labels[widget.selected]?.currentContext;
if (context == null) return;
Scrollable.ensureVisible(
context,
alignment: 0.5,
duration: const Duration(milliseconds: 200),
);
});
}
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
if (widget.bottom) {
final divider = cupertino
? CupertinoColors.separator.resolveFrom(context)
: Theme.of(context).colorScheme.outlineVariant;
return DecoratedBox(
decoration: BoxDecoration(
border: Border(top: BorderSide(color: divider, width: 0.5)),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
child: SizedBox(
width: double.infinity,
child: KeyedSubtree(
key: const Key('run-detail-tabs'),
child: cupertino ? _cupertinoControl() : _materialControl(),
final index = tabs.indexOf(selected);
return KeyedSubtree(
key: const Key('run-detail-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
currentIndex: index < 0 ? 0 : index,
onTap: (value) => onSelected(tabs[value]),
items: [
for (final tab in tabs)
FloatingDestinationItem(
key: ValueKey('run-detail-tab-${tab.name}'),
icon: Icon(cupertino ? tab.cupertinoIcon : tab.icon),
label: tab.label,
),
),
),
);
}
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: ScrollWhenOverflowing(
child: KeyedSubtree(
key: const Key('run-detail-tabs'),
child: cupertino ? _cupertinoControl() : _materialControl(),
),
],
),
);
}
Widget _materialControl() => SegmentedButton<RunDetailTab>(
segments: [
for (final tab in widget.tabs)
ButtonSegment(value: tab, label: _label(tab)),
],
selected: {widget.selected},
showSelectedIcon: false,
// The bottom bar spans the width; the header strip keeps its content size.
expandedInsets: widget.bottom ? EdgeInsets.zero : null,
onSelectionChanged: (selection) => widget.onSelected(selection.single),
);
Widget _cupertinoControl() => CupertinoSegmentedControl<RunDetailTab>(
// The strip already insets 16; the control's own default inset would put
// the tabs out of line with the header and body text.
padding: EdgeInsets.zero,
groupValue: widget.selected,
onValueChanged: widget.onSelected,
children: {
for (final tab in widget.tabs)
tab: Padding(
padding: const EdgeInsets.symmetric(horizontal: 8),
child: _label(tab),
),
},
);
Widget _label(RunDetailTab tab) => KeyedSubtree(
key: _labels[tab],
child: KeyedSubtree(
key: ValueKey('run-detail-tab-${tab.name}'),
// A full-width bar shrinks a long label rather than overflowing it,
// and shows the tab's glyph above its name.
child: widget.bottom
? FittedBox(
fit: BoxFit.scaleDown,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
usesCupertinoHost(context) ? tab.cupertinoIcon : tab.icon,
size: 18,
),
Text(tab.label, maxLines: 1, softWrap: false),
],
),
)
: Text(tab.label, maxLines: 1, softWrap: false),
),
);
}
/// Gives [child] at least the pane width, then scrolls instead of squeezing it
/// below its content width.
///
/// The run detail's tab strips both use this, so the pointer-drag rule and the
/// minimum-width rule live in one place.
class ScrollWhenOverflowing extends StatelessWidget {
const ScrollWhenOverflowing({super.key, required this.child});
final Widget child;
@override
Widget build(BuildContext context) {
return LayoutBuilder(
builder: (context, constraints) {
if (!constraints.hasBoundedWidth) return child;
return ScrollConfiguration(
// Desktop pointer scrolling is vertical only, so a mouse can drag
// the tab row as well as touch and trackpad.
behavior: ScrollConfiguration.of(context).copyWith(
dragDevices: const {
PointerDeviceKind.touch,
PointerDeviceKind.mouse,
PointerDeviceKind.stylus,
PointerDeviceKind.invertedStylus,
PointerDeviceKind.trackpad,
},
),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: ConstrainedBox(
// Content width, not the pane width: the web's tabs are compact
// and left-aligned, not a full-width segmented bar. The scroll
// view still reveals every segment on a narrow pane.
constraints: const BoxConstraints(),
child: child,
),
),
);
},
);
}
}
+14 -20
View File
@@ -1,3 +1,4 @@
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/segmented_bar.dart';
import 'dart:math' as math;
@@ -28,11 +29,8 @@ import 'run_search_selection.dart';
/// reserve keeps its bounded canvas positive at 320px with 2x text.
const double kRunDetailMinContentHeight = 240;
/// Below this width (a phone) the run detail's tabs sit at the bottom.
const double kRunDetailBottomTabsWidth = 600;
/// The run detail's tabbed body: the host-built header and platform tab strip
/// above the bounded selected tab.
/// 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 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
@@ -369,14 +367,6 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
return LayoutBuilder(
builder: (context, constraints) {
final headerLimit = _headerLimit(constraints);
// On a phone the tabs are a bottom bar, under the content they switch.
final bottomTabs = constraints.maxWidth < kRunDetailBottomTabsWidth;
final strip = RunDetailTabStrip(
tabs: tabs,
selected: shown,
bottom: bottomTabs,
onSelected: (tab) => setState(() => _tab = tab),
);
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
@@ -384,20 +374,24 @@ class _RunDetailTabsState extends State<RunDetailTabs> {
constraints: BoxConstraints(maxHeight: headerLimit),
child: SingleChildScrollView(
key: ValueKey('run-detail-header-${widget.run['id']}'),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [widget.header, if (!bottomTabs) strip],
),
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.
// never asked for an unbounded extent. The tabs float over the
// bottom of it, and the tab learns their height as bottom padding.
Expanded(
key: ValueKey('run-detail-body-${widget.run['id']}'),
child: _body(shown),
child: FloatingBarOverlay(
bar: RunDetailTabStrip(
tabs: tabs,
selected: shown,
onSelected: (tab) => setState(() => _tab = tab),
),
child: _body(shown),
),
),
if (bottomTabs) SafeArea(top: false, child: strip),
],
);
},
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import '../../../ui/status/run_status_icon.dart';
import '../domain/run_models.dart';
import 'run_detail_content.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The Timeline tab's recorded visits, one native row per visit.
///
@@ -33,7 +34,7 @@ class RunTimelineList extends StatelessWidget {
if (visits.isEmpty) {
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: const EdgeInsets.all(16),
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
children: const [Text('No visits recorded.')],
);
}
@@ -63,7 +64,10 @@ class RunTimelineList extends StatelessWidget {
}
return ListView(
key: const Key('run-detail-tab-body-timeline'),
padding: const EdgeInsets.symmetric(vertical: 8),
padding: withFloatingBarClearance(
context,
const EdgeInsets.symmetric(vertical: 8),
),
children: rows,
);
}
+20 -19
View File
@@ -4,6 +4,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
import '../../../ui/adaptive/host.dart';
import 'run_detail_content.dart';
import 'run_detail_visit_facts.dart';
@@ -105,26 +106,26 @@ class _RunVisitPaneState extends State<RunVisitPane> {
),
),
),
// The sections are floating tabs over the bottom of what they
// show; the section learns their height as bottom padding.
Expanded(
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,
),
),
// The sections are tabs at the bottom, under what they show.
SafeArea(
top: false,
child: RunVisitSectionStrip(
selected: _section,
onSelected: (section) => setState(() => _section = section),
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,
),
),
),
],
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import '../../../core/api_gateway.dart';
import '../../../ui/adaptive/floating_destination_bar.dart';
import '../../../ui/adaptive/host.dart';
import '../../changes/changes.dart';
import 'run_detail_tab_bodies.dart';
@@ -12,6 +13,7 @@ import 'run_detail_visit_artifacts.dart';
import 'run_detail_visit_definition.dart';
import 'run_detail_visit_facts.dart';
import 'run_detail_visit_session.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The visit pane's recorded sections, in the Android audit order the web
/// client follows: the turn's Input and Output, its Artifacts, the files this
@@ -43,9 +45,10 @@ enum RunVisitSection {
final IconData cupertinoIcon;
}
/// The visit pane's native tab strip: a Material segmented button or a Cupertino
/// segmented control. It scrolls instead of squeezing the labels when a narrow
/// pane or scaled text cannot fit them.
/// The stage page'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. Float it over
/// the section with `FloatingBarOverlay`. The whole bar is keyed
/// `run-visit-tabs`, each tab `run-visit-tab-<name>`.
class RunVisitSectionStrip extends StatelessWidget {
const RunVisitSectionStrip({
super.key,
@@ -59,72 +62,24 @@ class RunVisitSectionStrip extends StatelessWidget {
@override
Widget build(BuildContext context) {
final cupertino = usesCupertinoHost(context);
// A full-width bar under the section, as the run's own tabs on a phone.
final divider = cupertino
? CupertinoColors.separator.resolveFrom(context)
: Theme.of(context).colorScheme.outlineVariant;
return DecoratedBox(
decoration: BoxDecoration(
border: Border(top: BorderSide(color: divider, width: 0.5)),
),
child: Padding(
padding: const EdgeInsets.fromLTRB(8, 8, 8, 8),
child: SizedBox(
width: double.infinity,
child: KeyedSubtree(
key: const Key('run-visit-tabs'),
child: cupertino ? _cupertinoControl() : _materialControl(),
),
),
final index = shownVisitSections.indexOf(visitTabFor(selected));
return KeyedSubtree(
key: const Key('run-visit-tabs'),
child: FloatingDestinationBar(
cupertino: cupertino,
currentIndex: index < 0 ? 0 : index,
onTap: (value) => onSelected(shownVisitSections[value]),
items: [
for (final section in shownVisitSections)
FloatingDestinationItem(
key: ValueKey('run-visit-tab-${section.name}'),
icon: Icon(cupertino ? section.cupertinoIcon : section.icon),
label: section.label,
),
],
),
);
}
Widget _materialControl() => SegmentedButton<RunVisitSection>(
segments: [
for (final section in shownVisitSections)
ButtonSegment(value: section, label: _label(section)),
],
selected: {selected},
showSelectedIcon: false,
expandedInsets: EdgeInsets.zero,
onSelectionChanged: (selection) => onSelected(selection.single),
);
Widget _cupertinoControl() => CupertinoSegmentedControl<RunVisitSection>(
// The strip already insets 16; the control's default inset would push
// the tabs out of line with the content.
padding: EdgeInsets.zero,
groupValue: selected,
onValueChanged: onSelected,
children: {
for (final section in shownVisitSections)
section: Padding(
padding: const EdgeInsets.symmetric(horizontal: 2),
child: _label(section),
),
},
);
Widget _label(RunVisitSection section) => KeyedSubtree(
key: ValueKey('run-visit-tab-${section.name}'),
// Six sections share the width; a long label shrinks rather than clips.
child: FittedBox(
fit: BoxFit.scaleDown,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Builder(
builder: (context) => Icon(
usesCupertinoHost(context) ? section.cupertinoIcon : section.icon,
size: 18,
),
),
Text(section.label, maxLines: 1, softWrap: false),
],
),
),
);
}
/// The stage page's tabs: Summary (Input and Output), Artifacts, Changes and
@@ -298,6 +253,7 @@ class _VisitSummaryState extends State<_VisitSummary> {
slivers: [
_section('Input', widget.input, visitEmptyInput),
_section('Output', widget.output, visitEmptyOutput),
const SliverFloatingBarClearance(),
],
);
}
@@ -11,6 +11,7 @@ import '../actions/session_export_repair_action.dart';
import 'run_detail_visit_recorded.dart';
import 'run_detail_visit_documents.dart';
import 'run_detail_visit_session_state.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The visit's recorded session pointer, its recorded export state and, when
/// the visit exported one, a read-only external open of that document.
@@ -133,7 +134,7 @@ class _RunVisitSessionState extends State<RunVisitSession> {
}
return ListView(
key: const Key('run-visit-body-session'),
padding: const EdgeInsets.all(16),
padding: withFloatingBarClearance(context, const EdgeInsets.all(16)),
children: _spaced(children),
);
}
@@ -119,7 +119,9 @@ class _SearchScreenState extends State<SearchScreen> {
}
Widget _materialScreen() {
// Results scroll behind a floating tab bar; the list clears it itself.
final body = SafeArea(
bottom: false,
child: SearchArtifactScope(
gateway: widget.gateway,
onOpen: widget.onOpen,
@@ -192,6 +194,7 @@ class _SearchScreenState extends State<SearchScreen> {
Widget _cupertinoScreen() {
final body = SafeArea(
bottom: false,
child: SearchArtifactScope(
gateway: widget.gateway,
onOpen: widget.onOpen,
@@ -5,6 +5,7 @@ import '../../../core/api_gateway.dart';
import '../domain/search_controller.dart';
import '../domain/search_row.dart';
import 'search_result_view.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The Cupertino search view: native search/kind controls and grouped list rows
/// in one scroll view, with standard activity and retry controls.
@@ -35,6 +36,7 @@ class CupertinoSearchBody extends StatelessWidget {
),
),
..._content(context),
const SliverFloatingBarClearance(),
],
);
}
@@ -4,6 +4,7 @@ import '../../../core/api_gateway.dart';
import '../domain/search_controller.dart';
import '../domain/search_row.dart';
import 'search_result_view.dart';
import '../../../ui/adaptive/floating_bar_layout.dart';
/// The Material search view: the controls header and a flat native result list
/// in one scroll view, so text scaling can never clip the controls or a row.
@@ -29,6 +30,7 @@ class MaterialSearchBody extends StatelessWidget {
if (controller.showProgress)
const SliverToBoxAdapter(child: LinearProgressIndicator()),
..._content(context),
const SliverFloatingBarClearance(),
],
);
}
+12 -5
View File
@@ -24,6 +24,7 @@ import 'settings_templates_section.dart';
import 'server_connections.dart';
import 'saved_servers_section.dart';
import 'managed_connection_section.dart';
import '../../ui/adaptive/floating_bar_layout.dart';
/// The Settings destination: the server connection and the server-side
/// workspace, in native Material (native platforms) or Cupertino (iOS) controls.
@@ -134,15 +135,21 @@ class _SettingsScreenState extends State<SettingsScreen> {
@override
Widget build(BuildContext context) {
// The content scrolls behind a floating tab bar and pads its end clear of
// it (or of the system inset on its own page).
final content = SafeArea(
bottom: false,
child: SingleChildScrollView(
// Web `.settings` page insets: 20 above the title, 16 at the sides and
// a clear 32 below the last section.
padding: const EdgeInsetsDirectional.fromSTEB(
settingsPageSidePadding,
settingsPageTopPadding,
settingsPageSidePadding,
settingsPageBottomPadding,
padding: withFloatingBarClearance(
context,
const EdgeInsetsDirectional.fromSTEB(
settingsPageSidePadding,
settingsPageTopPadding,
settingsPageSidePadding,
settingsPageBottomPadding,
),
),
child: Center(
child: ConstrainedBox(
+44 -144
View File
@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/adaptive/segmented_bar.dart';
import '../ui/adaptive/floating_bar_layout.dart';
import '../ui/adaptive/floating_destination_bar.dart';
import 'attention_badge.dart';
import 'destination.dart';
@@ -43,8 +44,7 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
late AppDestination _selected;
final Set<AppDestination> _visited = {};
final ShellBarRegistry _bar = ShellBarRegistry();
// The Cupertino sidebar and tab layouts have different parents. Preserve
// destination selection/state while the same content moves between them.
// Keeps every destination's state if the stack's parent ever changes.
final GlobalKey _destinationStackKey = GlobalKey();
@override
@@ -82,9 +82,6 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
});
}
List<T> _items<T>(T Function(AppDestination) build) =>
AppDestination.values.map(build).toList();
/// The destination's icon; only Runs carries the attention count.
Widget _icon(AppDestination destination, IconData data) {
Widget icon = Icon(data);
@@ -137,97 +134,58 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
}).toList();
return ListenableBuilder(
listenable: _bar,
builder: (context, _) => LayoutBuilder(
builder: (context, constraints) {
final wide = constraints.maxWidth >= 600;
if (widget.cupertino) {
final spec = _bar.specFor(_selected);
return CupertinoPageScaffold(
navigationBar: _segmentedBar(spec, details.label),
child: SafeArea(
child: wide
// The web keeps a destination rail on a wide window. A native
// Cupertino sidebar list is the same idea with the host's own
// controls; the tab bar stays the narrow-window navigation.
? Row(
children: [
_CupertinoSidebar(
selected: _selected,
onSelected: _select,
attentionCount: widget.attentionCount,
),
Expanded(child: _destinationStack(contents, index)),
],
)
: Column(
children: [
Expanded(child: _destinationStack(contents, index)),
// Keep the host's native tab semantics while giving
// the selector the same floating glass treatment as
// the top bar.
MediaQuery.withNoTextScaling(
child: FloatingDestinationBar(
cupertino: true,
currentIndex: index,
onTap: (value) =>
_select(AppDestination.values[value]),
items: _destinationItems(cupertino: true),
),
),
],
),
),
);
}
final spec = _bar.specFor(_selected);
return Scaffold(
extendBodyBehindAppBar: true,
appBar: _segmentedBar(spec, details.label),
// Destinations start below the floating bar.
body: SafeArea(
left: false,
right: false,
builder: (context, _) {
final spec = _bar.specFor(_selected);
// One floating glass tab bar at every width: full width on a phone,
// sized to its tabs at the right edge on a wide window (the bar judges
// that itself, live). Content keeps the whole width and scrolls behind
// it, learning the bar's height as its bottom media padding. Neither
// scaffold's structure depends on the width, so resizing never
// remounts a destination.
final bar = FloatingDestinationBar(
cupertino: widget.cupertino,
currentIndex: index,
onTap: (value) => _select(AppDestination.values[value]),
items: _destinationItems(),
);
if (widget.cupertino) {
return CupertinoPageScaffold(
navigationBar: _segmentedBar(spec, details.label),
child: SafeArea(
bottom: false,
child: Row(
children: [
if (wide)
NavigationRail(
selectedIndex: index,
onDestinationSelected: (value) =>
_select(AppDestination.values[value]),
labelType: NavigationRailLabelType.all,
destinations: _items((destination) {
final item = destinationDetails(destination);
return NavigationRailDestination(
icon: _icon(destination, item.icon),
label: Text(item.label),
);
}),
),
Expanded(child: _destinationStack(contents, index)),
],
child: FloatingBarOverlay(
bar: bar,
child: _destinationStack(contents, index),
),
),
extendBody: true,
bottomNavigationBar: wide
? null
: FloatingDestinationBar(
cupertino: false,
currentIndex: index,
onTap: (value) => _select(AppDestination.values[value]),
items: _destinationItems(),
),
);
},
),
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: _segmentedBar(spec, details.label),
// Destinations start below the floating top bar.
body: SafeArea(
left: false,
right: false,
bottom: false,
child: _destinationStack(contents, index),
),
extendBody: true,
bottomNavigationBar: bar,
);
},
);
}
List<FloatingDestinationItem> _destinationItems({bool cupertino = false}) =>
List<FloatingDestinationItem> _destinationItems() =>
AppDestination.values.map((destination) {
final item = destinationDetails(destination);
return FloatingDestinationItem(
icon: _icon(destination, cupertino ? item.cupertinoIcon : item.icon),
key: ValueKey('shell.destination.${destination.name}'),
icon: _icon(
destination,
widget.cupertino ? item.cupertinoIcon : item.icon,
),
label: item.label,
);
}).toList();
@@ -286,61 +244,3 @@ class _AdaptiveShellState extends State<AdaptiveShell> {
Widget _destinationStack(List<Widget> contents, int index) =>
IndexedStack(key: _destinationStackKey, index: index, children: contents);
}
/// The wide-window Cupertino destination list: the web's 200px rail with the
/// host's own grouped list controls.
class _CupertinoSidebar extends StatelessWidget {
const _CupertinoSidebar({
required this.selected,
required this.onSelected,
this.attentionCount = 0,
});
final AppDestination selected;
final ValueChanged<AppDestination> onSelected;
final int attentionCount;
@override
Widget build(BuildContext context) {
final theme = CupertinoTheme.of(context);
return Container(
width: 200,
decoration: BoxDecoration(
color: CupertinoColors.secondarySystemGroupedBackground.resolveFrom(
context,
),
border: Border(
right: BorderSide(
color: CupertinoColors.separator.resolveFrom(context),
),
),
),
child: ListView(
padding: const EdgeInsets.symmetric(vertical: 8),
children: [
for (final destination in AppDestination.values)
CupertinoListTile(
key: ValueKey('shell.destination.${destination.name}'),
leading: destination == AppDestination.runs
? AttentionDestinationIcon(
count: attentionCount,
cupertino: true,
child: Icon(
destinationDetails(destination).cupertinoIcon,
),
)
: Icon(destinationDetails(destination).cupertinoIcon),
title: Text(destinationDetails(destination).label),
trailing: destination == selected
? Icon(
CupertinoIcons.checkmark_alt,
color: theme.primaryColor,
)
: null,
onTap: () => onSelected(destination),
),
],
),
);
}
}
+5 -2
View File
@@ -143,16 +143,19 @@ class _DetailPaneState extends State<DetailPane> {
title: title,
actions: actions,
);
// The bottom inset (the system's, or a floating tab bar's when the
// pane sits beside a list) passes through: the open item's content
// floats its own tabs above it and pads its lists clear of it.
if (cupertino) {
return CupertinoPageScaffold(
navigationBar: bar,
child: SafeArea(child: body),
child: SafeArea(bottom: false, child: body),
);
}
return Scaffold(
extendBodyBehindAppBar: true,
appBar: bar,
body: SafeArea(child: body),
body: SafeArea(bottom: false, child: body),
);
},
);
@@ -0,0 +1,133 @@
import 'package:flutter/widgets.dart';
/// At least this wide, a floating tab bar is sized to its tabs and sits at the
/// trailing edge; narrower, it spans the width minus [kFloatingBarMargin].
const double kFloatingBarWideWidth = 600;
/// The gap between a floating tab bar and the edges (and bottom safe area).
const double kFloatingBarMargin = 16;
/// [padding] with the floating bar's clearance added at the bottom.
///
/// A scrollable under a floating bar (see [FloatingBarOverlay] and the shell)
/// reads the bar's height as [MediaQuery.paddingOf] bottom; adding it to the
/// list's own padding lets the content scroll behind the bar yet still bring
/// its last item clear of it at rest. Lists without explicit padding already
/// do this themselves.
EdgeInsetsGeometry withFloatingBarClearance(
BuildContext context,
EdgeInsetsGeometry padding,
) => padding.add(EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom));
/// Empty space as tall as the floating bar's clearance
/// ([MediaQuery.paddingOf] bottom), ending a scrolling column so its last item
/// comes clear of the bar at rest.
class FloatingBarClearance extends StatelessWidget {
const FloatingBarClearance({super.key});
@override
Widget build(BuildContext context) =>
SizedBox(height: MediaQuery.paddingOf(context).bottom);
}
/// [FloatingBarClearance] as the last sliver of a [CustomScrollView].
class SliverFloatingBarClearance extends StatelessWidget {
const SliverFloatingBarClearance({super.key});
@override
Widget build(BuildContext context) =>
const SliverToBoxAdapter(child: FloatingBarClearance());
}
/// Floats [bar] over the bottom of [child], the way a scaffold with
/// `extendBody` floats its bottom bar, for a bar that is not a scaffold's.
///
/// [child] fills the whole area and scrolls behind the bar; it learns the
/// bar's measured height (bottom safe area and margins included) as its
/// [MediaQuery.paddingOf] bottom, so a list can pad its last item clear of the
/// bar at rest (see [withFloatingBarClearance]). Taps the bar does not take,
/// such as beside a bar narrower than the area, reach [child].
class FloatingBarOverlay extends StatelessWidget {
const FloatingBarOverlay({super.key, required this.bar, required this.child});
final Widget bar;
final Widget child;
@override
Widget build(BuildContext context) => CustomMultiChildLayout(
delegate: _OverlayLayout(),
children: [
// Painted first, so the bar draws (and takes taps) above it.
LayoutId(
id: _Slot.content,
child: LayoutBuilder(
builder: (context, constraints) {
final barHeight = constraints is _ContentConstraints
? constraints.barHeight
: 0.0;
final media = MediaQuery.of(context);
return MediaQuery(
data: media.copyWith(
padding: media.padding.copyWith(
bottom: barHeight > media.padding.bottom
? barHeight
: media.padding.bottom,
),
),
child: child,
);
},
),
),
LayoutId(id: _Slot.bar, child: bar),
],
);
}
enum _Slot { content, bar }
/// The content's tight constraints, carrying the bar's height so the content
/// rebuilds its inset when the bar grows or shrinks.
class _ContentConstraints extends BoxConstraints {
_ContentConstraints(Size size, {required this.barHeight})
: super(
minWidth: size.width,
maxWidth: size.width,
minHeight: size.height,
maxHeight: size.height,
);
final double barHeight;
@override
bool operator ==(Object other) =>
other is _ContentConstraints &&
super == other &&
other.barHeight == barHeight;
@override
int get hashCode => Object.hash(super.hashCode, barHeight);
}
class _OverlayLayout extends MultiChildLayoutDelegate {
@override
void performLayout(Size size) {
final bar = layoutChild(
_Slot.bar,
BoxConstraints(
minWidth: size.width,
maxWidth: size.width,
maxHeight: size.height,
),
);
positionChild(_Slot.bar, Offset(0, size.height - bar.height));
layoutChild(
_Slot.content,
_ContentConstraints(size, barHeight: bar.height),
);
positionChild(_Slot.content, Offset.zero);
}
@override
bool shouldRelayout(_OverlayLayout oldDelegate) => false;
}
+152 -25
View File
@@ -1,12 +1,26 @@
import 'dart:math' as math;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'floating_bar_layout.dart';
import 'glass_pill.dart';
/// A compact destination switcher which floats above the bottom edge instead
/// of becoming a full-width system bar. The controls inside remain the
/// platform navigation controls, so their labels, semantics and selection
/// behaviour are not recreated by the glass treatment.
/// A tab bar which floats above the bottom edge in a frosted [GlassPill]
/// instead of becoming a full-width system bar. Used for the app's
/// destinations and for every page's own tabs.
///
/// Placement follows the width the bar is given, live: below
/// [kFloatingBarWideWidth] the pill spans it minus [kFloatingBarMargin] on
/// each side; at or above it the pill is only as wide as its tabs and sits at
/// the trailing (right, in left-to-right text) edge, near the thumb. Either
/// way it keeps [kFloatingBarMargin] above the bottom safe area. Only the pill
/// takes taps: the space beside it reaches the content behind.
///
/// The controls inside remain the platform navigation controls (Material
/// [NavigationBar], Cupertino [CupertinoTabBar]), so tab semantics (selected
/// state, "tab n of m") come from the host. The Cupertino path builds no
/// Material widget.
class FloatingDestinationBar extends StatelessWidget {
const FloatingDestinationBar({
super.key,
@@ -21,23 +35,90 @@ class FloatingDestinationBar extends StatelessWidget {
final ValueChanged<int> onTap;
final List<FloatingDestinationItem> items;
/// Height of the Material bar inside the pill (the stock bar is 80).
static const double materialHeight = 64;
/// Height of the Cupertino bar inside the pill (the stock bar is 50).
static const double cupertinoHeight = 54;
@override
Widget build(BuildContext context) {
final width = MediaQuery.sizeOf(context).width;
final bar = cupertino ? _cupertinoBar() : _materialBar(context);
return SafeArea(
top: false,
minimum: const EdgeInsets.fromLTRB(16, 0, 16, 8),
child: Align(
alignment: Alignment.bottomCenter,
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: width - 32),
child: GlassPill(cupertino: cupertino, child: bar),
),
minimum: const EdgeInsets.fromLTRB(
kFloatingBarMargin,
0,
kFloatingBarMargin,
kFloatingBarMargin,
),
child: LayoutBuilder(
builder: (context, constraints) {
// Wide is judged on the space the bar is given, margins included,
// the way the shell and the pages judge their own layouts.
final available = constraints.maxWidth;
final wide =
available + 2 * kFloatingBarMargin >= kFloatingBarWideWidth;
final width = wide
? math.min(available, _tabsWidth(context))
: available;
return Align(
// As tall as the pill, so a scaffold or overlay measures the bar
// and not the whole area it may grow into.
heightFactor: 1,
alignment: wide
? AlignmentDirectional.bottomEnd
: Alignment.bottomCenter,
child: SizedBox(
width: math.max(0, width),
child: GlassPill(
cupertino: cupertino,
child: cupertino
? _cupertinoBar(context)
: _materialBar(context),
),
),
);
},
),
);
}
/// The width the tabs need side by side: every tab as wide as the widest
/// label (as the host lays them out), never narrower than a comfortable
/// touch target.
double _tabsWidth(BuildContext context) {
final TextStyle? style;
final TextScaler scaler;
final double minimum;
if (cupertino) {
style = CupertinoTheme.of(context).textTheme.tabLabelTextStyle;
scaler = TextScaler.noScaling;
minimum = 76;
} else {
final theme = Theme.of(context);
style =
theme.navigationBarTheme.labelTextStyle?.resolve(const {
WidgetState.selected,
}) ??
theme.textTheme.labelMedium;
// NavigationBar clamps its labels at 1.3x.
scaler = MediaQuery.textScalerOf(context).clamp(maxScaleFactor: 1.3);
minimum = 88;
}
var widest = 0.0;
for (final item in items) {
final painter = TextPainter(
text: TextSpan(text: item.label, style: style),
textScaler: scaler,
textDirection: Directionality.of(context),
maxLines: 1,
)..layout();
widest = math.max(widest, painter.width);
painter.dispose();
}
return math.max(minimum, widest + 24) * items.length;
}
Widget _materialBar(BuildContext context) {
final scheme = Theme.of(context).colorScheme;
return NavigationBarTheme(
@@ -46,6 +127,8 @@ class FloatingDestinationBar extends StatelessWidget {
elevation: 0,
surfaceTintColor: Colors.transparent,
indicatorColor: scheme.secondaryContainer,
height: materialHeight,
labelBehavior: NavigationDestinationLabelBehavior.alwaysShow,
),
child: NavigationBar(
selectedIndex: currentIndex,
@@ -53,6 +136,7 @@ class FloatingDestinationBar extends StatelessWidget {
destinations: [
for (final item in items)
NavigationDestination(
key: item.key,
icon: item.icon,
selectedIcon: item.selectedIcon ?? item.icon,
label: item.label,
@@ -62,19 +146,58 @@ class FloatingDestinationBar extends StatelessWidget {
);
}
Widget _cupertinoBar() => CupertinoTabBar(
backgroundColor: CupertinoColors.transparent,
currentIndex: currentIndex,
onTap: onTap,
items: [
for (final item in items)
BottomNavigationBarItem(
icon: item.icon,
activeIcon: item.selectedIcon ?? item.icon,
label: item.label,
/// The stock Cupertino bar, transparent inside the pill. Each tab's label is
/// drawn with its icon (in the bar's own label style and colours) so the
/// item's key covers the whole tab, and the selected tab's icon sits in a
/// tinted capsule so the selection reads at a glance, not by colour alone.
Widget _cupertinoBar(BuildContext context) {
final active = CupertinoTheme.of(context).primaryColor;
Widget tab(FloatingDestinationItem item, {required bool selected}) {
Widget icon = item.icon;
if (selected) {
icon = DecoratedBox(
decoration: ShapeDecoration(
color: active.withValues(alpha: 0.16),
shape: const StadiumBorder(),
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 2),
child: item.selectedIcon ?? item.icon,
),
);
}
return KeyedSubtree(
key: item.key,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
icon,
const SizedBox(height: 2),
Text(item.label, maxLines: 1, softWrap: false),
],
),
],
);
);
}
// The tab bar does not scale its text on iOS either; its height is fixed.
return MediaQuery.withNoTextScaling(
child: CupertinoTabBar(
backgroundColor: CupertinoColors.transparent,
border: null,
iconSize: 24,
height: cupertinoHeight,
currentIndex: currentIndex,
onTap: onTap,
items: [
for (var index = 0; index < items.length; index += 1)
BottomNavigationBarItem(
icon: tab(items[index], selected: false),
activeIcon: tab(items[index], selected: true),
),
],
),
);
}
}
/// The platform-neutral data needed by [FloatingDestinationBar].
@@ -83,9 +206,13 @@ class FloatingDestinationItem {
required this.icon,
required this.label,
this.selectedIcon,
this.key,
});
final Widget icon;
final String label;
final Widget? selectedIcon;
/// Identifies the whole tab (icon and label), for tests and automation.
final Key? key;
}
+130
View File
@@ -0,0 +1,130 @@
# Floating glass tab bars
Every bottom tab bar in the app is now one ChatGPT-style floating glass bar:
the shell's destinations, the run detail's tabs, the stage (visit) page's tabs
and the pipeline detail's tabs. The NavigationRail (Material) and the 200px
Cupertino sidebar are gone.
## Shared pieces (`lib/ui/adaptive/`)
- `floating_destination_bar.dart` — `FloatingDestinationBar({cupertino,
currentIndex, onTap, items})`, `FloatingDestinationItem({icon, label,
selectedIcon, key})`. The host's own `NavigationBar` (Material, 64 high,
labels always shown, `secondaryContainer` indicator) or `CupertinoTabBar`
(54 high, no text scaling, transparent, no border; the selected icon sits in
a tinted capsule so selection does not rely on colour alone) inside the
shared `GlassPill`. Tab semantics (selected, "tab n of m") come from the
host control. The item key covers the whole tab (icon and label) on both
hosts. The Cupertino path builds no Material widget.
- Placement follows the width the bar is given, live (its own
`LayoutBuilder`): below `kFloatingBarWideWidth` (600) the pill spans the
width minus `kFloatingBarMargin` (16) per side; at or above it the pill is
sized to its tabs (every tab as wide as the widest label + 24, at least
88 Material / 76 Cupertino) and aligned to the trailing (right) edge.
Either way it floats 16 above the bottom safe area (`SafeArea.minimum`).
- `Align(heightFactor: 1)`, so a scaffold/overlay measures the pill, not
the whole area; space beside a narrow pill does not take taps.
- `floating_bar_layout.dart`
- `FloatingBarOverlay(bar:, child:)` — floats a bar over the bottom of
content outside a scaffold (the bottom twin of `SegmentedBarOverlay`); the
content fills the area and gets the bar's measured height as
`MediaQuery.paddingOf(context).bottom`.
- `withFloatingBarClearance(context, padding)`, `FloatingBarClearance`,
`SliverFloatingBarClearance` — add that bottom padding to a list's own
padding / end a column or `CustomScrollView`, so the last item clears the
bar at rest. Lists without explicit padding (`ListView` default) already
consume media padding.
## Where
- Shell (`shell/adaptive_shell.dart`): Material keeps `Scaffold(extendBody:
true, bottomNavigationBar: bar)` at every width; Cupertino uses
`FloatingBarOverlay` inside `SafeArea(bottom: false)`. Neither structure
depends on width, so resizing never remounts a destination (the destination
`IndexedStack` keeps its GlobalKey). Destination keys
`shell.destination.<name>` now live on the floating bar items (both hosts).
Badges (attention, running, unread) unchanged.
- Run detail (`features/runs/ui/run_detail_tab_strip.dart`,
`run_detail_tabs.dart`): the header no longer carries the strip; the tab
body is a `FloatingBarOverlay` with the tabs at every width. Keys
`run-detail-tabs`, `run-detail-tab-<name>` kept.
`kRunDetailBottomTabsWidth`, the `bottom` flag and the strip's
scroll-into-view are gone (all tabs are always visible).
- Stage page (`run_detail_visit_sections.dart`, `run_detail_visit.dart`): the
same; keys `run-visit-tabs`, `run-visit-tab-<name>` kept. The selected tab
is `visitTabFor(section)`, so Input/Output highlight Summary.
- Pipeline detail (`features/pipelines/widgets/pipeline_tabs.dart`,
`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
16 above the bar (`bottom: 16 + MediaQuery.paddingOf(context).bottom`).
- `DetailPane` (`shell/detail_page.dart`) no longer consumes the bottom inset;
its content (run detail, pipeline detail, chat thread with its own
`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
at the right edge) and content scrolls behind both.
- Not converted (judged not bottom tabs): the segmented filters/toggles at the
top of lists and viewers (`SegmentedButton` / `CupertinoSlidingSegmentedControl`
in markdown source view, artifact gallery mode, diff form, pipeline scope,
schedules filter). They switch a view's mode in place, not pages.
## Content clearance
Scrollables under a floating bar that use explicit padding (or slivers) now
add the clearance: run Summary (`run_detail_tab_bodies.dart`), field tabs,
Timeline, artifacts gallery (`artifact_visit_list.dart`), Changes
(`changes_viewer.dart`), visit Summary and Session, pipeline Source, Settings
(now `SafeArea(bottom: false)`), Search (both bodies,
`SafeArea(bottom: false)`), Cupertino chat sessions list. Runs, Pipelines and
Material chat lists use default `ListView` padding.
## widget_test failure on main
`Material shell adapts at width 390.0 and supports large text` failed with
`BoxConstraints(0.0<=w<=-32.0) NOT NORMALIZED`. The test wraps the shell in
`MediaQuery(data: MediaQueryData(textScaler: 2x))`, whose default size is
`Size.zero`; `FloatingDestinationBar` sized itself from
`MediaQuery.sizeOf(context).width - 32` (the screen) instead of the space it
was laid out in. The bar now measures its own constraints (`LayoutBuilder`),
which is also what lets it follow a pane's width rather than the window's. The
test keeps its intent (2x text, both widths, tab switching) and now also
asserts no rail and no exception.
## Tests
New: `test/shell/floating_tab_bar_test.dart` (phone full width; wide
right-aligned, under 60% of 1200, content full width, tap beside the bar
reaches content; content bottom padding equals the bar's height + margin;
resizing moves the bar without remounting content; bottom safe area; selected
semantics; no Material widget in the Cupertino bar; 320px at 2x),
`test/ui/adaptive/floating_bar_layout_test.dart` (last list item clears the
bar at rest at 390 and 1200; taps beside the wide bar reach content).
Updated: `widget_test.dart`, `shell/attention_badge_test.dart`,
`application/list_detail_consistency_test.dart` (taps destination keys),
`application/chat_registration_test.dart`,
`features/chat/chat_list_detail_test.dart`,
`features/pipelines/pipeline_tabs_test.dart` (floating placement at
320/390/720/1200 at 2x), `features/pipelines/pipelines_adaptive_test.dart`,
`features/runs/ui/run_detail_tabs_test.dart` (floating full width / right
aligned, content behind the bar with clearance),
`features/runs/ui/run_detail_visit_sections_test.dart` (placement at
390/884/1000), `features/runs/ui/run_decision_wiring_test.dart` (banner spans
the header inset instead of the old strip). Test-font widths are inflated
(every glyph a full em), so wide-width assertions in run/visit tests use 70%.
## Evidence
Headless Chrome captures in `/tmp/floating-tabs-evidence/`:
`shell-{material,cupertino}-560`, `shell-material-1200`,
`shell-cupertino-1200-dark` (new `tool/floating_tabs_probe_entry.dart`,
`?platform=cupertino&theme=dark&tab=runs`), `run-detail-*`,
`run-timeline-cupertino-*`, `stage-page-*` (`tool/run_detail_visit_probe.dart`,
stage pages opened by CDP clicks), and the real app over the loopback
fixtures: `app-runs-material-560`, `app-run-detail-material-{560,1200}`,
`app-pipelines-material-560`, `app-pipeline-detail-material-{560,1200}`
(`tool/runs_probe_entry.dart`, `tool/pipelines_wiring_probe_entry.dart`). The
full app is Material on the web by design (`prefersCupertino` is false on web),
so Cupertino evidence comes from the standalone probes.
Known gaps: no device run (Android/iOS unverified); the existing
`tool/run_detail_visit_probe.mjs` predates this change (it still looks for a
Graph tab) and was not updated.
+2 -2
View File
@@ -31,7 +31,7 @@ pill on the page's own background) is now the app's only top bar.
`BackdropFilter` blur, sigma 16, clipped to the shape; fill
`surfaceContainerHigh` / `systemGrey6` at 72%; hairline `outlineVariant` /
`separator` border). Under `MediaQuery.highContrast` the fill is solid and
nothing blurs. Intended for the floating tab bar follow-up too.
nothing blurs. Also the floating tab bars' pill (`notes/floating-tab-bars.md`).
- `segmented_bar_overlay.dart` — `SegmentedBarOverlay(bar:, child:)`: floats a
bar over content outside a scaffold (like `extendBodyBehindAppBar`), giving
the content the bar's measured height as `MediaQuery.paddingOf(context).top`.
@@ -49,7 +49,7 @@ pill on the page's own background) is now the app's only top bar.
schedules bodies gained a top-only `SafeArea`). They show the new bar but
their content does not yet scroll behind it — each list has its own fixed
padding/headers and needs a per-screen change to consume the media padding.
- The bottom tab bar is unchanged (floating tab bars are a separate change).
- Bottom tab bars float too: see `notes/floating-tab-bars.md`.
## Converted
@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/application/pipelines_app.dart';
import 'package:pipelines_app/application/server_endpoint.dart';
import 'package:pipelines_app/core/transport/pipelines_client.dart';
@@ -208,14 +209,12 @@ void main() {
expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget);
expect(find.text('Kept behind a native disclosure.'), findsNothing);
// The shell bar stays over the list and rail; the open chat draws its
// The shell bar stays over the list and tabs; the open chat draws its
// own floating bar in its pane, with no Back: the list beside it is the
// way out.
expect(find.byType(ChatSessionsScreen), findsOneWidget);
expect(
find.byType(NavigationRail),
cupertino ? findsNothing : findsOneWidget,
);
expect(find.byType(NavigationRail), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
// The shell's bar and the conversation's own header.
expect(find.byType(SegmentedBar), findsNWidgets(2));
expect(find.byType(AppBar), findsNothing);
@@ -109,7 +109,11 @@ void main() {
final bodyWidths = <double>[];
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
if (destination != 'Pipelines') {
await tester.tap(find.text(destination).first);
await tester.tap(
find.byKey(
ValueKey('shell.destination.${destination.toLowerCase()}'),
),
);
await tester.pumpAndSettle();
expect(
tester.takeException(),
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/core/api_gateway.dart';
import 'package:pipelines_app/features/chat/screen.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
@@ -47,7 +48,7 @@ Future<void> _pumpShell(WidgetTester tester, Size size) async {
void main() {
for (final size in [const Size(1280, 800), const Size(800, 830)]) {
testWidgets('a wide window keeps the rail and list beside the open chat '
testWidgets('a wide window keeps the tab bar and list beside the open chat '
'at $size', (tester) async {
await _pumpShell(tester, size);
expect(find.text('Select a chat to open it here.'), findsOneWidget);
@@ -60,7 +61,8 @@ void main() {
await tester.pumpAndSettle();
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
expect(find.byType(NavigationRail), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing);
expect(find.byType(FloatingDestinationBar), findsOneWidget);
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
expect(find.text('Second chat'), findsOneWidget);
expect(
@@ -1,11 +1,9 @@
import 'dart:ui' show PointerDeviceKind;
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_styles.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
void main() {
testWidgets('code-like values still use native host typography', (
@@ -30,7 +28,7 @@ void main() {
for (final cupertino in [false, true]) {
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
testWidgets('native tabs at $width, 2x, Cupertino=$cupertino', (
testWidgets('floating tabs at $width, 2x, Cupertino=$cupertino', (
tester,
) async {
tester.view.physicalSize = Size(width, 640);
@@ -38,7 +36,7 @@ void main() {
addTearDown(tester.view.reset);
PipelineDetailTab? selected;
final body = Align(
alignment: Alignment.topLeft,
alignment: Alignment.bottomCenter,
child: PipelineDetailTabs(
selected: PipelineDetailTab.summary,
onSelected: (value) => selected = value,
@@ -62,30 +60,27 @@ void main() {
),
);
await tester.pumpAndSettle();
// The host's own tab bar inside the shared glass pill.
expect(
cupertino
? find.byType(CupertinoSegmentedControl<PipelineDetailTab>)
: find.byType(SegmentedButton<PipelineDetailTab>),
find.byType(cupertino ? CupertinoTabBar : NavigationBar),
findsOneWidget,
);
for (final tab in PipelineDetailTab.values) {
final paragraph = tester.renderObject<RenderParagraph>(
find.text(tab.label),
);
expect(
paragraph.size.width,
greaterThanOrEqualTo(
paragraph.getMaxIntrinsicWidth(double.infinity) - 0.01,
),
reason: 'Whole labels must not be squeezed inside a native segment',
);
final pill = tester.getRect(find.byType(GlassPill));
if (width < 600) {
expect(pill.left, 16);
expect(pill.right, width - 16);
} else {
// Sized to its three tabs at the right edge.
expect(pill.right, width - 16);
expect(pill.width, lessThan(width * 0.6));
}
for (final tab in PipelineDetailTab.values) {
final rect = tester.getRect(
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
);
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
}
await tester.drag(
find.byType(SingleChildScrollView),
const Offset(-1000, 0),
kind: PointerDeviceKind.mouse,
);
await tester.pumpAndSettle();
await tester.tap(find.text('Source'));
await tester.pumpAndSettle();
expect(selected, PipelineDetailTab.source);
@@ -8,7 +8,6 @@ import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
import 'fixtures.dart';
import 'test_helpers.dart';
@@ -127,8 +126,12 @@ void main() {
expect(find.byType(CupertinoActionSheet), findsNothing);
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
// The tabs are the floating glass Cupertino tab bar.
expect(
find.byType(CupertinoSegmentedControl<PipelineDetailTab>),
find.descendant(
of: find.byKey(const Key('pipeline-detail-tabs')),
matching: find.byType(CupertinoTabBar),
),
findsOneWidget,
);
expect(find.byType(CupertinoListTile), findsWidgets);
@@ -73,13 +73,16 @@ void main() {
);
await tester.pumpAndSettle();
expect(find.text(decisionWaitingTitle), findsOneWidget);
// The web's decision banner spans the header, with Decide trailing.
// The web's decision banner spans the header at its 16px inset, with
// Decide trailing.
final banner = tester.getRect(
find.byKey(const Key('run-decision-banner')),
);
final tabs = tester.getRect(find.byKey(const Key('run-detail-tabs')));
expect(banner.left, tabs.left);
expect(banner.width, greaterThanOrEqualTo(tabs.width));
final pane = tester.getRect(
find.byKey(const ValueKey('list-detail-body')),
);
expect(banner.left, pane.left + 16);
expect(banner.right, pane.right - 16);
expect(
tester.getCenter(find.byKey(decisionActionKey)).dx,
greaterThan(banner.center.dx),
@@ -5,6 +5,7 @@ import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'run_detail_graph_support.dart';
@@ -48,19 +49,15 @@ void main() {
previous = center.dx;
}
expect(find.byKey(runMoreMenuKey), findsOneWidget);
// The strip lines up with the header's 16px inset on both hosts: the
// first label sits within its segment's own padding of that inset, not
// behind a second 16px control inset (which put it at 48 on Cupertino).
expect(
tester
.getTopLeft(
find.descendant(of: strip, matching: find.text('Summary')),
)
.dx,
// Segments share the widest label's width, so a short first label
// sits a little in from its edge; a doubled inset would be 48+.
lessThan(46),
// The tabs are the floating glass bar: on this 900px detail it is sized
// to its tabs at the right edge, above the bottom.
final pill = tester.getRect(
find.descendant(of: strip, matching: find.byType(GlassPill)),
);
expect(pill.right, 900 - 16);
expect(pill.bottom, 1000 - 16);
// (The test font draws every glyph a full em wide.)
expect(pill.width, lessThan(900 * 0.7));
for (final tab in [
RunDetailTab.timeline,
@@ -74,30 +71,50 @@ void main() {
}
});
testWidgets('${platform.name} phone tabs sit at the bottom, wide ones '
'under the header', (tester) async {
testWidgets('${platform.name} tabs float full width on a phone and at '
'the right edge when wide, over content that scrolls behind them', (
tester,
) async {
await pumpRunDetail(tester, platform, size: const Size(390, 844));
final strip = tester.getRect(find.byKey(const Key('run-detail-tabs')));
final body = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
final strip = find.byKey(const Key('run-detail-tabs'));
final pill = tester.getRect(
find.descendant(of: strip, matching: find.byType(GlassPill)),
);
expect(strip.top, greaterThanOrEqualTo(body.bottom));
expect(strip.bottom, greaterThan(844 - 80));
final body = find.byKey(const Key('run-detail-tab-body-summary'));
// Full width minus the margins, floating above the bottom.
expect(pill.left, 16);
expect(pill.right, 390 - 16);
expect(pill.bottom, 844 - 16);
// The tab's content reaches the bottom edge, behind the bar.
expect(tester.getRect(body).bottom, 844);
// Every tab is on screen without scrolling the bar.
for (final tab in renderedRunDetailTabs) {
final rect = tester.getRect(runDetailTab(tab));
expect(rect.left, greaterThanOrEqualTo(0), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(390), reason: tab.name);
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
}
// At rest after scrolling to the end, the last content clears the bar.
final scrollable = find.descendant(
of: body,
matching: find.byType(Scrollable),
);
final position = tester.state<ScrollableState>(scrollable.first).position;
position.jumpTo(position.maxScrollExtent);
await tester.pumpAndSettle();
expect(
MediaQuery.paddingOf(tester.element(body)).bottom,
greaterThanOrEqualTo(844 - pill.top),
);
await pumpRunDetail(tester, platform, size: const Size(1000, 844));
final wideStrip = tester.getRect(
find.byKey(const Key('run-detail-tabs')),
final widePill = tester.getRect(
find.descendant(of: strip, matching: find.byType(GlassPill)),
);
final wideBody = tester.getRect(
find.byKey(const Key('run-detail-tab-body-summary')),
);
expect(wideStrip.bottom, lessThanOrEqualTo(wideBody.top));
expect(widePill.right, 1000 - 16);
expect(widePill.bottom, 844 - 16);
expect(widePill.width, lessThan(1000 * 0.6));
// Beside the bar the content takes taps: the body spans the width.
expect(tester.getRect(body).width, 1000);
});
testWidgets('${platform.name} missing graph states the exact wording', (
@@ -6,6 +6,7 @@ import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart'
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
import 'package:pipelines_app/ui/layout/sticky_section.dart';
import 'run_detail_graph_support.dart';
@@ -236,6 +237,22 @@ void main() {
final strip = tester.getRect(find.byType(RunVisitSectionStrip));
expect(strip.bottom, size.height, reason: section.name);
}
// The floating glass bar: full width on a phone, sized to its tabs
// at the right edge of a wide page.
final pill = tester.getRect(
find.descendant(
of: find.byType(RunVisitSectionStrip),
matching: find.byType(GlassPill),
),
);
expect(pill.right, size.width - 16);
expect(pill.bottom, size.height - 16);
if (size.width < 600) {
expect(pill.left, 16);
} else {
// (The test font draws every glyph a full em wide.)
expect(pill.width, lessThan(size.width * 0.7));
}
},
);
}
+7 -11
View File
@@ -4,7 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
/// The Runs tab mirrors the attention count in every mount of both hosts:
/// Material rail and bottom bar, Cupertino sidebar and tab bar. Zero draws the
/// the floating tab bar at full width on a phone and right-aligned on a wide
/// window. Zero draws the
/// bare icon with no count and no attention semantics.
void main() {
final needingAttention = RegExp('Notifications, 3 needing attention');
@@ -27,17 +28,15 @@ void main() {
}
for (final width in [390.0, 1000.0]) {
final mount = width < 600 ? 'bottom bar' : 'rail';
final mount = width < 600 ? 'bottom bar' : 'wide bar';
testWidgets('Material $mount shows the count on the Runs tab', (
tester,
) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: false, count: 3);
expect(
find.byType(width < 600 ? NavigationBar : NavigationRail),
findsOneWidget,
);
expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing);
final badge = find.byType(Badge);
expect(badge, findsOneWidget);
expect(tester.widget<Badge>(badge).isLabelVisible, isTrue);
@@ -68,17 +67,14 @@ void main() {
}
for (final width in [390.0, 1280.0]) {
final mount = width < 600 ? 'tab bar' : 'sidebar';
final mount = width < 600 ? 'tab bar' : 'wide tab bar';
testWidgets('Cupertino $mount shows the count on the Runs item', (
tester,
) async {
final semantics = tester.ensureSemantics();
await pumpShell(tester, width: width, cupertino: true, count: 3);
expect(
find.byType(CupertinoTabBar),
width < 600 ? findsOneWidget : findsNothing,
);
expect(find.byType(CupertinoTabBar), findsOneWidget);
expect(find.byType(Badge), findsNothing, reason: 'no Material badge');
expect(find.text('3'), findsOneWidget);
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
+186
View File
@@ -0,0 +1,186 @@
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/ui/adaptive/floating_destination_bar.dart';
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
/// The shell's one floating glass tab bar: full width on a phone, sized to its
/// tabs at the right edge on a wide window, with content behind it.
void main() {
Finder pill() => find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.byType(GlassPill),
);
Finder barText(String label) => find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.text(label),
);
Future<void> setSize(WidgetTester tester, Size size) async {
tester.view.physicalSize = size;
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
}
var taps = 0;
double? contentBottomPadding;
Widget shell({required bool cupertino}) {
final app = AdaptiveShell(
cupertino: cupertino,
destinationBodies: {
AppDestination.pipelines: (_) => Builder(
builder: (context) {
contentBottomPadding = MediaQuery.paddingOf(context).bottom;
return StatefulBuilder(
builder: (context, setState) => GestureDetector(
key: const Key('content'),
behavior: HitTestBehavior.opaque,
onTap: () => setState(() => taps++),
child: SizedBox.expand(child: Text('taps $taps')),
),
);
},
),
},
);
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
}
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host: phone bar spans the width minus its margins', (
tester,
) async {
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino));
final rect = tester.getRect(pill());
expect(rect.left, 16);
expect(rect.right, 390 - 16);
expect(rect.bottom, 844 - 16);
expect(find.byType(NavigationRail), findsNothing);
});
testWidgets('$host: wide bar hugs its tabs at the right edge, content '
'keeps the width and taps beside the bar reach it', (tester) async {
taps = 0;
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
final rect = tester.getRect(pill());
expect(rect.right, 1200 - 16);
expect(rect.bottom, 800 - 16);
expect(rect.width, lessThan(1200 * 0.6));
expect(rect.width, greaterThan(5 * 72));
// No rail or sidebar: the content starts at the left edge.
expect(find.byType(NavigationRail), findsNothing);
expect(find.byType(CupertinoListTile), findsNothing);
expect(tester.getRect(find.byKey(const Key('content'))).left, 0);
// Beside the bar, at the bar's height, the content takes the tap.
await tester.tapAt(Offset(rect.left - 40, rect.center.dy));
await tester.pump();
expect(taps, 1);
// On the bar, the tab takes it.
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
await tester.pumpAndSettle();
expect(find.text('Chat — Not implemented'), findsOneWidget);
});
testWidgets('$host: content learns the bar height as bottom padding', (
tester,
) async {
for (final size in const [Size(390, 844), Size(1200, 800)]) {
await setSize(tester, size);
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pump();
final rect = tester.getRect(pill());
// The content's bottom padding clears the whole bar and its margin.
expect(
contentBottomPadding,
moreOrLessEquals(size.height - rect.top, epsilon: 0.5),
reason: '$size',
);
}
});
testWidgets('$host: resizing moves the bar without remounting content', (
tester,
) async {
taps = 0;
await setSize(tester, const Size(390, 844));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.tap(find.byKey(const Key('content')));
await tester.pump();
expect(find.text('taps 1'), findsOneWidget);
final state = tester.state(find.byType(StatefulBuilder));
tester.view.physicalSize = const Size(1200, 800);
await tester.pump();
expect(tester.getRect(pill()).right, 1200 - 16);
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
expect(tester.state(find.byType(StatefulBuilder)), same(state));
tester.view.physicalSize = const Size(390, 844);
await tester.pump();
expect(tester.getRect(pill()).width, 390 - 32);
expect(tester.state(find.byType(StatefulBuilder)), same(state));
});
testWidgets('$host: the bar respects the bottom safe area', (tester) async {
await setSize(tester, const Size(390, 844));
tester.view.padding = const FakeViewPadding(bottom: 34);
await tester.pumpWidget(shell(cupertino: cupertino));
expect(tester.getRect(pill()).bottom, 844 - 34);
});
testWidgets('$host: the selected tab is marked selected for assistive '
'technology', (tester) async {
final semantics = tester.ensureSemantics();
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
await tester.pumpAndSettle();
expect(
tester.getSemantics(barText('Runs')),
isSemantics(isSelected: true),
);
expect(
tester.getSemantics(barText('Chat')),
isNot(isSemantics(isSelected: true)),
);
semantics.dispose();
});
}
testWidgets('Cupertino bar builds no Material widget', (tester) async {
await setSize(tester, const Size(1200, 800));
await tester.pumpWidget(shell(cupertino: true));
expect(
find.descendant(
of: find.byType(FloatingDestinationBar),
matching: find.byWidgetPredicate(
(widget) =>
widget is Material ||
widget is NavigationBar ||
widget is InkWell,
),
),
findsNothing,
);
});
testWidgets('phone at 320 with 2x text does not overflow', (tester) async {
for (final cupertino in [false, true]) {
await setSize(tester, const Size(320, 568));
tester.platformDispatcher.textScaleFactorTestValue = 2;
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
await tester.pumpWidget(shell(cupertino: cupertino));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
expect(tester.getRect(pill()).width, 320 - 32);
}
});
}
@@ -0,0 +1,77 @@
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';
void main() {
Widget page({
required Widget Function(BuildContext) list,
VoidCallback? onTap,
}) => MaterialApp(
home: Scaffold(
body: FloatingBarOverlay(
bar: FloatingDestinationBar(
cupertino: false,
currentIndex: 0,
onTap: (_) {},
items: const [
FloatingDestinationItem(icon: Icon(Icons.list), label: 'One'),
FloatingDestinationItem(icon: Icon(Icons.map), label: 'Two'),
],
),
child: GestureDetector(
behavior: HitTestBehavior.translucent,
onTap: onTap,
child: Builder(builder: list),
),
),
),
);
for (final width in [390.0, 1200.0]) {
testWidgets('a padded list scrolls behind the bar and its last item '
'clears it at rest (width $width)', (tester) async {
tester.view.physicalSize = Size(width, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
await tester.pumpWidget(
page(
list: (context) => ListView(
padding: withFloatingBarClearance(
context,
const EdgeInsets.all(16),
),
children: [
for (var i = 0; i < 40; i += 1)
SizedBox(height: 48, child: Text('Item $i')),
],
),
),
);
final pill = tester.getRect(find.byType(GlassPill));
// The list fills the area, behind the bar.
expect(tester.getRect(find.byType(ListView)).bottom, 800);
await tester.drag(find.byType(ListView), const Offset(0, -5000));
await tester.pumpAndSettle();
final last = tester.getRect(find.text('Item 39'));
expect(last.bottom, lessThanOrEqualTo(pill.top));
});
}
testWidgets('taps beside a wide bar reach the content', (tester) async {
tester.view.physicalSize = const Size(1200, 800);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
var taps = 0;
await tester.pumpWidget(
page(list: (_) => const SizedBox.expand(), onTap: () => taps++),
);
final pill = tester.getRect(find.byType(GlassPill));
expect(pill.right, 1200 - kFloatingBarMargin);
await tester.tapAt(Offset(pill.left - 24, pill.center.dy));
expect(taps, 1);
await tester.tapAt(pill.center);
expect(taps, 1, reason: 'the bar takes its own taps');
});
}
+7 -10
View File
@@ -24,14 +24,10 @@ void main() {
);
expect(find.text('Pipelines'), findsWidgets);
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
expect(
find.byType(NavigationBar),
width < 600 ? findsOneWidget : findsNothing,
);
expect(
find.byType(NavigationRail),
width >= 600 ? findsOneWidget : findsNothing,
);
// One floating tab bar at every width; no rail.
expect(find.byType(NavigationBar), findsOneWidget);
expect(find.byType(NavigationRail), findsNothing);
expect(tester.takeException(), isNull);
await tester.tap(find.text('Runs').last);
await tester.pumpAndSettle();
expect(find.text('Runs — Not implemented'), findsOneWidget);
@@ -53,7 +49,7 @@ void main() {
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
});
testWidgets('Cupertino shell uses a sidebar on a wide window', (
testWidgets('Cupertino shell floats its tab bar on a wide window', (
tester,
) async {
tester.view.physicalSize = const Size(1280, 900);
@@ -61,7 +57,8 @@ void main() {
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(const MyApp(cupertino: true));
expect(find.byType(CupertinoTabBar), findsNothing);
expect(find.byType(CupertinoTabBar), findsOneWidget);
expect(find.byType(CupertinoListTile), findsNothing);
expect(
find.byKey(const ValueKey('shell.destination.pipelines')),
findsOneWidget,
+157
View File
@@ -0,0 +1,157 @@
// Standalone browser fixture for the floating glass tab bar in the shell.
//
// Build and capture (from app/):
// flutter build web --target tool/floating_tabs_probe_entry.dart \
// -o build/probe-floating-tabs
// python3 -I -m http.server 0 --bind 127.0.0.1 \
// --directory build/probe-floating-tabs
// Chrome --headless=new --window-size=W,H --screenshot=OUT \
// 'http://127.0.0.1:PORT/?platform=cupertino&theme=dark'
//
// Query: platform=cupertino (else Material), theme=dark, tab=runs|chat|...
// The destinations are long local lists, so the capture shows content passing
// behind the bar and the last row clearing it. No server is involved.
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/shell/shell_bar.dart';
void main() {
final params = Uri.base.queryParameters;
final cupertino = params['platform'] == 'cupertino';
final dark = params['theme'] == 'dark';
final tab = AppDestination.values.firstWhere(
(value) => value.name == params['tab'],
orElse: () => AppDestination.pipelines,
);
final end = params['end'] == '1';
runApp(_Probe(cupertino: cupertino, dark: dark, tab: tab, end: end));
}
class _Probe extends StatelessWidget {
const _Probe({
required this.cupertino,
required this.dark,
required this.tab,
required this.end,
});
final bool cupertino;
final bool dark;
final AppDestination tab;
/// Starts every list scrolled to its end, to show the last row at rest.
final bool end;
Widget _list(String noun, {required int count}) =>
_ProbeList(noun: noun, count: count, cupertino: cupertino, end: end);
@override
Widget build(BuildContext context) {
final shell = AdaptiveShell(
cupertino: cupertino,
destination: tab,
attentionCount: 3,
destinationBodies: {
AppDestination.pipelines: (_) => _list('Pipeline', count: 40),
AppDestination.runs: (_) => ShellBadge(
kind: ShellBadgeKind.running,
count: 2,
child: _list('Run', count: 40),
),
AppDestination.chat: (_) => ShellBadge(
kind: ShellBadgeKind.unread,
count: 1,
child: _list('Chat', count: 12),
),
},
);
if (cupertino) {
return CupertinoApp(
debugShowCheckedModeBanner: false,
theme: CupertinoThemeData(
brightness: dark ? Brightness.dark : Brightness.light,
),
home: shell,
);
}
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: ThemeData(
brightness: dark ? Brightness.dark : Brightness.light,
colorSchemeSeed: Colors.indigo,
),
home: shell,
);
}
}
class _ProbeList extends StatefulWidget {
const _ProbeList({
required this.noun,
required this.count,
required this.cupertino,
required this.end,
});
final String noun;
final int count;
final bool cupertino;
final bool end;
@override
State<_ProbeList> createState() => _ProbeListState();
}
class _ProbeListState extends State<_ProbeList> {
final _scroll = ScrollController();
@override
void initState() {
super.initState();
if (widget.end) {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (_scroll.hasClients) {
_scroll.jumpTo(_scroll.position.maxScrollExtent);
}
});
}
}
@override
void dispose() {
_scroll.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
// No explicit padding: the list pads itself by the media insets, which
// include the floating bar's height.
return ListView.builder(
controller: _scroll,
itemCount: widget.count,
itemBuilder: (context, index) {
final title = '${widget.noun} ${index + 1}';
final subtitle = index.isEven
? 'Succeeded · 2m 05s'
: 'Running · started 1m ago';
if (widget.cupertino) {
return CupertinoListTile(
leading: const Icon(CupertinoIcons.circle_fill, size: 12),
title: Text(title),
subtitle: Text(subtitle),
);
}
return ListTile(
leading: Icon(
index.isEven ? Icons.check_circle_outline : Icons.timelapse,
),
title: Text(title),
subtitle: Text(subtitle),
);
},
);
}
}