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/run_changes.dart';
|
||||||
export 'domain/unified_patch.dart';
|
export 'domain/unified_patch.dart';
|
||||||
export 'widgets/capture_section.dart' show ChangeFileRow;
|
export 'widgets/capture_section.dart' show ChangeFileRow;
|
||||||
export 'widgets/change_style.dart'
|
export 'widgets/change_style.dart' show ChangeStatText, DiffForm;
|
||||||
show ChangeStatText, DiffForm, hostTextTheme, usesCupertino;
|
|
||||||
export 'widgets/changes_viewer.dart';
|
export 'widgets/changes_viewer.dart';
|
||||||
export 'widgets/file_diff_viewer.dart';
|
export 'widgets/file_diff_viewer.dart';
|
||||||
export 'widgets/patch_view.dart';
|
export 'widgets/patch_view.dart';
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../domain/change_capture.dart';
|
import '../domain/change_capture.dart';
|
||||||
@@ -63,16 +62,13 @@ class StageCaptureSection extends StatelessWidget {
|
|||||||
const Divider(height: 1),
|
const Divider(height: 1),
|
||||||
if (capture == null)
|
if (capture == null)
|
||||||
_CaptureNote(
|
_CaptureNote(
|
||||||
icon: _noteIcon(
|
icon: _noteIcon(pending ? _NoteKind.pending : _NoteKind.missing),
|
||||||
context,
|
|
||||||
pending ? _NoteKind.pending : _NoteKind.missing,
|
|
||||||
),
|
|
||||||
title: pending ? 'Capture pending' : 'Capture unavailable',
|
title: pending ? 'Capture pending' : 'Capture unavailable',
|
||||||
detail: pending ? pendingCaptureDetail : missingCaptureDetail,
|
detail: pending ? pendingCaptureDetail : missingCaptureDetail,
|
||||||
)
|
)
|
||||||
else if (capture.unavailable)
|
else if (capture.unavailable)
|
||||||
_CaptureNote(
|
_CaptureNote(
|
||||||
icon: _noteIcon(context, _NoteKind.unavailable),
|
icon: _noteIcon(_NoteKind.unavailable),
|
||||||
title: 'Capture unavailable',
|
title: 'Capture unavailable',
|
||||||
detail: capture.diagnostic.isEmpty
|
detail: capture.diagnostic.isEmpty
|
||||||
? unavailableCaptureDetail
|
? unavailableCaptureDetail
|
||||||
@@ -81,7 +77,6 @@ class StageCaptureSection extends StatelessWidget {
|
|||||||
else if (capture.files.isEmpty)
|
else if (capture.files.isEmpty)
|
||||||
_CaptureNote(
|
_CaptureNote(
|
||||||
icon: _noteIcon(
|
icon: _noteIcon(
|
||||||
context,
|
|
||||||
capture.partial ? _NoteKind.partial : _NoteKind.empty,
|
capture.partial ? _NoteKind.partial : _NoteKind.empty,
|
||||||
),
|
),
|
||||||
title: capture.partial ? 'Partial capture' : 'No changes observed',
|
title: capture.partial ? 'Partial capture' : 'No changes observed',
|
||||||
@@ -114,13 +109,10 @@ class ChangeFileRow extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final mono = nativeDiffText(DefaultTextStyle.of(context).style);
|
final mono = nativeDiffText(DefaultTextStyle.of(context).style);
|
||||||
final cupertino = usesCupertino(context);
|
final leading = Icon(_kindIcon(file.kind));
|
||||||
final leading = Icon(_kindIcon(context, file.kind));
|
|
||||||
final title = Text(file.path, style: mono);
|
final title = Text(file.path, style: mono);
|
||||||
final subtitle = ChangeStatText(changeFileMeta(file));
|
final subtitle = ChangeStatText(changeFileMeta(file));
|
||||||
final trailing = cupertino
|
const trailing = Icon(Icons.chevron_right);
|
||||||
? const CupertinoListTileChevron()
|
|
||||||
: const Icon(Icons.chevron_right);
|
|
||||||
return Semantics(
|
return Semantics(
|
||||||
container: true,
|
container: true,
|
||||||
button: true,
|
button: true,
|
||||||
@@ -131,48 +123,17 @@ class ChangeFileRow extends StatelessWidget {
|
|||||||
'${changeKindTitle(file.kind)} · ${changeFileMeta(file)}',
|
'${changeKindTitle(file.kind)} · ${changeFileMeta(file)}',
|
||||||
excludeSemantics: true,
|
excludeSemantics: true,
|
||||||
onTap: () => onOpen(file),
|
onTap: () => onOpen(file),
|
||||||
child: cupertino
|
child: ListTile(
|
||||||
? CupertinoListTile(
|
leading: leading,
|
||||||
leading: leading,
|
title: title,
|
||||||
// A recorded path is the row's identity, so it wraps instead of
|
subtitle: subtitle,
|
||||||
// being ellipsized to one line.
|
trailing: trailing,
|
||||||
title: _unclampedText(title),
|
onTap: () => onOpen(file),
|
||||||
subtitle: _unclampedText(subtitle),
|
),
|
||||||
trailing: trailing,
|
|
||||||
onTap: () => onOpen(file),
|
|
||||||
)
|
|
||||||
: 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 {
|
class _CaptureNote extends StatelessWidget {
|
||||||
const _CaptureNote({
|
const _CaptureNote({
|
||||||
required this.icon,
|
required this.icon,
|
||||||
@@ -211,28 +172,16 @@ class _CaptureNote extends StatelessWidget {
|
|||||||
|
|
||||||
enum _NoteKind { missing, unavailable, empty, partial, pending }
|
enum _NoteKind { missing, unavailable, empty, partial, pending }
|
||||||
|
|
||||||
IconData _noteIcon(BuildContext context, _NoteKind kind) {
|
IconData _noteIcon(_NoteKind kind) => switch (kind) {
|
||||||
final cupertino = usesCupertino(context);
|
_NoteKind.missing || _NoteKind.unavailable => Icons.warning_amber,
|
||||||
return switch (kind) {
|
_NoteKind.empty => Icons.check_circle_outline,
|
||||||
_NoteKind.missing || _NoteKind.unavailable =>
|
_NoteKind.partial => Icons.info_outline,
|
||||||
cupertino ? CupertinoIcons.exclamationmark_triangle : Icons.warning_amber,
|
_NoteKind.pending => Icons.schedule,
|
||||||
_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 _kindIcon(BuildContext context, ChangeKind kind) {
|
IconData _kindIcon(ChangeKind kind) => switch (kind) {
|
||||||
final cupertino = usesCupertino(context);
|
ChangeKind.added => Icons.add_circle_outline,
|
||||||
return switch (kind) {
|
ChangeKind.deleted => Icons.delete_outline,
|
||||||
ChangeKind.added =>
|
ChangeKind.modified => Icons.edit_outlined,
|
||||||
cupertino ? CupertinoIcons.add_circled : Icons.add_circle_outline,
|
ChangeKind.other => Icons.description_outlined,
|
||||||
ChangeKind.deleted =>
|
};
|
||||||
cupertino ? CupertinoIcons.trash : Icons.delete_outline,
|
|
||||||
ChangeKind.modified =>
|
|
||||||
cupertino ? CupertinoIcons.pencil : Icons.edit_outlined,
|
|
||||||
ChangeKind.other =>
|
|
||||||
cupertino ? CupertinoIcons.doc : Icons.description_outlined,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../domain/unified_patch.dart';
|
import '../domain/unified_patch.dart';
|
||||||
import 'diff_form_control.dart';
|
|
||||||
|
|
||||||
export 'diff_form_control.dart';
|
export 'diff_form_control.dart';
|
||||||
|
|
||||||
@@ -10,12 +8,6 @@ export 'diff_form_control.dart';
|
|||||||
TextStyle nativeDiffText(TextStyle base) =>
|
TextStyle nativeDiffText(TextStyle base) =>
|
||||||
base.copyWith(fontFamily: 'RobotoMono');
|
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,
|
/// 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
|
/// 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
|
/// 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) =>
|
bool _isDark(BuildContext context) =>
|
||||||
(usesCupertino(context)
|
Theme.of(context).brightness == Brightness.dark;
|
||||||
? CupertinoTheme.brightnessOf(context)
|
|
||||||
: Theme.of(context).brightness) ==
|
|
||||||
Brightness.dark;
|
|
||||||
|
|
||||||
/// Added lines and counts: GitHub's addition green.
|
/// Added lines and counts: GitHub's addition green.
|
||||||
Color addedColor(BuildContext context) =>
|
Color addedColor(BuildContext context) =>
|
||||||
@@ -94,17 +83,14 @@ class ChangeStatText extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Color labelColor(BuildContext context) => usesCupertino(context)
|
Color labelColor(BuildContext context) =>
|
||||||
? CupertinoColors.label.resolveFrom(context)
|
Theme.of(context).colorScheme.onSurface;
|
||||||
: Theme.of(context).colorScheme.onSurface;
|
|
||||||
|
|
||||||
Color mutedColor(BuildContext context) => usesCupertino(context)
|
Color mutedColor(BuildContext context) =>
|
||||||
? CupertinoColors.secondaryLabel.resolveFrom(context)
|
Theme.of(context).colorScheme.onSurfaceVariant;
|
||||||
: Theme.of(context).colorScheme.onSurfaceVariant;
|
|
||||||
|
|
||||||
Color hunkHeaderColor(BuildContext context) => usesCupertino(context)
|
Color hunkHeaderColor(BuildContext context) =>
|
||||||
? CupertinoColors.tertiarySystemFill.resolveFrom(context)
|
Theme.of(context).colorScheme.surfaceContainerHighest;
|
||||||
: Theme.of(context).colorScheme.surfaceContainerHighest;
|
|
||||||
|
|
||||||
Widget copyPatchControl(
|
Widget copyPatchControl(
|
||||||
BuildContext context, {
|
BuildContext context, {
|
||||||
@@ -113,21 +99,6 @@ Widget copyPatchControl(
|
|||||||
required VoidCallback onPressed,
|
required VoidCallback onPressed,
|
||||||
}) {
|
}) {
|
||||||
final label = copied ? 'Copied' : 'Copy patch';
|
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(
|
return TextButton.icon(
|
||||||
style: TextButton.styleFrom(minimumSize: const Size(0, 48)),
|
style: TextButton.styleFrom(minimumSize: const Size(0, 48)),
|
||||||
onPressed: enabled ? onPressed : null,
|
onPressed: enabled ? onPressed : null,
|
||||||
@@ -137,20 +108,6 @@ Widget copyPatchControl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
Widget closeDiffControl(BuildContext context, VoidCallback onClose) {
|
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(
|
return IconButton(
|
||||||
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import 'file_diff_viewer.dart';
|
|||||||
import 'visit_pager.dart';
|
import 'visit_pager.dart';
|
||||||
import '../../../ui/adaptive/floating_bar_layout.dart';
|
import '../../../ui/adaptive/floating_bar_layout.dart';
|
||||||
import '../../../ui/adaptive/glass_bar.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
|
/// The run's Changes surface: an honest final-state summary followed by the
|
||||||
/// recorded stage/visit captures, with changed-filename filtering and the
|
/// recorded stage/visit captures, with changed-filename filtering and the
|
||||||
@@ -247,10 +246,7 @@ class _ChangesViewerState extends State<ChangesViewer> {
|
|||||||
child: Padding(
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(8),
|
padding: const EdgeInsets.all(8),
|
||||||
child: IntrinsicWidth(
|
child: IntrinsicWidth(
|
||||||
child: GlassControlBar(
|
child: GlassControlBar(cupertino: false, child: pager),
|
||||||
cupertino: usesCupertinoHost(context),
|
|
||||||
child: pager,
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -1,14 +1,9 @@
|
|||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/adaptive/host.dart';
|
|
||||||
|
|
||||||
enum DiffForm { rendered, raw }
|
enum DiffForm { rendered, raw }
|
||||||
|
|
||||||
bool usesCupertino(BuildContext context) => usesCupertinoHost(context);
|
|
||||||
|
|
||||||
const diffFormLabels = <DiffForm, String>{
|
const diffFormLabels = <DiffForm, String>{
|
||||||
DiffForm.rendered: 'Rendered',
|
DiffForm.rendered: 'Rendered',
|
||||||
DiffForm.raw: 'Raw patch',
|
DiffForm.raw: 'Raw patch',
|
||||||
@@ -17,10 +12,9 @@ const diffFormLabels = <DiffForm, String>{
|
|||||||
/// Conservatively choose between two stock controls using the current native
|
/// Conservatively choose between two stock controls using the current native
|
||||||
/// label role and text scaler. This does not size or restyle either control.
|
/// label role and text scaler. This does not size or restyle either control.
|
||||||
bool diffFormSegmentsFit(BuildContext context, double maxWidth) {
|
bool diffFormSegmentsFit(BuildContext context, double maxWidth) {
|
||||||
final style = usesCupertino(context)
|
final style =
|
||||||
? CupertinoTheme.of(context).textTheme.textStyle
|
Theme.of(context).textTheme.labelLarge ??
|
||||||
: Theme.of(context).textTheme.labelLarge ??
|
DefaultTextStyle.of(context).style;
|
||||||
DefaultTextStyle.of(context).style;
|
|
||||||
var widest = 0.0;
|
var widest = 0.0;
|
||||||
for (final label in diffFormLabels.values) {
|
for (final label in diffFormLabels.values) {
|
||||||
final painter = TextPainter(
|
final painter = TextPainter(
|
||||||
@@ -40,24 +34,6 @@ Widget diffFormControl(
|
|||||||
required DiffForm form,
|
required DiffForm form,
|
||||||
required ValueChanged<DiffForm> onChanged,
|
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>(
|
return SegmentedButton<DiffForm>(
|
||||||
style: ButtonStyle(minimumSize: const WidgetStatePropertyAll(Size(0, 48))),
|
style: ButtonStyle(minimumSize: const WidgetStatePropertyAll(Size(0, 48))),
|
||||||
segments: [
|
segments: [
|
||||||
@@ -78,34 +54,6 @@ Widget diffFormMenu(
|
|||||||
required DiffForm form,
|
required DiffForm form,
|
||||||
required ValueChanged<DiffForm> onChanged,
|
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(
|
return IconButton(
|
||||||
tooltip: 'Diff form',
|
tooltip: 'Diff form',
|
||||||
constraints: const BoxConstraints(minWidth: 48, minHeight: 48),
|
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 '../../../ui/input/arrow_key_pager.dart';
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
@@ -70,7 +69,6 @@ class _FileDiffViewerState extends State<FileDiffViewer> {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final file = widget.file;
|
final file = widget.file;
|
||||||
final cupertino = usesCupertino(context);
|
|
||||||
final base = DefaultTextStyle.of(context).style;
|
final base = DefaultTextStyle.of(context).style;
|
||||||
final mono = nativeDiffText(base);
|
final mono = nativeDiffText(base);
|
||||||
final stat = changeStat(file.added, file.removed);
|
final stat = changeStat(file.added, file.removed);
|
||||||
@@ -196,12 +194,7 @@ class _FileDiffViewerState extends State<FileDiffViewer> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
Divider(
|
Divider(height: 16, color: Theme.of(context).dividerColor),
|
||||||
height: 16,
|
|
||||||
color: cupertino
|
|
||||||
? CupertinoColors.separator.resolveFrom(context)
|
|
||||||
: Theme.of(context).dividerColor,
|
|
||||||
),
|
|
||||||
Flexible(child: _body(context, mono)),
|
Flexible(child: _body(context, mono)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -260,11 +253,9 @@ Future<void> showFileDiffViewer(
|
|||||||
}) {
|
}) {
|
||||||
final list = files == null || !files.contains(file) ? [file] : files;
|
final list = files == null || !files.contains(file) ? [file] : files;
|
||||||
final page = FileDiffPage(files: list, initialIndex: list.indexOf(file));
|
final page = FileDiffPage(files: list, initialIndex: list.indexOf(file));
|
||||||
return Navigator.of(context).push<void>(
|
return Navigator.of(
|
||||||
usesCupertino(context)
|
context,
|
||||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
).push<void>(MaterialPageRoute<void>(builder: (_) => page));
|
||||||
: MaterialPageRoute<void>(builder: (_) => page),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One recorded file's diff as a page, with the previous and next file of the
|
/// 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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertino(context);
|
|
||||||
final file = widget.files[_index];
|
final file = widget.files[_index];
|
||||||
final name = file.path.split('/').last;
|
final name = file.path.split('/').last;
|
||||||
final count = widget.files.length;
|
final count = widget.files.length;
|
||||||
@@ -321,18 +311,12 @@ class _FileDiffPageState extends State<FileDiffPage> {
|
|||||||
child: SafeArea(
|
child: SafeArea(
|
||||||
top: false,
|
top: false,
|
||||||
minimum: const EdgeInsets.all(8),
|
minimum: const EdgeInsets.all(8),
|
||||||
child: GlassControlBar(cupertino: cupertino, child: pager),
|
child: GlassControlBar(cupertino: false, child: pager),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
child: viewer,
|
child: viewer,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
if (cupertino) {
|
|
||||||
return CupertinoPageScaffold(
|
|
||||||
navigationBar: SegmentedBar(cupertino: true, title: name),
|
|
||||||
child: Theme(data: hostTextTheme(context), child: body),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
extendBodyBehindAppBar: true,
|
extendBodyBehindAppBar: true,
|
||||||
appBar: SegmentedBar(cupertino: false, title: name),
|
appBar: SegmentedBar(cupertino: false, title: name),
|
||||||
|
|||||||
@@ -1,74 +1,32 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'change_style.dart';
|
/// The recorded raw patch bytes, one recorded line per line, in a selectable
|
||||||
|
/// body.
|
||||||
/// The recorded raw patch bytes, one recorded line per line, in the host's own
|
|
||||||
/// selectable body.
|
|
||||||
///
|
///
|
||||||
/// Material uses [SelectionArea]; a Cupertino host has no
|
/// The text keeps its intrinsic line width, so long lines scroll sideways
|
||||||
/// [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
|
|
||||||
/// instead of wrapping a continuation under a new line.
|
/// 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});
|
const RawPatchView({super.key, required this.patch, required this.style});
|
||||||
|
|
||||||
final String patch;
|
final String patch;
|
||||||
final TextStyle style;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final cupertino = usesCupertino(context);
|
|
||||||
return SingleChildScrollView(
|
return SingleChildScrollView(
|
||||||
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
padding: const EdgeInsets.fromLTRB(16, 0, 16, 16),
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: cupertino
|
child: ExcludeSemantics(
|
||||||
? IntrinsicWidth(
|
child: SelectionArea(
|
||||||
child: ExcludeSemantics(
|
child: Text(
|
||||||
child: CupertinoTextField(
|
patch,
|
||||||
key: const ValueKey('raw-patch-field'),
|
style: style,
|
||||||
controller: _text,
|
softWrap: false,
|
||||||
readOnly: true,
|
overflow: TextOverflow.visible,
|
||||||
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,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../../../ui/navigation/chevron_pager.dart';
|
import '../../../ui/navigation/chevron_pager.dart';
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_test/flutter_test.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', (
|
testWidgets('narrow viewport and large text keep every control reachable', (
|
||||||
tester,
|
tester,
|
||||||
) async {
|
) async {
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:flutter/cupertino.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/rendering.dart';
|
import 'package:flutter/rendering.dart';
|
||||||
import 'package:flutter/services.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 '
|
testWidgets('a file opens as a page that steps to the previous and next '
|
||||||
'file', (tester) async {
|
'file', (tester) async {
|
||||||
tester.view.physicalSize = const Size(390, 844);
|
tester.view.physicalSize = const Size(390, 844);
|
||||||
@@ -341,112 +265,72 @@ void main() {
|
|||||||
patch: multiHunkPatch,
|
patch: multiHunkPatch,
|
||||||
);
|
);
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
testWidgets('diff labels stay whole at 320x720 with 2x text', (tester) async {
|
||||||
final host = cupertino ? 'Cupertino' : 'Material';
|
tester.view.physicalSize = const Size(320, 720);
|
||||||
|
tester.view.devicePixelRatio = 1;
|
||||||
testWidgets('$host diff labels stay whole at 320x720 with 2x text', (
|
addTearDown(tester.view.reset);
|
||||||
tester,
|
final opener = _diffDialogOpener(diffFile);
|
||||||
) async {
|
await tester.pumpWidget(
|
||||||
tester.view.physicalSize = const Size(320, 720);
|
materialHost(opener, scaler: const TextScaler.linear(2)),
|
||||||
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);
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
}
|
await tester.tap(find.text('Open diff'));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
for (final cupertino in [false, true]) {
|
// A segmented control cannot keep both fixed words at this size, so the
|
||||||
testWidgets('Escape closes the full-screen diff '
|
// diff form menu carries them instead. "Rendered" used to break
|
||||||
'(${cupertino ? 'cupertino' : 'material'})', (tester) async {
|
// mid-word and "Raw patch" used to be clipped to "Raw".
|
||||||
final file = FileChange(
|
expect(find.byType(SegmentedButton<DiffForm>), findsNothing);
|
||||||
path: 'lib/first.dart',
|
|
||||||
kind: ChangeKind.modified,
|
// Copy patch stays a standard action at intrinsic width; it must not
|
||||||
patch: _raggedPatch,
|
// 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.descendant(of: items, matching: find.text('Raw patch')),
|
||||||
await tester.tap(find.text('Open diff'));
|
);
|
||||||
await tester.pumpAndSettle();
|
await tester.pumpAndSettle();
|
||||||
expect(find.byType(FileDiffPage), findsOneWidget);
|
expect(find.text(multiHunkPatch), findsOneWidget);
|
||||||
await tester.sendKeyEvent(LogicalKeyboardKey.escape);
|
expect(tester.takeException(), isNull);
|
||||||
await tester.pumpAndSettle();
|
});
|
||||||
expect(find.byType(FileDiffPage), findsNothing);
|
|
||||||
expect(find.text('Open diff'), findsOneWidget);
|
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';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
/// The two platform hosts the Changes widget tests share: Material for
|
/// The host the Changes widget tests share. The app is Material-only on every
|
||||||
/// Android/desktop/web and Cupertino for iOS/macOS. They state the platform
|
/// platform, so the tests state the host explicitly instead of mutating a
|
||||||
/// explicitly instead of mutating a global debug override.
|
/// global debug override.
|
||||||
Widget materialHost(
|
Widget materialHost(
|
||||||
Widget child, {
|
Widget child, {
|
||||||
TextScaler scaler = TextScaler.noScaling,
|
TextScaler scaler = TextScaler.noScaling,
|
||||||
@@ -18,24 +17,3 @@ Widget materialHost(
|
|||||||
home: Scaffold(body: child),
|
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