Support proxies search Add some scenes auto close connections Update core Optimize more details
81 lines
1.7 KiB
Dart
81 lines
1.7 KiB
Dart
import 'dart:ui';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class EffectGestureDetector extends StatefulWidget {
|
|
final Widget child;
|
|
final GestureLongPressCallback? onLongPress;
|
|
final GestureTapCallback? onTap;
|
|
|
|
const EffectGestureDetector({
|
|
super.key,
|
|
required this.child,
|
|
this.onLongPress,
|
|
this.onTap,
|
|
});
|
|
|
|
@override
|
|
State<EffectGestureDetector> createState() => _EffectGestureDetectorState();
|
|
}
|
|
|
|
class _EffectGestureDetectorState extends State<EffectGestureDetector>
|
|
with SingleTickerProviderStateMixin {
|
|
late AnimationController _controller;
|
|
double _scale = 1;
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
_controller = AnimationController(vsync: this);
|
|
}
|
|
|
|
@override
|
|
void dispose() {
|
|
_controller.dispose();
|
|
super.dispose();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return AnimatedScale(
|
|
scale: _scale,
|
|
duration: kThemeAnimationDuration,
|
|
curve: Curves.easeOut,
|
|
child: GestureDetector(
|
|
onLongPress: widget.onLongPress,
|
|
onLongPressStart: (_) {
|
|
setState(() {
|
|
_scale = 0.95;
|
|
});
|
|
},
|
|
onTap: widget.onTap,
|
|
onLongPressEnd: (_) {
|
|
setState(() {
|
|
_scale = 1;
|
|
});
|
|
},
|
|
child: widget.child,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget proxyDecorator(
|
|
Widget child,
|
|
int index,
|
|
Animation<double> animation,
|
|
) {
|
|
return AnimatedBuilder(
|
|
animation: animation,
|
|
builder: (_, Widget? child) {
|
|
final double animValue = Curves.easeInOut.transform(animation.value);
|
|
final double scale = lerpDouble(1, 1.02, animValue)!;
|
|
return Transform.scale(
|
|
scale: scale,
|
|
child: child,
|
|
);
|
|
},
|
|
child: child,
|
|
);
|
|
}
|