Float glass tab bars everywhere the app has bottom tabs
One floating frosted tab bar (host NavigationBar / CupertinoTabBar in the shared GlassPill) replaces the NavigationRail, the Cupertino sidebar and the run detail, stage page and pipeline detail tab strips. Below 600px it spans the width minus 16px margins; wider it is sized to its tabs at the right edge. Content keeps the full width, scrolls behind the bar and learns its height as bottom media padding; lists pad their end clear of it and FABs sit above it. The bar now sizes itself from its own constraints instead of the screen size, which fixes the widget_test failure where a MediaQuery without a size gave it negative width constraints.
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:convert';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/application/pipelines_app.dart';
|
||||
import 'package:pipelines_app/application/server_endpoint.dart';
|
||||
import 'package:pipelines_app/core/transport/pipelines_client.dart';
|
||||
@@ -208,14 +209,12 @@ void main() {
|
||||
expect(find.byKey(const Key('chat-turn-activity')), findsOneWidget);
|
||||
expect(find.text('Kept behind a native disclosure.'), findsNothing);
|
||||
|
||||
// The shell bar stays over the list and rail; the open chat draws its
|
||||
// The shell bar stays over the list and tabs; the open chat draws its
|
||||
// own floating bar in its pane, with no Back: the list beside it is the
|
||||
// way out.
|
||||
expect(find.byType(ChatSessionsScreen), findsOneWidget);
|
||||
expect(
|
||||
find.byType(NavigationRail),
|
||||
cupertino ? findsNothing : findsOneWidget,
|
||||
);
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
||||
// The shell's bar and the conversation's own header.
|
||||
expect(find.byType(SegmentedBar), findsNWidgets(2));
|
||||
expect(find.byType(AppBar), findsNothing);
|
||||
|
||||
@@ -109,7 +109,11 @@ void main() {
|
||||
final bodyWidths = <double>[];
|
||||
for (final destination in ['Pipelines', 'Runs', 'Chat']) {
|
||||
if (destination != 'Pipelines') {
|
||||
await tester.tap(find.text(destination).first);
|
||||
await tester.tap(
|
||||
find.byKey(
|
||||
ValueKey('shell.destination.${destination.toLowerCase()}'),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.takeException(),
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/core/api_gateway.dart';
|
||||
import 'package:pipelines_app/features/chat/screen.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
@@ -47,7 +48,7 @@ Future<void> _pumpShell(WidgetTester tester, Size size) async {
|
||||
|
||||
void main() {
|
||||
for (final size in [const Size(1280, 800), const Size(800, 830)]) {
|
||||
testWidgets('a wide window keeps the rail and list beside the open chat '
|
||||
testWidgets('a wide window keeps the tab bar and list beside the open chat '
|
||||
'at $size', (tester) async {
|
||||
await _pumpShell(tester, size);
|
||||
expect(find.text('Select a chat to open it here.'), findsOneWidget);
|
||||
@@ -60,7 +61,8 @@ void main() {
|
||||
await tester.pumpAndSettle();
|
||||
final navigator = tester.state<NavigatorState>(find.byType(Navigator));
|
||||
expect(navigator.canPop(), isFalse, reason: 'No page covers the shell');
|
||||
expect(find.byType(NavigationRail), findsOneWidget);
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
expect(find.byType(FloatingDestinationBar), findsOneWidget);
|
||||
expect(find.byKey(const ValueKey('chat-thread-a')), findsOneWidget);
|
||||
expect(find.text('Second chat'), findsOneWidget);
|
||||
expect(
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import 'dart:ui' show PointerDeviceKind;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_styles.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
|
||||
void main() {
|
||||
testWidgets('code-like values still use native host typography', (
|
||||
@@ -30,7 +28,7 @@ void main() {
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
for (final width in [320.0, 390.0, 720.0, 1200.0]) {
|
||||
testWidgets('native tabs at $width, 2x, Cupertino=$cupertino', (
|
||||
testWidgets('floating tabs at $width, 2x, Cupertino=$cupertino', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = Size(width, 640);
|
||||
@@ -38,7 +36,7 @@ void main() {
|
||||
addTearDown(tester.view.reset);
|
||||
PipelineDetailTab? selected;
|
||||
final body = Align(
|
||||
alignment: Alignment.topLeft,
|
||||
alignment: Alignment.bottomCenter,
|
||||
child: PipelineDetailTabs(
|
||||
selected: PipelineDetailTab.summary,
|
||||
onSelected: (value) => selected = value,
|
||||
@@ -62,30 +60,27 @@ void main() {
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
// The host's own tab bar inside the shared glass pill.
|
||||
expect(
|
||||
cupertino
|
||||
? find.byType(CupertinoSegmentedControl<PipelineDetailTab>)
|
||||
: find.byType(SegmentedButton<PipelineDetailTab>),
|
||||
find.byType(cupertino ? CupertinoTabBar : NavigationBar),
|
||||
findsOneWidget,
|
||||
);
|
||||
for (final tab in PipelineDetailTab.values) {
|
||||
final paragraph = tester.renderObject<RenderParagraph>(
|
||||
find.text(tab.label),
|
||||
);
|
||||
expect(
|
||||
paragraph.size.width,
|
||||
greaterThanOrEqualTo(
|
||||
paragraph.getMaxIntrinsicWidth(double.infinity) - 0.01,
|
||||
),
|
||||
reason: 'Whole labels must not be squeezed inside a native segment',
|
||||
);
|
||||
final pill = tester.getRect(find.byType(GlassPill));
|
||||
if (width < 600) {
|
||||
expect(pill.left, 16);
|
||||
expect(pill.right, width - 16);
|
||||
} else {
|
||||
// Sized to its three tabs at the right edge.
|
||||
expect(pill.right, width - 16);
|
||||
expect(pill.width, lessThan(width * 0.6));
|
||||
}
|
||||
for (final tab in PipelineDetailTab.values) {
|
||||
final rect = tester.getRect(
|
||||
find.byKey(ValueKey('pipeline-detail-tab-${tab.name}')),
|
||||
);
|
||||
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
|
||||
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
|
||||
}
|
||||
await tester.drag(
|
||||
find.byType(SingleChildScrollView),
|
||||
const Offset(-1000, 0),
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('Source'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(selected, PipelineDetailTab.source);
|
||||
|
||||
@@ -8,7 +8,6 @@ import 'package:pipelines_app/features/pipelines/pipeline_repository.dart';
|
||||
import 'package:pipelines_app/features/pipelines/pipelines_controller.dart';
|
||||
import 'package:pipelines_app/features/pipelines/screen.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_detail_panel.dart';
|
||||
import 'package:pipelines_app/features/pipelines/widgets/pipeline_tabs.dart';
|
||||
|
||||
import 'fixtures.dart';
|
||||
import 'test_helpers.dart';
|
||||
@@ -127,8 +126,12 @@ void main() {
|
||||
expect(find.byType(CupertinoActionSheet), findsNothing);
|
||||
await tester.tap(find.byKey(const Key('pipeline-row-1')));
|
||||
await tester.pumpAndSettle();
|
||||
// The tabs are the floating glass Cupertino tab bar.
|
||||
expect(
|
||||
find.byType(CupertinoSegmentedControl<PipelineDetailTab>),
|
||||
find.descendant(
|
||||
of: find.byKey(const Key('pipeline-detail-tabs')),
|
||||
matching: find.byType(CupertinoTabBar),
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(CupertinoListTile), findsWidgets);
|
||||
|
||||
@@ -73,13 +73,16 @@ void main() {
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text(decisionWaitingTitle), findsOneWidget);
|
||||
// The web's decision banner spans the header, with Decide trailing.
|
||||
// The web's decision banner spans the header at its 16px inset, with
|
||||
// Decide trailing.
|
||||
final banner = tester.getRect(
|
||||
find.byKey(const Key('run-decision-banner')),
|
||||
);
|
||||
final tabs = tester.getRect(find.byKey(const Key('run-detail-tabs')));
|
||||
expect(banner.left, tabs.left);
|
||||
expect(banner.width, greaterThanOrEqualTo(tabs.width));
|
||||
final pane = tester.getRect(
|
||||
find.byKey(const ValueKey('list-detail-body')),
|
||||
);
|
||||
expect(banner.left, pane.left + 16);
|
||||
expect(banner.right, pane.right - 16);
|
||||
expect(
|
||||
tester.getCenter(find.byKey(decisionActionKey)).dx,
|
||||
greaterThan(banner.center.dx),
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:pipelines_app/features/runs/ui/run_more_menu.dart';
|
||||
import 'package:pipelines_app/features/graph/widgets/run_graph_view.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_tab_strip.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
|
||||
import 'run_detail_graph_support.dart';
|
||||
|
||||
@@ -48,19 +49,15 @@ void main() {
|
||||
previous = center.dx;
|
||||
}
|
||||
expect(find.byKey(runMoreMenuKey), findsOneWidget);
|
||||
// The strip lines up with the header's 16px inset on both hosts: the
|
||||
// first label sits within its segment's own padding of that inset, not
|
||||
// behind a second 16px control inset (which put it at 48 on Cupertino).
|
||||
expect(
|
||||
tester
|
||||
.getTopLeft(
|
||||
find.descendant(of: strip, matching: find.text('Summary')),
|
||||
)
|
||||
.dx,
|
||||
// Segments share the widest label's width, so a short first label
|
||||
// sits a little in from its edge; a doubled inset would be 48+.
|
||||
lessThan(46),
|
||||
// The tabs are the floating glass bar: on this 900px detail it is sized
|
||||
// to its tabs at the right edge, above the bottom.
|
||||
final pill = tester.getRect(
|
||||
find.descendant(of: strip, matching: find.byType(GlassPill)),
|
||||
);
|
||||
expect(pill.right, 900 - 16);
|
||||
expect(pill.bottom, 1000 - 16);
|
||||
// (The test font draws every glyph a full em wide.)
|
||||
expect(pill.width, lessThan(900 * 0.7));
|
||||
|
||||
for (final tab in [
|
||||
RunDetailTab.timeline,
|
||||
@@ -74,30 +71,50 @@ void main() {
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('${platform.name} phone tabs sit at the bottom, wide ones '
|
||||
'under the header', (tester) async {
|
||||
testWidgets('${platform.name} tabs float full width on a phone and at '
|
||||
'the right edge when wide, over content that scrolls behind them', (
|
||||
tester,
|
||||
) async {
|
||||
await pumpRunDetail(tester, platform, size: const Size(390, 844));
|
||||
final strip = tester.getRect(find.byKey(const Key('run-detail-tabs')));
|
||||
final body = tester.getRect(
|
||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
||||
final strip = find.byKey(const Key('run-detail-tabs'));
|
||||
final pill = tester.getRect(
|
||||
find.descendant(of: strip, matching: find.byType(GlassPill)),
|
||||
);
|
||||
expect(strip.top, greaterThanOrEqualTo(body.bottom));
|
||||
expect(strip.bottom, greaterThan(844 - 80));
|
||||
final body = find.byKey(const Key('run-detail-tab-body-summary'));
|
||||
// Full width minus the margins, floating above the bottom.
|
||||
expect(pill.left, 16);
|
||||
expect(pill.right, 390 - 16);
|
||||
expect(pill.bottom, 844 - 16);
|
||||
// The tab's content reaches the bottom edge, behind the bar.
|
||||
expect(tester.getRect(body).bottom, 844);
|
||||
// Every tab is on screen without scrolling the bar.
|
||||
for (final tab in renderedRunDetailTabs) {
|
||||
final rect = tester.getRect(runDetailTab(tab));
|
||||
expect(rect.left, greaterThanOrEqualTo(0), reason: tab.name);
|
||||
expect(rect.right, lessThanOrEqualTo(390), reason: tab.name);
|
||||
expect(rect.left, greaterThanOrEqualTo(pill.left), reason: tab.name);
|
||||
expect(rect.right, lessThanOrEqualTo(pill.right), reason: tab.name);
|
||||
}
|
||||
// At rest after scrolling to the end, the last content clears the bar.
|
||||
final scrollable = find.descendant(
|
||||
of: body,
|
||||
matching: find.byType(Scrollable),
|
||||
);
|
||||
final position = tester.state<ScrollableState>(scrollable.first).position;
|
||||
position.jumpTo(position.maxScrollExtent);
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
MediaQuery.paddingOf(tester.element(body)).bottom,
|
||||
greaterThanOrEqualTo(844 - pill.top),
|
||||
);
|
||||
|
||||
await pumpRunDetail(tester, platform, size: const Size(1000, 844));
|
||||
final wideStrip = tester.getRect(
|
||||
find.byKey(const Key('run-detail-tabs')),
|
||||
final widePill = tester.getRect(
|
||||
find.descendant(of: strip, matching: find.byType(GlassPill)),
|
||||
);
|
||||
final wideBody = tester.getRect(
|
||||
find.byKey(const Key('run-detail-tab-body-summary')),
|
||||
);
|
||||
expect(wideStrip.bottom, lessThanOrEqualTo(wideBody.top));
|
||||
expect(widePill.right, 1000 - 16);
|
||||
expect(widePill.bottom, 844 - 16);
|
||||
expect(widePill.width, lessThan(1000 * 0.6));
|
||||
// Beside the bar the content takes taps: the body spans the width.
|
||||
expect(tester.getRect(body).width, 1000);
|
||||
});
|
||||
|
||||
testWidgets('${platform.name} missing graph states the exact wording', (
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:pipelines_app/features/graph/widgets/stage_definition_view.dart'
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_facts.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_sections.dart';
|
||||
import 'package:pipelines_app/features/runs/ui/run_detail_visit_session_state.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
import 'package:pipelines_app/ui/layout/sticky_section.dart';
|
||||
|
||||
import 'run_detail_graph_support.dart';
|
||||
@@ -236,6 +237,22 @@ void main() {
|
||||
final strip = tester.getRect(find.byType(RunVisitSectionStrip));
|
||||
expect(strip.bottom, size.height, reason: section.name);
|
||||
}
|
||||
// The floating glass bar: full width on a phone, sized to its tabs
|
||||
// at the right edge of a wide page.
|
||||
final pill = tester.getRect(
|
||||
find.descendant(
|
||||
of: find.byType(RunVisitSectionStrip),
|
||||
matching: find.byType(GlassPill),
|
||||
),
|
||||
);
|
||||
expect(pill.right, size.width - 16);
|
||||
expect(pill.bottom, size.height - 16);
|
||||
if (size.width < 600) {
|
||||
expect(pill.left, 16);
|
||||
} else {
|
||||
// (The test font draws every glyph a full em wide.)
|
||||
expect(pill.width, lessThan(size.width * 0.7));
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:pipelines_app/shell/adaptive_shell.dart';
|
||||
|
||||
/// The Runs tab mirrors the attention count in every mount of both hosts:
|
||||
/// Material rail and bottom bar, Cupertino sidebar and tab bar. Zero draws the
|
||||
/// the floating tab bar at full width on a phone and right-aligned on a wide
|
||||
/// window. Zero draws the
|
||||
/// bare icon with no count and no attention semantics.
|
||||
void main() {
|
||||
final needingAttention = RegExp('Notifications, 3 needing attention');
|
||||
@@ -27,17 +28,15 @@ void main() {
|
||||
}
|
||||
|
||||
for (final width in [390.0, 1000.0]) {
|
||||
final mount = width < 600 ? 'bottom bar' : 'rail';
|
||||
final mount = width < 600 ? 'bottom bar' : 'wide bar';
|
||||
|
||||
testWidgets('Material $mount shows the count on the Runs tab', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
await pumpShell(tester, width: width, cupertino: false, count: 3);
|
||||
expect(
|
||||
find.byType(width < 600 ? NavigationBar : NavigationRail),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
final badge = find.byType(Badge);
|
||||
expect(badge, findsOneWidget);
|
||||
expect(tester.widget<Badge>(badge).isLabelVisible, isTrue);
|
||||
@@ -68,17 +67,14 @@ void main() {
|
||||
}
|
||||
|
||||
for (final width in [390.0, 1280.0]) {
|
||||
final mount = width < 600 ? 'tab bar' : 'sidebar';
|
||||
final mount = width < 600 ? 'tab bar' : 'wide tab bar';
|
||||
|
||||
testWidgets('Cupertino $mount shows the count on the Runs item', (
|
||||
tester,
|
||||
) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
await pumpShell(tester, width: width, cupertino: true, count: 3);
|
||||
expect(
|
||||
find.byType(CupertinoTabBar),
|
||||
width < 600 ? findsOneWidget : findsNothing,
|
||||
);
|
||||
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||
expect(find.byType(Badge), findsNothing, reason: 'no Material badge');
|
||||
expect(find.text('3'), findsOneWidget);
|
||||
expect(find.bySemanticsLabel(needingAttention), findsOneWidget);
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
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/ui/adaptive/floating_destination_bar.dart';
|
||||
import 'package:pipelines_app/ui/adaptive/glass_pill.dart';
|
||||
|
||||
/// The shell's one floating glass tab bar: full width on a phone, sized to its
|
||||
/// tabs at the right edge on a wide window, with content behind it.
|
||||
void main() {
|
||||
Finder pill() => find.descendant(
|
||||
of: find.byType(FloatingDestinationBar),
|
||||
matching: find.byType(GlassPill),
|
||||
);
|
||||
|
||||
Finder barText(String label) => find.descendant(
|
||||
of: find.byType(FloatingDestinationBar),
|
||||
matching: find.text(label),
|
||||
);
|
||||
|
||||
Future<void> setSize(WidgetTester tester, Size size) async {
|
||||
tester.view.physicalSize = size;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
}
|
||||
|
||||
var taps = 0;
|
||||
double? contentBottomPadding;
|
||||
|
||||
Widget shell({required bool cupertino}) {
|
||||
final app = AdaptiveShell(
|
||||
cupertino: cupertino,
|
||||
destinationBodies: {
|
||||
AppDestination.pipelines: (_) => Builder(
|
||||
builder: (context) {
|
||||
contentBottomPadding = MediaQuery.paddingOf(context).bottom;
|
||||
return StatefulBuilder(
|
||||
builder: (context, setState) => GestureDetector(
|
||||
key: const Key('content'),
|
||||
behavior: HitTestBehavior.opaque,
|
||||
onTap: () => setState(() => taps++),
|
||||
child: SizedBox.expand(child: Text('taps $taps')),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
},
|
||||
);
|
||||
return cupertino ? CupertinoApp(home: app) : MaterialApp(home: app);
|
||||
}
|
||||
|
||||
for (final cupertino in [false, true]) {
|
||||
final host = cupertino ? 'Cupertino' : 'Material';
|
||||
|
||||
testWidgets('$host: phone bar spans the width minus its margins', (
|
||||
tester,
|
||||
) async {
|
||||
await setSize(tester, const Size(390, 844));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
final rect = tester.getRect(pill());
|
||||
expect(rect.left, 16);
|
||||
expect(rect.right, 390 - 16);
|
||||
expect(rect.bottom, 844 - 16);
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('$host: wide bar hugs its tabs at the right edge, content '
|
||||
'keeps the width and taps beside the bar reach it', (tester) async {
|
||||
taps = 0;
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
final rect = tester.getRect(pill());
|
||||
expect(rect.right, 1200 - 16);
|
||||
expect(rect.bottom, 800 - 16);
|
||||
expect(rect.width, lessThan(1200 * 0.6));
|
||||
expect(rect.width, greaterThan(5 * 72));
|
||||
// No rail or sidebar: the content starts at the left edge.
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
expect(find.byType(CupertinoListTile), findsNothing);
|
||||
expect(tester.getRect(find.byKey(const Key('content'))).left, 0);
|
||||
// Beside the bar, at the bar's height, the content takes the tap.
|
||||
await tester.tapAt(Offset(rect.left - 40, rect.center.dy));
|
||||
await tester.pump();
|
||||
expect(taps, 1);
|
||||
// On the bar, the tab takes it.
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.chat')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Chat — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('$host: content learns the bar height as bottom padding', (
|
||||
tester,
|
||||
) async {
|
||||
for (final size in const [Size(390, 844), Size(1200, 800)]) {
|
||||
await setSize(tester, size);
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pump();
|
||||
final rect = tester.getRect(pill());
|
||||
// The content's bottom padding clears the whole bar and its margin.
|
||||
expect(
|
||||
contentBottomPadding,
|
||||
moreOrLessEquals(size.height - rect.top, epsilon: 0.5),
|
||||
reason: '$size',
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
testWidgets('$host: resizing moves the bar without remounting content', (
|
||||
tester,
|
||||
) async {
|
||||
taps = 0;
|
||||
await setSize(tester, const Size(390, 844));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.tap(find.byKey(const Key('content')));
|
||||
await tester.pump();
|
||||
expect(find.text('taps 1'), findsOneWidget);
|
||||
final state = tester.state(find.byType(StatefulBuilder));
|
||||
|
||||
tester.view.physicalSize = const Size(1200, 800);
|
||||
await tester.pump();
|
||||
expect(tester.getRect(pill()).right, 1200 - 16);
|
||||
expect(tester.getRect(pill()).width, lessThan(1200 * 0.6));
|
||||
expect(tester.state(find.byType(StatefulBuilder)), same(state));
|
||||
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
await tester.pump();
|
||||
expect(tester.getRect(pill()).width, 390 - 32);
|
||||
expect(tester.state(find.byType(StatefulBuilder)), same(state));
|
||||
});
|
||||
|
||||
testWidgets('$host: the bar respects the bottom safe area', (tester) async {
|
||||
await setSize(tester, const Size(390, 844));
|
||||
tester.view.padding = const FakeViewPadding(bottom: 34);
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
expect(tester.getRect(pill()).bottom, 844 - 34);
|
||||
});
|
||||
|
||||
testWidgets('$host: the selected tab is marked selected for assistive '
|
||||
'technology', (tester) async {
|
||||
final semantics = tester.ensureSemantics();
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.tap(find.byKey(const ValueKey('shell.destination.runs')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
tester.getSemantics(barText('Runs')),
|
||||
isSemantics(isSelected: true),
|
||||
);
|
||||
expect(
|
||||
tester.getSemantics(barText('Chat')),
|
||||
isNot(isSemantics(isSelected: true)),
|
||||
);
|
||||
semantics.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('Cupertino bar builds no Material widget', (tester) async {
|
||||
await setSize(tester, const Size(1200, 800));
|
||||
await tester.pumpWidget(shell(cupertino: true));
|
||||
expect(
|
||||
find.descendant(
|
||||
of: find.byType(FloatingDestinationBar),
|
||||
matching: find.byWidgetPredicate(
|
||||
(widget) =>
|
||||
widget is Material ||
|
||||
widget is NavigationBar ||
|
||||
widget is InkWell,
|
||||
),
|
||||
),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('phone at 320 with 2x text does not overflow', (tester) async {
|
||||
for (final cupertino in [false, true]) {
|
||||
await setSize(tester, const Size(320, 568));
|
||||
tester.platformDispatcher.textScaleFactorTestValue = 2;
|
||||
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
|
||||
await tester.pumpWidget(shell(cupertino: cupertino));
|
||||
await tester.pumpAndSettle();
|
||||
expect(tester.takeException(), isNull);
|
||||
expect(tester.getRect(pill()).width, 320 - 32);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
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';
|
||||
|
||||
void main() {
|
||||
Widget page({
|
||||
required Widget Function(BuildContext) list,
|
||||
VoidCallback? onTap,
|
||||
}) => MaterialApp(
|
||||
home: Scaffold(
|
||||
body: FloatingBarOverlay(
|
||||
bar: FloatingDestinationBar(
|
||||
cupertino: false,
|
||||
currentIndex: 0,
|
||||
onTap: (_) {},
|
||||
items: const [
|
||||
FloatingDestinationItem(icon: Icon(Icons.list), label: 'One'),
|
||||
FloatingDestinationItem(icon: Icon(Icons.map), label: 'Two'),
|
||||
],
|
||||
),
|
||||
child: GestureDetector(
|
||||
behavior: HitTestBehavior.translucent,
|
||||
onTap: onTap,
|
||||
child: Builder(builder: list),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
for (final width in [390.0, 1200.0]) {
|
||||
testWidgets('a padded list scrolls behind the bar and its last item '
|
||||
'clears it at rest (width $width)', (tester) async {
|
||||
tester.view.physicalSize = Size(width, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
await tester.pumpWidget(
|
||||
page(
|
||||
list: (context) => ListView(
|
||||
padding: withFloatingBarClearance(
|
||||
context,
|
||||
const EdgeInsets.all(16),
|
||||
),
|
||||
children: [
|
||||
for (var i = 0; i < 40; i += 1)
|
||||
SizedBox(height: 48, child: Text('Item $i')),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
final pill = tester.getRect(find.byType(GlassPill));
|
||||
// The list fills the area, behind the bar.
|
||||
expect(tester.getRect(find.byType(ListView)).bottom, 800);
|
||||
await tester.drag(find.byType(ListView), const Offset(0, -5000));
|
||||
await tester.pumpAndSettle();
|
||||
final last = tester.getRect(find.text('Item 39'));
|
||||
expect(last.bottom, lessThanOrEqualTo(pill.top));
|
||||
});
|
||||
}
|
||||
|
||||
testWidgets('taps beside a wide bar reach the content', (tester) async {
|
||||
tester.view.physicalSize = const Size(1200, 800);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
var taps = 0;
|
||||
await tester.pumpWidget(
|
||||
page(list: (_) => const SizedBox.expand(), onTap: () => taps++),
|
||||
);
|
||||
final pill = tester.getRect(find.byType(GlassPill));
|
||||
expect(pill.right, 1200 - kFloatingBarMargin);
|
||||
await tester.tapAt(Offset(pill.left - 24, pill.center.dy));
|
||||
expect(taps, 1);
|
||||
await tester.tapAt(pill.center);
|
||||
expect(taps, 1, reason: 'the bar takes its own taps');
|
||||
});
|
||||
}
|
||||
@@ -24,14 +24,10 @@ void main() {
|
||||
);
|
||||
expect(find.text('Pipelines'), findsWidgets);
|
||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||
expect(
|
||||
find.byType(NavigationBar),
|
||||
width < 600 ? findsOneWidget : findsNothing,
|
||||
);
|
||||
expect(
|
||||
find.byType(NavigationRail),
|
||||
width >= 600 ? findsOneWidget : findsNothing,
|
||||
);
|
||||
// One floating tab bar at every width; no rail.
|
||||
expect(find.byType(NavigationBar), findsOneWidget);
|
||||
expect(find.byType(NavigationRail), findsNothing);
|
||||
expect(tester.takeException(), isNull);
|
||||
await tester.tap(find.text('Runs').last);
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Runs — Not implemented'), findsOneWidget);
|
||||
@@ -53,7 +49,7 @@ void main() {
|
||||
expect(find.text('Pipelines — Not implemented'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino shell uses a sidebar on a wide window', (
|
||||
testWidgets('Cupertino shell floats its tab bar on a wide window', (
|
||||
tester,
|
||||
) async {
|
||||
tester.view.physicalSize = const Size(1280, 900);
|
||||
@@ -61,7 +57,8 @@ void main() {
|
||||
addTearDown(tester.view.resetPhysicalSize);
|
||||
addTearDown(tester.view.resetDevicePixelRatio);
|
||||
await tester.pumpWidget(const MyApp(cupertino: true));
|
||||
expect(find.byType(CupertinoTabBar), findsNothing);
|
||||
expect(find.byType(CupertinoTabBar), findsOneWidget);
|
||||
expect(find.byType(CupertinoListTile), findsNothing);
|
||||
expect(
|
||||
find.byKey(const ValueKey('shell.destination.pipelines')),
|
||||
findsOneWidget,
|
||||
|
||||
Reference in New Issue
Block a user