feat(app): pipeline detail tabs are a bottom bar with icons on phones, with Run and Runs above it
This commit is contained in:
@@ -99,6 +99,13 @@ 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;
|
||||
final tabs = PipelineDetailTabs(
|
||||
selected: _tab,
|
||||
bottom: bottomTabs,
|
||||
onSelected: (tab) => setState(() => _tab = tab),
|
||||
);
|
||||
return Column(
|
||||
key: const Key('pipeline-detail'),
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
@@ -122,10 +129,7 @@ class _PipelineDetailPanelState extends State<PipelineDetailPanel> {
|
||||
message: _controller.detailError!,
|
||||
onRetry: _controller.retryDetail,
|
||||
),
|
||||
PipelineDetailTabs(
|
||||
selected: _tab,
|
||||
onSelected: (tab) => setState(() => _tab = tab),
|
||||
),
|
||||
if (!bottomTabs) tabs,
|
||||
],
|
||||
),
|
||||
),
|
||||
@@ -134,37 +138,41 @@ 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: switch (_tab) {
|
||||
PipelineDetailTab.summary => _scrolling(
|
||||
PipelineSummaryView(
|
||||
controller: _controller,
|
||||
detail: detail,
|
||||
gateway: widget.gateway,
|
||||
child: 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),
|
||||
),
|
||||
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),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
return Stack(
|
||||
children: [
|
||||
Positioned.fill(child: panel),
|
||||
PositionedDirectional(
|
||||
end: 16,
|
||||
bottom: 16,
|
||||
child: SafeArea(child: _fabs(context, detail)),
|
||||
),
|
||||
],
|
||||
);
|
||||
return panel;
|
||||
}
|
||||
|
||||
/// 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.
|
||||
enum PipelineDetailTab {
|
||||
summary('Summary'),
|
||||
graph('Graph'),
|
||||
source('Source');
|
||||
summary('Summary', Icons.summarize_outlined, CupertinoIcons.doc_text),
|
||||
graph('Graph', Icons.account_tree_outlined, CupertinoIcons.arrow_branch),
|
||||
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;
|
||||
|
||||
/// 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,
|
||||
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(),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
child: _ScrollWhenOverflowing(
|
||||
@@ -43,6 +67,7 @@ class PipelineDetailTabs extends StatelessWidget {
|
||||
],
|
||||
selected: {selected},
|
||||
showSelectedIcon: false,
|
||||
expandedInsets: bottom ? EdgeInsets.zero : null,
|
||||
onSelectionChanged: (selection) => onSelected(selection.single),
|
||||
);
|
||||
}
|
||||
@@ -67,7 +92,23 @@ class PipelineDetailTabs extends StatelessWidget {
|
||||
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.
|
||||
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));
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user