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:
2026-11-11 03:48:41 +00:00
parent baac6eca9a
commit 9bdabb32d9
33 changed files with 1646 additions and 2326 deletions
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_cupertino.dart';
import 'package:pipelines_app/features/chat/ui/sessions/session_list_material.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
@@ -9,114 +7,88 @@ import 'package:pipelines_app/shell/list_detail.dart';
import 'package:pipelines_app/ui/adaptive/floating_destination_bar.dart';
void main() {
for (final cupertino in [false, true]) {
for (final scale in [1.0, 2.0]) {
testWidgets(
'chat list stays above labeled navigation ($cupertino, $scale)',
(tester) async {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(tester.view.reset);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
String? opened;
final sessions = [
for (var i = 0; i < 14; i++)
{
'id': 's$i',
'title': 'Chat item $i',
'model': 'model',
'directory': '/work/project-$i',
},
];
Widget list() => cupertino
? CupertinoSessionList(
sections: [(title: 'Chats', sessions: sessions)],
emptyMessage: null,
duplicateTitles: const {},
onOpen: (row) => opened = row['id'] as String,
onRename: (_) {},
onClose: (_) {},
onReopen: (_) {},
onStar: (_) {},
onHide: (_) {},
onClearSearch: null,
isUnseen: (_) => false,
errorFor: (_) => null,
)
: MaterialSessionList(
sections: [(title: 'Chats', sessions: sessions)],
emptyMessage: null,
duplicateTitles: const {},
onOpen: (row) => opened = row['id'] as String,
onRename: (_) {},
onClose: (_) {},
onReopen: (_) {},
onStar: (_) {},
onHide: (_) {},
onClearSearch: null,
isUnseen: (_) => false,
errorFor: (_) => null,
);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) => ListDetailPanes(
list: list(),
detail: const SizedBox.expand(),
),
},
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
await tester.pumpAndSettle();
final navigation = tester.getRect(
find.byKey(FloatingDestinationBar.rowKey),
);
final scrollView = find.byType(CustomScrollView);
final viewport = tester.getRect(scrollView);
expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5));
expect(viewport.width, greaterThan(0));
final scrollable = tester.state<ScrollableState>(
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
);
scrollable.position.jumpTo(scrollable.position.maxScrollExtent);
await tester.pumpAndSettle();
final last = find.byKey(const Key('chat-row-s13'));
expect(
tester.getRect(last).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
final metadata = find.descendant(
of: last,
matching: find.text('model · /work/project-13'),
);
expect(metadata, findsOneWidget);
expect(
tester.getRect(metadata).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
await tester.tap(find.text('Chat item 13'));
await tester.pump();
expect(opened, 's13');
final retainedOffset = scrollable.position.pixels;
tester.view.physicalSize = const Size(1440, 900);
await tester.pumpAndSettle();
expect(
tester.state<ScrollableState>(
find.descendant(
of: scrollView,
matching: find.byType(Scrollable),
),
),
same(scrollable),
);
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
expect(tester.takeException(), isNull);
for (final scale in [1.0, 2.0]) {
testWidgets('chat list stays above labeled navigation ($scale)', (
tester,
) async {
tester.view.physicalSize = const Size(1200, 900);
tester.view.devicePixelRatio = 1;
tester.platformDispatcher.textScaleFactorTestValue = scale;
addTearDown(tester.view.reset);
addTearDown(tester.platformDispatcher.clearTextScaleFactorTestValue);
String? opened;
final sessions = [
for (var i = 0; i < 14; i++)
{
'id': 's$i',
'title': 'Chat item $i',
'model': 'model',
'directory': '/work/project-$i',
},
];
Widget list() => MaterialSessionList(
sections: [(title: 'Chats', sessions: sessions)],
emptyMessage: null,
duplicateTitles: const {},
onOpen: (row) => opened = row['id'] as String,
onRename: (_) {},
onClose: (_) {},
onReopen: (_) {},
onStar: (_) {},
onHide: (_) {},
onClearSearch: null,
isUnseen: (_) => false,
errorFor: (_) => null,
);
final shell = AdaptiveShell(
destination: AppDestination.chat,
destinationBodies: {
AppDestination.chat: (_) =>
ListDetailPanes(list: list(), detail: const SizedBox.expand()),
},
);
}
await tester.pumpWidget(MaterialApp(home: shell));
await tester.pumpAndSettle();
final navigation = tester.getRect(
find.byKey(FloatingDestinationBar.rowKey),
);
final scrollView = find.byType(CustomScrollView);
final viewport = tester.getRect(scrollView);
expect(viewport.bottom, lessThanOrEqualTo(navigation.top + .5));
expect(viewport.width, greaterThan(0));
final scrollable = tester.state<ScrollableState>(
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
);
scrollable.position.jumpTo(scrollable.position.maxScrollExtent);
await tester.pumpAndSettle();
final last = find.byKey(const Key('chat-row-s13'));
expect(
tester.getRect(last).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
final metadata = find.descendant(
of: last,
matching: find.text('model · /work/project-13'),
);
expect(metadata, findsOneWidget);
expect(
tester.getRect(metadata).bottom,
lessThanOrEqualTo(navigation.top + .5),
);
await tester.tap(find.text('Chat item 13'));
await tester.pump();
expect(opened, 's13');
final retainedOffset = scrollable.position.pixels;
tester.view.physicalSize = const Size(1440, 900);
await tester.pumpAndSettle();
expect(
tester.state<ScrollableState>(
find.descendant(of: scrollView, matching: find.byType(Scrollable)),
),
same(scrollable),
);
expect(scrollable.position.pixels, closeTo(retainedOffset, .5));
expect(tester.takeException(), isNull);
});
}
}
@@ -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/core/transport/pipelines_client.dart'
@@ -9,22 +8,18 @@ import 'package:pipelines_app/features/settings/settings_store.dart';
import 'package:pipelines_app/shell/adaptive_shell.dart';
import 'package:pipelines_app/shell/destination.dart';
import 'package:pipelines_app/ui/adaptive/segmented_bar.dart';
import 'package:pipelines_app/ui/theme/app_theme.dart';
import 'fake_channel.dart';
/// Settings as the shell's tab: the page runs behind the shell's bar, and on
/// Cupertino the grouped background reaches the top edge with the bar's
/// scrim in the same colour, so no white band or seam shows under the bar.
/// Settings as the shell's tab: the page runs behind the shell's bar.
void main() {
Future<void> pump(WidgetTester tester, {required bool cupertino}) async {
Future<void> pump(WidgetTester tester) async {
await tester.binding.setSurfaceSize(const Size(560, 1000));
addTearDown(() => tester.binding.setSurfaceSize(null));
final factory = FakeChannelFactory();
final client = transport.PipelinesClient(channelFactory: factory.call);
addTearDown(client.dispose);
final shell = AdaptiveShell(
cupertino: cupertino,
destination: AppDestination.settings,
destinationBodies: {
AppDestination.settings: (_) => SettingsScreen(
@@ -34,9 +29,7 @@ void main() {
),
},
);
await tester.pumpWidget(
cupertino ? CupertinoApp(home: shell) : MaterialApp(home: shell),
);
await tester.pumpWidget(MaterialApp(home: shell));
await tester.pump();
await tester.pump();
}
@@ -52,34 +45,8 @@ void main() {
)
.color;
testWidgets('Cupertino: the grouped background runs under the bar', (
tester,
) async {
await pump(tester, cupertino: true);
final grouped = AppColors.groupedBackground.color.toARGB32();
expect(scrimOf(tester).toARGB32(), grouped);
// The page's background starts at the top edge, behind the bar.
final page = find.ancestor(
of: find.byKey(const ValueKey<String>('settings.scroll')),
matching: find.byWidgetPredicate(
(widget) => widget is ColoredBox && widget.color.toARGB32() == grouped,
),
);
expect(page, findsWidgets);
expect(tester.getTopLeft(page.last).dy, 0);
// The groups start below the bar and persistent category selector.
final bar = tester.getRect(find.byType(SegmentedBar));
expect(
tester.getTopLeft(find.byType(SettingsGroup).first).dy,
greaterThanOrEqualTo(bar.bottom - 8),
);
});
testWidgets('Material: the bar keeps the shell page background', (
tester,
) async {
await pump(tester, cupertino: false);
testWidgets('the bar keeps the shell page background', (tester) async {
await pump(tester);
final context = tester.element(find.byType(SettingsGroup).first);
expect(