diff --git a/Sources/justMUSIC/lib/components/top_nav_bar_component.dart b/Sources/justMUSIC/lib/components/top_nav_bar_component.dart index b990baa..ab0c499 100644 --- a/Sources/justMUSIC/lib/components/top_nav_bar_component.dart +++ b/Sources/justMUSIC/lib/components/top_nav_bar_component.dart @@ -157,7 +157,7 @@ class _TopNavBarComponentState extends State with TickerProv longTapRepeatDuration: const Duration(milliseconds: 100), begin: 1.0, onTap: () { - Navigator.of(context).pushNamed('/launchingRocket'); + checkAvailable(); }, end: 0.97, beginDuration: const Duration(milliseconds: 70), diff --git a/Sources/justMUSIC/lib/screens/launching_rocker_screen.dart b/Sources/justMUSIC/lib/screens/launching_rocker_screen.dart index d68dbef..b815342 100644 --- a/Sources/justMUSIC/lib/screens/launching_rocker_screen.dart +++ b/Sources/justMUSIC/lib/screens/launching_rocker_screen.dart @@ -1,6 +1,8 @@ import 'package:flutter/Material.dart'; import 'package:lottie/lottie.dart'; +import '../values/constants.dart'; + class LaunchingRocketScreen extends StatefulWidget { const LaunchingRocketScreen({super.key}); @@ -11,33 +13,102 @@ class LaunchingRocketScreen extends StatefulWidget { class _LaunchingRocketScreenState extends State with TickerProviderStateMixin { late final AnimationController _controller; + late AnimationController _controller2; + late Animation _animation; + @override initState() { _controller = AnimationController(vsync: this, duration: Duration(seconds: 3)); + + _controller2 = AnimationController( + vsync: this, + duration: Duration(milliseconds: 800), + ); + + final CurvedAnimation curve = CurvedAnimation(parent: _controller2, curve: Curves.easeIn); + + _animation = Tween( + begin: 0, + end: 1, + ).animate(curve); + + _controller2.addStatusListener((status) { + print("cccccccc"); + if (status == AnimationStatus.completed) { + Navigator.of(context).popUntil((route) => route.settings.name == '/feed'); + } + }); + super.initState(); } + @override + void dispose() { + _controller.dispose(); + _controller2.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { - return Stack( - fit: StackFit.expand, - children: [ - Align( - alignment: Alignment.topCenter, - child: Lottie.asset( - 'assets/animations/rocket.json', - width: double.infinity, - frameRate: FrameRate(60), - fit: BoxFit.contain, - controller: _controller, - onLoaded: (composition) { - // Configure the AnimationController with the duration of the - // Lottie file and start the animation. - _controller.forward(); - }, - ), + bool animationCompleted = false; + return Scaffold( + backgroundColor: primaryColor, + body: Container( + width: double.infinity, + height: double.infinity, + child: Stack( + children: [ + Lottie.asset( + 'assets/animations/rocket.json', + height: 600, + frameRate: FrameRate(60), + fit: BoxFit.contain, + controller: _controller, + onLoaded: (composition) { + _controller + ..duration = composition.duration + ..forward().whenComplete(() { + setState(() { + animationCompleted = true; + }); + _controller2.forward(); + }); + }, + ), + Center( + child: AnimatedBuilder( + animation: _animation, + builder: (context, child) { + double circlePosition = MediaQuery.of(context).size.height * _animation.value; + return CustomPaint( + painter: CirclePainter(circlePosition), + ); + }, + )), + ], ), - ], + ), ); } } + +class CirclePainter extends CustomPainter { + final double circlePosition; + + CirclePainter(this.circlePosition); + + @override + void paint(Canvas canvas, Size size) { + Paint paint = Paint()..color = Colors.white; + double radius = 50 * circlePosition; // Remplacez par le rayon souhaité de votre cercle + Offset center = Offset(size.width / 2, size.height / 2); + + canvas.drawCircle(center, radius, paint); + } + + @override + bool shouldRepaint(CustomPainter oldDelegate) { + return true; + } +} diff --git a/Sources/justMUSIC/lib/screens/post_screen.dart b/Sources/justMUSIC/lib/screens/post_screen.dart index ac94942..3f76761 100644 --- a/Sources/justMUSIC/lib/screens/post_screen.dart +++ b/Sources/justMUSIC/lib/screens/post_screen.dart @@ -19,8 +19,7 @@ class PostScreen extends StatefulWidget { State createState() => _PostScreenState(); } -class _PostScreenState extends State - with SingleTickerProviderStateMixin { +class _PostScreenState extends State with SingleTickerProviderStateMixin { final scrollController = ScrollController(); late AnimationController _controller; @@ -82,25 +81,22 @@ class _PostScreenState extends State isScrollControlled: true, context: context, shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(20), topRight: Radius.circular(20))), + borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))), builder: ((context) { return ClipRRect( - borderRadius: BorderRadius.only( - topLeft: Radius.circular(20), topRight: Radius.circular(20)), + borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)), child: SearchSongScreen(callback: _selectMusic)); }), ); } handleSubmit() async { - await MyApp.postViewModel.addPost( - description, (selectedMusic?.id)!, selectedImage, selectedCity); + MyApp.postViewModel.addPost(description, (selectedMusic?.id)!, selectedImage, selectedCity); quit(); } quit() { - Navigator.pop(context); + Navigator.pushNamed(context, '/launchingRocket'); } @override @@ -113,10 +109,7 @@ class _PostScreenState extends State preferredSize: Size(double.infinity, 80), child: SafeArea( child: Padding( - padding: EdgeInsets.only( - left: defaultPadding, - right: defaultPadding, - top: defaultPadding), + padding: EdgeInsets.only(left: defaultPadding, right: defaultPadding, top: defaultPadding), child: Row( children: [BackButtonComponent()], ), @@ -124,8 +117,7 @@ class _PostScreenState extends State ), ), body: Container( - padding: - const EdgeInsets.only(left: defaultPadding, right: defaultPadding), + padding: const EdgeInsets.only(left: defaultPadding, right: defaultPadding), width: double.infinity, height: double.infinity, decoration: const BoxDecoration(