diff options
author | Lisandro Pérez Meyer <lpmeyer@ics.com> | 2023-11-14 17:20:58 -0300 |
---|---|---|
committer | Lisandro Pérez Meyer <lpmeyer@ics.com> | 2023-11-14 17:31:12 -0300 |
commit | 70ec8a79a121471a004e7e4c23157d10157e136f (patch) | |
tree | a4f9c0a4fac4e4274ec4324a289b6ef62e1c5653 /lib/presentation/screens/splash/widget |
Initial cleanup push.
Based on agldemo2024 on commit 2a5dc04d801134338150c3f6afc67eaa65599763
Disable device preview.
Disable Lottie animation.
The original commit was b3c493c340fcb4bb0a937692838fc830bec3e9ea
but I am just keeping this change, because the json did not really
needed to change. I think.
Signed-off-by: Lisandro Pérez Meyer <lpmeyer@ics.com>
Diffstat (limited to 'lib/presentation/screens/splash/widget')
-rw-r--r-- | lib/presentation/screens/splash/widget/splash_content.dart | 142 |
1 files changed, 142 insertions, 0 deletions
diff --git a/lib/presentation/screens/splash/widget/splash_content.dart b/lib/presentation/screens/splash/widget/splash_content.dart new file mode 100644 index 0000000..325baeb --- /dev/null +++ b/lib/presentation/screens/splash/widget/splash_content.dart @@ -0,0 +1,142 @@ +import 'package:flutter_ics_homescreen/export.dart'; + +class SplashContent extends ConsumerStatefulWidget { + const SplashContent({super.key}); + + @override + SplashContentState createState() => SplashContentState(); +} + +class SplashContentState extends ConsumerState<SplashContent> + with TickerProviderStateMixin { + late Animation<double> _fadeAnimation; + late AnimationController _lottieController; + late AnimationController _fadeController; + bool _showLottieAnimation = + true; // New state to control the visibility of Lottie animation + + @override + void initState() { + super.initState(); + // If you need to control the Lottie animation, initialize its controller + _lottieController = AnimationController( + vsync: this, + duration: const Duration(seconds: 7), + ); + + Future.delayed(const Duration(milliseconds: 1500), () { + _lottieController.repeat(); + }); + + // Initialize the fade animation controller + _fadeController = AnimationController( + vsync: this, + duration: const Duration(seconds: 1), // Fade transition duration + ); + + // Set up the fade animation + _fadeAnimation = + Tween<double>(begin: 0.0, end: 1.0).animate(_fadeController) + ..addListener(() { + // Check the status of the animation and set the state to hide Lottie when fading starts. + if (_fadeAnimation.value > 0.0 && _showLottieAnimation) { + setState(() { + _showLottieAnimation = false; + }); + } + }); + + // Start the fade-in transition after the Lottie animation has played for some time + Future.delayed(const Duration(seconds: 6), () { + // Stop the Lottie animation if needed + _lottieController.stop(); + + // Start the fade-in transition + _fadeController.forward(); + }); + } + + @override + void dispose() { + // Dispose the animation controller to release resources. + _fadeController.dispose(); + _lottieController.dispose(); + super.dispose(); + } + + @override + void didChangeDependencies() { + ref.read(vehicleProvider.notifier).startListen(); + super.didChangeDependencies(); + } + + @override + Widget build(BuildContext context) { + return Stack( + children: [ + if (_showLottieAnimation) + Center( + child: Lottie.asset( + 'animations/Logo_JSON.json', + controller: _lottieController, + onLoaded: (composition) { + _lottieController.duration = composition.duration; + }, + ), + ), + // FadeTransition wraps existing UI. + FadeTransition( + opacity: _fadeAnimation, + child: Center( + child: buildWarningUI(), + ), + ), + ], + ); + } + + Widget buildWarningUI() { + return Column( + children: [ + const Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + 'WARNING:', + style: TextStyle(color: Color(0xFFC1D8FF), fontSize: 44), + ), + SizedBox(height: 38), + SizedBox( + //color: Colors.amber, + width: 757, + height: 488, + child: Text( + splashWarning, + style: TextStyle(color: Colors.white, fontSize: 40, height: 1.7, fontWeight: FontWeight.w400), + textAlign: TextAlign.left, + + ), + ), + ], + ), + ), + GenericButton( + heigth: 122, + width: 452, + text: 'Continue', + onTap: () { + ref.read(vehicleProvider.notifier).setInitialState(); + ref + .read(appProvider.notifier) + .update((state) => state = AppState.dashboard); + }, + ), + + const SizedBox( + height: 72, + ) + ], + ); + } +} |