diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index b34dbd8..36e15e8 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -695,6 +695,48 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -975,6 +1017,13 @@ + + + + + + diff --git a/Sources/justMUSIC/lib/screens/detail_post_screen.dart b/Sources/justMUSIC/lib/screens/detail_post_screen.dart index 1383acc..a557036 100644 --- a/Sources/justMUSIC/lib/screens/detail_post_screen.dart +++ b/Sources/justMUSIC/lib/screens/detail_post_screen.dart @@ -302,33 +302,32 @@ class _DetailPostScreenState extends State { onTap: () async { var bool = await MyApp.postViewModel .addOrDeleteFavoritePost(widget.post.id); + print("testttt"); if (!bool) { widget.post.likes.add(MyApp.userViewModel.userCurrent.id); + + setState(() {}); + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Vous avez liké cette capsule", + style: TextStyle(fontWeight: FontWeight.bold)), + backgroundColor: primaryColor, + closeIconColor: Colors.white, + ), + ); } else { widget.post.likes.remove(MyApp.userViewModel.userCurrent.id); + setState(() {}); + + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text("Vous avez supprimé votre like", + style: TextStyle(fontWeight: FontWeight.bold)), + backgroundColor: Colors.red, + closeIconColor: Colors.white, + ), + ); } - !bool - ? ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: Text("Vous avez liké cette capsule", - style: TextStyle(fontWeight: FontWeight.bold)), - backgroundColor: primaryColor, - closeIconColor: Colors.white, - ), - ) - : ScaffoldMessenger.of(context).showSnackBar( - const SnackBar( - content: SnackBar( - content: Text("Vous avez supprimé votre like", - style: TextStyle(fontWeight: FontWeight.bold)), - backgroundColor: primaryColor, - closeIconColor: Colors.white, - ), - backgroundColor: Colors.red, - closeIconColor: Colors.white, - ), - ); - setState(() {}); }, child: SvgPicture.asset( "assets/images/heart.svg", diff --git a/Sources/justMUSIC/lib/view_model/PostViewModel.dart b/Sources/justMUSIC/lib/view_model/PostViewModel.dart index f7498ce..1c2a361 100644 --- a/Sources/justMUSIC/lib/view_model/PostViewModel.dart +++ b/Sources/justMUSIC/lib/view_model/PostViewModel.dart @@ -108,9 +108,11 @@ class PostViewModel { Future addOrDeleteFavoritePost(String id) async { try { - return await _postService.addOrDeleteFavoritePost(id); + var bool = await _postService.addOrDeleteFavoritePost(id); + print(bool); + return bool; } catch (e) { - print(e); + print("haaaaaaaaa"); rethrow; } }