Files
meshcore-open/lib/widgets/confirm_clear_dialog.dart
T
celsoazevedoandClaude Opus 5.5 c45424adaa Settings actions: theme colours and filled confirm buttons
Reboot and Delete All Paths rows use scheme.tertiary and scheme.error
instead of fixed palette colours. Their dialogs use showConfirmClearDialog,
which gains confirmLabel and warning options.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-24 05:50:55 +00:00

42 lines
1.3 KiB
Dart

import 'package:flutter/material.dart';
import '../l10n/l10n.dart';
/// Asks the user to confirm a destructive action (Clear by default). Resolves
/// to true only when the user taps the confirm button. [warning] uses the
/// amber warning colour instead of red.
Future<bool> showConfirmClearDialog(
BuildContext context, {
required String title,
required String message,
String? confirmLabel,
bool warning = false,
}) async {
final l10n = context.l10n;
final confirmed = await showDialog<bool>(
context: context,
builder: (dialogContext) {
final scheme = Theme.of(dialogContext).colorScheme;
return AlertDialog(
title: Text(title),
content: Text(message),
actions: [
TextButton(
onPressed: () => Navigator.pop(dialogContext, false),
child: Text(l10n.common_cancel),
),
FilledButton(
onPressed: () => Navigator.pop(dialogContext, true),
style: FilledButton.styleFrom(
backgroundColor: warning ? scheme.tertiary : scheme.error,
foregroundColor: warning ? scheme.onTertiary : scheme.onError,
),
child: Text(confirmLabel ?? l10n.common_clear),
),
],
);
},
);
return confirmed == true;
}