From f21365f60905568be9d6a2c1fe5e2d87f60184df Mon Sep 17 00:00:00 2001 From: Alan Silva Date: Wed, 11 Nov 2026 01:23:59 +0000 Subject: [PATCH] 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. --- .../chat/files/files_delete_dialog.dart | 55 +++----- .../features/chat/files/files_download.dart | 32 ++--- app/lib/features/chat/files/files_header.dart | 47 +++---- app/lib/features/chat/files/files_panel.dart | 119 ++++++++---------- .../chat/files/files_rename_dialog.dart | 44 +------ .../chat/files/files_upload_notice.dart | 36 +----- app/lib/features/chat/files/files_viewer.dart | 26 ++-- .../features/chat/files/files_panel_test.dart | 18 +++ 8 files changed, 128 insertions(+), 249 deletions(-) diff --git a/app/lib/features/chat/files/files_delete_dialog.dart b/app/lib/features/chat/files/files_delete_dialog.dart index 7c71f616..2d02d5ba 100644 --- a/app/lib/features/chat/files/files_delete_dialog.dart +++ b/app/lib/features/chat/files/files_delete_dialog.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../data/directory_listing.dart'; -import '../ui/sessions/chat_adaptive.dart'; /// Confirms deleting [entry]. A folder is described as deleted only when /// empty; the server refuses a folder with contents and the panel then asks @@ -38,41 +36,22 @@ Future _confirm( required String body, required String action, }) async { - final confirmed = chatControlsStyleOf(context) == ChatControlsStyle.cupertino - ? await showCupertinoDialog( - context: context, - builder: (context) => CupertinoAlertDialog( - title: Text(title), - content: Text(body), - actions: [ - CupertinoDialogAction( - onPressed: () => Navigator.pop(context, false), - child: const Text('Cancel'), - ), - CupertinoDialogAction( - isDestructiveAction: true, - onPressed: () => Navigator.pop(context, true), - child: Text(action), - ), - ], - ), - ) - : await showDialog( - 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), - ), - ], - ), - ); + final confirmed = await showDialog( + 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; } diff --git a/app/lib/features/chat/files/files_download.dart b/app/lib/features/chat/files/files_download.dart index bdad75d3..328613e6 100644 --- a/app/lib/features/chat/files/files_download.dart +++ b/app/lib/features/chat/files/files_download.dart @@ -1,6 +1,4 @@ import 'package:flutter/foundation.dart'; -import 'package:flutter/cupertino.dart'; -import '../../../ui/adaptive/host.dart'; import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -115,25 +113,17 @@ class _FileDownloadButtonState extends State { Widget build(BuildContext context) => Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - if (usesCupertinoHost(context)) - CupertinoButton.filled( - onPressed: _busy ? null : _download, - child: _busy - ? const CupertinoActivityIndicator() - : const Text('Download'), - ) - else - FilledButton.icon( - onPressed: _busy ? null : _download, - icon: _busy - ? const SizedBox( - width: 18, - height: 18, - child: CircularProgressIndicator(strokeWidth: 2), - ) - : const Icon(Icons.download_outlined), - label: const Text('Download'), - ), + FilledButton.icon( + onPressed: _busy ? null : _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) Padding(padding: const EdgeInsets.only(top: 8), child: Text(_status!)), ], diff --git a/app/lib/features/chat/files/files_header.dart b/app/lib/features/chat/files/files_header.dart index 33b7251e..6c59c479 100644 --- a/app/lib/features/chat/files/files_header.dart +++ b/app/lib/features/chat/files/files_header.dart @@ -1,9 +1,7 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../../../ui/layout/app_overflow_menu.dart'; import '../data/directory_listing.dart'; import '../domain/chat_attachment_picker.dart'; -import '../ui/sessions/chat_adaptive.dart'; import 'files_controller.dart'; import 'files_models.dart'; @@ -103,42 +101,27 @@ class FilesHeader extends StatelessWidget { child: Row( children: [ for (final crumb in folderCrumbs(listing.home, listing.path)) - chatControlsStyleOf(context) == ChatControlsStyle.cupertino - ? CupertinoButton( - padding: const EdgeInsets.symmetric(horizontal: 6), - onPressed: controller.loading - ? null - : () => controller.open(crumb.path), - child: Text(crumb.label), - ) - : TextButton( - onPressed: controller.loading - ? null - : () => controller.open(crumb.path), - child: Text(crumb.label), - ), + TextButton( + onPressed: controller.loading + ? null + : () => controller.open(crumb.path), + child: Text(crumb.label), + ), ], ), ), Row( children: [ Expanded( - child: - chatControlsStyleOf(context) == ChatControlsStyle.cupertino - ? CupertinoSearchTextField( - controller: filter, - onChanged: controller.setFilter, - placeholder: 'Filter files', - ) - : TextField( - controller: filter, - onChanged: controller.setFilter, - decoration: const InputDecoration( - prefixIcon: Icon(Icons.search), - hintText: 'Filter files', - isDense: true, - ), - ), + child: TextField( + controller: filter, + onChanged: controller.setFilter, + decoration: const InputDecoration( + prefixIcon: Icon(Icons.search), + hintText: 'Filter files', + isDense: true, + ), + ), ), IconButton( tooltip: 'Show hidden files', diff --git a/app/lib/features/chat/files/files_panel.dart b/app/lib/features/chat/files/files_panel.dart index af0d2ba7..2a091e8d 100644 --- a/app/lib/features/chat/files/files_panel.dart +++ b/app/lib/features/chat/files/files_panel.dart @@ -1,6 +1,4 @@ import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import '../../../ui/adaptive/host.dart'; import '../../../core/transport/pipelines_client.dart'; import '../data/directory_listing.dart'; import '../domain/chat_attachment_picker.dart'; @@ -100,73 +98,60 @@ class _FilesPanelState extends State { if (controller.missingDirectory) { return const _FilesMessage('This chat has no working directory.'); } - return Theme( - data: usesCupertinoHost(context) - ? ThemeData( - brightness: CupertinoTheme.brightnessOf(context), - colorSchemeSeed: CupertinoTheme.of(context).primaryColor, - ) - : Theme.of(context), - child: Builder( - builder: (context) => Material( - color: Theme.of(context).colorScheme.surface, - child: FilesDropArea( - drop: _drop, - folderLabel: listing == null - ? null - : homeRelativeLabel(listing.home, listing.path), - onFiles: controller.upload, - onError: (error) => controller.reportUploadError( - 'A dropped item could not be read: $error', + return Material( + color: Theme.of(context).colorScheme.surface, + child: FilesDropArea( + drop: _drop, + folderLabel: listing == null + ? null + : homeRelativeLabel(listing.home, listing.path), + onFiles: controller.upload, + onError: (error) => controller.reportUploadError( + 'A dropped item could not be read: $error', + ), + child: Column( + children: [ + FilesHeader( + controller: controller, + filter: _filter, + picker: _picker, + onUpload: _pickAndUpload, ), - child: Column( - children: [ - FilesHeader( - controller: controller, - filter: _filter, - picker: _picker, - onUpload: _pickAndUpload, + if (controller.error != null) + ChatErrorNotice( + message: controller.error!, + onRetry: controller.retry, + ), + FilesUploadNotice(controller: controller), + 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( - message: controller.error!, - onRetry: controller.retry, - ), - FilesUploadNotice(controller: controller), - 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.', - ), - ) - 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.'), - ), - ], - ), - ), + ) + 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.'), + ), + ], ), ), ); diff --git a/app/lib/features/chat/files/files_rename_dialog.dart b/app/lib/features/chat/files/files_rename_dialog.dart index 7afdea55..c7609de3 100644 --- a/app/lib/features/chat/files/files_rename_dialog.dart +++ b/app/lib/features/chat/files/files_rename_dialog.dart @@ -1,8 +1,6 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import '../data/directory_listing.dart'; -import '../ui/sessions/chat_adaptive.dart'; import 'files_mutations.dart'; /// Asks for [entry]'s new name, prefilled and selected. Resolves to the @@ -14,9 +12,7 @@ Future showRenameEntryDialog( DirectoryEntry entry, ) { final dialog = _RenameEntryDialog(entry: entry); - return chatControlsStyleOf(context) == ChatControlsStyle.cupertino - ? showCupertinoDialog(context: context, builder: (_) => dialog) - : showDialog(context: context, builder: (_) => dialog); + return showDialog(context: context, builder: (_) => dialog); } class _RenameEntryDialog extends StatefulWidget { @@ -62,44 +58,6 @@ class _RenameEntryDialogState extends State<_RenameEntryDialog> { builder: (context, value, _) { final error = renameNameError(value.text); 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( scrollable: true, title: Text(title), diff --git a/app/lib/features/chat/files/files_upload_notice.dart b/app/lib/features/chat/files/files_upload_notice.dart index 3cb3cdf3..ef6b1e04 100644 --- a/app/lib/features/chat/files/files_upload_notice.dart +++ b/app/lib/features/chat/files/files_upload_notice.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../ui/sessions/chat_adaptive.dart'; import 'files_controller.dart'; /// The Files panel's operation feedback: a progress strip while files are @@ -15,8 +13,6 @@ class FilesUploadNotice extends StatelessWidget { @override Widget build(BuildContext context) { - final cupertino = - chatControlsStyleOf(context) == ChatControlsStyle.cupertino; final progress = controller.uploading > 0 ? controller.uploadLabel : controller.mutationLabel; @@ -29,11 +25,7 @@ class FilesUploadNotice extends StatelessWidget { padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4), child: Row( children: [ - Expanded( - child: cupertino - ? const CupertinoActivityIndicator() - : const LinearProgressIndicator(), - ), + const Expanded(child: LinearProgressIndicator()), const SizedBox(width: 12), Text(progress), ], @@ -42,13 +34,11 @@ class FilesUploadNotice extends StatelessWidget { ), if (controller.uploadError != null) _Refusal( - cupertino: cupertino, message: controller.uploadError!, onDismiss: controller.dismissUploadError, ), if (controller.mutationError != null) _Refusal( - cupertino: cupertino, message: controller.mutationError!, onDismiss: controller.dismissMutationError, ), @@ -58,27 +48,13 @@ class FilesUploadNotice extends StatelessWidget { } class _Refusal extends StatelessWidget { - const _Refusal({ - required this.cupertino, - required this.message, - required this.onDismiss, - }); - final bool cupertino; + const _Refusal({required this.message, required this.onDismiss}); final String message; final VoidCallback onDismiss; @override - Widget build(BuildContext context) => cupertino - ? ChatCupertinoMessage( - message: message, - icon: CupertinoIcons.exclamationmark_circle, - actionLabel: 'Dismiss', - onAction: onDismiss, - ) - : MaterialBanner( - content: Text(message), - actions: [ - TextButton(onPressed: onDismiss, child: const Text('Dismiss')), - ], - ); + Widget build(BuildContext context) => MaterialBanner( + content: Text(message), + actions: [TextButton(onPressed: onDismiss, child: const Text('Dismiss'))], + ); } diff --git a/app/lib/features/chat/files/files_viewer.dart b/app/lib/features/chat/files/files_viewer.dart index 65cd8024..93e9342e 100644 --- a/app/lib/features/chat/files/files_viewer.dart +++ b/app/lib/features/chat/files/files_viewer.dart @@ -1,7 +1,5 @@ -import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import '../../../ui/adaptive/host.dart'; import '../../artifacts/actions/artifact_file_bridge.dart'; import '../../artifacts/actions/artifact_transfer.dart'; import '../../artifacts/domain/artifact_groups.dart'; @@ -100,11 +98,9 @@ class FilesViewer { fileBridge: bridge, ); if (!context.mounted) return; - Navigator.of(context).push( - usesCupertinoHost(context) - ? CupertinoPageRoute(builder: (_) => page) - : MaterialPageRoute(builder: (_) => page), - ); + Navigator.of( + context, + ).push(MaterialPageRoute(builder: (_) => page)); } /// 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))); 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) { return; } @@ -137,16 +133,10 @@ class FilesViewer { title: Text(entry.name), content: Text(result.message), actions: [ - if (usesCupertinoHost(dialog)) - CupertinoDialogAction( - onPressed: () => Navigator.pop(dialog), - child: const Text('OK'), - ) - else - TextButton( - onPressed: () => Navigator.pop(dialog), - child: const Text('OK'), - ), + TextButton( + onPressed: () => Navigator.pop(dialog), + child: const Text('OK'), + ), ], ), ); diff --git a/app/test/features/chat/files/files_panel_test.dart b/app/test/features/chat/files/files_panel_test.dart index f8377874..a562f6c6 100644 --- a/app/test/features/chat/files/files_panel_test.dart +++ b/app/test/features/chat/files/files_panel_test.dart @@ -75,6 +75,24 @@ void main() { 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(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', ( tester, ) async {