Float detail tabs at the bottom of the split detail pane and keep its bars below the status bar
This commit is contained in:
@@ -12,7 +12,8 @@ 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.
|
||||
/// item's tabs float at the bottom of its own pane, beside (never on) the
|
||||
/// shell's tab bar over the list.
|
||||
void main() {
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
tester.view.physicalSize = size;
|
||||
@@ -149,18 +150,20 @@ void main() {
|
||||
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 {
|
||||
testWidgets('$host 1200: the item\'s tabs float at the bottom of its '
|
||||
'pane, beside 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),
|
||||
),
|
||||
find
|
||||
.ancestor(
|
||||
of: find.byKey(const ValueKey('shell.destination.runs')).first,
|
||||
matching: find.byType(GlassPill),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
final itemTabs = tester.getRect(
|
||||
find.descendant(
|
||||
@@ -168,16 +171,26 @@ void main() {
|
||||
matching: find.byType(GlassPill),
|
||||
),
|
||||
);
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
// Near the bottom of the detail pane, never on the shell's tabs.
|
||||
expect(itemTabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(itemTabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(itemTabs.overlaps(shellTabs), isFalse);
|
||||
// The item's list starts below its bar and clears its tabs at rest.
|
||||
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),
|
||||
greaterThanOrEqualTo(paneBarPill.bottom),
|
||||
);
|
||||
expect(
|
||||
MediaQuery.paddingOf(
|
||||
tester.element(find.byKey(const Key('item-list'))),
|
||||
).bottom,
|
||||
greaterThanOrEqualTo(800 - itemTabs.top),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,191 @@
|
||||
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';
|
||||
import 'package:pipelines_app/ui/adaptive/segmented_bar_overlay.dart';
|
||||
|
||||
/// On a wide split window (an unfolded foldable) under a system status bar,
|
||||
/// every pane's bar sits below the status-bar inset while content still
|
||||
/// reaches the top edge; and the open item's tabs float at the bottom of the
|
||||
/// detail pane, beside (never on) the shell's tab bar over the list.
|
||||
void main() {
|
||||
const statusBar = 40.0;
|
||||
|
||||
Future<void> setUp(WidgetTester tester, Size size) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
tester.view.padding = const FakeViewPadding(top: statusBar);
|
||||
tester.view.viewPadding = const FakeViewPadding(top: statusBar);
|
||||
addTearDown(tester.view.reset);
|
||||
}
|
||||
|
||||
List<Widget> rows(String label) => [
|
||||
for (var index = 0; index < 40; index++)
|
||||
SizedBox(height: 40, child: Text('$label $index')),
|
||||
];
|
||||
|
||||
/// An item publishing its bar to the pane, with its own floating tabs
|
||||
/// placed where the pane says (like run and pipeline detail).
|
||||
Widget tabbedItem(bool cupertino) => ShellBar(
|
||||
title: 'Open item',
|
||||
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.share), label: 'Two'),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: Builder(
|
||||
builder: (context) => ListView(
|
||||
key: const Key('item-list'),
|
||||
padding: withBarClearance(context, EdgeInsets.zero),
|
||||
children: rows('item'),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
/// An item drawing its own header over itself (like the chat thread).
|
||||
Widget overlayItem(bool cupertino) => ShellBar(
|
||||
barless: true,
|
||||
child: SegmentedBarOverlay(
|
||||
bar: SegmentedBar(
|
||||
key: const Key('own-header'),
|
||||
cupertino: cupertino,
|
||||
automaticallyImplyLeading: false,
|
||||
title: 'Own header',
|
||||
),
|
||||
child: ListView(key: const Key('item-list'), children: rows('item')),
|
||||
),
|
||||
);
|
||||
|
||||
Widget shell(bool cupertino, Widget Function(bool) item) {
|
||||
final app = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
destination: AppDestination.runs,
|
||||
destinationBodies: {
|
||||
AppDestination.runs: (_) => ListDetailPanes(
|
||||
list: ShellBar(
|
||||
child: ListView(key: const Key('list'), children: rows('list')),
|
||||
),
|
||||
detail: DetailPane(
|
||||
destination: AppDestination.runs,
|
||||
implyBack: false,
|
||||
builder: (_) => item(cupertino),
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
|
||||
}
|
||||
|
||||
Iterable<Rect> pillsOf(WidgetTester tester, Finder bar) => find
|
||||
.descendant(of: bar, matching: find.byType(GlassPill))
|
||||
.evaluate()
|
||||
.map((element) {
|
||||
final box = element.renderObject! as RenderBox;
|
||||
return box.localToGlobal(Offset.zero) & box.size;
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host split under a status bar: list and pane bars sit '
|
||||
'below it, content reaches the top edge', (tester) async {
|
||||
await setUp(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino, tabbedItem));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final listBar = find.byWidgetPredicate(
|
||||
(widget) => widget is SegmentedBar && widget.title == 'Runs',
|
||||
);
|
||||
final paneBar = find.byWidgetPredicate(
|
||||
(widget) => widget is SegmentedBar && widget.title == 'Open item',
|
||||
);
|
||||
for (final bar in [listBar, paneBar]) {
|
||||
final pills = pillsOf(tester, bar);
|
||||
expect(pills, isNotEmpty);
|
||||
for (final pill in pills) {
|
||||
expect(pill.top, greaterThanOrEqualTo(statusBar));
|
||||
}
|
||||
}
|
||||
// Content may still extend under the bars and the status bar.
|
||||
expect(tester.getTopLeft(find.byKey(const Key('list'))).dy, 0);
|
||||
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
|
||||
// At rest the first rows start below the bars.
|
||||
final paneBottom = pillsOf(tester, paneBar).first.bottom;
|
||||
expect(
|
||||
tester.getTopLeft(find.text('item 0')).dy,
|
||||
greaterThanOrEqualTo(paneBottom),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('$host split under a status bar: a self-drawn header (chat) '
|
||||
'sits below it', (tester) async {
|
||||
await setUp(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino, overlayItem));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
final pills = pillsOf(tester, find.byKey(const Key('own-header')));
|
||||
expect(pills, isNotEmpty);
|
||||
for (final pill in pills) {
|
||||
expect(pill.top, greaterThanOrEqualTo(statusBar));
|
||||
}
|
||||
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
|
||||
});
|
||||
|
||||
testWidgets('$host split: the item tabs float at the bottom of the '
|
||||
'detail pane, beside the shell tab bar over the list', (tester) async {
|
||||
await setUp(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino, tabbedItem));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final tabs = pillsOf(tester, find.byKey(const Key('item-tabs'))).single;
|
||||
expect(tabs.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
||||
expect(tabs.left, greaterThanOrEqualTo(body.left));
|
||||
expect(tabs.right, lessThanOrEqualTo(body.right));
|
||||
final shellTabs = tester.getRect(
|
||||
find
|
||||
.ancestor(
|
||||
of: find.byKey(const ValueKey('shell.destination.runs')).first,
|
||||
matching: find.byType(GlassPill),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
expect(shellTabs.overlaps(tabs), isFalse);
|
||||
expect(shellTabs.right, lessThanOrEqualTo(body.left));
|
||||
// The item's list clears its tabs at rest.
|
||||
final list = tester.element(find.byKey(const Key('item-list')));
|
||||
expect(
|
||||
MediaQuery.paddingOf(list).bottom,
|
||||
greaterThanOrEqualTo(800 - tabs.top),
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user