import 'package:flutter/material.dart'; import '../../../ui/adaptive/app_popups.dart'; import '../../artifacts/actions/artifact_transfer.dart'; import '../../artifacts/domain/artifact_kind.dart'; import '../../artifacts/ui/artifact_external_open.dart'; import '../data/directory_listing.dart'; import 'files_download.dart'; import 'files_models.dart'; import 'files_preview.dart'; import 'files_urls.dart'; /// Details and host-native actions for a file the embedded viewer cannot show. void showFileDetails( BuildContext context, { required DirectoryEntry entry, required FileUrls? urls, required Future Function()? download, required ArtifactExternalOpen openExternal, }) { Widget content(BuildContext sheet) { Future open() async { var opened = false; try { opened = await openExternal(urls!.view); } catch (_) { /* keep the sheet and download action available */ } if (opened && sheet.mounted) Navigator.pop(sheet); } final body = SafeArea( child: Padding( padding: const EdgeInsets.all(20), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ Text(entry.name, style: Theme.of(sheet).textTheme.titleLarge), const SizedBox(height: 12), Text( '${artifactKindLabel(artifactKind(fileContentType(entry.name), entry.name))} ยท ${fileSizeLabel(entry.size)}', ), Text('Modified: ${fileModifiedLabel(entry.modified)}'), const SizedBox(height: 8), Text( urls == null ? 'No server address is configured, so this file cannot be fetched.' : 'This file type cannot be previewed here.', ), const SizedBox(height: 16), if (download != null) FileDownloadButton(download: download), if (urls != null) TextButton.icon( onPressed: open, icon: const Icon(Icons.open_in_new), label: const Text('Open externally'), ), ], ), ), ); return body; } showAppDetails(context, builder: content); }