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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user