turn off choice array animation

pull/1428/head
ggurdin 1 year ago
parent f0dd984e7a
commit 59682599a5
No known key found for this signature in database
GPG Key ID: A01CB41737CBB478

@ -1,5 +1,4 @@
import 'dart:developer'; import 'dart:developer';
import 'dart:math';
import 'package:collection/collection.dart'; import 'package:collection/collection.dart';
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
@ -213,98 +212,99 @@ class ChoiceAnimationWidgetState extends State<ChoiceAnimationWidget>
with SingleTickerProviderStateMixin { with SingleTickerProviderStateMixin {
late final AnimationController _controller; late final AnimationController _controller;
late final Animation<double> _animation; late final Animation<double> _animation;
AnimationState animationState = AnimationState.ready; // AnimationState animationState = AnimationState.ready;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_controller = AnimationController( // _controller = AnimationController(
duration: const Duration(milliseconds: 300), // duration: const Duration(milliseconds: 300),
vsync: this, // vsync: this,
); // );
_animation = widget.isGold // _animation = widget.isGold
? Tween<double>(begin: 1.0, end: 1.2).animate(_controller) // ? Tween<double>(begin: 1.0, end: 1.2).animate(_controller)
: TweenSequence<double>([ // : TweenSequence<double>([
TweenSequenceItem<double>( // TweenSequenceItem<double>(
tween: Tween<double>(begin: 0, end: -8 * pi / 180), // tween: Tween<double>(begin: 0, end: -8 * pi / 180),
weight: 1.0, // weight: 1.0,
), // ),
TweenSequenceItem<double>( // TweenSequenceItem<double>(
tween: Tween<double>(begin: -8 * pi / 180, end: 16 * pi / 180), // tween: Tween<double>(begin: -8 * pi / 180, end: 16 * pi / 180),
weight: 2.0, // weight: 2.0,
), // ),
TweenSequenceItem<double>( // TweenSequenceItem<double>(
tween: Tween<double>(begin: 16 * pi / 180, end: 0), // tween: Tween<double>(begin: 16 * pi / 180, end: 0),
weight: 1.0, // weight: 1.0,
), // ),
]).animate(_controller); // ]).animate(_controller);
widget.enableInteraction(); widget.enableInteraction();
if (widget.selected && animationState == AnimationState.ready) { // if (widget.selected && animationState == AnimationState.ready) {
widget.disableInteraction(); // widget.disableInteraction();
_controller.forward(); // _controller.forward();
setState(() { // setState(() {
animationState = AnimationState.forward; // animationState = AnimationState.forward;
}); // });
} // }
_controller.addStatusListener((status) { // _controller.addStatusListener((status) {
if (status == AnimationStatus.completed && // if (status == AnimationStatus.completed &&
animationState == AnimationState.forward) { // animationState == AnimationState.forward) {
_controller.reverse(); // _controller.reverse();
setState(() { // setState(() {
animationState = AnimationState.reverse; // animationState = AnimationState.reverse;
}); // });
} // }
if (status == AnimationStatus.dismissed && // if (status == AnimationStatus.dismissed &&
animationState == AnimationState.reverse) { // animationState == AnimationState.reverse) {
widget.enableInteraction(); // widget.enableInteraction();
setState(() { // setState(() {
animationState = AnimationState.finished; // animationState = AnimationState.finished;
}); // });
} // }
}); // });
} }
@override @override
void didUpdateWidget(ChoiceAnimationWidget oldWidget) { void didUpdateWidget(ChoiceAnimationWidget oldWidget) {
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
if (widget.selected && animationState == AnimationState.ready) { // if (widget.selected && animationState == AnimationState.ready) {
widget.disableInteraction(); // widget.disableInteraction();
_controller.forward(); // _controller.forward();
setState(() { // setState(() {
animationState = AnimationState.forward; // animationState = AnimationState.forward;
}); // });
} // }
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return widget.isGold return widget.child;
? AnimatedBuilder( // widget.isGold
key: UniqueKey(), // ? AnimatedBuilder(
animation: _animation, // key: UniqueKey(),
builder: (context, child) { // animation: _animation,
return Transform.scale( // builder: (context, child) {
scale: _animation.value, // return Transform.scale(
child: child, // scale: _animation.value,
); // child: child,
}, // );
child: widget.child, // },
) // child: widget.child,
: AnimatedBuilder( // )
key: UniqueKey(), // : AnimatedBuilder(
animation: _animation, // key: UniqueKey(),
builder: (context, child) { // animation: _animation,
return Transform.rotate( // builder: (context, child) {
angle: _animation.value, // return Transform.rotate(
child: child, // angle: _animation.value,
); // child: child,
}, // );
child: widget.child, // },
); // child: widget.child,
// );
} }
@override @override

Loading…
Cancel
Save