536807e7c8
Adds PressableScale (0.94 squish on tap-down) around the Adventure FilledButton, Classic OutlinedButton, and each season-map stage node. Replaces all in-app MaterialPageRoute pushes with a gentle fade+scale PageRouteBuilder (320ms in, 240ms out) via a new fadeRoute helper.
38 lines
1.1 KiB
Dart
38 lines
1.1 KiB
Dart
// lib/ui/widgets/pressable_scale.dart
|
|
import 'package:flutter/material.dart';
|
|
|
|
/// Wraps a tappable child with a quick scale-down on press for tactile feel.
|
|
/// If [onTap] is provided it handles the tap; otherwise the child's own
|
|
/// gesture/button handles it and this only adds the visual squish.
|
|
class PressableScale extends StatefulWidget {
|
|
const PressableScale({super.key, required this.child, this.onTap});
|
|
|
|
final Widget child;
|
|
final VoidCallback? onTap;
|
|
|
|
@override
|
|
State<PressableScale> createState() => _PressableScaleState();
|
|
}
|
|
|
|
class _PressableScaleState extends State<PressableScale> {
|
|
bool _down = false;
|
|
void _set(bool v) => setState(() => _down = v);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTapDown: (_) => _set(true),
|
|
onTapUp: (_) => _set(false),
|
|
onTapCancel: () => _set(false),
|
|
onTap: widget.onTap,
|
|
child: AnimatedScale(
|
|
scale: _down ? 0.94 : 1.0,
|
|
duration: const Duration(milliseconds: 90),
|
|
curve: Curves.easeOut,
|
|
child: widget.child,
|
|
),
|
|
);
|
|
}
|
|
}
|