feat(app): pipeline detail tabs are a bottom bar with icons on phones, with Run and Runs above it

This commit is contained in:
2026-10-23 19:36:23 +01:00
parent cc05b94c65
commit 9fa932c8e6
4 changed files with 122 additions and 34 deletions
@@ -99,6 +99,13 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
final panel = LayoutBuilder( final panel = LayoutBuilder(
builder: (context, constraints) { builder: (context, constraints) {
final headerLimit = _headerLimit(constraints); final headerLimit = _headerLimit(constraints);
// On a phone the tabs are a bottom bar, as in the run detail.
final bottomTabs = constraints.maxWidth < 600;
final tabs = PipelineDetailTabs(
selected: _tab,
bottom: bottomTabs,
onSelected: (tab) => setState(() => _tab = tab),
);
return Column( return Column(
key: const Key('pipeline-detail'), key: const Key('pipeline-detail'),
crossAxisAlignment: CrossAxisAlignment.stretch, crossAxisAlignment: CrossAxisAlignment.stretch,
@@ -122,10 +129,7 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
message: _controller.detailError!, message: _controller.detailError!,
onRetry: _controller.retryDetail, onRetry: _controller.retryDetail,
), ),
PipelineDetailTabs( if (!bottomTabs) tabs,
selected: _tab,
onSelected: (tab) => setState(() => _tab = tab),
),
], ],
), ),
), ),
@@ -134,37 +138,41 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
// scroll their own content; the graph fills the slot so its canvas // scroll their own content; the graph fills the slot so its canvas
// is never asked for an unbounded extent inside a scroll view. // is never asked for an unbounded extent inside a scroll view.
Expanded( Expanded(
child: switch (_tab) { child: Stack(
PipelineDetailTab.summary => _scrolling( children: [
PipelineSummaryView( Positioned.fill(
controller: _controller, child: switch (_tab) {
detail: detail, PipelineDetailTab.summary => _scrolling(
gateway: widget.gateway, 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),
},
), ),
), // Run and Runs float over the content, above the tabs.
PipelineDetailTab.graph => PipelineGraphTab( PositionedDirectional(
detail: detail, end: 16,
selectedStage: _graphSelection, bottom: 16,
onSelected: (stageKey) => child: _fabs(context, detail),
_openGraphStage(context, detail, stageKey), ),
), ],
PipelineDetailTab.source => _source(context, detail), ),
},
), ),
if (bottomTabs) SafeArea(top: false, child: tabs),
], ],
); );
}, },
); );
return Stack( return panel;
children: [
Positioned.fill(child: panel),
PositionedDirectional(
end: 16,
bottom: 16,
child: SafeArea(child: _fabs(context, detail)),
),
],
);
} }
/// The header keeps its natural height while at least /// The header keeps its natural height while at least
@@ -1,10 +1,17 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
/// The detail sections: Summary, the pinned definition Graph and Source. /// The detail sections: Summary, the pinned definition Graph and Source.
enum PipelineDetailTab { enum PipelineDetailTab {
summary('Summary'), summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text),
graph('Graph'), graph('Graph', Icons.account_tree_outlined, CupertinoIcons.arrow_branch),
source('Source'); source('Source', Icons.code, CupertinoIcons.chevron_left_slash_chevron_right);
const PipelineDetailTab(this.label); const PipelineDetailTab(this.label, this.icon, this.cupertinoIcon);
final String label; final String label;
/// The tab's glyph, shown above its name in the bottom bar.
final IconData icon;
final IconData cupertinoIcon;
} }
@@ -16,14 +16,38 @@ class PipelineDetailTabs extends StatelessWidget {
super.key, super.key,
required this.selected, required this.selected,
required this.onSelected, 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 PipelineDetailTab selected;
final ValueChanged<PipelineDetailTab> onSelected; final ValueChanged<PipelineDetailTab> onSelected;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino = useCupertinoControls(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(),
),
),
),
);
}
return Padding( return Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8), padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
child: _ScrollWhenOverflowing( child: _ScrollWhenOverflowing(
@@ -43,6 +67,7 @@ class PipelineDetailTabs extends StatelessWidget {
], ],
selected: {selected}, selected: {selected},
showSelectedIcon: false, showSelectedIcon: false,
expandedInsets: bottom ? EdgeInsets.zero : null,
onSelectionChanged: (selection) => onSelected(selection.single), onSelectionChanged: (selection) => onSelected(selection.single),
); );
} }
@@ -67,7 +92,23 @@ class PipelineDetailTabs extends StatelessWidget {
Widget _label(PipelineDetailTab tab) { Widget _label(PipelineDetailTab tab) {
// One line, and let the control size the segment to the whole word rather // 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. // than wrapping inside it when scaled text is wider than the pane.
return Text(tab.label, maxLines: 1, softWrap: false); 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,
],
),
);
} }
} }
@@ -0,0 +1,32 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/pipelines/screen.dart';
import 'package:pipelines_app/features/pipelines/ui/run_pipeline_wording.dart';
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_tab.dart';
import 'fixtures.dart';
import 'test_helpers.dart';
void main() {
testWidgets('on a phone the pipeline tabs sit at the bottom with icons, '
'Run above them', (tester) async {
tester.view.physicalSize = const Size(390, 844);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final fixture = PipelineFixture();
await tester.pumpWidget(
MaterialApp(home: PipelinesScreen(gateway: gatewayFor(fixture))),
);
await tester.pumpAndSettle();
await tester.tap(find.byKey(const Key('pipeline-row-1')));
await tester.pumpAndSettle();
final tabs = tester.getRect(find.byKey(const Key('pipeline-detail-tabs')));
expect(tabs.bottom, greaterThan(844 - 90));
for (final tab in PipelineDetailTab.values) {
expect(find.byIcon(tab.icon), findsOneWidget, reason: tab.name);
}
final run = tester.getRect(find.byKey(runPipelineActionKey));
expect(run.bottom, lessThanOrEqualTo(tabs.top));
});
}