fix(app): float content behind top bars and give each wide pane its own bar row
- 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.
This commit is contained in:
@@ -8,6 +8,7 @@ import 'package:pipelines_app/application/runs_destination.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
import 'package:pipelines_app/features/runs/screen.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
||||
|
||||
import '../core/transport/pipelines_client_test.dart' show FakeChannel;
|
||||
import '../features/runs/ui/run_detail_finders.dart';
|
||||
@@ -229,7 +230,8 @@ void main() {
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
expect(runDetailText('Open run'), findsOneWidget);
|
||||
// The detail is open; its title reaches the pane's bar a frame later.
|
||||
expect(find.byType(RunDetailView), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
|
||||
|
||||
first.incoming.addError(StateError('network drop'));
|
||||
@@ -272,6 +274,7 @@ void main() {
|
||||
}),
|
||||
);
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(runDetailText('Open run'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
import 'package:pipelines_app/shell/detail_page.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'test_helpers.dart';
|
||||
@@ -44,38 +45,34 @@ void main() {
|
||||
expect(find.text('no runs recorded'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('the detail header is one identity line; Summary keeps facts', (
|
||||
tester,
|
||||
) async {
|
||||
testWidgets('the pane bar names the pipeline and its identity; the body '
|
||||
'repeats neither', (tester) async {
|
||||
final fixture = PipelineFixture();
|
||||
await pumpWide(tester, gatewayFor(fixture));
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
final pane = find.byType(DetailPane);
|
||||
final detail = find.byKey(const Key('pipeline-detail'));
|
||||
final header = find.byKey(const Key('pipeline-detail-header'));
|
||||
expect(header, findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: header, matching: find.text('Alpha review')),
|
||||
findsOneWidget,
|
||||
// No headline in the body: the title pill holds the name over the
|
||||
// recorded identity.
|
||||
expect(find.byKey(const Key('pipeline-detail-header')), findsNothing);
|
||||
final title = find.descendant(
|
||||
of: pane,
|
||||
matching: find.text('Alpha review'),
|
||||
);
|
||||
final identity = find.text('id 1 · v2 · 2 stages');
|
||||
expect(title, findsOneWidget);
|
||||
expect(identity, findsOneWidget);
|
||||
expect(
|
||||
find.descendant(of: header, matching: find.text('id 1 · v2 · 2 stages')),
|
||||
find.descendant(of: detail, matching: find.text('Alpha review')),
|
||||
findsNothing,
|
||||
);
|
||||
// The recorded identity now sits at the top of the Summary tab.
|
||||
expect(find.text('id 1 · v2 · 2 stages'), findsOneWidget);
|
||||
expect(find.descendant(of: detail, matching: identity), findsNothing);
|
||||
// The identity is the pill's subtitle, under the name.
|
||||
expect(
|
||||
tester
|
||||
.getTopLeft(
|
||||
find.descendant(
|
||||
of: header,
|
||||
matching: find.text('Alpha review'),
|
||||
),
|
||||
)
|
||||
.dx -
|
||||
tester.getTopLeft(detail).dx,
|
||||
12,
|
||||
tester.getTopLeft(identity).dy,
|
||||
greaterThan(tester.getTopLeft(title).dy),
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -106,14 +106,15 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.bySemanticsLabel('View runs of Alpha review'), findsOneWidget);
|
||||
// Run and Runs share one action row, as the web's pipeline actions.
|
||||
// Run and Runs float at the bottom right, Runs above the primary Run.
|
||||
// Run and Runs share the detail pane's actions pill at the top right,
|
||||
// Runs before the primary Run; nothing floats over the content.
|
||||
final runs = tester.getRect(find.byKey(const Key('pipeline-view-runs')));
|
||||
final run = tester.getRect(find.byKey(runPipelineActionKey));
|
||||
final screen = tester.view.physicalSize / tester.view.devicePixelRatio;
|
||||
expect(runs.bottom, lessThanOrEqualTo(run.top));
|
||||
expect(runs.right, lessThanOrEqualTo(run.left));
|
||||
expect((runs.center.dy - run.center.dy).abs(), lessThan(1));
|
||||
expect(run.right, greaterThan(screen.width - 40));
|
||||
expect(run.bottom, greaterThan(screen.height - 120));
|
||||
expect(run.bottom, lessThan(screen.height / 4));
|
||||
await tester.tap(find.byKey(const Key('pipeline-view-runs')));
|
||||
expect(opened, [1]);
|
||||
});
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_view.dart';
|
||||
import 'package:pipelines_app/shell/detail_page.dart';
|
||||
|
||||
/// Wide screens deliberately repeat the selected title in the visible list.
|
||||
Finder runDetailText(String text) =>
|
||||
find.descendant(of: find.byType(RunDetailView), matching: find.text(text));
|
||||
/// The run's title is in its top bar: the detail pane's (or page's) when the
|
||||
/// detail sits in one, else the run detail's own.
|
||||
Finder runDetailText(String text) => find.descendant(
|
||||
of: find.byWidgetPredicate(
|
||||
(widget) => widget is RunDetailView || widget is DetailPane,
|
||||
),
|
||||
matching: find.text(text),
|
||||
);
|
||||
|
||||
/// Stage identity and visit coordinates are separate rendered fields now.
|
||||
void expectVisitHeading(WidgetTester tester, String stage, num sequence) {
|
||||
|
||||
@@ -89,7 +89,11 @@ void main() {
|
||||
await tester.tap(find.byKey(runPipelineLinkKey));
|
||||
await tester.pump();
|
||||
expect(opened, [(10, 3)]);
|
||||
expect(find.bySemanticsLabel('Open pipeline nightly'), findsOneWidget);
|
||||
// The run's title pill is the link, announced as opening the pipeline.
|
||||
expect(
|
||||
find.bySemanticsLabel(RegExp('Open pipeline nightly')),
|
||||
findsOneWidget,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('$host: a succeeded run offers no Retry', (tester) async {
|
||||
|
||||
@@ -147,11 +147,12 @@ void main() {
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(find.text('Nightly build'), findsOneWidget);
|
||||
expect(find.textContaining('Original prompt'), findsNothing);
|
||||
// Both hosts lead with the web's status kicker above the title.
|
||||
// The title is the top bar's; the status kicker leads the body below
|
||||
// it, and the body does not repeat the title.
|
||||
expect(find.byKey(const Key('run-status-kicker')), findsOneWidget);
|
||||
expect(
|
||||
tester.getTopLeft(find.byKey(const Key('run-status-kicker'))).dy,
|
||||
lessThan(tester.getTopLeft(find.text('Nightly build')).dy),
|
||||
greaterThan(tester.getBottomLeft(find.text('Nightly build')).dy),
|
||||
);
|
||||
// Input and Output are sticky collapsibles on both hosts.
|
||||
expect(
|
||||
|
||||
@@ -119,6 +119,7 @@ void main() {
|
||||
'input': {'prompt': 'initial prompt'},
|
||||
});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
expect(runDetailText('Alpha run'), findsOneWidget);
|
||||
expect(find.text('Input'), findsOneWidget);
|
||||
@@ -159,6 +160,7 @@ void main() {
|
||||
expect(gateway.detailRequests[2], hasLength(1));
|
||||
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(runDetailText('Beta run'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
|
||||
});
|
||||
@@ -251,6 +253,7 @@ void main() {
|
||||
expect(gateway.detailRequests[2], hasLength(1));
|
||||
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(runDetailText('Beta run'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(_materialScreen(gateway, initialRunId: 1));
|
||||
@@ -258,6 +261,7 @@ void main() {
|
||||
expect(gateway.detailRequests[1], hasLength(1));
|
||||
gateway.replyDetail(1, 0, {'id': 1, 'title': 'Alpha run'});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(runDetailText('Alpha run'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(_materialScreen(gateway));
|
||||
@@ -274,6 +278,7 @@ void main() {
|
||||
await _mountList(tester, gateway);
|
||||
gateway.replyDetail(2, 0, {'id': 2, 'title': 'Beta run'});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(runDetailText('Beta run'), findsOneWidget);
|
||||
|
||||
await tester.pumpWidget(
|
||||
@@ -291,6 +296,7 @@ void main() {
|
||||
'status': 'succeeded',
|
||||
});
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(runDetailText('Beta run'), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('run-row-1')), findsOneWidget);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,231 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
import 'package:pipelines_app/shell/destination.dart';
|
||||
import 'package:pipelines_app/shell/detail_page.dart';
|
||||
import 'package:pipelines_app/shell/list_detail.dart';
|
||||
import 'package:pipelines_app/shell/shell_bar.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';
|
||||
|
||||
/// Beside a list each pane owns its bar on one shared top row, and an open
|
||||
/// item's tabs never stack on the shell's tab bar at the bottom.
|
||||
void main() {
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
}
|
||||
|
||||
Rect rectOf(Element element) {
|
||||
final box = element.renderObject! as RenderBox;
|
||||
return box.localToGlobal(Offset.zero) & box.size;
|
||||
}
|
||||
|
||||
/// An open item: its title published to the pane's bar, its own tabs
|
||||
/// floating where the pane says, and a list padded clear of both bars.
|
||||
Widget item({bool cupertino = false}) => ShellBar(
|
||||
title: 'Open item',
|
||||
subtitle: 'Its context',
|
||||
actions: const [Icon(Icons.more_vert, semanticLabel: 'More')],
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
final edge = PageTabsEdge.of(context);
|
||||
return FloatingBarOverlay(
|
||||
edge: edge,
|
||||
bar: KeyedSubtree(
|
||||
key: const Key('item-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
edge: edge,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: const [
|
||||
FloatingDestinationItem(icon: Icon(Icons.notes), label: 'One'),
|
||||
FloatingDestinationItem(
|
||||
icon: Icon(Icons.timeline),
|
||||
label: 'Two',
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Builder(
|
||||
builder: (context) => ListView(
|
||||
key: const Key('item-list'),
|
||||
padding: withBarClearance(context, EdgeInsets.zero),
|
||||
children: [
|
||||
for (var index = 0; index < 30; index++)
|
||||
SizedBox(height: 40, child: Text('item row $index')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
Widget shell({bool cupertino = false, int attention = 0}) {
|
||||
final app = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
attentionCount: attention,
|
||||
destinationBodies: {
|
||||
AppDestination.runs: (_) => ShellBadge(
|
||||
kind: ShellBadgeKind.running,
|
||||
count: 4,
|
||||
child: ListDetailPanes(
|
||||
list: ShellBar(
|
||||
actions: [const Icon(Icons.sort, semanticLabel: 'Sort')],
|
||||
child: ListView(
|
||||
children: [
|
||||
for (var index = 0; index < 30; index++)
|
||||
SizedBox(height: 40, child: Text('list row $index')),
|
||||
],
|
||||
),
|
||||
),
|
||||
detail: DetailPane(
|
||||
destination: AppDestination.runs,
|
||||
implyBack: false,
|
||||
builder: (_) => item(cupertino: cupertino),
|
||||
),
|
||||
),
|
||||
),
|
||||
},
|
||||
destination: AppDestination.runs,
|
||||
);
|
||||
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
|
||||
}
|
||||
|
||||
Finder shellBar() => find.byWidgetPredicate(
|
||||
(widget) => widget is SegmentedBar && widget.title == 'Runs',
|
||||
);
|
||||
Finder paneBar() => find.descendant(
|
||||
of: find.byType(DetailPane),
|
||||
matching: find.byType(SegmentedBar),
|
||||
);
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host 1200: the shell bar covers the list pane and the '
|
||||
'item\'s bar shares its row', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final list = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final shellPills = find.descendant(
|
||||
of: shellBar(),
|
||||
matching: find.byType(GlassPill),
|
||||
);
|
||||
for (final element in shellPills.evaluate()) {
|
||||
expect(
|
||||
rectOf(element).right,
|
||||
lessThanOrEqualTo(list.right),
|
||||
reason: 'no shell piece sits over the open item',
|
||||
);
|
||||
}
|
||||
// Both titles on the same top row.
|
||||
final shellTitle = tester.getRect(
|
||||
find.descendant(of: shellBar(), matching: find.text('Runs')),
|
||||
);
|
||||
final paneTitle = tester.getRect(find.text('Open item'));
|
||||
expect(paneTitle.left, greaterThanOrEqualTo(body.left));
|
||||
final paneTop = tester.getRect(
|
||||
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
final shellTop = tester.getRect(shellPills.first);
|
||||
expect(paneTop.top, shellTop.top);
|
||||
expect(paneTitle.top, lessThan(shellTitle.bottom));
|
||||
// The title pill carries the item's context too.
|
||||
expect(find.text('Its context'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host 1200: the item\'s tabs float under its bar, not on '
|
||||
'the shell\'s tab bar', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final shellTabs = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const ValueKey('shell.destination.runs')).first,
|
||||
matching: find.byType(Icon),
|
||||
),
|
||||
);
|
||||
final itemTabs = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('item-tabs')),
|
||||
matching: find.byType(GlassPill),
|
||||
),
|
||||
);
|
||||
final paneBarPill = tester.getRect(
|
||||
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
expect(itemTabs.top, greaterThanOrEqualTo(paneBarPill.bottom));
|
||||
expect(itemTabs.top, lessThan(200));
|
||||
expect(itemTabs.bottom, lessThan(shellTabs.top - 100));
|
||||
// The item's list starts below its tabs at rest.
|
||||
expect(
|
||||
tester.getTopLeft(find.text('item row 0')).dy,
|
||||
greaterThanOrEqualTo(itemTabs.bottom),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('390: an open item is its own page with its tabs at the bottom', (
|
||||
tester,
|
||||
) async {
|
||||
await setSize(tester, const Size(390, 844));
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: DetailPane(
|
||||
destination: AppDestination.runs,
|
||||
builder: (_) => item(),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
final tabs = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('item-tabs')),
|
||||
matching: find.byType(GlassPill),
|
||||
),
|
||||
);
|
||||
expect(tabs.bottom, greaterThan(844 - 40));
|
||||
// Content reaches the top edge and starts below the page's bar.
|
||||
final bar = tester.getRect(
|
||||
find.descendant(of: paneBar(), matching: find.byType(GlassPill)).first,
|
||||
);
|
||||
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
|
||||
expect(
|
||||
tester.getTopLeft(find.text('item row 0')).dy,
|
||||
greaterThanOrEqualTo(bar.bottom),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('the Runs tab shows one indicator: attention outranks running', (
|
||||
tester,
|
||||
) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(attention: 2));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.text('2'), findsOneWidget);
|
||||
expect(find.text('4'), findsNothing);
|
||||
|
||||
await tester.pumpWidget(shell());
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
expect(find.text('4'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -87,10 +87,14 @@ void main() {
|
||||
MaterialApp(
|
||||
home: AdaptiveShell(
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) => StatefulBuilder(
|
||||
builder: (context, setState) => TextButton(
|
||||
onPressed: () => setState(() => builds++),
|
||||
child: Text('Builds: $builds'),
|
||||
// Bodies reach the top edge under the floating bar; this one
|
||||
// keeps its button clear of it.
|
||||
AppDestination.pipelines: (_) => Center(
|
||||
child: StatefulBuilder(
|
||||
builder: (context, setState) => TextButton(
|
||||
onPressed: () => setState(() => builds++),
|
||||
child: Text('Builds: $builds'),
|
||||
),
|
||||
),
|
||||
),
|
||||
AppDestination.runs: (_) => const Text('Runs screen'),
|
||||
|
||||
Reference in New Issue
Block a user