diff --git a/lib/common/animation/custom_fade_slide_animation.dart b/lib/common/animation/custom_fade_slide_animation.dart deleted file mode 100644 index 76b9141..0000000 --- a/lib/common/animation/custom_fade_slide_animation.dart +++ /dev/null @@ -1,88 +0,0 @@ -import 'package:flutter/material.dart'; - -/// [CustomFadeSlideAnimation] is build using [FadeTransition] and [SlideTransition] - -/// Fade and Slide animation wrapper widget -/// Just wrap the child with this widget and widget will be animated -/// [child] : the widget to be animated -/// [fadeDuration] : duration of animation of fade (default: Duration(milliseconds: 1000)) -/// [slideDuration] : duration of animation of slide (default: Duration(milliseconds: 500)) -/// [fadeCurve] : curve of the fade animation (default: [Curves.decelerate]) -/// [slideCurve] : curve of the scale animation (default: [Curves.decelerate]) -/// [delay] : delay before the animation start (default: Duration(milliseconds: 0)) -/// [textDirection] : direction of the text for slide animation (default: [TextDirection.ltr]) -class CustomFadeSlideAnimation extends StatefulWidget { - const CustomFadeSlideAnimation({ - required this.child, - super.key, - this.beginOffset = const Offset(0, 0.5), - this.endOffset = Offset.zero, - this.fadeDuration = const Duration(milliseconds: 1000), - this.slideDuration = const Duration(milliseconds: 500), - this.fadeCurve = Curves.decelerate, - this.slideCurve = Curves.decelerate, - this.delay = Duration.zero, - this.textDirection = TextDirection.ltr, - }); - - final Widget child; - final Offset beginOffset; - final Offset endOffset; - final Duration fadeDuration; - final Duration slideDuration; - final Curve fadeCurve; - final Curve slideCurve; - final Duration delay; - final TextDirection textDirection; - - @override - CustomFadeSlideAnimationState createState() => CustomFadeSlideAnimationState(); -} - -/// [TickerProviderStateMixin] is used because two animation controllers are being used for making [CustomFadeSlideAnimation]. -class CustomFadeSlideAnimationState extends State with TickerProviderStateMixin { - late CurvedAnimation _fadeAnimation; - late Animation _slideAnimation; - late AnimationController? _fadeController; - late AnimationController? _slideController; - - /// Controllers are initialized in [initState] with the values defined or received as parameters in the widget - @override - void initState() { - super.initState(); - // Setup animation controllers - _fadeController = AnimationController(vsync: this, duration: widget.fadeDuration); - _slideController = AnimationController(vsync: this, duration: widget.slideDuration); - - // Create animations - _fadeAnimation = CurvedAnimation(parent: _fadeController!, curve: widget.fadeCurve); - _slideAnimation = Tween(begin: widget.beginOffset, end: widget.endOffset).animate( - CurvedAnimation(parent: _slideController!, curve: widget.slideCurve), - ); - - // Start animation after the specified delay - Future.delayed(widget.delay).then((value) => {_fadeController?.forward(), _slideController?.forward()}); - } - - /// Both the animation controllers are being disposed for safety - @override - void dispose() { - _fadeController?.dispose(); - _slideController?.dispose(); - _fadeController = null; - _slideController = null; - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return FadeTransition( - opacity: _fadeAnimation, - child: SlideTransition( - position: _slideAnimation, - textDirection: widget.textDirection, - child: widget.child, - ), - ); - } -} diff --git a/lib/features/home/home_page_content.dart b/lib/features/home/home_page_content.dart index e2ca31d..255cfd8 100644 --- a/lib/features/home/home_page_content.dart +++ b/lib/features/home/home_page_content.dart @@ -1,7 +1,6 @@ import 'package:auto_route/auto_route.dart'; import 'package:flutter/material.dart'; import 'package:flutter_app/app/navigation/app_router.dart'; -import 'package:flutter_app/common/animation/custom_fade_slide_animation.dart'; import 'package:flutter_app/common/component/custom_button/custom_button_primary.dart'; import 'package:flutter_app/common/component/custom_text/custom_text.dart'; import 'package:flutter_app/common/extension/build_context.dart'; @@ -18,22 +17,16 @@ class HomePageContent extends StatelessWidget { child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - CustomFadeSlideAnimation( - delay: const Duration(milliseconds: 300), - child: CustomText( - key: const Key('home_title'), // Used for Integration testing - text: 'Home', - style: context.textTheme.titleMedium, - textAlign: TextAlign.center, - ), + CustomText( + key: const Key('home_title'), // Used for Integration testing + text: 'Home', + style: context.textTheme.titleMedium, + textAlign: TextAlign.center, ), const SizedBox(height: 16), - CustomFadeSlideAnimation( - delay: const Duration(milliseconds: 600), - child: CustomButtonPrimary( - onPressed: () => context.pushRoute(const DebugToolsRoute()), - text: context.locale.featureHomepageOpenDebugTools, - ), + CustomButtonPrimary( + onPressed: () => context.pushRoute(const DebugToolsRoute()), + text: context.locale.featureHomepageOpenDebugTools, ), ], ),