Merge commit 'f21365f60905568be9d6a2c1fe5e2d87f60184df' into pipelines/run-20261111-0115-cupertino-out-attention-fde4
This commit is contained in:
@@ -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<bool> _confirm(
|
||||
required String body,
|
||||
required String action,
|
||||
}) async {
|
||||
final confirmed = chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? await showCupertinoDialog<bool>(
|
||||
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<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),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
final confirmed = 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;
|
||||
}
|
||||
|
||||
@@ -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<FileDownloadButton> {
|
||||
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!)),
|
||||
],
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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<FilesPanel> {
|
||||
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.'),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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<String?> showRenameEntryDialog(
|
||||
DirectoryEntry entry,
|
||||
) {
|
||||
final dialog = _RenameEntryDialog(entry: entry);
|
||||
return chatControlsStyleOf(context) == ChatControlsStyle.cupertino
|
||||
? showCupertinoDialog<String>(context: context, builder: (_) => dialog)
|
||||
: showDialog<String>(context: context, builder: (_) => dialog);
|
||||
return showDialog<String>(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),
|
||||
|
||||
@@ -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'))],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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<void>(
|
||||
usesCupertinoHost(context)
|
||||
? CupertinoPageRoute<void>(builder: (_) => page)
|
||||
: MaterialPageRoute<void>(builder: (_) => page),
|
||||
);
|
||||
Navigator.of(
|
||||
context,
|
||||
).push<void>(MaterialPageRoute<void>(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'),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
@@ -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<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', (
|
||||
tester,
|
||||
) async {
|
||||
|
||||
Reference in New Issue
Block a user