main
1import 'package:flutter/material.dart';
2import 'package:blood_pressure_app/l10n/app_localizations.dart';
3
4/// Show a dialoge that prompts the user to confirm a deletion.
5///
6/// Returns whether it is ok to proceed with deletion.
7///
8/// When [customDescription] is set it is used instead of confirmDeleteDesc.
9Future<bool> showConfirmDeletionDialoge(BuildContext context, [String? customDescription]) async =>
10await showDialog<bool>(context: context,
11 builder: (context) => AlertDialog(
12 title: Text(AppLocalizations.of(context)!.confirmDelete),
13 content: Text(customDescription ?? AppLocalizations.of(context)!.confirmDeleteDesc),
14 actions: [
15 TextButton(
16 onPressed: () => Navigator.pop(context, false),
17 child: Text(AppLocalizations.of(context)!.btnCancel),
18 ),
19 Theme(
20 data: ThemeData.from(
21 colorScheme: ColorScheme.fromSeed(
22 seedColor: Colors.red,
23 brightness: Theme.of(context).brightness,
24 ),
25 useMaterial3: true,
26 ),
27 child: ElevatedButton.icon(
28 onPressed: () => Navigator.pop(context, true),
29 icon: const Icon(Icons.delete_forever),
30 label: Text(AppLocalizations.of(context)!.btnConfirm),
31 ),
32 ),
33 ],
34 ),
35) ?? false;