Files
pipelines/app/lib/features/chat/files/files_delete_dialog.dart
T
alan f21365f609 Remove Cupertino chat file branches
Keep the Material-only file explorer path while preserving public APIs used by callers. Remove unreachable Cupertino widgets, hosts, routes, and tests so the app remains behaviorally unchanged on Material screens.
2026-11-11 01:23:59 +00:00

58 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
import '../data/directory_listing.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
/// again with [confirmDeleteRecursive].
Future<bool> confirmDeleteEntry(BuildContext context, DirectoryEntry entry) =>
_confirm(
context,
title: 'Delete “${entry.name}”?',
body: entry.isDir
? 'The folder is removed from the server if it is empty. '
'This cannot be undone.'
: 'The file is removed from the server. This cannot be undone.',
action: 'Delete',
);
/// Asks again once the server reported the folder is not empty; confirming
/// deletes the folder and everything inside it.
Future<bool> confirmDeleteRecursive(
BuildContext context,
DirectoryEntry entry,
) => _confirm(
context,
title: 'Delete “${entry.name}” and its contents?',
body:
'“${entry.name}” is not empty. Delete the folder and everything '
'inside it? This cannot be undone.',
action: 'Delete all',
);
Future<bool> _confirm(
BuildContext context, {
required String title,
required String body,
required String action,
}) async {
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;
}