implement animation
This commit is contained in:
@@ -97,23 +97,14 @@ class _SettingsViewState extends State<SettingsView> {
|
|||||||
title: '${loc.delete_all_data}?',
|
title: '${loc.delete_all_data}?',
|
||||||
content: loc.this_cannot_be_undone,
|
content: loc.this_cannot_be_undone,
|
||||||
actions: [
|
actions: [
|
||||||
TextButton(
|
_PressableButton(
|
||||||
style: TextButton.styleFrom(
|
|
||||||
splashFactory: NoSplash.splashFactory,
|
|
||||||
overlayColor: Colors.transparent,
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.of(context).pop(false),
|
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(
|
_PressableButton(
|
||||||
style: TextButton.styleFrom(
|
|
||||||
splashFactory: NoSplash.splashFactory,
|
|
||||||
overlayColor: Colors.transparent,
|
|
||||||
),
|
|
||||||
onPressed: () => Navigator.of(context).pop(true),
|
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) {
|
).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),),
|
||||||
|
),
|
||||||
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user