From 816aebf4a8986f3fd2b0d7a87dac698610840a28 Mon Sep 17 00:00:00 2001 From: Bo Lopker Date: Sun, 3 Nov 2024 17:37:51 +0700 Subject: [PATCH] Add help text and reset confirmation --- lib/settings.dart | 37 ++++++++++++++++++++++++++++++++++++- lib/tooltip.dart | 19 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 lib/tooltip.dart diff --git a/lib/settings.dart b/lib/settings.dart index 9b2ba5f..5b34490 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -1,4 +1,5 @@ import 'package:alic/config.dart'; +import 'package:alic/tooltip.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:signals/signals_flutter.dart'; @@ -80,7 +81,31 @@ class _SettingsWidgetState extends State { children: [ TextButton( onPressed: () { - Config.reset(); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: const Text('Reset Settings'), + content: const Text( + 'Are you sure you want to reset all settings to default?'), + actions: [ + TextButton( + child: const Text('Cancel'), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: const Text('Reset'), + onPressed: () { + Config.reset(); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, + ); }, child: const Text('Reset')), const Spacer(), @@ -136,6 +161,7 @@ class GeneralPage extends StatelessWidget { @override Widget build(BuildContext context) { + var theme = Theme.of(context); return Watch( (context) { final config = Config.signal.value; @@ -170,6 +196,15 @@ class GeneralPage extends StatelessWidget { Row( children: [ const Text('Overwrite original files'), + Padding( + padding: const EdgeInsets.all(8.0), + child: AlicTooltip( + message: + 'Original files will be overwritten with the compressed version. Original files are moved to the Trash. ' + 'If disabled, the compressed version will be saved in the same directory as the original file, with a postfix.', + child: Icon(Icons.help, color: theme.hintColor), + ), + ), const Spacer(), Switch( value: !config.enablePostfix, diff --git a/lib/tooltip.dart b/lib/tooltip.dart new file mode 100644 index 0000000..08e411d --- /dev/null +++ b/lib/tooltip.dart @@ -0,0 +1,19 @@ +import 'package:flutter/material.dart'; + +class AlicTooltip extends StatelessWidget { + const AlicTooltip({super.key, required this.message, required this.child}); + + final String message; + final Widget child; + + @override + Widget build(BuildContext context) { + return Tooltip( + message: message, + child: MouseRegion( + cursor: SystemMouseCursors.click, + child: child, + ), + ); + } +}