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>
This commit is contained in:
celsoazevedoandClaude Opus 5.5 committed 2026-11-24 05:50:55 +00:00
1 parent 0aa867e40e
commit c45424adaa
5 files changed
+103 -74

No files matched your search

+27 -53
View File
@@ -7,6 +7,7 @@ import '../connector/meshcore_protocol.dart';
import '../l10n/l10n.dart';
import '../theme/mesh_theme.dart';
import '../helpers/snack_bar_builder.dart';
import '../widgets/confirm_clear_dialog.dart';
import '../widgets/mesh_nav_tile.dart';
import '../widgets/adaptive_app_bar_title.dart';
import '../widgets/mesh_ui.dart';
@@ -621,6 +622,7 @@ class _SettingsScreenState extends State<SettingsScreen> {
MeshCoreConnector connector,
) {
final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
final connected = connector.isConnected;
final offline = l10n.settings_requiresConnection;
return Column(
@@ -643,8 +645,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
icon: Icons.restart_alt,
title: l10n.settings_rebootDevice,
subtitle: connected ? l10n.settings_rebootDeviceSubtitle : offline,
titleColor: MeshPalette.warn,
iconColor: MeshPalette.warn,
titleColor: scheme.tertiary,
iconColor: scheme.tertiary,
onTap: connected ? () => _confirmReboot(context, connector) : null,
),
const Divider(height: 1, indent: 16),
@@ -652,8 +654,8 @@ class _SettingsScreenState extends State<SettingsScreen> {
icon: Icons.delete_outline,
title: l10n.settings_deleteAllPaths,
subtitle: l10n.settings_deleteAllPathsSubtitle,
titleColor: MeshPalette.alert,
iconColor: MeshPalette.alert,
titleColor: scheme.error,
iconColor: scheme.error,
onTap: () => _confirmDeleteAllPaths(context, connector),
),
],
@@ -717,62 +719,34 @@ class _SettingsScreenState extends State<SettingsScreen> {
}
}
void _confirmDeleteAllPaths(
Future<void> _confirmDeleteAllPaths(
BuildContext context,
MeshCoreConnector connector,
) {
) async {
final l10n = context.l10n;
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(l10n.settings_deleteAllPaths),
content: Text(l10n.settings_deleteAllPathsSubtitle),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(l10n.common_cancel),
),
TextButton(
onPressed: () {
Navigator.pop(context);
connector.deleteAllPaths();
},
child: Text(
l10n.common_deleteAll,
style: TextStyle(color: Theme.of(context).colorScheme.error),
),
),
],
),
final confirmed = await showConfirmClearDialog(
context,
title: l10n.settings_deleteAllPaths,
message: l10n.settings_deleteAllPathsSubtitle,
confirmLabel: l10n.common_deleteAll,
);
if (confirmed) connector.deleteAllPaths();
}
void _confirmReboot(BuildContext context, MeshCoreConnector connector) {
Future<void> _confirmReboot(
BuildContext context,
MeshCoreConnector connector,
) async {
final l10n = context.l10n;
final screenContext = context;
showDialog(
context: context,
builder: (context) => AlertDialog(
title: Text(l10n.settings_rebootDevice),
content: Text(l10n.settings_rebootDeviceConfirm),
actions: [
TextButton(
onPressed: () => Navigator.pop(context),
child: Text(l10n.common_cancel),
),
TextButton(
onPressed: () {
Navigator.pop(context);
if (!_ensureConnected(screenContext, connector)) return;
connector.rebootDevice();
},
child: Text(
l10n.common_reboot,
style: TextStyle(color: Theme.of(context).colorScheme.tertiary),
),
),
],
),
final confirmed = await showConfirmClearDialog(
context,
title: l10n.settings_rebootDevice,
message: l10n.settings_rebootDeviceConfirm,
confirmLabel: l10n.common_reboot,
warning: true,
);
if (!confirmed || !context.mounted) return;
if (!_ensureConnected(context, connector)) return;
connector.rebootDevice();
}
}
+25 -19
View File
@@ -2,34 +2,40 @@ import 'package:flutter/material.dart';
import '../l10n/l10n.dart';
/// Asks the user to confirm clearing a log or history. Resolves to true only
/// when the user taps Clear.
/// 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) => 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: Theme.of(dialogContext).colorScheme.error,
foregroundColor: Theme.of(dialogContext).colorScheme.onError,
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),
),
child: Text(l10n.common_clear),
),
],
),
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;
}