implement animation
All checks were successful
Pull Request Pipeline / test (pull_request) Successful in 2m4s
Pull Request Pipeline / lint (pull_request) Successful in 2m8s

This commit is contained in:
2026-01-11 17:21:05 +01:00
parent 22ce742d43
commit 1ebcfc9e57

View File

@@ -97,23 +97,14 @@ class _SettingsViewState extends State<SettingsView> {
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<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),),
),
*/