Commit 79de08240bec0394cbe7abdc21d81049accaec96
1 parent
d9fcc552
feat:小鹅通入口图片增加摇摆动画
Showing
3 changed files
with
72 additions
and
4 deletions
assets/images/xe_shop.png
lib/pages/home/view.dart
| 1 | -import 'package:audioplayers/audioplayers.dart'; | ||
| 2 | import 'package:flutter/material.dart'; | 1 | import 'package:flutter/material.dart'; |
| 3 | import 'package:flutter_app_update/azhon_app_update.dart'; | 2 | import 'package:flutter_app_update/azhon_app_update.dart'; |
| 4 | import 'package:flutter_app_update/update_model.dart'; | 3 | import 'package:flutter_app_update/update_model.dart'; |
| @@ -10,7 +9,7 @@ import 'package:wow_english/common/extension/string_extension.dart'; | @@ -10,7 +9,7 @@ import 'package:wow_english/common/extension/string_extension.dart'; | ||
| 10 | import 'package:wow_english/models/app_version_entity.dart'; | 9 | import 'package:wow_english/models/app_version_entity.dart'; |
| 11 | import 'package:wow_english/pages/home/state.dart'; | 10 | import 'package:wow_english/pages/home/state.dart'; |
| 12 | import 'package:wow_english/pages/home/widgets/BaseHomeHeaderWidget.dart'; | 11 | import 'package:wow_english/pages/home/widgets/BaseHomeHeaderWidget.dart'; |
| 13 | -import 'package:wow_english/pages/shop/exchane/bloc/exchange_lesson_bloc.dart'; | 12 | +import 'package:wow_english/pages/home/widgets/ShakeImage.dart'; |
| 14 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; | 13 | import 'package:wow_english/pages/user/bloc/user_bloc.dart'; |
| 15 | import 'package:wow_english/utils/audio_player_util.dart'; | 14 | import 'package:wow_english/utils/audio_player_util.dart'; |
| 16 | 15 | ||
| @@ -129,8 +128,7 @@ class _HomePageView extends StatelessWidget { | @@ -129,8 +128,7 @@ class _HomePageView extends StatelessWidget { | ||
| 129 | child: Offstage( | 128 | child: Offstage( |
| 130 | offstage: AppConfigHelper.shouldHidePay() || | 129 | offstage: AppConfigHelper.shouldHidePay() || |
| 131 | !UserUtil.isLogined(), | 130 | !UserUtil.isLogined(), |
| 132 | - child: Image.asset('xe_shop'.assetPng, | ||
| 133 | - width: 140.5.w, height: 172.h), | 131 | + child: const ShakeImage(), |
| 134 | )); | 132 | )); |
| 135 | }), | 133 | }), |
| 136 | Expanded( | 134 | Expanded( |
lib/pages/home/widgets/ShakeImage.dart
0 → 100644
| 1 | + | ||
| 2 | +import 'package:flutter/cupertino.dart'; | ||
| 3 | +import 'package:wow_english/common/extension/string_extension.dart'; | ||
| 4 | + | ||
| 5 | +///带左右摇晃的wow封面 | ||
| 6 | +class ShakeImage extends StatefulWidget { | ||
| 7 | + const ShakeImage({super.key}); | ||
| 8 | + | ||
| 9 | + @override | ||
| 10 | + _ShakeImageState createState() => _ShakeImageState(); | ||
| 11 | +} | ||
| 12 | + | ||
| 13 | +class _ShakeImageState extends State<ShakeImage> with SingleTickerProviderStateMixin { | ||
| 14 | + late AnimationController _controller; | ||
| 15 | + late Animation<double> _animation; | ||
| 16 | + | ||
| 17 | + @override | ||
| 18 | + void initState() { | ||
| 19 | + super.initState(); | ||
| 20 | + _controller = AnimationController( | ||
| 21 | + duration: const Duration(seconds: 2), | ||
| 22 | + vsync: this, | ||
| 23 | + ); | ||
| 24 | + | ||
| 25 | + _animation = TweenSequence([ | ||
| 26 | + TweenSequenceItem(tween: Tween(begin: 0.0, end: 0.05).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), | ||
| 27 | + TweenSequenceItem(tween: Tween(begin: 0.05, end: -0.1).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), | ||
| 28 | + TweenSequenceItem(tween: Tween(begin: -0.1, end: 0.2).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), | ||
| 29 | + TweenSequenceItem(tween: Tween(begin: 0.2, end: -0.2).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), | ||
| 30 | + TweenSequenceItem(tween: Tween(begin: -0.2, end: 0.1).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), | ||
| 31 | + TweenSequenceItem(tween: Tween(begin: 0.1, end: -0.05).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), | ||
| 32 | + TweenSequenceItem(tween: Tween(begin: -0.05, end: 0.0).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), | ||
| 33 | + ]).animate(_controller); | ||
| 34 | + | ||
| 35 | + Future.delayed(const Duration(seconds: 1), () { | ||
| 36 | + _controller.forward(); | ||
| 37 | + }); | ||
| 38 | + | ||
| 39 | + // _controller.addStatusListener((status) { | ||
| 40 | + // if (status == AnimationStatus.completed) { | ||
| 41 | + // _controller.reverse(); | ||
| 42 | + // } else if (status == AnimationStatus.dismissed) { | ||
| 43 | + // _controller.forward(); | ||
| 44 | + // } | ||
| 45 | + // }); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + @override | ||
| 49 | + void dispose() { | ||
| 50 | + _controller.dispose(); | ||
| 51 | + super.dispose(); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @override | ||
| 55 | + Widget build(BuildContext context) { | ||
| 56 | + return Center( | ||
| 57 | + child: AnimatedBuilder( | ||
| 58 | + animation: _animation, | ||
| 59 | + builder: (context, child) { | ||
| 60 | + return Transform.rotate( | ||
| 61 | + angle: _animation.value, | ||
| 62 | + child: child, | ||
| 63 | + ); | ||
| 64 | + }, | ||
| 65 | + child: Image.asset('xe_shop'.assetPng, | ||
| 66 | + width: 153), | ||
| 67 | + ), | ||
| 68 | + ); | ||
| 69 | + } | ||
| 70 | +} | ||
| 0 | \ No newline at end of file | 71 | \ No newline at end of file |