From 124c1056d469582c50bb2525cc88c01a39071e44 Mon Sep 17 00:00:00 2001 From: dhzdhd Date: Tue, 18 Jun 2024 00:53:20 +0530 Subject: [PATCH] Add alert dialog guard to clearing cache --- lib/src/settings/views/settings_view.dart | 43 +++++++++++++++++++---- 1 file changed, 37 insertions(+), 6 deletions(-) diff --git a/lib/src/settings/views/settings_view.dart b/lib/src/settings/views/settings_view.dart index d4bd171..a52afaa 100644 --- a/lib/src/settings/views/settings_view.dart +++ b/lib/src/settings/views/settings_view.dart @@ -32,9 +32,12 @@ class SettingsView extends ConsumerWidget { crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( + const Text( 'Theme', - style: Theme.of(context).textTheme.titleLarge, + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w400, + ), ), SizedBox( child: DropdownMenu( @@ -65,9 +68,12 @@ class SettingsView extends ConsumerWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Text( + const Text( 'Enable Sentry monitoring', - style: Theme.of(context).textTheme.titleLarge, + style: TextStyle( + fontSize: 20, + fontWeight: FontWeight.w400, + ), ), Switch( value: settings.isSentryEnabled, @@ -84,9 +90,34 @@ class SettingsView extends ConsumerWidget { height: 50, child: OutlinedButton( onPressed: () async { - await folderNotifier.clearCache().run(); + showDialog( + context: context, + builder: (context) => AlertDialog( + title: const Text('Are you sure'), + actions: [ + OutlinedButton( + onPressed: () async { + await folderNotifier.clearCache().run(); + if (context.mounted) { + Navigator.of(context).pop(); + } + }, + child: const Text('Yes'), + ), + FilledButton( + onPressed: () { + Navigator.of(context).pop(); + }, + child: const Text('No'), + ) + ], + ), + ); }, - child: const Text('Clear local folder storage'), + child: const Text( + 'Clear local folder storage', + style: TextStyle(fontSize: 18), + ), ), ), )