Commit e0e89ade4259b1492673268b793465d045cf4bc9
1 parent
2512b58c
feat:选择选项组件动画防抖
Showing
4 changed files
with
19 additions
and
14 deletions
lib/common/widgets/option_widget.dart
... | ... | @@ -82,14 +82,15 @@ class _OptionWidgetState extends State<OptionWidget> |
82 | 82 | void didUpdateWidget(OptionWidget oldWidget) { |
83 | 83 | super.didUpdateWidget(oldWidget); |
84 | 84 | Log.d( |
85 | - '$TAG didUpdateWidget widget.isCorrect=${widget.isCorrect} oldWidget.isCorrect=${oldWidget.isCorrect} isAnimation=${_controller.isAnimating} status=${_controller.status}'); | |
86 | - if (widget.isCorrect != oldWidget.isCorrect) { | |
87 | - _controller.reset(); | |
88 | - if (widget.isCorrect == true) { | |
89 | - _controller.forward(); | |
90 | - } else if (widget.isCorrect == false) { | |
91 | - _controller.forward(); | |
92 | - } | |
85 | + '$TAG ${identityHashCode(this)} didUpdateWidget widget.isCorrect=${widget.isCorrect} oldWidget.isCorrect=${oldWidget.isCorrect} isAnimation=${_controller.isAnimating} status=${_controller.status}'); | |
86 | + if (widget.isCorrect == oldWidget.isCorrect && _controller.isAnimating) { | |
87 | + return; | |
88 | + } | |
89 | + _controller.reset(); | |
90 | + if (widget.isCorrect == true) { | |
91 | + _controller.forward(); | |
92 | + } else if (widget.isCorrect == false) { | |
93 | + _controller.forward(); | |
93 | 94 | } |
94 | 95 | } |
95 | 96 | ... | ... |
lib/common/widgets/recorder_widget.dart
... | ... | @@ -51,7 +51,7 @@ class _RecorderWidgetState extends State<RecorderWidget> |
51 | 51 | void didUpdateWidget(RecorderWidget oldWidget) { |
52 | 52 | super.didUpdateWidget(oldWidget); |
53 | 53 | Log.d( |
54 | - "$TAG didUpdateWidget widget=${widget.isPlaying} oldWidget=${oldWidget.isPlaying} _isPlaying=$_isPlaying"); | |
54 | + "$TAG ${identityHashCode(this)} didUpdateWidget widget=${widget.isPlaying} oldWidget=${oldWidget.isPlaying} _isPlaying=$_isPlaying"); | |
55 | 55 | if (widget.isPlaying && !_isPlaying) { |
56 | 56 | setState(() { |
57 | 57 | _isPlaying = true; | ... | ... |
lib/common/widgets/speaker_widget.dart
... | ... | @@ -49,6 +49,8 @@ class _SpeakerWidgetState extends State<SpeakerWidget> |
49 | 49 | vsync: this, |
50 | 50 | ); |
51 | 51 | |
52 | + Log.d( | |
53 | + "$TAG ${identityHashCode(this)} initState widget=${widget.isPlaying} _isPlaying=$_isPlaying _controller=${identityHashCode(_controller)}"); | |
52 | 54 | if (widget.isPlaying) { |
53 | 55 | _startAnimation(); |
54 | 56 | } |
... | ... | @@ -58,7 +60,7 @@ class _SpeakerWidgetState extends State<SpeakerWidget> |
58 | 60 | void didUpdateWidget(SpeakerWidget oldWidget) { |
59 | 61 | super.didUpdateWidget(oldWidget); |
60 | 62 | Log.d( |
61 | - "$TAG didUpdateWidget widget=${widget.isPlaying} oldWidget=${oldWidget.isPlaying} _isPlaying=$_isPlaying"); | |
63 | + "$TAG ${identityHashCode(this)} didUpdateWidget widget=${widget.isPlaying} oldWidget=${oldWidget.isPlaying} _isPlaying=$_isPlaying"); | |
62 | 64 | if (widget.isPlaying && !_isPlaying) { |
63 | 65 | setState(() { |
64 | 66 | _isPlaying = true; |
... | ... | @@ -71,7 +73,7 @@ class _SpeakerWidgetState extends State<SpeakerWidget> |
71 | 73 | |
72 | 74 | void _startAnimation() { |
73 | 75 | Log.d( |
74 | - "$TAG _startAnimation widget=${widget.isPlaying} _isPlaying=$_isPlaying _controller.isAnimating=${_controller.isAnimating}"); | |
76 | + "$TAG ${identityHashCode(this)} _startAnimation widget=${widget.isPlaying} _isPlaying=$_isPlaying isAnimating=${_controller.isAnimating}"); | |
75 | 77 | _timer = Timer.periodic(const Duration(milliseconds: 300), (Timer timer) { |
76 | 78 | if (mounted) { |
77 | 79 | setState(() { |
... | ... | @@ -83,7 +85,7 @@ class _SpeakerWidgetState extends State<SpeakerWidget> |
83 | 85 | |
84 | 86 | void _stopAnimation() { |
85 | 87 | Log.d( |
86 | - "$TAG _stopAnimation widget=${widget.isPlaying} _isPlaying=$_isPlaying _controller.isAnimating=${_controller.isAnimating}"); | |
88 | + "$TAG ${identityHashCode(this)} _stopAnimation widget=${widget.isPlaying} _isPlaying=$_isPlaying isAnimating=${_controller.isAnimating}"); | |
87 | 89 | _timer?.cancel(); |
88 | 90 | _controller.stop(); |
89 | 91 | _controller.reset(); |
... | ... | @@ -98,6 +100,8 @@ class _SpeakerWidgetState extends State<SpeakerWidget> |
98 | 100 | |
99 | 101 | @override |
100 | 102 | void dispose() { |
103 | + Log.d( | |
104 | + "$TAG ${identityHashCode(this)} dispose widget=${widget.isPlaying} _isPlaying=$_isPlaying isAnimating=${_controller.isAnimating}"); | |
101 | 105 | _controller.dispose(); |
102 | 106 | _timer?.cancel(); |
103 | 107 | super.dispose(); | ... | ... |
lib/common/widgets/star_reward_widget.dart
... | ... | @@ -60,13 +60,13 @@ class _StarRewardWidgetState extends State<StarRewardWidget> |
60 | 60 | } |
61 | 61 | |
62 | 62 | void _startAnimation() { |
63 | - Log.d("$TAG _startAnimation"); | |
63 | + Log.d("$TAG ${identityHashCode(this)} _startAnimation"); | |
64 | 64 | setState(() { |
65 | 65 | _isVisible = true; |
66 | 66 | }); |
67 | 67 | |
68 | 68 | _futureComposition.then((composition) { |
69 | - Log.d("$TAG _futureComposition.then duration=${composition.duration}"); | |
69 | + Log.d("$TAG ${identityHashCode(this)} _futureComposition.then duration=${composition.duration}"); | |
70 | 70 | _controller.duration = composition.duration; |
71 | 71 | _controller.forward().whenCompleteOrCancel(() { |
72 | 72 | if (mounted) { | ... | ... |