Skip to content

Commit

Permalink
Add help text and reset confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
blopker committed Nov 3, 2024
1 parent 18dff33 commit 816aebf
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
37 changes: 36 additions & 1 deletion lib/settings.dart
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -80,7 +81,31 @@ class _SettingsWidgetState extends State<SettingsWidget> {
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: <Widget>[
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(),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
19 changes: 19 additions & 0 deletions lib/tooltip.dart
Original file line number Diff line number Diff line change
@@ -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,
),
);
}
}

0 comments on commit 816aebf

Please sign in to comment.