Remove Cupertino UI branches
Keep the public Cupertino-compatible parameters while retaining only the Material implementations and tests. The app is Material-only, so deleting unreachable Cupertino branches reduces dead code without changing the active path.
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -11,10 +10,9 @@ const _rowColor = Color(0xFFE3F2FD);
|
||||
|
||||
/// A list of three rows; tapping one pushes its page, grown from that row.
|
||||
class _List extends StatelessWidget {
|
||||
const _List({required this.sources, required this.cupertino});
|
||||
const _List({required this.sources});
|
||||
|
||||
final ContainerTransformSources sources;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => ContainerTransformScope(
|
||||
@@ -33,8 +31,8 @@ class _List extends StatelessWidget {
|
||||
onTap: () => Navigator.of(context).push(
|
||||
ContainerTransformPageRoute<void>(
|
||||
link: sources.link(() => id),
|
||||
cupertino: cupertino,
|
||||
builder: (_) => _Page(id: id, cupertino: cupertino),
|
||||
cupertino: false,
|
||||
builder: (_) => _Page(id: id),
|
||||
),
|
||||
),
|
||||
child: SizedBox(height: 72, child: Text('row $id')),
|
||||
@@ -46,42 +44,31 @@ class _List extends StatelessWidget {
|
||||
}
|
||||
|
||||
class _Page extends StatelessWidget {
|
||||
const _Page({required this.id, required this.cupertino});
|
||||
const _Page({required this.id});
|
||||
|
||||
final String id;
|
||||
final bool cupertino;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => cupertino
|
||||
? CupertinoPageScaffold(
|
||||
navigationBar: const CupertinoNavigationBar(),
|
||||
child: Center(child: Text('page $id')),
|
||||
)
|
||||
: Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(child: Text('page $id')),
|
||||
);
|
||||
Widget build(BuildContext context) => Scaffold(
|
||||
appBar: AppBar(),
|
||||
body: Center(child: Text('page $id')),
|
||||
);
|
||||
}
|
||||
|
||||
Future<ContainerTransformSources> _pump(
|
||||
WidgetTester tester, {
|
||||
bool cupertino = false,
|
||||
bool reduced = false,
|
||||
}) async {
|
||||
tester.view.physicalSize = _screen;
|
||||
tester.view.devicePixelRatio = 1;
|
||||
addTearDown(tester.view.reset);
|
||||
final sources = ContainerTransformSources();
|
||||
final home = _List(sources: sources, cupertino: cupertino);
|
||||
final home = _List(sources: sources);
|
||||
Widget media(BuildContext context, Widget? child) => MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(disableAnimations: reduced),
|
||||
child: child!,
|
||||
);
|
||||
await tester.pumpWidget(
|
||||
cupertino
|
||||
? CupertinoApp(builder: media, home: home)
|
||||
: MaterialApp(builder: media, home: home),
|
||||
);
|
||||
await tester.pumpWidget(MaterialApp(builder: media, home: home));
|
||||
return sources;
|
||||
}
|
||||
|
||||
@@ -186,7 +173,7 @@ void main() {
|
||||
ContainerTransformPageRoute<void>(
|
||||
link: sources.link(() => 'missing'),
|
||||
cupertino: false,
|
||||
builder: (_) => const _Page(id: 'x', cupertino: false),
|
||||
builder: (_) => const _Page(id: 'x'),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
@@ -196,54 +183,6 @@ void main() {
|
||||
expect(find.text('page x'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a Cupertino swipe back shrinks the page with the finger', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, cupertino: true);
|
||||
final row = tester.getRect(find.byKey(const Key('row-b')));
|
||||
await tester.tap(find.byKey(const Key('row-b')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(_surface(tester), Offset.zero & _screen);
|
||||
|
||||
final gesture = await tester.startGesture(const Offset(5, 400));
|
||||
await gesture.moveBy(const Offset(20, 0));
|
||||
await gesture.moveBy(const Offset(100, 0));
|
||||
await tester.pump();
|
||||
final early = _surface(tester);
|
||||
_expectBetween(early, row);
|
||||
await gesture.moveBy(const Offset(100, 0));
|
||||
await tester.pump();
|
||||
final later = _surface(tester);
|
||||
expect(later.height, lessThan(early.height), reason: 'follows the finger');
|
||||
|
||||
// Back toward the start edge, the page grows again.
|
||||
await gesture.moveBy(const Offset(-150, 0));
|
||||
await tester.pump();
|
||||
expect(_surface(tester).height, greaterThan(later.height));
|
||||
|
||||
await gesture.moveBy(const Offset(200, 0));
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page b'), findsNothing);
|
||||
expect(find.byKey(const Key('row-b')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('a short Cupertino swipe released early stays on the page', (
|
||||
tester,
|
||||
) async {
|
||||
await _pump(tester, cupertino: true);
|
||||
await tester.tap(find.byKey(const Key('row-b')));
|
||||
await tester.pumpAndSettle();
|
||||
final gesture = await tester.startGesture(const Offset(5, 400));
|
||||
await gesture.moveBy(const Offset(20, 0));
|
||||
await gesture.moveBy(const Offset(40, 0));
|
||||
await tester.pump();
|
||||
await gesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('page b'), findsOneWidget);
|
||||
expect(_surface(tester), Offset.zero & _screen);
|
||||
});
|
||||
|
||||
testWidgets('Android predictive back drives the shrink, then commits', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user