Compare commits
4 Commits
setup/upda
...
feature/12
| Author | SHA1 | Date | |
|---|---|---|---|
| 1ebcfc9e57 | |||
| 22ce742d43 | |||
| 3ceae8341b | |||
| 76ce3af643 |
@@ -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<SettingsView> {
|
||||
onPressed: () {
|
||||
showDialog<bool>(
|
||||
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<SettingsView> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
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),),
|
||||
),
|
||||
*/
|
||||
|
||||
30
lib/presentation/widgets/custom_alert_dialog.dart
Normal file
30
lib/presentation/widgets/custom_alert_dialog.dart
Normal file
@@ -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<Widget> 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),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user