c6c6dcfe18
- Top-bar clearance helpers (withTopBarClearance, withBarClearance, SliverTopBarClearance, BelowTopBar, TopBarNotices); shell, DetailPane and the runs/pipelines/templates/artifacts/stage definition/filter/usage pages drop their top SafeArea and pad their own lists, pinned headers pin at the inset. - Wide windows: the shell bar narrows to the list pane (ShellPaneSplit) and the open item's bar shares its row; item tabs float at the pane's top (PageTabsEdge) instead of stacking on the shell's tab bar; the floating tab pill no longer swells over leftover media padding. - Pipeline detail is a DetailPane on wide too; Run/Runs move from FABs into the bar's actions; name and identity live in the title pill. - Run detail title pill shows the real title with Run N, pipeline and version (the pill links to the pipeline); the body keeps only status, actions and notices; standalone detail draws the same segmented bar. - One Runs tab badge: attention outranks running. - Tests for content-behind-bar padding and the no-stacking wide layout; notes/app-chrome-fixes.md.
214 lines
7.0 KiB
Dart
214 lines
7.0 KiB
Dart
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_bar_layout.dart';
|
|
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
|
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
|
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
|
|
import 'package:pipelines_app/ui/adaptive/top_bar_notices.dart';
|
|
|
|
/// Content floats behind the top bar: lists reach the top edge, start below
|
|
/// the bar at rest and scroll behind it; pinned headers pin under it.
|
|
void main() {
|
|
Future<void> setSize(WidgetTester tester, Size size) async {
|
|
tester.view.physicalSize = size;
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
}
|
|
|
|
Rect barRect(WidgetTester tester) => tester.getRect(
|
|
find.descendant(
|
|
of: find.byType(SegmentedBar),
|
|
matching: find.byType(GlassPill),
|
|
),
|
|
);
|
|
|
|
Widget page(Widget body, {bool cupertino = false}) {
|
|
final bar = SegmentedBar(cupertino: cupertino, title: 'Page');
|
|
if (cupertino) {
|
|
return CupertinoApp(
|
|
home: CupertinoPageScaffold(navigationBar: bar, child: body),
|
|
);
|
|
}
|
|
return MaterialApp(
|
|
home: Scaffold(extendBodyBehindAppBar: true, appBar: bar, body: body),
|
|
);
|
|
}
|
|
|
|
Widget rows() => Builder(
|
|
builder: (context) => ListView(
|
|
key: const Key('list'),
|
|
padding: withTopBarClearance(context, const EdgeInsets.all(16)),
|
|
children: [
|
|
for (var index = 0; index < 40; index++)
|
|
SizedBox(height: 48, child: Text('row $index')),
|
|
],
|
|
),
|
|
);
|
|
|
|
for (final cupertino in [false, true]) {
|
|
final host = cupertino ? 'Cupertino' : 'Material';
|
|
|
|
testWidgets('$host: a list reaches the top edge, starts below the bar at '
|
|
'rest and scrolls behind it', (tester) async {
|
|
await setSize(tester, const Size(390, 844));
|
|
await tester.pumpWidget(page(rows(), cupertino: cupertino));
|
|
|
|
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
|
|
final bar = barRect(tester);
|
|
expect(
|
|
tester.getTopLeft(find.text('row 0')).dy,
|
|
greaterThanOrEqualTo(bar.bottom),
|
|
);
|
|
|
|
await tester.drag(find.byKey(const Key('list')), const Offset(0, -120));
|
|
await tester.pump();
|
|
// A row now passes behind the glass title pill.
|
|
final behind = find.byWidgetPredicate((widget) {
|
|
if (widget is! Text || !(widget.data ?? '').startsWith('row ')) {
|
|
return false;
|
|
}
|
|
return true;
|
|
});
|
|
final rects = behind.evaluate().map(
|
|
(element) => tester.getRect(find.byWidget(element.widget)),
|
|
);
|
|
expect(rects.any((rect) => rect.overlaps(bar)), isTrue);
|
|
});
|
|
}
|
|
|
|
testWidgets('a pinned header after SliverTopBarClearance pins below the '
|
|
'bar', (tester) async {
|
|
await setSize(tester, const Size(390, 844));
|
|
await tester.pumpWidget(
|
|
page(
|
|
CustomScrollView(
|
|
key: const Key('list'),
|
|
slivers: [
|
|
const SliverTopBarClearance(),
|
|
const SliverToBoxAdapter(child: SizedBox(height: 200)),
|
|
const PinnedHeaderSliver(
|
|
child: SizedBox(height: 40, child: Text('pinned')),
|
|
),
|
|
SliverList.list(
|
|
children: [
|
|
for (var index = 0; index < 40; index++)
|
|
SizedBox(height: 48, child: Text('row $index')),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
final inset = barRect(tester).bottom;
|
|
await tester.drag(find.byKey(const Key('list')), const Offset(0, -600));
|
|
await tester.pump();
|
|
// The header pins at the bar's inset, not behind the bar.
|
|
expect(
|
|
tester.getTopLeft(find.text('pinned')).dy,
|
|
greaterThanOrEqualTo(inset),
|
|
);
|
|
expect(tester.getTopLeft(find.text('pinned')).dy, lessThan(inset + 16));
|
|
});
|
|
|
|
testWidgets('BelowTopBar and TopBarNotices keep fixed content below the bar '
|
|
'without remounting it', (tester) async {
|
|
await setSize(tester, const Size(390, 844));
|
|
var notice = false;
|
|
late StateSetter update;
|
|
await tester.pumpWidget(
|
|
page(
|
|
StatefulBuilder(
|
|
builder: (context, setState) {
|
|
update = setState;
|
|
return TopBarNotices(
|
|
notices: [if (notice) const Text('Offline')],
|
|
child: const _Probe(),
|
|
);
|
|
},
|
|
),
|
|
),
|
|
);
|
|
final bar = barRect(tester);
|
|
final probe = tester.state<_ProbeState>(find.byType(_Probe));
|
|
expect(probe.topPadding, greaterThanOrEqualTo(bar.bottom));
|
|
expect(tester.getTopLeft(find.byType(_Probe)).dy, 0);
|
|
|
|
update(() => notice = true);
|
|
await tester.pump();
|
|
expect(tester.state<_ProbeState>(find.byType(_Probe)), same(probe));
|
|
expect(
|
|
tester.getTopLeft(find.text('Offline')).dy,
|
|
greaterThanOrEqualTo(bar.bottom),
|
|
);
|
|
expect(probe.topPadding, 0);
|
|
expect(
|
|
tester.getTopLeft(find.byType(_Probe)).dy,
|
|
greaterThanOrEqualTo(tester.getBottomLeft(find.text('Offline')).dy),
|
|
);
|
|
});
|
|
|
|
testWidgets('a top-edge tab bar sits under the inset and pads the content '
|
|
'by both, without swelling over leftover padding', (tester) async {
|
|
await setSize(tester, const Size(800, 600));
|
|
late double contentTop;
|
|
await tester.pumpWidget(
|
|
MaterialApp(
|
|
home: MediaQuery(
|
|
data: const MediaQueryData(
|
|
size: Size(800, 600),
|
|
padding: EdgeInsets.only(top: 64, bottom: 96),
|
|
),
|
|
child: FloatingBarOverlay(
|
|
edge: FloatingBarEdge.top,
|
|
bar: FloatingDestinationBar(
|
|
cupertino: false,
|
|
edge: FloatingBarEdge.top,
|
|
currentIndex: 0,
|
|
onTap: (_) {},
|
|
items: const [
|
|
FloatingDestinationItem(icon: Icon(Icons.notes), label: 'One'),
|
|
FloatingDestinationItem(
|
|
icon: Icon(Icons.timeline),
|
|
label: 'Two',
|
|
),
|
|
],
|
|
),
|
|
child: Builder(
|
|
builder: (context) {
|
|
contentTop = MediaQuery.paddingOf(context).top;
|
|
return const SizedBox.expand();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
final pill = tester.getRect(find.byType(GlassPill));
|
|
expect(pill.top, 64);
|
|
// The pill is the bar's own height: leftover media padding is not added.
|
|
expect(pill.height, FloatingDestinationBar.materialHeight);
|
|
// Wide: sized to its tabs at the leading edge, under the title.
|
|
expect(pill.left, FloatingDestinationBar.topMargin);
|
|
expect(pill.width, lessThan(400));
|
|
expect(contentTop, pill.bottom + 8);
|
|
});
|
|
}
|
|
|
|
class _Probe extends StatefulWidget {
|
|
const _Probe();
|
|
|
|
@override
|
|
State<_Probe> createState() => _ProbeState();
|
|
}
|
|
|
|
class _ProbeState extends State<_Probe> {
|
|
double topPadding = -1;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
topPadding = MediaQuery.paddingOf(context).top;
|
|
return const SizedBox.expand();
|
|
}
|
|
}
|