diff --git a/assets/images/xe_shop.png b/assets/images/xe_shop.png index 28d040d..61c8953 100644 --- a/assets/images/xe_shop.png +++ b/assets/images/xe_shop.png diff --git a/lib/pages/home/view.dart b/lib/pages/home/view.dart index c1d86b7..dee90db 100644 --- a/lib/pages/home/view.dart +++ b/lib/pages/home/view.dart @@ -1,4 +1,3 @@ -import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app_update/azhon_app_update.dart'; import 'package:flutter_app_update/update_model.dart'; @@ -10,7 +9,7 @@ import 'package:wow_english/common/extension/string_extension.dart'; import 'package:wow_english/models/app_version_entity.dart'; import 'package:wow_english/pages/home/state.dart'; import 'package:wow_english/pages/home/widgets/BaseHomeHeaderWidget.dart'; -import 'package:wow_english/pages/shop/exchane/bloc/exchange_lesson_bloc.dart'; +import 'package:wow_english/pages/home/widgets/ShakeImage.dart'; import 'package:wow_english/pages/user/bloc/user_bloc.dart'; import 'package:wow_english/utils/audio_player_util.dart'; @@ -129,8 +128,7 @@ class _HomePageView extends StatelessWidget { child: Offstage( offstage: AppConfigHelper.shouldHidePay() || !UserUtil.isLogined(), - child: Image.asset('xe_shop'.assetPng, - width: 140.5.w, height: 172.h), + child: const ShakeImage(), )); }), Expanded( diff --git a/lib/pages/home/widgets/ShakeImage.dart b/lib/pages/home/widgets/ShakeImage.dart new file mode 100644 index 0000000..f2df578 --- /dev/null +++ b/lib/pages/home/widgets/ShakeImage.dart @@ -0,0 +1,70 @@ + +import 'package:flutter/cupertino.dart'; +import 'package:wow_english/common/extension/string_extension.dart'; + +///带左右摇晃的wow封面 +class ShakeImage extends StatefulWidget { + const ShakeImage({super.key}); + + @override + _ShakeImageState createState() => _ShakeImageState(); +} + +class _ShakeImageState extends State with SingleTickerProviderStateMixin { + late AnimationController _controller; + late Animation _animation; + + @override + void initState() { + super.initState(); + _controller = AnimationController( + duration: const Duration(seconds: 2), + vsync: this, + ); + + _animation = TweenSequence([ + TweenSequenceItem(tween: Tween(begin: 0.0, end: 0.05).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), + TweenSequenceItem(tween: Tween(begin: 0.05, end: -0.1).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), + TweenSequenceItem(tween: Tween(begin: -0.1, end: 0.2).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), + TweenSequenceItem(tween: Tween(begin: 0.2, end: -0.2).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), + TweenSequenceItem(tween: Tween(begin: -0.2, end: 0.1).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), + TweenSequenceItem(tween: Tween(begin: 0.1, end: -0.05).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), + TweenSequenceItem(tween: Tween(begin: -0.05, end: 0.0).chain(CurveTween(curve: Curves.easeInOut)), weight: 1), + ]).animate(_controller); + + Future.delayed(const Duration(seconds: 1), () { + _controller.forward(); + }); + + // _controller.addStatusListener((status) { + // if (status == AnimationStatus.completed) { + // _controller.reverse(); + // } else if (status == AnimationStatus.dismissed) { + // _controller.forward(); + // } + // }); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Center( + child: AnimatedBuilder( + animation: _animation, + builder: (context, child) { + return Transform.rotate( + angle: _animation.value, + child: child, + ); + }, + child: Image.asset('xe_shop'.assetPng, + width: 153), + ), + ); + } +} \ No newline at end of file