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:
@@ -12,8 +12,7 @@ export 'domain/file_change.dart';
|
||||
export 'domain/run_changes.dart';
|
||||
export 'domain/unified_patch.dart';
|
||||
export 'widgets/capture_section.dart' show ChangeFileRow;
|
||||
export 'widgets/change_style.dart'
|
||||
show ChangeStatText, DiffForm, hostTextTheme, usesCupertino;
|
||||
export 'widgets/change_style.dart' show ChangeStatText, DiffForm;
|
||||
export 'widgets/changes_viewer.dart';
|
||||
export 'widgets/file_diff_viewer.dart';
|
||||
export 'widgets/patch_view.dart';
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/change_capture.dart';
|
||||
@@ -63,16 +62,13 @@ class StageCaptureSection extends StatelessWidget {
|
||||
const Divider(height: 1),
|
||||
if (capture == null)
|
||||
_CaptureNote(
|
||||
icon: _noteIcon(
|
||||
context,
|
||||
pending ? _NoteKind.pending : _NoteKind.missing,
|
||||
),
|
||||
icon: _noteIcon(pending ? _NoteKind.pending : _NoteKind.missing),
|
||||
title: pending ? 'Capture pending' : 'Capture unavailable',
|
||||
detail: pending ? pendingCaptureDetail : missingCaptureDetail,
|
||||
)
|
||||
else if (capture.unavailable)
|
||||
_CaptureNote(
|
||||
icon: _noteIcon(context, _NoteKind.unavailable),
|
||||
icon: _noteIcon(_NoteKind.unavailable),
|
||||
title: 'Capture unavailable',
|
||||
detail: capture.diagnostic.isEmpty
|
||||
? unavailableCaptureDetail
|
||||
@@ -81,7 +77,6 @@ class StageCaptureSection extends StatelessWidget {
|
||||
else if (capture.files.isEmpty)
|
||||
_CaptureNote(
|
||||
icon: _noteIcon(
|
||||
context,
|
||||
capture.partial ? _NoteKind.partial : _NoteKind.empty,
|
||||
),
|
||||
title: capture.partial ? 'Partial capture' : 'No changes observed',
|
||||
@@ -114,13 +109,10 @@ class ChangeFileRow extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final mono = nativeDiffText(DefaultTextStyle.of(context).style);
|
||||
final cupertino = usesCupertino(context);
|
||||
final leading = Icon(_kindIcon(context, file.kind));
|
||||
final leading = Icon(_kindIcon(file.kind));
|
||||
final title = Text(file.path, style: mono);
|
||||
final subtitle = ChangeStatText(changeFileMeta(file));
|
||||
final trailing = cupertino
|
||||
? const CupertinoListTileChevron()
|
||||
: const Icon(Icons.chevron_right);
|
||||
const trailing = Icon(Icons.chevron_right);
|
||||
return Semantics(
|
||||
container: true,
|
||||
button: true,
|
||||
@@ -131,48 +123,17 @@ class ChangeFileRow extends StatelessWidget {
|
||||
'${changeKindTitle(file.kind)} · ${changeFileMeta(file)}',
|
||||
excludeSemantics: true,
|
||||
onTap: () => onOpen(file),
|
||||
child: cupertino
|
||||
? CupertinoListTile(
|
||||
leading: leading,
|
||||
// A recorded path is the row's identity, so it wraps instead of
|
||||
// being ellipsized to one line.
|
||||
title: _unclampedText(title),
|
||||
subtitle: _unclampedText(subtitle),
|
||||
trailing: trailing,
|
||||
onTap: () => onOpen(file),
|
||||
)
|
||||
: ListTile(
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
trailing: trailing,
|
||||
onTap: () => onOpen(file),
|
||||
),
|
||||
child: ListTile(
|
||||
leading: leading,
|
||||
title: title,
|
||||
subtitle: subtitle,
|
||||
trailing: trailing,
|
||||
onTap: () => onOpen(file),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// CupertinoListTile caps its title and subtitle at one ellipsized line through
|
||||
/// the inherited [DefaultTextStyle]. Re-establish the ambient style without that
|
||||
/// cap so a long recorded path stays readable; the tile keeps its native
|
||||
/// padding, pressed state and chevron.
|
||||
Widget _unclampedText(Widget child) {
|
||||
return Builder(
|
||||
builder: (context) {
|
||||
final inherited = DefaultTextStyle.of(context);
|
||||
return DefaultTextStyle(
|
||||
style: inherited.style,
|
||||
softWrap: true,
|
||||
overflow: TextOverflow.visible,
|
||||
textAlign: inherited.textAlign,
|
||||
textWidthBasis: inherited.textWidthBasis,
|
||||
textHeightBehavior: inherited.textHeightBehavior,
|
||||
child: child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
class _CaptureNote extends StatelessWidget {
|
||||
const _CaptureNote({
|
||||
required this.icon,
|
||||
@@ -211,28 +172,16 @@ class _CaptureNote extends StatelessWidget {
|
||||
|
||||
enum _NoteKind { missing, unavailable, empty, partial, pending }
|
||||
|
||||
IconData _noteIcon(BuildContext context, _NoteKind kind) {
|
||||
final cupertino = usesCupertino(context);
|
||||
return switch (kind) {
|
||||
_NoteKind.missing || _NoteKind.unavailable =>
|
||||
cupertino ? CupertinoIcons.exclamationmark_triangle : Icons.warning_amber,
|
||||
_NoteKind.empty =>
|
||||
cupertino ? CupertinoIcons.checkmark_circle : Icons.check_circle_outline,
|
||||
_NoteKind.partial => cupertino ? CupertinoIcons.info : Icons.info_outline,
|
||||
_NoteKind.pending => cupertino ? CupertinoIcons.clock : Icons.schedule,
|
||||
};
|
||||
}
|
||||
IconData _noteIcon(_NoteKind kind) => switch (kind) {
|
||||
_NoteKind.missing || _NoteKind.unavailable => Icons.warning_amber,
|
||||
_NoteKind.empty => Icons.check_circle_outline,
|
||||
_NoteKind.partial => Icons.info_outline,
|
||||
_NoteKind.pending => Icons.schedule,
|
||||
};
|
||||
|
||||
IconData _kindIcon(BuildContext context, ChangeKind kind) {
|
||||
final cupertino = usesCupertino(context);
|
||||
return switch (kind) {
|
||||
ChangeKind.added =>
|
||||
cupertino ? CupertinoIcons.add_circled : Icons.add_circle_outline,
|
||||
ChangeKind.deleted =>
|
||||
cupertino ? CupertinoIcons.trash : Icons.delete_outline,
|
||||
ChangeKind.modified =>
|
||||
cupertino ? CupertinoIcons.pencil : Icons.edit_outlined,
|
||||
ChangeKind.other =>
|
||||
cupertino ? CupertinoIcons.doc : Icons.description_outlined,
|
||||
};
|
||||
}
|
||||
IconData _kindIcon(ChangeKind kind) => switch (kind) {
|
||||
ChangeKind.added => Icons.add_circle_outline,
|
||||
ChangeKind.deleted => Icons.delete_outline,
|
||||
ChangeKind.modified => Icons.edit_outlined,
|
||||
ChangeKind.other => Icons.description_outlined,
|
||||
};
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../domain/unified_patch.dart';
|
||||
import 'diff_form_control.dart';
|
||||
|
||||
export 'diff_form_control.dart';
|
||||
|
||||
@@ -10,12 +8,6 @@ export 'diff_form_control.dart';
|
||||
TextStyle nativeDiffText(TextStyle base) =>
|
||||
base.copyWith(fontFamily: 'RobotoMono');
|
||||
|
||||
/// Keep Material-derived metadata roles readable inside a Cupertino host.
|
||||
ThemeData hostTextTheme(BuildContext context) => ThemeData(
|
||||
brightness: CupertinoTheme.brightnessOf(context),
|
||||
platform: Theme.of(context).platform,
|
||||
);
|
||||
|
||||
/// GitHub's diff palette (Primer): each changed line on a green or red tint,
|
||||
/// its +/- marker and the +N/-N counts in the strong green or red. The code
|
||||
/// itself keeps the label colour, as on GitHub, and the exact recorded
|
||||
@@ -45,10 +37,7 @@ ThemeData hostTextTheme(BuildContext context) => ThemeData(
|
||||
}
|
||||
|
||||
bool _isDark(BuildContext context) =>
|
||||
(usesCupertino(context)
|
||||
? CupertinoTheme.brightnessOf(context)
|
||||
: Theme.of(context).brightness) ==
|
||||
Brightness.dark;
|
||||
Theme.of(context).brightness == Brightness.dark;
|
||||
|
||||
/// Added lines and counts: GitHub's addition green.
|
||||
Color addedColor(BuildContext context) =>
|
||||
@@ -94,17 +83,14 @@ class ChangeStatText extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
Color labelColor(BuildContext context) => usesCupertino(context)
|
||||
? CupertinoColors.label.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurface;
|
||||
Color labelColor(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.onSurface;
|
||||
|
||||
Color mutedColor(BuildContext context) => usesCupertino(context)
|
||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
Color mutedColor(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||
|
||||
Color hunkHeaderColor(BuildContext context) => usesCupertino(context)
|
||||
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
Color hunkHeaderColor(BuildContext context) =>
|
||||
Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||
|
||||
Widget copyPatchControl(
|
||||
BuildContext context, {
|
||||
@@ -113,21 +99,6 @@ Widget copyPatchControl(
|
||||
required VoidCallback onPressed,
|
||||
}) {
|
||||
final label = copied ? 'Copied' : 'Copy patch';
|
||||
if (usesCupertino(context)) {
|
||||
return CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size(44, 44),
|
||||
onPressed: enabled ? onPressed : null,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
const Icon(CupertinoIcons.doc_on_doc, size: 30),
|
||||
const SizedBox(width: 8),
|
||||
Text(label),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
return TextButton.icon(
|
||||
style: TextButton.styleFrom(minimumSize: const Size(0, 48)),
|
||||
onPressed: enabled ? onPressed : null,
|
||||
@@ -137,20 +108,6 @@ Widget copyPatchControl(
|
||||
}
|
||||
|
||||
Widget closeDiffControl(BuildContext context, VoidCallback onClose) {
|
||||
if (usesCupertino(context)) {
|
||||
return Semantics(
|
||||
label: 'Close diff',
|
||||
button: true,
|
||||
excludeSemantics: true,
|
||||
onTap: onClose,
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size(44, 44),
|
||||
onPressed: onClose,
|
||||
child: const Icon(CupertinoIcons.xmark, size: 30),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
||||
padding: EdgeInsets.zero,
|
||||
|
||||
@@ -11,7 +11,6 @@ import 'file_diff_viewer.dart';
|
||||
import 'visit_pager.dart';
|
||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||
import '../../../ui/adaptive/glass_bar.dart';
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
/// The run's Changes surface: an honest final-state summary followed by the
|
||||
/// recorded stage/visit captures, with changed-filename filtering and the
|
||||
@@ -247,10 +246,7 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(8),
|
||||
child: IntrinsicWidth(
|
||||
child: GlassControlBar(
|
||||
cupertino: usesCupertinoHost(context),
|
||||
child: pager,
|
||||
),
|
||||
child: GlassControlBar(cupertino: false, child: pager),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
@@ -1,14 +1,9 @@
|
||||
import 'dart:math' as math;
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/adaptive/host.dart';
|
||||
|
||||
enum DiffForm { rendered, raw }
|
||||
|
||||
bool usesCupertino(BuildContext context) => usesCupertinoHost(context);
|
||||
|
||||
const diffFormLabels = <DiffForm, String>{
|
||||
DiffForm.rendered: 'Rendered',
|
||||
DiffForm.raw: 'Raw patch',
|
||||
@@ -17,10 +12,9 @@ const diffFormLabels = <DiffForm, String>{
|
||||
/// Conservatively choose between two stock controls using the current native
|
||||
/// label role and text scaler. This does not size or restyle either control.
|
||||
bool diffFormSegmentsFit(BuildContext context, double maxWidth) {
|
||||
final style = usesCupertino(context)
|
||||
? CupertinoTheme.of(context).textTheme.textStyle
|
||||
: Theme.of(context).textTheme.labelLarge ??
|
||||
DefaultTextStyle.of(context).style;
|
||||
final style =
|
||||
Theme.of(context).textTheme.labelLarge ??
|
||||
DefaultTextStyle.of(context).style;
|
||||
var widest = 0.0;
|
||||
for (final label in diffFormLabels.values) {
|
||||
final painter = TextPainter(
|
||||
@@ -40,24 +34,6 @@ Widget diffFormControl(
|
||||
required DiffForm form,
|
||||
required ValueChanged<DiffForm> onChanged,
|
||||
}) {
|
||||
if (usesCupertino(context)) {
|
||||
return CupertinoSlidingSegmentedControl<DiffForm>(
|
||||
groupValue: form,
|
||||
onValueChanged: (value) {
|
||||
if (value != null) onChanged(value);
|
||||
},
|
||||
children: {
|
||||
for (final entry in diffFormLabels.entries)
|
||||
entry.key: ConstrainedBox(
|
||||
constraints: const BoxConstraints(minHeight: 44),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
child: Center(child: Text(entry.value)),
|
||||
),
|
||||
),
|
||||
},
|
||||
);
|
||||
}
|
||||
return SegmentedButton<DiffForm>(
|
||||
style: ButtonStyle(minimumSize: const WidgetStatePropertyAll(Size(0, 48))),
|
||||
segments: [
|
||||
@@ -78,34 +54,6 @@ Widget diffFormMenu(
|
||||
required DiffForm form,
|
||||
required ValueChanged<DiffForm> onChanged,
|
||||
}) {
|
||||
if (usesCupertino(context)) {
|
||||
return Semantics(
|
||||
label: 'Diff form',
|
||||
button: true,
|
||||
child: CupertinoButton(
|
||||
padding: EdgeInsets.zero,
|
||||
minimumSize: const Size(44, 44),
|
||||
onPressed: () => showCupertinoModalPopup<void>(
|
||||
context: context,
|
||||
builder: (sheetContext) => CupertinoActionSheet(
|
||||
title: const Text('Diff form'),
|
||||
actions: [
|
||||
for (final entry in diffFormLabels.entries)
|
||||
CupertinoActionSheetAction(
|
||||
isDefaultAction: entry.key == form,
|
||||
onPressed: () {
|
||||
Navigator.of(sheetContext).pop();
|
||||
onChanged(entry.key);
|
||||
},
|
||||
child: Text(entry.value),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
child: const Icon(CupertinoIcons.ellipsis, size: 30),
|
||||
),
|
||||
);
|
||||
}
|
||||
return IconButton(
|
||||
tooltip: 'Diff form',
|
||||
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
||||
|
||||
@@ -2,7 +2,6 @@ import '../../../ui/adaptive/segmented_bar.dart';
|
||||
import '../../../ui/input/arrow_key_pager.dart';
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
@@ -70,7 +69,6 @@ class _FileDiffViewerState extends State<FileDiffViewer> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final file = widget.file;
|
||||
final cupertino = usesCupertino(context);
|
||||
final base = DefaultTextStyle.of(context).style;
|
||||
final mono = nativeDiffText(base);
|
||||
final stat = changeStat(file.added, file.removed);
|
||||
@@ -196,12 +194,7 @@ class _FileDiffViewerState extends State<FileDiffViewer> {
|
||||
],
|
||||
),
|
||||
),
|
||||
Divider(
|
||||
height: 16,
|
||||
color: cupertino
|
||||
? CupertinoColors.separator.resolveFrom(context)
|
||||
: Theme.of(context).dividerColor,
|
||||
),
|
||||
Divider(height: 16, color: Theme.of(context).dividerColor),
|
||||
Flexible(child: _body(context, mono)),
|
||||
],
|
||||
),
|
||||
@@ -260,11 +253,9 @@ Future<void> showFileDiffViewer(
|
||||
}) {
|
||||
final list = files == null || !files.contains(file) ? [file] : files;
|
||||
final page = FileDiffPage(files: list, initialIndex: list.indexOf(file));
|
||||
return Navigator.of(context).push<void>(
|
||||
usesCupertino(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
return Navigator.of(
|
||||
context,
|
||||
).push<void>(MaterialPageRoute<void>(builder: (_) => page));
|
||||
}
|
||||
|
||||
/// One recorded file's diff as a page, with the previous and next file of the
|
||||
@@ -286,7 +277,6 @@ class _FileDiffPageState extends State<FileDiffPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertino(context);
|
||||
final file = widget.files[_index];
|
||||
final name = file.path.split('/').last;
|
||||
final count = widget.files.length;
|
||||
@@ -321,18 +311,12 @@ class _FileDiffPageState extends State<FileDiffPage> {
|
||||
child: SafeArea(
|
||||
top: false,
|
||||
minimum: const EdgeInsets.all(8),
|
||||
child: GlassControlBar(cupertino: cupertino, child: pager),
|
||||
child: GlassControlBar(cupertino: false, child: pager),
|
||||
),
|
||||
),
|
||||
child: viewer,
|
||||
),
|
||||
);
|
||||
if (cupertino) {
|
||||
return CupertinoPageScaffold(
|
||||
navigationBar: SegmentedBar(cupertino: true, title: name),
|
||||
child: Theme(data: hostTextTheme(context), child: body),
|
||||
);
|
||||
}
|
||||
return Scaffold(
|
||||
extendBodyBehindAppBar: true,
|
||||
appBar: SegmentedBar(cupertino: false, title: name),
|
||||
|
||||
@@ -1,74 +1,32 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'change_style.dart';
|
||||
|
||||
/// The recorded raw patch bytes, one recorded line per line, in the host's own
|
||||
/// selectable body.
|
||||
/// The recorded raw patch bytes, one recorded line per line, in a selectable
|
||||
/// body.
|
||||
///
|
||||
/// Material uses [SelectionArea]; a Cupertino host has no
|
||||
/// [MaterialLocalizations], so it renders the same text in the read-only
|
||||
/// [CupertinoTextField] the run detail already uses for plain selectable text.
|
||||
/// Both forms keep their intrinsic line width, so long lines scroll sideways
|
||||
/// The text keeps its intrinsic line width, so long lines scroll sideways
|
||||
/// instead of wrapping a continuation under a new line.
|
||||
class RawPatchView extends StatefulWidget {
|
||||
class RawPatchView extends StatelessWidget {
|
||||
const RawPatchView({super.key, required this.patch, required this.style});
|
||||
|
||||
final String patch;
|
||||
final TextStyle style;
|
||||
|
||||
@override
|
||||
State<RawPatchView> createState() => _RawPatchViewState();
|
||||
}
|
||||
|
||||
class _RawPatchViewState extends State<RawPatchView> {
|
||||
late final TextEditingController _text = TextEditingController(
|
||||
text: widget.patch,
|
||||
);
|
||||
|
||||
@override
|
||||
void didUpdateWidget(RawPatchView oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.patch != _text.text) _text.text = widget.patch;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_text.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final cupertino = usesCupertino(context);
|
||||
return SingleChildScrollView(
|
||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||
child: SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: cupertino
|
||||
? IntrinsicWidth(
|
||||
child: ExcludeSemantics(
|
||||
child: CupertinoTextField(
|
||||
key: const ValueKey('raw-patch-field'),
|
||||
controller: _text,
|
||||
readOnly: true,
|
||||
maxLines: null,
|
||||
padding: EdgeInsets.zero,
|
||||
decoration: const BoxDecoration(),
|
||||
style: widget.style,
|
||||
),
|
||||
),
|
||||
)
|
||||
: ExcludeSemantics(
|
||||
child: SelectionArea(
|
||||
child: Text(
|
||||
widget.patch,
|
||||
style: widget.style,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.visible,
|
||||
),
|
||||
),
|
||||
),
|
||||
child: ExcludeSemantics(
|
||||
child: SelectionArea(
|
||||
child: Text(
|
||||
patch,
|
||||
style: style,
|
||||
softWrap: false,
|
||||
overflow: TextOverflow.visible,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../../../ui/navigation/chevron_pager.dart';
|
||||
|
||||
@@ -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';
|
||||
@@ -363,49 +362,6 @@ void main() {
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('Cupertino uses native list tiles and segmented control', (
|
||||
tester,
|
||||
) async {
|
||||
await tester.pumpWidget(
|
||||
cupertinoHost(
|
||||
ChangesViewer(
|
||||
steps: [
|
||||
stepFixture(
|
||||
fileChanges: captureFixture(
|
||||
files: [
|
||||
fileChangeFixture(
|
||||
path: 'lib/feature.dart',
|
||||
patch: multiHunkPatch,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
expect(find.byType(CupertinoListTile), findsOneWidget);
|
||||
// No filter field: the changes list shows every recorded file.
|
||||
expect(find.byType(CupertinoSearchTextField), findsNothing);
|
||||
expect(find.byType(TextField), findsNothing);
|
||||
|
||||
await tester.tap(find.byKey(const ValueKey('change-1-lib/feature.dart')));
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byType(CupertinoSlidingSegmentedControl<DiffForm>),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Rendered'), findsOneWidget);
|
||||
expect(find.text('Raw patch'), findsOneWidget);
|
||||
|
||||
await tester.pageBack();
|
||||
await tester.pumpAndSettle();
|
||||
expect(
|
||||
find.byType(CupertinoSlidingSegmentedControl<DiffForm>),
|
||||
findsNothing,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('narrow viewport and large text keep every control reachable', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// The two platform hosts the Changes widget tests share: Material for
|
||||
/// Android/desktop/web and Cupertino for iOS/macOS. They state the platform
|
||||
/// explicitly instead of mutating a global debug override.
|
||||
/// The host the Changes widget tests share. The app is Material-only on every
|
||||
/// platform, so the tests state the host explicitly instead of mutating a
|
||||
/// global debug override.
|
||||
Widget materialHost(
|
||||
Widget child, {
|
||||
TextScaler scaler = TextScaler.noScaling,
|
||||
@@ -18,24 +17,3 @@ Widget materialHost(
|
||||
home: Scaffold(body: child),
|
||||
);
|
||||
}
|
||||
|
||||
Widget cupertinoHost(
|
||||
Widget child, {
|
||||
TextScaler scaler = TextScaler.noScaling,
|
||||
Brightness brightness = Brightness.light,
|
||||
}) {
|
||||
return CupertinoApp(
|
||||
theme: CupertinoThemeData(brightness: brightness),
|
||||
builder: (context, app) => Theme(
|
||||
// The real app selects Cupertino by platform; the test host states it
|
||||
// explicitly without changing a global debug override. The Theme wraps
|
||||
// the Navigator so dialogs opened later resolve the same platform.
|
||||
data: ThemeData(platform: TargetPlatform.iOS),
|
||||
child: MediaQuery(
|
||||
data: MediaQuery.of(context).copyWith(textScaler: scaler),
|
||||
child: app!,
|
||||
),
|
||||
),
|
||||
home: CupertinoPageScaffold(child: SafeArea(child: child)),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user