286506310c
Phase 2b.4 of docs/plans/floating-windows.md: both use showAppDetails (a dialog on a wide app, a bottom sheet on a phone). Implemented by pipeline run 305; landed by hand after its UI review found the dialog clipped, which the helper now scrolls.
67 lines
2.2 KiB
Dart
67 lines
2.2 KiB
Dart
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<ArtifactTransferResult> Function()? download,
|
|
required ArtifactExternalOpen openExternal,
|
|
}) {
|
|
Widget content(BuildContext sheet) {
|
|
Future<void> 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<void>(context, builder: content);
|
|
}
|