Remove Cupertino changes branches

Keep the Material-only changes feature while preserving public Cupertino parameters for callers. Remove Cupertino-only widgets, imports, hosts, and tests because the app never reaches that path.
This commit is contained in:
2026-11-11 16:22:09 +00:00
parent 4b4628f35c
commit edc503b228
11 changed files with 122 additions and 514 deletions
@@ -1,4 +1,3 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/services.dart';
@@ -219,81 +218,6 @@ void main() {
);
});
testWidgets('the Cupertino raw patch is a native selectable field', (
tester,
) async {
await tester.pumpWidget(
cupertinoHost(
SizedBox(
height: 400,
child: FileDiffViewer(
file: FileChange(
path: 'lib/feature.dart',
kind: ChangeKind.modified,
patch: multiHunkPatch,
),
),
),
),
);
await tester.tap(find.text('Raw patch'));
await tester.pumpAndSettle();
// A CupertinoApp has no MaterialLocalizations, so Raw must not use the
// Material SelectionArea; it renders the recorded bytes in a native field.
expect(tester.takeException(), isNull);
expect(find.byType(SelectionArea), findsNothing);
final field = tester.widget<CupertinoTextField>(
find.byKey(const ValueKey('raw-patch-field')),
);
expect(field.readOnly, isTrue);
expect(field.maxLines, isNull);
expect(field.controller?.text, multiHunkPatch);
expect(
find.ancestor(
of: find.byKey(const ValueKey('raw-patch-field')),
matching: find.byWidgetPredicate(
(widget) =>
widget is SingleChildScrollView &&
widget.scrollDirection == Axis.horizontal,
),
),
findsOneWidget,
);
});
testWidgets('a Cupertino row wraps its recorded path instead of clipping it', (
tester,
) async {
tester.view.physicalSize = const Size(320, 720);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
const path =
'lib/features/changes/domain/a_rather_long_unified_patch_file_name.dart';
await tester.pumpWidget(
cupertinoHost(
ChangesViewer(
steps: [
stepFixture(
fileChanges: captureFixture(
files: [fileChangeFixture(path: path, patch: multiHunkPatch)],
),
),
],
),
),
);
final rich = tester
.widgetList<RichText>(find.byType(RichText))
.firstWhere((widget) => widget.text.toPlainText() == path);
// CupertinoListTile caps a title at one ellipsized line; the row must lift
// that cap so the filename stays visible.
expect(rich.maxLines, isNull);
expect(rich.overflow, TextOverflow.visible);
expect(tester.getSize(find.text(path)).height, greaterThan(30));
expect(tester.takeException(), isNull);
});
testWidgets('a file opens as a page that steps to the previous and next '
'file', (tester) async {
tester.view.physicalSize = const Size(390, 844);
@@ -341,112 +265,72 @@ void main() {
patch: multiHunkPatch,
);
for (final cupertino in [false, true]) {
final host = cupertino ? 'Cupertino' : 'Material';
testWidgets('$host diff labels stay whole at 320x720 with 2x text', (
tester,
) async {
tester.view.physicalSize = const Size(320, 720);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final opener = _diffDialogOpener(diffFile);
await tester.pumpWidget(
cupertino
? cupertinoHost(opener, scaler: const TextScaler.linear(2))
: materialHost(opener, scaler: const TextScaler.linear(2)),
);
await tester.tap(find.text('Open diff'));
await tester.pumpAndSettle();
// A segmented control cannot keep both fixed words at this size, so the
// host's native menu carries them instead. "Rendered" used to break
// mid-word and "Raw patch" used to be clipped to "Raw".
expect(find.byType(SegmentedButton<DiffForm>), findsNothing);
expect(
find.byType(CupertinoSlidingSegmentedControl<DiffForm>),
findsNothing,
);
// Copy patch stays a standard action at intrinsic width; it must not
// break its two words either.
_expectWholeLabel(tester, find.text('Copy patch'), 'Copy patch');
await tester.tap(
cupertino
? find.byIcon(CupertinoIcons.ellipsis)
: find.byTooltip('Diff form'),
);
await tester.pumpAndSettle();
final items = cupertino
? find.byType(CupertinoActionSheetAction)
: find.byType(ListTile);
expect(items, findsNWidgets(2));
for (final label in ['Rendered', 'Raw patch']) {
_expectWholeLabel(
tester,
find.descendant(of: items, matching: find.text(label)),
label,
);
}
await tester.tap(
find.descendant(of: items, matching: find.text('Raw patch')),
);
await tester.pumpAndSettle();
if (cupertino) {
expect(find.byKey(const ValueKey('raw-patch-field')), findsOneWidget);
} else {
expect(find.text(multiHunkPatch), findsOneWidget);
}
expect(tester.takeException(), isNull);
});
}
for (final cupertino in [false, true]) {
testWidgets(
'${cupertino ? 'Cupertino' : 'Material'} wide host keeps the native '
'segmented control',
(tester) async {
await tester.pumpWidget(
cupertino
? cupertinoHost(_diffDialogOpener(diffFile))
: materialHost(_diffDialogOpener(diffFile)),
);
await tester.tap(find.text('Open diff'));
await tester.pumpAndSettle();
final control = cupertino
? find.byType(CupertinoSlidingSegmentedControl<DiffForm>)
: find.byType(SegmentedButton<DiffForm>);
expect(control, findsOneWidget);
expect(tester.getSize(control).height, greaterThanOrEqualTo(44));
expect(find.text('Rendered'), findsOneWidget);
expect(find.text('Raw patch'), findsOneWidget);
expect(tester.takeException(), isNull);
},
testWidgets('diff labels stay whole at 320x720 with 2x text', (tester) async {
tester.view.physicalSize = const Size(320, 720);
tester.view.devicePixelRatio = 1;
addTearDown(tester.view.reset);
final opener = _diffDialogOpener(diffFile);
await tester.pumpWidget(
materialHost(opener, scaler: const TextScaler.linear(2)),
);
}
await tester.tap(find.text('Open diff'));
await tester.pumpAndSettle();
for (final cupertino in [false, true]) {
testWidgets('Escape closes the full-screen diff '
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
final file = FileChange(
path: 'lib/first.dart',
kind: ChangeKind.modified,
patch: _raggedPatch,
// A segmented control cannot keep both fixed words at this size, so the
// diff form menu carries them instead. "Rendered" used to break
// mid-word and "Raw patch" used to be clipped to "Raw".
expect(find.byType(SegmentedButton<DiffForm>), findsNothing);
// Copy patch stays a standard action at intrinsic width; it must not
// break its two words either.
_expectWholeLabel(tester, find.text('Copy patch'), 'Copy patch');
await tester.tap(find.byTooltip('Diff form'));
await tester.pumpAndSettle();
final items = find.byType(ListTile);
expect(items, findsNWidgets(2));
for (final label in ['Rendered', 'Raw patch']) {
_expectWholeLabel(
tester,
find.descendant(of: items, matching: find.text(label)),
label,
);
final opener = _diffDialogOpener(file);
await tester.pumpWidget(
cupertino ? cupertinoHost(opener) : materialHost(opener),
);
await tester.tap(find.text('Open diff'));
await tester.pumpAndSettle();
expect(find.byType(FileDiffPage), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(FileDiffPage), findsNothing);
expect(find.text('Open diff'), findsOneWidget);
});
}
}
await tester.tap(
find.descendant(of: items, matching: find.text('Raw patch')),
);
await tester.pumpAndSettle();
expect(find.text(multiHunkPatch), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('wide host keeps the native segmented control', (tester) async {
await tester.pumpWidget(materialHost(_diffDialogOpener(diffFile)));
await tester.tap(find.text('Open diff'));
await tester.pumpAndSettle();
final control = find.byType(SegmentedButton<DiffForm>);
expect(control, findsOneWidget);
expect(tester.getSize(control).height, greaterThanOrEqualTo(44));
expect(find.text('Rendered'), findsOneWidget);
expect(find.text('Raw patch'), findsOneWidget);
expect(tester.takeException(), isNull);
});
testWidgets('Escape closes the full-screen diff', (tester) async {
final file = FileChange(
path: 'lib/first.dart',
kind: ChangeKind.modified,
patch: _raggedPatch,
);
await tester.pumpWidget(materialHost(_diffDialogOpener(file)));
await tester.tap(find.text('Open diff'));
await tester.pumpAndSettle();
expect(find.byType(FileDiffPage), findsOneWidget);
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
await tester.pumpAndSettle();
expect(find.byType(FileDiffPage), findsNothing);
expect(find.text('Open diff'), findsOneWidget);
});
}