Files
pipelines/app/lib/features/chat/files/files_upload_notice.dart
T
alan b8fb4d350c Upload files into the shown folder from the chat Files panel
The header gains an Upload button that uses the host file picker (disabled
with its reason where no picker exists), and the panel body becomes a drop
target: on web, document drag events are observed through a dart:js_interop
seam and a file drag over the panel shows a highlight naming the folder.
Each file is posted to POST /files?path=<folder> through an injectable
transport; refusals (exists, sign in, too large) stay visible until dismissed
and the folder reloads afterwards. The list/grid builders move to
files_entries.dart to keep the panel small.
2026-11-09 00:09:01 +00:00

61 lines
2.0 KiB
Dart

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import '../ui/sessions/chat_adaptive.dart';
import 'files_controller.dart';
/// The Files panel's upload feedback: a progress strip while files are being
/// stored and the server's refusal (exists, sign in, too large) until the
/// operator dismisses it. Upload failures are separate from the folder error,
/// whose Retry reloads the listing.
class FilesUploadNotice extends StatelessWidget {
const FilesUploadNotice({super.key, required this.controller});
final FilesController controller;
@override
Widget build(BuildContext context) {
final error = controller.uploadError;
final cupertino =
chatControlsStyleOf(context) == ChatControlsStyle.cupertino;
return Column(
children: [
if (controller.uploading > 0)
Semantics(
label: controller.uploadLabel,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 4),
child: Row(
children: [
Expanded(
child: cupertino
? const CupertinoActivityIndicator()
: const LinearProgressIndicator(),
),
const SizedBox(width: 12),
Text(controller.uploadLabel),
],
),
),
),
if (error != null)
cupertino
? ChatCupertinoMessage(
message: error,
icon: CupertinoIcons.exclamationmark_circle,
actionLabel: 'Dismiss',
onAction: controller.dismissUploadError,
)
: MaterialBanner(
content: Text(error),
actions: [
TextButton(
onPressed: controller.dismissUploadError,
child: const Text('Dismiss'),
),
],
),
],
);
}
}