From 76ce3af6437690ae004fae3c909f77539859a380 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sun, 11 Jan 2026 15:26:10 +0100 Subject: [PATCH 1/4] implement custom alert dialog --- .../views/main_menu/settings_view.dart | 11 +++---- .../widgets/custom_alert_dialog.dart | 29 +++++++++++++++++++ 2 files changed, 35 insertions(+), 5 deletions(-) create mode 100644 lib/presentation/widgets/custom_alert_dialog.dart diff --git a/lib/presentation/views/main_menu/settings_view.dart b/lib/presentation/views/main_menu/settings_view.dart index 0fa7085..d416deb 100644 --- a/lib/presentation/views/main_menu/settings_view.dart +++ b/lib/presentation/views/main_menu/settings_view.dart @@ -5,6 +5,7 @@ import 'package:game_tracker/l10n/generated/app_localizations.dart'; import 'package:game_tracker/presentation/widgets/tiles/settings_list_tile.dart'; import 'package:game_tracker/services/data_transfer_service.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:game_tracker/presentation/widgets/custom_alert_dialog.dart'; class SettingsView extends StatefulWidget { const SettingsView({super.key}); @@ -92,17 +93,17 @@ class _SettingsViewState extends State { onPressed: () { showDialog( context: context, - builder: (context) => AlertDialog( - title: Text('${loc.delete_all_data}?'), - content: Text(loc.this_cannot_be_undone), + builder: (context) => CustomAlertDialog( + title: '${loc.delete_all_data}?', + content: loc.this_cannot_be_undone, actions: [ TextButton( onPressed: () => Navigator.of(context).pop(false), - child: Text(loc.cancel), + child: Text(loc.cancel, style: TextStyle(color: CustomTheme.textColor),), ), TextButton( onPressed: () => Navigator.of(context).pop(true), - child: Text(loc.delete), + child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor),), ), ], ), diff --git a/lib/presentation/widgets/custom_alert_dialog.dart b/lib/presentation/widgets/custom_alert_dialog.dart new file mode 100644 index 0000000..6a6019a --- /dev/null +++ b/lib/presentation/widgets/custom_alert_dialog.dart @@ -0,0 +1,29 @@ +import 'package:flutter/material.dart'; +import 'package:game_tracker/core/custom_theme.dart'; + +class CustomAlertDialog extends StatelessWidget { + final String title; + final String content; + final List actions; + + const CustomAlertDialog({ + super.key, + required this.title, + required this.content, + required this.actions, + }); + + @override + Widget build(BuildContext context) { + return AlertDialog( + title: Text(title, style: const TextStyle(color: CustomTheme.textColor,),), + content: Text(content, style: const TextStyle(color: CustomTheme.textColor),), + actions: actions, + backgroundColor: CustomTheme.boxColor, + shape: RoundedRectangleBorder( + borderRadius: CustomTheme.standardBorderRadiusAll, + side: BorderSide(color: CustomTheme.boxBorder), + ), + ); + } +} -- 2.49.1 From 3ceae8341b56461d6d376d54f7fa57afa481cb79 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sun, 11 Jan 2026 15:26:50 +0100 Subject: [PATCH 2/4] add const --- lib/presentation/views/main_menu/settings_view.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/presentation/views/main_menu/settings_view.dart b/lib/presentation/views/main_menu/settings_view.dart index d416deb..500a550 100644 --- a/lib/presentation/views/main_menu/settings_view.dart +++ b/lib/presentation/views/main_menu/settings_view.dart @@ -99,7 +99,7 @@ class _SettingsViewState extends State { actions: [ TextButton( onPressed: () => Navigator.of(context).pop(false), - child: Text(loc.cancel, style: TextStyle(color: CustomTheme.textColor),), + child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor),), ), TextButton( onPressed: () => Navigator.of(context).pop(true), -- 2.49.1 From 22ce742d4333a80d9b759de160591245b98ddbfa Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sun, 11 Jan 2026 17:14:28 +0100 Subject: [PATCH 3/4] change button alignment & remove InkWell Animation --- lib/presentation/views/main_menu/settings_view.dart | 9 +++++++++ lib/presentation/widgets/custom_alert_dialog.dart | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/presentation/views/main_menu/settings_view.dart b/lib/presentation/views/main_menu/settings_view.dart index 500a550..5814537 100644 --- a/lib/presentation/views/main_menu/settings_view.dart +++ b/lib/presentation/views/main_menu/settings_view.dart @@ -98,13 +98,22 @@ class _SettingsViewState extends State { content: loc.this_cannot_be_undone, actions: [ TextButton( + style: TextButton.styleFrom( + splashFactory: NoSplash.splashFactory, + overlayColor: Colors.transparent, + ), onPressed: () => Navigator.of(context).pop(false), child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor),), ), TextButton( + style: TextButton.styleFrom( + splashFactory: NoSplash.splashFactory, + overlayColor: Colors.transparent, + ), onPressed: () => Navigator.of(context).pop(true), child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor),), ), + ], ), ).then((confirmed) { diff --git a/lib/presentation/widgets/custom_alert_dialog.dart b/lib/presentation/widgets/custom_alert_dialog.dart index 6a6019a..2456b56 100644 --- a/lib/presentation/widgets/custom_alert_dialog.dart +++ b/lib/presentation/widgets/custom_alert_dialog.dart @@ -20,6 +20,7 @@ class CustomAlertDialog extends StatelessWidget { content: Text(content, style: const TextStyle(color: CustomTheme.textColor),), actions: actions, backgroundColor: CustomTheme.boxColor, + actionsAlignment: MainAxisAlignment.spaceAround, shape: RoundedRectangleBorder( borderRadius: CustomTheme.standardBorderRadiusAll, side: BorderSide(color: CustomTheme.boxBorder), -- 2.49.1 From 1ebcfc9e57e1685fe75a0c2438ab297c8de2f0c9 Mon Sep 17 00:00:00 2001 From: Mathis Kirchner Date: Sun, 11 Jan 2026 17:21:05 +0100 Subject: [PATCH 4/4] implement animation --- .../views/main_menu/settings_view.dart | 73 +++++++++++++++---- 1 file changed, 60 insertions(+), 13 deletions(-) diff --git a/lib/presentation/views/main_menu/settings_view.dart b/lib/presentation/views/main_menu/settings_view.dart index 5814537..cab26ef 100644 --- a/lib/presentation/views/main_menu/settings_view.dart +++ b/lib/presentation/views/main_menu/settings_view.dart @@ -97,23 +97,14 @@ class _SettingsViewState extends State { title: '${loc.delete_all_data}?', content: loc.this_cannot_be_undone, actions: [ - TextButton( - style: TextButton.styleFrom( - splashFactory: NoSplash.splashFactory, - overlayColor: Colors.transparent, - ), + _PressableButton( onPressed: () => Navigator.of(context).pop(false), - child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor),), + child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor)), ), - TextButton( - style: TextButton.styleFrom( - splashFactory: NoSplash.splashFactory, - overlayColor: Colors.transparent, - ), + _PressableButton( onPressed: () => Navigator.of(context).pop(true), - child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor),), + child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor)), ), - ], ), ).then((confirmed) { @@ -227,3 +218,59 @@ class _SettingsViewState extends State { }); } } + +class _PressableButton extends StatefulWidget { + final VoidCallback onPressed; + final Widget child; + + const _PressableButton({required this.onPressed, required this.child}); + + @override + State<_PressableButton> createState() => _PressableButtonState(); +} + +class _PressableButtonState extends State<_PressableButton> { + bool _isPressed = false; + + @override + Widget build(BuildContext context) { + return GestureDetector( + onTapDown: (_) => setState(() => _isPressed = true), + onTapUp: (_) => setState(() => _isPressed = false), + onTapCancel: () => setState(() => _isPressed = false), + onTap: widget.onPressed, + child: AnimatedScale( + scale: _isPressed ? 0.95 : 1.0, + duration: const Duration(milliseconds: 100), + child: AnimatedOpacity( + opacity: _isPressed ? 0.6 : 1.0, + duration: const Duration(milliseconds: 100), + child: Padding( + padding: const EdgeInsets.all(8.0), + child: widget.child, + ), + ), + ), + ); + } +} + + +/* + TextButton( + style: TextButton.styleFrom( + splashFactory: NoSplash.splashFactory, + overlayColor: Colors.transparent, + ), + onPressed: () => Navigator.of(context).pop(false), + child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor),), + ), + TextButton( + style: TextButton.styleFrom( + splashFactory: NoSplash.splashFactory, + overlayColor: Colors.transparent, + ), + onPressed: () => Navigator.of(context).pop(true), + child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor),), + ), + */ -- 2.49.1