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';
|
||||
|
||||
Reference in New Issue
Block a user