From 6e614e2100711cdc584503a4dc9750a04264f2f0 Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Tue, 1 Aug 2023 18:06:50 +0200 Subject: [PATCH] add friend is live !!! :sparkles: --- .../justMUSIC/assets/animations/rocket.json | 1 + .../components/profile_list_component.dart | 22 ++++++++++ .../lib/components/top_nav_bar_component.dart | 26 +++++------ Sources/justMUSIC/lib/main.dart | 2 + .../lib/screens/launching_rocker_screen.dart | 43 +++++++++++++++++++ 5 files changed, 79 insertions(+), 15 deletions(-) create mode 100644 Sources/justMUSIC/assets/animations/rocket.json create mode 100644 Sources/justMUSIC/lib/screens/launching_rocker_screen.dart diff --git a/Sources/justMUSIC/assets/animations/rocket.json b/Sources/justMUSIC/assets/animations/rocket.json new file mode 100644 index 0000000..e960151 --- /dev/null +++ b/Sources/justMUSIC/assets/animations/rocket.json @@ -0,0 +1 @@ +{"nm":"newScene","ddd":0,"h":506,"w":246,"meta":{"g":"LottieFiles Figma v38"},"layers":[{"ty":4,"nm":"","sr":1,"st":0,"op":55,"ip":0,"hd":false,"ddd":0,"bm":0,"hasMask":false,"ao":0,"ks":{"a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":0,"k":0},"sa":{"a":0,"k":0},"o":{"a":0,"k":100}},"ef":[],"shapes":[{"ty":"gr","bm":0,"hd":false,"nm":"","it":[{"ty":"sh","bm":0,"hd":false,"nm":"","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[18.31699999999998,-14.117000000000019],[0,0],[4.924000000000007,-5.552999999999997],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[-2.176000000000016,8.12299999999999],[0,0],[-4.0330000000000155,15.050000000000011],[0,0],[0,0]],"o":[[-15.049000000000007,-4.031999999999982],[0,0],[-8.12299999999999,-2.1759999999999877],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[7.271000000000015,-1.488999999999976],[0,0],[21.383999999999986,-8.803999999999974],[0,0],[0,0],[0,0]],"v":[[229.562,323.522],[173.235,338.521],[161.993,335.509],[142.666,343.701],[136.075,351.133],[146.207,353.848],[156.351,356.566],[164.059,369.916],[171.766,383.266],[169.048,393.41],[166.333,403.542],[176.065,401.551],[192.823,388.908],[195.836,377.666],[236.989,336.385],[239.707,326.24],[229.562,323.522]]}}},{"ty":"sh","bm":0,"hd":false,"nm":"","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[1.0389999999999873,-3.8759999999999764],[3.8770000000000095,1.038000000000011],[-1.0389999999999873,3.8770000000000095],[-3.8770000000000095,-1.0389999999999873]],"o":[[3.8760000000000048,1.038000000000011],[-1.0390000000000157,3.8770000000000095],[-3.8770000000000095,-1.0389999999999873],[1.038000000000011,-3.8770000000000095],[0,0]],"v":[[205.989,339.775],[211.127,348.674],[202.227,353.813],[197.089,344.913],[205.989,339.775]]}}},{"ty":"sh","bm":0,"hd":false,"nm":"","d":1,"ks":{"a":0,"k":{"c":true,"i":[[0,0],[0,0],[0,0],[-7.138000000000005,4.120999999999981],[0,0],[0,0]],"o":[[0,0],[-6.4269999999999925,3.7110000000000127],[0,0],[0,0],[0,0],[0,0]],"v":[[149.08,369.664],[144.63,372.233],[132.909,387.9],[152.338,385.583],[156.788,383.014],[149.08,369.664]]}}},{"ty":"fl","bm":0,"hd":false,"nm":"","c":{"a":0,"k":[1,1,1]},"r":1,"o":{"a":0,"k":100}},{"ty":"tr","a":{"a":0,"k":[0,0]},"s":{"a":0,"k":[100,100]},"sk":{"a":0,"k":0},"p":{"a":0,"k":[0,0]},"r":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[90],"t":0},{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[90],"t":5},{"s":[0],"t":25}]},"sa":{"a":0,"k":0},"o":{"a":1,"k":[{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[0],"t":0},{"o":{"x":0.167,"y":0.167},"i":{"x":0.833,"y":0.833},"s":[0],"t":5},{"s":[100],"t":25}]}}]}],"ind":1}],"v":"5.7.0","fr":60,"op":55,"ip":0,"assets":[]} \ No newline at end of file diff --git a/Sources/justMUSIC/lib/components/profile_list_component.dart b/Sources/justMUSIC/lib/components/profile_list_component.dart index 66b02a3..ebb5363 100644 --- a/Sources/justMUSIC/lib/components/profile_list_component.dart +++ b/Sources/justMUSIC/lib/components/profile_list_component.dart @@ -1,4 +1,5 @@ import 'package:flutter/Material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; import '../main.dart'; import '../model/User.dart'; @@ -82,6 +83,17 @@ class _ProfileListComponentState extends State { splashColor: Colors.white.withOpacity(0.3), onTap: () async { await MyApp.userViewModel.addOrDeleteFriend(widget.user.id); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text( + "Vous ne suivez plus ${widget.user.pseudo}", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h), + ), + backgroundColor: Colors.red, + closeIconColor: Colors.white, + ), + ); setState(() {}); }, child: Container( @@ -100,6 +112,16 @@ class _ProfileListComponentState extends State { splashColor: Colors.white.withOpacity(0.3), onTap: () async { await MyApp.userViewModel.addOrDeleteFriend(widget.user.id); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + backgroundColor: primaryColor, + content: Text( + "Vous suivez à present ${widget.user.pseudo}", + style: GoogleFonts.plusJakartaSans( + color: Colors.white, fontWeight: FontWeight.w400, fontSize: 20.h), + ), + ), + ); setState(() {}); }, child: Container( diff --git a/Sources/justMUSIC/lib/components/top_nav_bar_component.dart b/Sources/justMUSIC/lib/components/top_nav_bar_component.dart index 688a762..b990baa 100644 --- a/Sources/justMUSIC/lib/components/top_nav_bar_component.dart +++ b/Sources/justMUSIC/lib/components/top_nav_bar_component.dart @@ -138,10 +138,7 @@ class _TopNavBarComponentState extends State with TickerProv child: GestureDetector( behavior: HitTestBehavior.translucent, onTap: () async { - bool returnFromOtherPage = await Navigator.of(context).push(routeAddFriend()); - if (returnFromOtherPage == true) { - checkAvailable(); - } + Navigator.of(context).push(routeAddFriend()); }, child: const Icon( Icons.person_add_alt_1_rounded, @@ -159,7 +156,9 @@ class _TopNavBarComponentState extends State with TickerProv enableLongTapRepeatEvent: false, longTapRepeatDuration: const Duration(milliseconds: 100), begin: 1.0, - onTap: () {}, + onTap: () { + Navigator.of(context).pushNamed('/launchingRocket'); + }, end: 0.97, beginDuration: const Duration(milliseconds: 70), endDuration: const Duration(milliseconds: 100), @@ -238,19 +237,16 @@ class _TopNavBarComponentState extends State with TickerProv child: GestureDetector( onTap: () async { await MyApp.userViewModel.updateUserCurrent(); - bool returnFromOtherPage = await Navigator.of(context).push(routeProfile()); - if (returnFromOtherPage == true) { - checkAvailable(); - } + Navigator.of(context).push(routeProfile()); }, child: ClipOval( child: SizedBox.fromSize( - // Image radius - child: Image( - image: NetworkImage(MyApp.userViewModel.userCurrent.pp), - width: 30, - ), - ), + // Image radius + child: FadeInImage.assetNetwork( + placeholder: 'assets/images/loadingPlaceholder.gif', + image: MyApp.userViewModel.userCurrent.pp, + width: 30, + )), ), ), ) diff --git a/Sources/justMUSIC/lib/main.dart b/Sources/justMUSIC/lib/main.dart index 38fa806..b2416fd 100644 --- a/Sources/justMUSIC/lib/main.dart +++ b/Sources/justMUSIC/lib/main.dart @@ -8,6 +8,7 @@ import 'package:justmusic/screens/add_friend_screen.dart'; import 'package:justmusic/screens/explanations_screen.dart'; import 'package:justmusic/screens/feed_screen.dart'; import 'package:justmusic/screens/login_screen.dart'; +import 'package:justmusic/screens/launching_rocker_screen.dart'; import 'package:justmusic/screens/post_screen.dart'; import 'package:justmusic/screens/profile_screen.dart'; import 'package:justmusic/screens/registration_screen.dart'; @@ -53,6 +54,7 @@ class MyApp extends StatelessWidget { '/profile': (context) => const ProfileScreen(), '/explanation': (context) => const ExplanationsScreen(), '/addFriend': (context) => const AddFriendScreen(), + '/launchingRocket': (context) => const LaunchingRocketScreen(), }, debugShowCheckedModeBanner: false, theme: ThemeData( diff --git a/Sources/justMUSIC/lib/screens/launching_rocker_screen.dart b/Sources/justMUSIC/lib/screens/launching_rocker_screen.dart new file mode 100644 index 0000000..d68dbef --- /dev/null +++ b/Sources/justMUSIC/lib/screens/launching_rocker_screen.dart @@ -0,0 +1,43 @@ +import 'package:flutter/Material.dart'; +import 'package:lottie/lottie.dart'; + +class LaunchingRocketScreen extends StatefulWidget { + const LaunchingRocketScreen({super.key}); + + @override + State createState() => _LaunchingRocketScreenState(); +} + +class _LaunchingRocketScreenState extends State with TickerProviderStateMixin { + late final AnimationController _controller; + + @override + initState() { + _controller = AnimationController(vsync: this, duration: Duration(seconds: 3)); + super.initState(); + } + + @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(); + }, + ), + ), + ], + ); + } +}