animation when post

pull/32/head
Lucas Delanier 2 years ago
parent 6e614e2100
commit 3771b40a49

@ -157,7 +157,7 @@ class _TopNavBarComponentState extends State<TopNavBarComponent> with TickerProv
longTapRepeatDuration: const Duration(milliseconds: 100), longTapRepeatDuration: const Duration(milliseconds: 100),
begin: 1.0, begin: 1.0,
onTap: () { onTap: () {
Navigator.of(context).pushNamed('/launchingRocket'); checkAvailable();
}, },
end: 0.97, end: 0.97,
beginDuration: const Duration(milliseconds: 70), beginDuration: const Duration(milliseconds: 70),

@ -1,6 +1,8 @@
import 'package:flutter/Material.dart'; import 'package:flutter/Material.dart';
import 'package:lottie/lottie.dart'; import 'package:lottie/lottie.dart';
import '../values/constants.dart';
class LaunchingRocketScreen extends StatefulWidget { class LaunchingRocketScreen extends StatefulWidget {
const LaunchingRocketScreen({super.key}); const LaunchingRocketScreen({super.key});
@ -11,33 +13,102 @@ class LaunchingRocketScreen extends StatefulWidget {
class _LaunchingRocketScreenState extends State<LaunchingRocketScreen> with TickerProviderStateMixin { class _LaunchingRocketScreenState extends State<LaunchingRocketScreen> with TickerProviderStateMixin {
late final AnimationController _controller; late final AnimationController _controller;
late AnimationController _controller2;
late Animation<double> _animation;
@override @override
initState() { initState() {
_controller = AnimationController(vsync: this, duration: Duration(seconds: 3)); _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<double>(
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(); super.initState();
} }
@override
void dispose() {
_controller.dispose();
_controller2.dispose();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Stack( bool animationCompleted = false;
fit: StackFit.expand, return Scaffold(
backgroundColor: primaryColor,
body: Container(
width: double.infinity,
height: double.infinity,
child: Stack(
children: [ children: [
Align( Lottie.asset(
alignment: Alignment.topCenter,
child: Lottie.asset(
'assets/animations/rocket.json', 'assets/animations/rocket.json',
width: double.infinity, height: 600,
frameRate: FrameRate(60), frameRate: FrameRate(60),
fit: BoxFit.contain, fit: BoxFit.contain,
controller: _controller, controller: _controller,
onLoaded: (composition) { onLoaded: (composition) {
// Configure the AnimationController with the duration of the _controller
// Lottie file and start the animation. ..duration = composition.duration
_controller.forward(); ..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;
}
}

@ -19,8 +19,7 @@ class PostScreen extends StatefulWidget {
State<PostScreen> createState() => _PostScreenState(); State<PostScreen> createState() => _PostScreenState();
} }
class _PostScreenState extends State<PostScreen> class _PostScreenState extends State<PostScreen> with SingleTickerProviderStateMixin {
with SingleTickerProviderStateMixin {
final scrollController = ScrollController(); final scrollController = ScrollController();
late AnimationController _controller; late AnimationController _controller;
@ -82,25 +81,22 @@ class _PostScreenState extends State<PostScreen>
isScrollControlled: true, isScrollControlled: true,
context: context, context: context,
shape: const RoundedRectangleBorder( shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))),
topLeft: Radius.circular(20), topRight: Radius.circular(20))),
builder: ((context) { builder: ((context) {
return ClipRRect( return ClipRRect(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)),
topLeft: Radius.circular(20), topRight: Radius.circular(20)),
child: SearchSongScreen(callback: _selectMusic)); child: SearchSongScreen(callback: _selectMusic));
}), }),
); );
} }
handleSubmit() async { handleSubmit() async {
await MyApp.postViewModel.addPost( MyApp.postViewModel.addPost(description, (selectedMusic?.id)!, selectedImage, selectedCity);
description, (selectedMusic?.id)!, selectedImage, selectedCity);
quit(); quit();
} }
quit() { quit() {
Navigator.pop(context); Navigator.pushNamed(context, '/launchingRocket');
} }
@override @override
@ -113,10 +109,7 @@ class _PostScreenState extends State<PostScreen>
preferredSize: Size(double.infinity, 80), preferredSize: Size(double.infinity, 80),
child: SafeArea( child: SafeArea(
child: Padding( child: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(left: defaultPadding, right: defaultPadding, top: defaultPadding),
left: defaultPadding,
right: defaultPadding,
top: defaultPadding),
child: Row( child: Row(
children: [BackButtonComponent()], children: [BackButtonComponent()],
), ),
@ -124,8 +117,7 @@ class _PostScreenState extends State<PostScreen>
), ),
), ),
body: Container( body: Container(
padding: padding: const EdgeInsets.only(left: defaultPadding, right: defaultPadding),
const EdgeInsets.only(left: defaultPadding, right: defaultPadding),
width: double.infinity, width: double.infinity,
height: double.infinity, height: double.infinity,
decoration: const BoxDecoration( decoration: const BoxDecoration(

Loading…
Cancel
Save