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 /// being stored or an entry is being renamed, moved or deleted, and the /// server's refusal (exists, sign in, too large, not empty, outside home) /// until the operator dismisses it. These 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 cupertino = chatControlsStyleOf(context) == ChatControlsStyle.cupertino; final progress = controller.uploading > 0 ? controller.uploadLabel : controller.mutationLabel; return Column( children: [ if (progress != null) Semantics( label: progress, 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(progress), ], ), ), ), 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, ), ], ); } } class _Refusal extends StatelessWidget { const _Refusal({ required this.cupertino, required this.message, required this.onDismiss, }); final bool cupertino; 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')), ], ); }