Remove Cupertino shell branches
Keep the Material-only shell path while preserving public cupertino parameters for callers. Narrow matching tests to Material hosts and behavior because the app always runs under MaterialApp.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
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';
|
||||
@@ -38,7 +37,7 @@ void main() {
|
||||
|
||||
/// 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(
|
||||
Widget tabbedItem() => ShellBar(
|
||||
title: 'Open item',
|
||||
child: Builder(
|
||||
builder: (context) {
|
||||
@@ -48,7 +47,7 @@ void main() {
|
||||
bar: KeyedSubtree(
|
||||
key: const Key('item-tabs'),
|
||||
child: FloatingDestinationBar(
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
edge: edge,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
@@ -71,12 +70,12 @@ void main() {
|
||||
);
|
||||
|
||||
/// An item drawing its own header over itself (like the chat thread).
|
||||
Widget overlayItem(bool cupertino) => ShellBar(
|
||||
Widget overlayItem() => ShellBar(
|
||||
barless: true,
|
||||
child: SegmentedBarOverlay(
|
||||
bar: SegmentedBar(
|
||||
key: const Key('own-header'),
|
||||
cupertino: cupertino,
|
||||
cupertino: false,
|
||||
automaticallyImplyLeading: false,
|
||||
title: 'Own header',
|
||||
),
|
||||
@@ -84,9 +83,8 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
Widget shell(bool cupertino, Widget Function(bool) item) {
|
||||
Widget shell(Widget item) {
|
||||
final app = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
destination: AppDestination.runs,
|
||||
destinationBodies: {
|
||||
AppDestination.runs: (_) => ListDetailPanes(
|
||||
@@ -96,12 +94,12 @@ void main() {
|
||||
detail: DetailPane(
|
||||
destination: AppDestination.runs,
|
||||
implyBack: false,
|
||||
builder: (_) => item(cupertino),
|
||||
builder: (_) => item,
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
|
||||
return MaterialApp(home: app);
|
||||
}
|
||||
|
||||
Iterable<Rect> pillsOf(WidgetTester tester, Finder bar) => find
|
||||
@@ -112,99 +110,93 @@ void main() {
|
||||
return box.localToGlobal(Offset.zero) & box.size;
|
||||
});
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
testWidgets('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(tabbedItem()));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
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 bars' pieces have popped in) the first rows start
|
||||
// below the bars.
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
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')));
|
||||
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));
|
||||
}
|
||||
expect(tester.getTopLeft(find.byKey(const Key('item-list'))).dy, 0);
|
||||
});
|
||||
}
|
||||
// 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 bars' pieces have popped in) the first rows start
|
||||
// below the bars.
|
||||
await tester.pump(const Duration(seconds: 1));
|
||||
final paneBottom = pillsOf(tester, paneBar).first.bottom;
|
||||
expect(
|
||||
tester.getTopLeft(find.text('item 0')).dy,
|
||||
greaterThanOrEqualTo(paneBottom),
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('$host split: the item tabs sit at the bottom right of the '
|
||||
'detail pane, the shell tab bar under the list', (tester) async {
|
||||
// A gesture-navigation inset as on the unfolded foldable.
|
||||
await setUp(tester, const Size(1200, 800), bottom: 24);
|
||||
await tester.pumpWidget(shell(cupertino, tabbedItem));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
testWidgets('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(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);
|
||||
});
|
||||
|
||||
final body = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
final tabs = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('item-tabs')),
|
||||
matching: find.byKey(FloatingDestinationBar.rowKey),
|
||||
),
|
||||
);
|
||||
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.byKey(FloatingDestinationBar.rowKey),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
// Both bars sit above the system inset: the shell's under the list
|
||||
// pane, the item's at the detail pane's trailing edge.
|
||||
final listPane = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(shellTabs.bottom, closeTo(800 - 24, 0.5));
|
||||
expect(shellTabs.right, lessThanOrEqualTo(listPane.right));
|
||||
expect(tabs.bottom, closeTo(800 - 24, 0.5));
|
||||
expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(shellTabs.overlaps(tabs), isFalse);
|
||||
// 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),
|
||||
);
|
||||
});
|
||||
}
|
||||
testWidgets('split: the item tabs sit at the bottom right of the '
|
||||
'detail pane, the shell tab bar under the list', (tester) async {
|
||||
// A gesture-navigation inset as on the unfolded foldable.
|
||||
await setUp(tester, const Size(1200, 800), bottom: 24);
|
||||
await tester.pumpWidget(shell(tabbedItem()));
|
||||
await tester.pump();
|
||||
await tester.pump();
|
||||
|
||||
final body = tester.getRect(find.byKey(const ValueKey('list-detail-body')));
|
||||
final tabs = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('item-tabs')),
|
||||
matching: find.byKey(FloatingDestinationBar.rowKey),
|
||||
),
|
||||
);
|
||||
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.byKey(FloatingDestinationBar.rowKey),
|
||||
)
|
||||
.first,
|
||||
);
|
||||
// Both bars sit above the system inset: the shell's under the list
|
||||
// pane, the item's at the detail pane's trailing edge.
|
||||
final listPane = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-list')),
|
||||
);
|
||||
expect(shellTabs.bottom, closeTo(800 - 24, 0.5));
|
||||
expect(shellTabs.right, lessThanOrEqualTo(listPane.right));
|
||||
expect(tabs.bottom, closeTo(800 - 24, 0.5));
|
||||
expect(tabs.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
||||
expect(shellTabs.overlaps(tabs), isFalse);
|
||||
// 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