|
|
@ -9,8 +9,7 @@ import 'package:get/get.dart';
|
|
|
|
|
|
|
|
|
|
|
|
const double _DEFAULT_SCALE_MIN_VALUE = 0.96;
|
|
|
|
const double _DEFAULT_SCALE_MIN_VALUE = 0.96;
|
|
|
|
const double _DEFAULT_OPACITY_MIN_VALUE = 0.90;
|
|
|
|
const double _DEFAULT_OPACITY_MIN_VALUE = 0.90;
|
|
|
|
final Curve _DEFAULT_SCALE_CURVE =
|
|
|
|
final Curve _DEFAULT_SCALE_CURVE = CurveSpring(); // ignore: non_constant_identifier_names
|
|
|
|
CurveSpring(); // ignore: non_constant_identifier_names
|
|
|
|
|
|
|
|
const Curve _DEFAULT_OPACITY_CURVE = Curves.ease;
|
|
|
|
const Curve _DEFAULT_OPACITY_CURVE = Curves.ease;
|
|
|
|
const Duration _DEFAULT_DURATION = Duration(milliseconds: 250);
|
|
|
|
const Duration _DEFAULT_DURATION = Duration(milliseconds: 250);
|
|
|
|
|
|
|
|
|
|
|
@ -53,8 +52,7 @@ class ScaleTap extends StatefulWidget {
|
|
|
|
_ScaleTapState createState() => _ScaleTapState();
|
|
|
|
_ScaleTapState createState() => _ScaleTapState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class _ScaleTapState extends State<ScaleTap>
|
|
|
|
class _ScaleTapState extends State<ScaleTap> with SingleTickerProviderStateMixin {
|
|
|
|
with SingleTickerProviderStateMixin {
|
|
|
|
|
|
|
|
late AnimationController _animationController;
|
|
|
|
late AnimationController _animationController;
|
|
|
|
late Animation<double> _scale;
|
|
|
|
late Animation<double> _scale;
|
|
|
|
late Animation<double> _opacity;
|
|
|
|
late Animation<double> _opacity;
|
|
|
@ -73,8 +71,7 @@ class _ScaleTapState extends State<ScaleTap>
|
|
|
|
|
|
|
|
|
|
|
|
_animationController = AnimationController(vsync: this);
|
|
|
|
_animationController = AnimationController(vsync: this);
|
|
|
|
_scale = Tween<double>(begin: 1.0, end: 1.0).animate(_animationController);
|
|
|
|
_scale = Tween<double>(begin: 1.0, end: 1.0).animate(_animationController);
|
|
|
|
_opacity =
|
|
|
|
_opacity = Tween<double>(begin: 1.0, end: 1.0).animate(_animationController);
|
|
|
|
Tween<double>(begin: 1.0, end: 1.0).animate(_animationController);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
@ -91,18 +88,14 @@ class _ScaleTapState extends State<ScaleTap>
|
|
|
|
begin: _scale.value,
|
|
|
|
begin: _scale.value,
|
|
|
|
end: scale,
|
|
|
|
end: scale,
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
curve: widget.scaleCurve ??
|
|
|
|
curve: widget.scaleCurve ?? ScaleTapConfig.scaleCurve ?? _DEFAULT_SCALE_CURVE,
|
|
|
|
ScaleTapConfig.scaleCurve ??
|
|
|
|
|
|
|
|
_DEFAULT_SCALE_CURVE,
|
|
|
|
|
|
|
|
parent: _animationController,
|
|
|
|
parent: _animationController,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
_opacity = Tween<double>(
|
|
|
|
_opacity = Tween<double>(
|
|
|
|
begin: _opacity.value,
|
|
|
|
begin: _opacity.value,
|
|
|
|
end: opacity,
|
|
|
|
end: opacity,
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
).animate(CurvedAnimation(
|
|
|
|
curve: widget.opacityCurve ??
|
|
|
|
curve: widget.opacityCurve ?? ScaleTapConfig.opacityCurve ?? _DEFAULT_OPACITY_CURVE,
|
|
|
|
ScaleTapConfig.opacityCurve ??
|
|
|
|
|
|
|
|
_DEFAULT_OPACITY_CURVE,
|
|
|
|
|
|
|
|
parent: _animationController,
|
|
|
|
parent: _animationController,
|
|
|
|
));
|
|
|
|
));
|
|
|
|
_animationController.reset();
|
|
|
|
_animationController.reset();
|
|
|
@ -114,8 +107,7 @@ class _ScaleTapState extends State<ScaleTap>
|
|
|
|
return await anim(
|
|
|
|
return await anim(
|
|
|
|
scale: 1.0,
|
|
|
|
scale: 1.0,
|
|
|
|
opacity: 1.0,
|
|
|
|
opacity: 1.0,
|
|
|
|
duration:
|
|
|
|
duration: widget.duration ?? ScaleTapConfig.duration ?? _DEFAULT_DURATION,
|
|
|
|
widget.duration ?? ScaleTapConfig.duration ?? _DEFAULT_DURATION,
|
|
|
|
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -127,12 +119,9 @@ class _ScaleTapState extends State<ScaleTap>
|
|
|
|
_scaleAnimating = true;
|
|
|
|
_scaleAnimating = true;
|
|
|
|
|
|
|
|
|
|
|
|
await anim(
|
|
|
|
await anim(
|
|
|
|
scale: widget.scaleMinValue ??
|
|
|
|
scale: widget.scaleMinValue ?? ScaleTapConfig.scaleMinValue ?? _DEFAULT_SCALE_MIN_VALUE,
|
|
|
|
ScaleTapConfig.scaleMinValue ??
|
|
|
|
opacity:
|
|
|
|
_DEFAULT_SCALE_MIN_VALUE,
|
|
|
|
widget.opacityMinValue ?? ScaleTapConfig.opacityMinValue ?? _DEFAULT_OPACITY_MIN_VALUE,
|
|
|
|
opacity: widget.opacityMinValue ??
|
|
|
|
|
|
|
|
ScaleTapConfig.opacityMinValue ??
|
|
|
|
|
|
|
|
_DEFAULT_OPACITY_MIN_VALUE,
|
|
|
|
|
|
|
|
duration: widget.duration ?? ScaleTapConfig.duration ?? _DEFAULT_DURATION,
|
|
|
|
duration: widget.duration ?? ScaleTapConfig.duration ?? _DEFAULT_DURATION,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
@ -152,8 +141,7 @@ class _ScaleTapState extends State<ScaleTap>
|
|
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
final bool isTapEnabled =
|
|
|
|
final bool isTapEnabled = widget.onPressed != null || widget.onLongPress != null;
|
|
|
|
widget.onPressed != null || widget.onLongPress != null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return AnimatedBuilder(
|
|
|
|
return AnimatedBuilder(
|
|
|
|
animation: _animationController,
|
|
|
|
animation: _animationController,
|
|
|
@ -219,9 +207,10 @@ class ScaleTapIgnore extends StatelessWidget {
|
|
|
|
c.ignoredAreaPressing = true;
|
|
|
|
c.ignoredAreaPressing = true;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
child: GestureDetector(
|
|
|
|
child: GestureDetector(
|
|
|
|
child: child,
|
|
|
|
behavior: HitTestBehavior.opaque,
|
|
|
|
onTap: () {},
|
|
|
|
onTap: () {},
|
|
|
|
onLongPress: () {},
|
|
|
|
onLongPress: () {},
|
|
|
|
|
|
|
|
child: child,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|