diff --git a/lib/presentation/views/main_menu/settings_view.dart b/lib/presentation/views/main_menu/settings_view.dart index 0fa7085..cab26ef 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( + _PressableButton( onPressed: () => Navigator.of(context).pop(false), - child: Text(loc.cancel), + child: Text(loc.cancel, style: const TextStyle(color: CustomTheme.textColor)), ), - TextButton( + _PressableButton( onPressed: () => Navigator.of(context).pop(true), - child: Text(loc.delete), + child: Text(loc.delete, style: TextStyle(color: CustomTheme.secondaryColor)), ), ], ), @@ -217,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),), + ), + */ diff --git a/lib/presentation/widgets/custom_alert_dialog.dart b/lib/presentation/widgets/custom_alert_dialog.dart new file mode 100644 index 0000000..2456b56 --- /dev/null +++ b/lib/presentation/widgets/custom_alert_dialog.dart @@ -0,0 +1,30 @@ +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, + actionsAlignment: MainAxisAlignment.spaceAround, + shape: RoundedRectangleBorder( + borderRadius: CustomTheme.standardBorderRadiusAll, + side: BorderSide(color: CustomTheme.boxBorder), + ), + ); + } +}