Remove Cupertino chat file branches

Keep the Material-only file explorer path while preserving public APIs used by callers. Remove unreachable Cupertino widgets, hosts, routes, and tests so the app remains behaviorally unchanged on Material screens.
This commit is contained in:
2026-11-11 01:23:59 +00:00
parent 37cf9472c2
commit f21365f609
8 changed files with 128 additions and 249 deletions
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../data/directory_listing.dart'; import '../data/directory_listing.dart';
import '../ui/sessions/chat_adaptive.dart';
/// Confirms deleting [entry]. A folder is described as deleted only when /// Confirms deleting [entry]. A folder is described as deleted only when
/// empty; the server refuses a folder with contents and the panel then asks /// empty; the server refuses a folder with contents and the panel then asks
@@ -38,41 +36,22 @@ Future<bool> _confirm(
required String body, required String body,
required String action, required String action,
}) async { }) async {
final confirmed = chatControlsStyleOf(context) == ChatControlsStyle.cupertino final confirmed = await showDialog<bool>(
? await showCupertinoDialog<bool>( context: context,
context: context, builder: (context) => AlertDialog(
builder: (context) => CupertinoAlertDialog( title: Text(title),
title: Text(title), content: Text(body),
content: Text(body), actions: [
actions: [ TextButton(
CupertinoDialogAction( onPressed: () => Navigator.pop(context, false),
onPressed: () => Navigator.pop(context, false), child: const Text('Cancel'),
child: const Text('Cancel'), ),
), FilledButton(
CupertinoDialogAction( onPressed: () => Navigator.pop(context, true),
isDestructiveAction: true, child: Text(action),
onPressed: () => Navigator.pop(context, true), ),
child: Text(action), ],
), ),
], );
),
)
: await showDialog<bool>(
context: context,
builder: (context) => AlertDialog(
title: Text(title),
content: Text(body),
actions: [
TextButton(
onPressed: () => Navigator.pop(context, false),
child: const Text('Cancel'),
),
FilledButton(
onPressed: () => Navigator.pop(context, true),
child: Text(action),
),
],
),
);
return confirmed == true; return confirmed == true;
} }
+11 -21
View File
@@ -1,6 +1,4 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/cupertino.dart';
import '../../../ui/adaptive/host.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart'; import 'package:url_launcher/url_launcher.dart';
@@ -115,25 +113,17 @@ class _FileDownloadButtonState extends State<FileDownloadButton> {
Widget build(BuildContext context) => Column( Widget build(BuildContext context) => Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
if (usesCupertinoHost(context)) FilledButton.icon(
CupertinoButton.filled( onPressed: _busy ? null : _download,
onPressed: _busy ? null : _download, icon: _busy
child: _busy ? const SizedBox(
? const CupertinoActivityIndicator() width: 18,
: const Text('Download'), height: 18,
) child: CircularProgressIndicator(strokeWidth: 2),
else )
FilledButton.icon( : const Icon(Icons.download_outlined),
onPressed: _busy ? null : _download, label: const Text('Download'),
icon: _busy ),
? const SizedBox(
width: 18,
height: 18,
child: CircularProgressIndicator(strokeWidth: 2),
)
: const Icon(Icons.download_outlined),
label: const Text('Download'),
),
if (_status != null) if (_status != null)
Padding(padding: const EdgeInsets.only(top: 8), child: Text(_status!)), Padding(padding: const EdgeInsets.only(top: 8), child: Text(_status!)),
], ],
+15 -32
View File
@@ -1,9 +1,7 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/layout/app_overflow_menu.dart'; import '../../../ui/layout/app_overflow_menu.dart';
import '../data/directory_listing.dart'; import '../data/directory_listing.dart';
import '../domain/chat_attachment_picker.dart'; import '../domain/chat_attachment_picker.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'files_controller.dart'; import 'files_controller.dart';
import 'files_models.dart'; import 'files_models.dart';
@@ -103,42 +101,27 @@ class FilesHeader extends StatelessWidget {
child: Row( child: Row(
children: [ children: [
for (final crumb in folderCrumbs(listing.home, listing.path)) for (final crumb in folderCrumbs(listing.home, listing.path))
chatControlsStyleOf(context) == ChatControlsStyle.cupertino TextButton(
? CupertinoButton( onPressed: controller.loading
padding: const EdgeInsets.symmetric(horizontal: 6), ? null
onPressed: controller.loading : () => controller.open(crumb.path),
? null child: Text(crumb.label),
: () => controller.open(crumb.path), ),
child: Text(crumb.label),
)
: TextButton(
onPressed: controller.loading
? null
: () => controller.open(crumb.path),
child: Text(crumb.label),
),
], ],
), ),
), ),
Row( Row(
children: [ children: [
Expanded( Expanded(
child: child: TextField(
chatControlsStyleOf(context) == ChatControlsStyle.cupertino controller: filter,
? CupertinoSearchTextField( onChanged: controller.setFilter,
controller: filter, decoration: const InputDecoration(
onChanged: controller.setFilter, prefixIcon: Icon(Icons.search),
placeholder: 'Filter files', hintText: 'Filter files',
) isDense: true,
: TextField( ),
controller: filter, ),
onChanged: controller.setFilter,
decoration: const InputDecoration(
prefixIcon: Icon(Icons.search),
hintText: 'Filter files',
isDense: true,
),
),
), ),
IconButton( IconButton(
tooltip: 'Show hidden files', tooltip: 'Show hidden files',
+52 -67
View File
@@ -1,6 +1,4 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/cupertino.dart';
import '../../../ui/adaptive/host.dart';
import '../../../core/transport/pipelines_client.dart'; import '../../../core/transport/pipelines_client.dart';
import '../data/directory_listing.dart'; import '../data/directory_listing.dart';
import '../domain/chat_attachment_picker.dart'; import '../domain/chat_attachment_picker.dart';
@@ -100,73 +98,60 @@ class _FilesPanelState extends State<FilesPanel> {
if (controller.missingDirectory) { if (controller.missingDirectory) {
return const _FilesMessage('This chat has no working directory.'); return const _FilesMessage('This chat has no working directory.');
} }
return Theme( return Material(
data: usesCupertinoHost(context) color: Theme.of(context).colorScheme.surface,
? ThemeData( child: FilesDropArea(
brightness: CupertinoTheme.brightnessOf(context), drop: _drop,
colorSchemeSeed: CupertinoTheme.of(context).primaryColor, folderLabel: listing == null
) ? null
: Theme.of(context), : homeRelativeLabel(listing.home, listing.path),
child: Builder( onFiles: controller.upload,
builder: (context) => Material( onError: (error) => controller.reportUploadError(
color: Theme.of(context).colorScheme.surface, 'A dropped item could not be read: $error',
child: FilesDropArea( ),
drop: _drop, child: Column(
folderLabel: listing == null children: [
? null FilesHeader(
: homeRelativeLabel(listing.home, listing.path), controller: controller,
onFiles: controller.upload, filter: _filter,
onError: (error) => controller.reportUploadError( picker: _picker,
'A dropped item could not be read: $error', onUpload: _pickAndUpload,
), ),
child: Column( if (controller.error != null)
children: [ ChatErrorNotice(
FilesHeader( message: controller.error!,
controller: controller, onRetry: controller.retry,
filter: _filter, ),
picker: _picker, FilesUploadNotice(controller: controller),
onUpload: _pickAndUpload, if (controller.loading && listing == null)
const Expanded(child: ChatLoadingIndicator())
else if (listing != null && entries.isEmpty && !controller.loading)
Expanded(
child: _FilesMessage(
controller.filter.isEmpty
? 'This folder is empty.'
: 'No files match your filter.',
), ),
if (controller.error != null) )
ChatErrorNotice( else
message: controller.error!, Expanded(
onRetry: controller.retry, child: FilesEntries(
), entries: entries,
FilesUploadNotice(controller: controller), view: controller.view,
if (controller.loading && listing == null) endpoint: _endpoint,
const Expanded(child: ChatLoadingIndicator()) onTap: (entry) =>
else if (listing != null && entry.isDir ? controller.open(entry.path) : _open(entry),
entries.isEmpty && menu: _menu,
!controller.loading) onDrop: (dragged, folder) =>
Expanded( controller.move(dragged, folder.path),
child: _FilesMessage( ),
controller.filter.isEmpty ),
? 'This folder is empty.' if (listing?.truncated == true)
: 'No files match your filter.', const Padding(
), padding: EdgeInsets.all(8),
) child: Text('Some entries are not shown.'),
else ),
Expanded( ],
child: FilesEntries(
entries: entries,
view: controller.view,
endpoint: _endpoint,
onTap: (entry) => entry.isDir
? controller.open(entry.path)
: _open(entry),
menu: _menu,
onDrop: (dragged, folder) =>
controller.move(dragged, folder.path),
),
),
if (listing?.truncated == true)
const Padding(
padding: EdgeInsets.all(8),
child: Text('Some entries are not shown.'),
),
],
),
),
), ),
), ),
); );
@@ -1,8 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../data/directory_listing.dart'; import '../data/directory_listing.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'files_mutations.dart'; import 'files_mutations.dart';
/// Asks for [entry]'s new name, prefilled and selected. Resolves to the /// Asks for [entry]'s new name, prefilled and selected. Resolves to the
@@ -14,9 +12,7 @@ Future<String?> showRenameEntryDialog(
DirectoryEntry entry, DirectoryEntry entry,
) { ) {
final dialog = _RenameEntryDialog(entry: entry); final dialog = _RenameEntryDialog(entry: entry);
return chatControlsStyleOf(context) == ChatControlsStyle.cupertino return showDialog<String>(context: context, builder: (_) => dialog);
? showCupertinoDialog<String>(context: context, builder: (_) => dialog)
: showDialog<String>(context: context, builder: (_) => dialog);
} }
class _RenameEntryDialog extends StatefulWidget { class _RenameEntryDialog extends StatefulWidget {
@@ -62,44 +58,6 @@ class _RenameEntryDialogState extends State<_RenameEntryDialog> {
builder: (context, value, _) { builder: (context, value, _) {
final error = renameNameError(value.text); final error = renameNameError(value.text);
final canSave = error == null && value.text.trim() != widget.entry.name; final canSave = error == null && value.text.trim() != widget.entry.name;
if (chatControlsStyleOf(context) == ChatControlsStyle.cupertino) {
return CupertinoAlertDialog(
title: Text(title),
content: Column(
mainAxisSize: MainAxisSize.min,
children: [
const SizedBox(height: 8),
CupertinoTextField(
key: const Key('files-rename-field'),
controller: _name,
autofocus: true,
placeholder: 'Name',
onSubmitted: (_) => _save(),
),
if (error != null) ...[
const SizedBox(height: 8),
Text(
error,
style: TextStyle(
color: CupertinoColors.systemRed.resolveFrom(context),
),
),
],
],
),
actions: [
CupertinoDialogAction(
onPressed: () => Navigator.pop(context),
child: const Text('Cancel'),
),
CupertinoDialogAction(
isDefaultAction: true,
onPressed: canSave ? _save : null,
child: const Text('Save'),
),
],
);
}
return AlertDialog( return AlertDialog(
scrollable: true, scrollable: true,
title: Text(title), title: Text(title),
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'files_controller.dart'; import 'files_controller.dart';
/// The Files panel's operation feedback: a progress strip while files are /// The Files panel's operation feedback: a progress strip while files are
@@ -15,8 +13,6 @@ class FilesUploadNotice extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
final progress = controller.uploading > 0 final progress = controller.uploading > 0
? controller.uploadLabel ? controller.uploadLabel
: controller.mutationLabel; : controller.mutationLabel;
@@ -29,11 +25,7 @@ class FilesUploadNotice extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
child: Row( child: Row(
children: [ children: [
Expanded( const Expanded(child: LinearProgressIndicator()),
child: cupertino
? const CupertinoActivityIndicator()
: const LinearProgressIndicator(),
),
const SizedBox(width: 12), const SizedBox(width: 12),
Text(progress), Text(progress),
], ],
@@ -42,13 +34,11 @@ class FilesUploadNotice extends StatelessWidget {
), ),
if (controller.uploadError != null) if (controller.uploadError != null)
_Refusal( _Refusal(
cupertino: cupertino,
message: controller.uploadError!, message: controller.uploadError!,
onDismiss: controller.dismissUploadError, onDismiss: controller.dismissUploadError,
), ),
if (controller.mutationError != null) if (controller.mutationError != null)
_Refusal( _Refusal(
cupertino: cupertino,
message: controller.mutationError!, message: controller.mutationError!,
onDismiss: controller.dismissMutationError, onDismiss: controller.dismissMutationError,
), ),
@@ -58,27 +48,13 @@ class FilesUploadNotice extends StatelessWidget {
} }
class _Refusal extends StatelessWidget { class _Refusal extends StatelessWidget {
const _Refusal({ const _Refusal({required this.message, required this.onDismiss});
required this.cupertino,
required this.message,
required this.onDismiss,
});
final bool cupertino;
final String message; final String message;
final VoidCallback onDismiss; final VoidCallback onDismiss;
@override @override
Widget build(BuildContext context) => cupertino Widget build(BuildContext context) => MaterialBanner(
? ChatCupertinoMessage( content: Text(message),
message: message, actions: [TextButton(onPressed: onDismiss, child: const Text('Dismiss'))],
icon: CupertinoIcons.exclamationmark_circle, );
actionLabel: 'Dismiss',
onAction: onDismiss,
)
: MaterialBanner(
content: Text(message),
actions: [
TextButton(onPressed: onDismiss, child: const Text('Dismiss')),
],
);
} }
+8 -18
View File
@@ -1,7 +1,5 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../../../ui/adaptive/host.dart';
import '../../artifacts/actions/artifact_file_bridge.dart'; import '../../artifacts/actions/artifact_file_bridge.dart';
import '../../artifacts/actions/artifact_transfer.dart'; import '../../artifacts/actions/artifact_transfer.dart';
import '../../artifacts/domain/artifact_groups.dart'; import '../../artifacts/domain/artifact_groups.dart';
@@ -100,11 +98,9 @@ class FilesViewer {
fileBridge: bridge, fileBridge: bridge,
); );
if (!context.mounted) return; if (!context.mounted) return;
Navigator.of(context).push<void>( Navigator.of(
usesCupertinoHost(context) context,
? CupertinoPageRoute<void>(builder: (_) => page) ).push<void>(MaterialPageRoute<void>(builder: (_) => page));
: MaterialPageRoute<void>(builder: (_) => page),
);
} }
/// Downloads [entry] straight from a row or tile menu and reports the /// Downloads [entry] straight from a row or tile menu and reports the
@@ -127,7 +123,7 @@ class FilesViewer {
messenger.showSnackBar(SnackBar(content: Text(result.message))); messenger.showSnackBar(SnackBar(content: Text(result.message)));
return; return;
} }
// A Cupertino host has no snack bar; a failure still has to be said. // Without a scaffold messenger a failure still has to be said.
if (result.state != ArtifactTransferState.failed || !context.mounted) { if (result.state != ArtifactTransferState.failed || !context.mounted) {
return; return;
} }
@@ -137,16 +133,10 @@ class FilesViewer {
title: Text(entry.name), title: Text(entry.name),
content: Text(result.message), content: Text(result.message),
actions: [ actions: [
if (usesCupertinoHost(dialog)) TextButton(
CupertinoDialogAction( onPressed: () => Navigator.pop(dialog),
onPressed: () => Navigator.pop(dialog), child: const Text('OK'),
child: const Text('OK'), ),
)
else
TextButton(
onPressed: () => Navigator.pop(dialog),
child: const Text('OK'),
),
], ],
), ),
); );
@@ -75,6 +75,24 @@ void main() {
return controller; return controller;
} }
testWidgets('the panel filters entries through its Material field', (
tester,
) async {
await pump(tester);
final field = find.byType(TextField);
expect(field, findsOneWidget);
expect(
tester.widget<TextField>(field).decoration?.hintText,
'Filter files',
);
await tester.enterText(field, 'notes');
await tester.pumpAndSettle();
expect(find.text('notes.txt'), findsOneWidget);
expect(find.text('picture.png'), findsNothing);
expect(find.widgetWithText(TextButton, '~'), findsOneWidget);
expect(find.widgetWithText(TextButton, 'demo'), findsOneWidget);
});
testWidgets('text tap opens shared viewer and fetches inline URL', ( testWidgets('text tap opens shared viewer and fetches inline URL', (
tester, tester,
) async { ) async {