fix: alot
This commit is contained in:
@@ -45,6 +45,36 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
).showSnackBar(SnackBar(content: Text(l10n.devAction(message))));
|
||||
}
|
||||
|
||||
Future<void> _confirmThen(
|
||||
String title,
|
||||
Future<void> Function() action,
|
||||
) async {
|
||||
final l10n = AppLocalizations.of(context);
|
||||
|
||||
final confirmed = await showDialog<bool>(
|
||||
context: context,
|
||||
builder: (dialogContext) => AlertDialog(
|
||||
title: Text(title),
|
||||
content: Text(l10n.actionCannotBeUndone),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, false),
|
||||
child: Text(l10n.cancel),
|
||||
),
|
||||
FilledButton(
|
||||
onPressed: () => Navigator.pop(dialogContext, true),
|
||||
style: FilledButton.styleFrom(
|
||||
backgroundColor: Theme.of(dialogContext).colorScheme.error,
|
||||
),
|
||||
child: Text(l10n.confirm),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
|
||||
if (confirmed == true) await action();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_vm?.removeListener(_onVmChange);
|
||||
@@ -78,12 +108,19 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
_Tile(
|
||||
icon: Icons.delete_sweep_rounded,
|
||||
title: l10n.clearOpenTabs,
|
||||
onTap: vm.isLoading ? null : () => vm.clearOpenTabs(),
|
||||
onTap: vm.isLoading
|
||||
? null
|
||||
: () => _confirmThen(l10n.clearOpenTabs, vm.clearOpenTabs),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.history_rounded,
|
||||
title: l10n.clearClosedHistory,
|
||||
onTap: vm.isLoading ? null : () => vm.clearClosedTabHistory(),
|
||||
onTap: vm.isLoading
|
||||
? null
|
||||
: () => _confirmThen(
|
||||
l10n.clearClosedHistory,
|
||||
vm.clearClosedTabHistory,
|
||||
),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.add_box_rounded,
|
||||
@@ -95,18 +132,33 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
icon: Icons.restart_alt_rounded,
|
||||
title: l10n.clearAndReseedProducts,
|
||||
subtitle: l10n.wipesAndReseeds,
|
||||
onTap: vm.isLoading ? null : () => vm.clearAndReseedProducts(),
|
||||
onTap: vm.isLoading
|
||||
? null
|
||||
: () => _confirmThen(
|
||||
l10n.clearAndReseedProducts,
|
||||
vm.clearAndReseedProducts,
|
||||
),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.delete_forever_rounded,
|
||||
title: l10n.clearAllProducts,
|
||||
onTap: vm.isLoading ? null : () => vm.clearAllProducts(),
|
||||
onTap: vm.isLoading
|
||||
? null
|
||||
: () => _confirmThen(
|
||||
l10n.clearAllProducts,
|
||||
vm.clearAllProducts,
|
||||
),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.image_rounded,
|
||||
title: l10n.clearProductImages,
|
||||
subtitle: l10n.deletesProductImages,
|
||||
onTap: vm.isLoading ? null : () => vm.clearProductImages(),
|
||||
onTap: vm.isLoading
|
||||
? null
|
||||
: () => _confirmThen(
|
||||
l10n.clearProductImages,
|
||||
vm.clearProductImages,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -117,7 +169,9 @@ class _DevMenuViewState extends State<DevMenuView> {
|
||||
icon: Icons.lock_reset_rounded,
|
||||
title: l10n.resetPin,
|
||||
subtitle: l10n.removePinLock,
|
||||
onTap: vm.isLoading ? null : () => vm.resetPin(),
|
||||
onTap: vm.isLoading
|
||||
? null
|
||||
: () => _confirmThen(l10n.resetPin, vm.resetPin),
|
||||
),
|
||||
_Tile(
|
||||
icon: Icons.bug_report_rounded,
|
||||
|
||||
Reference in New Issue
Block a user