a1c4c1c402
Settings leaves the tab bar (Pipelines, Runs, Chat, Search) and opens as a page from a gear in the Pipelines bar, keeping /settings, its keys and a Back to Pipelines (also the system Back). Every floating tab bar shows icons only, named for assistive technology. On wide windows the shell's tab bar stays at the bottom right; a split detail learns its height plus a 12px gap, so its tabs or the chat composer float above it, and pages the detail opens (the stage page) stay in its pane through its own navigator.
224 lines
8.0 KiB
Dart
224 lines
8.0 KiB
Dart
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/list_detail.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';
|
|
|
|
/// While a tab shows its list beside an open item, the shell's destination
|
|
/// bar keeps its place at the bottom right (near the thumb). The item's own
|
|
/// bottom control (its tabs, or a composer) floats above it with a gap, and
|
|
/// the item's content clears both.
|
|
void main() {
|
|
Future<void> setSize(WidgetTester tester, Size size) async {
|
|
tester.view.physicalSize = size;
|
|
tester.view.devicePixelRatio = 1;
|
|
addTearDown(tester.view.reset);
|
|
}
|
|
|
|
/// A detail whose composer sits at the bottom, padded by the media inset
|
|
/// the way the chat composer is.
|
|
Widget composerDetail() => Builder(
|
|
builder: (context) => Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: Padding(
|
|
padding: EdgeInsets.only(bottom: MediaQuery.paddingOf(context).bottom),
|
|
child: const SizedBox(
|
|
key: Key('composer'),
|
|
height: 56,
|
|
width: double.infinity,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
Widget listBody() => Builder(
|
|
builder: (context) => ListView(
|
|
key: const Key('list'),
|
|
children: [
|
|
for (var index = 0; index < 40; index++)
|
|
SizedBox(height: 40, child: Text('row $index')),
|
|
],
|
|
),
|
|
);
|
|
|
|
/// A detail with its own floating tabs over a list, like run detail.
|
|
Widget tabsDetail(bool cupertino) => FloatingBarOverlay(
|
|
bar: KeyedSubtree(
|
|
key: const Key('detail-tabs'),
|
|
child: FloatingDestinationBar(
|
|
cupertino: cupertino,
|
|
currentIndex: 0,
|
|
onTap: (_) {},
|
|
items: const [
|
|
FloatingDestinationItem(icon: Icon(Icons.summarize), label: 'One'),
|
|
FloatingDestinationItem(icon: Icon(Icons.timeline), label: 'Two'),
|
|
FloatingDestinationItem(icon: Icon(Icons.inventory), label: 'Three'),
|
|
],
|
|
),
|
|
),
|
|
child: Builder(
|
|
builder: (context) => ListView(
|
|
key: const Key('detail-list'),
|
|
children: [
|
|
for (var index = 0; index < 40; index++)
|
|
SizedBox(height: 40, child: Text('item $index')),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
|
|
Widget shell({
|
|
required bool cupertino,
|
|
bool split = true,
|
|
bool tabs = false,
|
|
double textScale = 1,
|
|
}) {
|
|
final app = AdaptiveShell(
|
|
cupertino: cupertino,
|
|
destination: AppDestination.chat,
|
|
destinationBodies: {
|
|
AppDestination.chat: (_) => split
|
|
? ListDetailPanes(
|
|
list: listBody(),
|
|
detail: tabs ? tabsDetail(cupertino) : composerDetail(),
|
|
)
|
|
: listBody(),
|
|
},
|
|
);
|
|
return MediaQuery(
|
|
data: MediaQueryData.fromView(
|
|
WidgetsBinding.instance.platformDispatcher.views.first,
|
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
|
child: cupertino ? CupertinoApp(home: app) : MaterialApp(home: app),
|
|
);
|
|
}
|
|
|
|
Rect destinationPill(WidgetTester tester) => tester.getRect(
|
|
find
|
|
.ancestor(
|
|
of: find.byKey(const ValueKey('shell.destination.chat')).first,
|
|
matching: find.byType(GlassPill),
|
|
)
|
|
.first,
|
|
);
|
|
|
|
for (final cupertino in [false, true]) {
|
|
final host = cupertino ? 'Cupertino' : 'Material';
|
|
|
|
for (final width in [1200.0, 1600.0]) {
|
|
testWidgets('$host $width split: the destination bar stays bottom '
|
|
'right and the composer floats above it', (tester) async {
|
|
await setSize(tester, Size(width, 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 pill = destinationPill(tester);
|
|
// Compact at the window's right edge, over the detail pane only.
|
|
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
|
expect(pill.bottom, closeTo(800 - kFloatingBarMargin, 0.5));
|
|
expect(pill.width, lessThan(body.width / 2));
|
|
expect(pill.overlaps(list), isFalse, reason: 'never over the list');
|
|
expect(pill.left, greaterThan(body.left));
|
|
|
|
// The composer's box starts a gap above the shell's pill (the real
|
|
// composer pads its pill by another 12 inside that box).
|
|
final composer = tester.getRect(find.byKey(const Key('composer')));
|
|
expect(composer.left, body.left);
|
|
expect(composer.overlaps(pill), isFalse);
|
|
expect(pill.top - composer.bottom, closeTo(kStackedBarGap, 0.5));
|
|
|
|
// The list is not under the bar: it clears only the system inset.
|
|
final listContext = tester.element(find.byKey(const Key('list')));
|
|
expect(MediaQuery.paddingOf(listContext).bottom, 0);
|
|
});
|
|
|
|
testWidgets('$host $width split: the item tabs float above the '
|
|
'destination bar with a gap, and its content clears both', (
|
|
tester,
|
|
) async {
|
|
await setSize(tester, Size(width, 800));
|
|
await tester.pumpWidget(shell(cupertino: cupertino, tabs: true));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
final body = tester.getRect(
|
|
find.byKey(const ValueKey('list-detail-body')),
|
|
);
|
|
final pill = destinationPill(tester);
|
|
final tabs = tester.getRect(
|
|
find
|
|
.descendant(
|
|
of: find.byKey(const Key('detail-tabs')),
|
|
matching: find.byType(GlassPill),
|
|
)
|
|
.first,
|
|
);
|
|
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
|
expect(tabs.right, closeTo(width - kFloatingBarMargin, 0.5));
|
|
expect(tabs.left, greaterThan(body.left));
|
|
expect(tabs.overlaps(pill), isFalse);
|
|
expect(pill.top - tabs.bottom, closeTo(kStackedBarGap, 0.5));
|
|
|
|
// The item's list pads its end clear of both pills.
|
|
final listContext = tester.element(
|
|
find.byKey(const Key('detail-list')),
|
|
);
|
|
expect(
|
|
MediaQuery.paddingOf(listContext).bottom,
|
|
closeTo(800 - tabs.top, 0.5),
|
|
);
|
|
});
|
|
}
|
|
|
|
testWidgets('$host 1200 unsplit: the bar is compact at the right edge', (
|
|
tester,
|
|
) async {
|
|
await setSize(tester, const Size(1200, 800));
|
|
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
|
|
await tester.pump();
|
|
final pill = destinationPill(tester);
|
|
expect(pill.right, closeTo(1200 - kFloatingBarMargin, 0.5));
|
|
expect(pill.width, lessThan(1200 * 0.6));
|
|
});
|
|
|
|
testWidgets('$host 390: the bar spans the phone', (tester) async {
|
|
await setSize(tester, const Size(390, 844));
|
|
await tester.pumpWidget(shell(cupertino: cupertino, split: false));
|
|
await tester.pump();
|
|
final pill = destinationPill(tester);
|
|
expect(pill.left, closeTo(kFloatingBarMargin, 0.5));
|
|
expect(pill.right, closeTo(390 - kFloatingBarMargin, 0.5));
|
|
});
|
|
|
|
for (final width in [600.0, 840.0]) {
|
|
testWidgets('$host $width split at 2x: both bars lay out over the '
|
|
'detail pane without overflow', (tester) async {
|
|
await setSize(tester, Size(width, 800));
|
|
await tester.pumpWidget(
|
|
shell(cupertino: cupertino, tabs: true, textScale: 2),
|
|
);
|
|
await tester.pump();
|
|
await tester.pump();
|
|
expect(tester.takeException(), isNull);
|
|
final body = tester.getRect(
|
|
find.byKey(const ValueKey('list-detail-body')),
|
|
);
|
|
final pill = destinationPill(tester);
|
|
expect(pill.left, greaterThanOrEqualTo(body.left));
|
|
expect(pill.right, closeTo(width - kFloatingBarMargin, 0.5));
|
|
});
|
|
}
|
|
}
|
|
}
|