53 lines
1.3 KiB
Dart
53 lines
1.3 KiB
Dart
|
|
import 'package:flutter/material.dart';
|
||
|
|
|
||
|
|
import '../../core/theme/design_tokens.dart';
|
||
|
|
|
||
|
|
class AppPressable extends StatefulWidget {
|
||
|
|
const AppPressable({
|
||
|
|
super.key,
|
||
|
|
required this.child,
|
||
|
|
this.onTap,
|
||
|
|
this.borderRadius,
|
||
|
|
this.pressedScale = 0.97,
|
||
|
|
});
|
||
|
|
|
||
|
|
final Widget child;
|
||
|
|
final VoidCallback? onTap;
|
||
|
|
final BorderRadius? borderRadius;
|
||
|
|
final double pressedScale;
|
||
|
|
|
||
|
|
@override
|
||
|
|
State<AppPressable> createState() => _AppPressableState();
|
||
|
|
}
|
||
|
|
|
||
|
|
class _AppPressableState extends State<AppPressable> {
|
||
|
|
bool _isPressed = false;
|
||
|
|
|
||
|
|
@override
|
||
|
|
Widget build(BuildContext context) {
|
||
|
|
return AnimatedScale(
|
||
|
|
scale: _isPressed ? widget.pressedScale : 1,
|
||
|
|
duration: const Duration(milliseconds: 110),
|
||
|
|
curve: Curves.easeOut,
|
||
|
|
child: Material(
|
||
|
|
color: Colors.transparent,
|
||
|
|
child: InkWell(
|
||
|
|
borderRadius: widget.borderRadius,
|
||
|
|
onTap: widget.onTap,
|
||
|
|
onHighlightChanged: (pressed) {
|
||
|
|
if (_isPressed == pressed) {
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
setState(() {
|
||
|
|
_isPressed = pressed;
|
||
|
|
});
|
||
|
|
},
|
||
|
|
splashColor: AppColors.blue100.withValues(alpha: 0.32),
|
||
|
|
highlightColor: AppColors.blue50.withValues(alpha: 0.28),
|
||
|
|
child: widget.child,
|
||
|
|
),
|
||
|
|
),
|
||
|
|
);
|
||
|
|
}
|
||
|
|
}
|