mirror of
https://github.com/foss42/apidash.git
synced 2025-06-04 01:13:30 +08:00
Confirm with user before clearing datastore
This commit is contained in:
@ -20,6 +20,7 @@ final kColorTransparentState =
|
|||||||
MaterialStateProperty.all<Color>(Colors.transparent);
|
MaterialStateProperty.all<Color>(Colors.transparent);
|
||||||
const kColorTransparent = Colors.transparent;
|
const kColorTransparent = Colors.transparent;
|
||||||
const kColorWhite = Colors.white;
|
const kColorWhite = Colors.white;
|
||||||
|
const kColorRed = Colors.red;
|
||||||
final kColorLightDanger = Colors.red.withOpacity(0.9);
|
final kColorLightDanger = Colors.red.withOpacity(0.9);
|
||||||
const kColorDarkDanger = Color(0xffcf6679);
|
const kColorDarkDanger = Color(0xffcf6679);
|
||||||
|
|
||||||
|
@ -83,18 +83,45 @@ class _SettingsPageState extends ConsumerState<SettingsPage> {
|
|||||||
backgroundColor: settings.isDark
|
backgroundColor: settings.isDark
|
||||||
? kColorDarkDanger
|
? kColorDarkDanger
|
||||||
: kColorLightDanger,
|
: kColorLightDanger,
|
||||||
surfaceTintColor: Colors.red,
|
surfaceTintColor: kColorRed,
|
||||||
foregroundColor: Theme.of(context).colorScheme.onPrimary),
|
foregroundColor: Theme.of(context).colorScheme.onPrimary),
|
||||||
onPressed: clearingData
|
onPressed: clearingData
|
||||||
? null
|
? null
|
||||||
: () async {
|
: () => showDialog<String>(
|
||||||
await ref
|
context: context,
|
||||||
.read(collectionStateNotifierProvider.notifier)
|
builder: (BuildContext context) => AlertDialog(
|
||||||
.clearData();
|
title: const Text('Clear Data'),
|
||||||
|
content: const Text(
|
||||||
|
'This action will clear all the requests data from the disk and is irreversible. Do you want to proceed?'),
|
||||||
|
actions: <Widget>[
|
||||||
|
TextButton(
|
||||||
|
onPressed: () =>
|
||||||
|
Navigator.pop(context, 'Cancel'),
|
||||||
|
child: const Text('Cancel'),
|
||||||
|
),
|
||||||
|
TextButton(
|
||||||
|
onPressed: () async {
|
||||||
|
Navigator.pop(context, 'Yes');
|
||||||
|
await ref
|
||||||
|
.read(collectionStateNotifierProvider
|
||||||
|
.notifier)
|
||||||
|
.clearData();
|
||||||
|
|
||||||
sm.hideCurrentSnackBar();
|
sm.hideCurrentSnackBar();
|
||||||
sm.showSnackBar(getSnackBar("Requests Data Cleared"));
|
sm.showSnackBar(
|
||||||
},
|
getSnackBar("Requests Data Cleared"));
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
'Yes',
|
||||||
|
style: kTextStyleButton.copyWith(
|
||||||
|
color: settings.isDark
|
||||||
|
? kColorDarkDanger
|
||||||
|
: kColorLightDanger),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
child: const Text("Clear Data"),
|
child: const Text("Clear Data"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user