From de013faa30e33b9bb9ed9f55840eb240692312f8 Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Mon, 31 Jul 2023 01:22:01 +0200 Subject: [PATCH] post capsule :sparkles: --- .idea/libraries/Dart_Packages.xml | 24 +++++++++++++++++++ .../justMUSIC/lib/screens/post_screen.dart | 2 ++ .../justMUSIC/lib/services/PostService.dart | 12 ++++++---- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml index 5d474aa..772a2fc 100644 --- a/.idea/libraries/Dart_Packages.xml +++ b/.idea/libraries/Dart_Packages.xml @@ -254,6 +254,27 @@ + + + + + + + + + + + + + + + + + + @@ -755,6 +776,9 @@ + + + diff --git a/Sources/justMUSIC/lib/screens/post_screen.dart b/Sources/justMUSIC/lib/screens/post_screen.dart index ac94942..c3fb4d1 100644 --- a/Sources/justMUSIC/lib/screens/post_screen.dart +++ b/Sources/justMUSIC/lib/screens/post_screen.dart @@ -94,8 +94,10 @@ class _PostScreenState extends State } handleSubmit() async { + print("ccccccccccccc"); await MyApp.postViewModel.addPost( description, (selectedMusic?.id)!, selectedImage, selectedCity); + print("ccccccccccccc"); quit(); } diff --git a/Sources/justMUSIC/lib/services/PostService.dart b/Sources/justMUSIC/lib/services/PostService.dart index c07059b..4a305a8 100644 --- a/Sources/justMUSIC/lib/services/PostService.dart +++ b/Sources/justMUSIC/lib/services/PostService.dart @@ -9,24 +9,26 @@ class PostService { createPost(String? description, String idMusic, File? image, Tuple2? location) async { var id = MyApp.userViewModel.userCurrent.id; - final post = { "user_id": id, "description": description, "date": DateTime.now(), "place": [location?.item1, location?.item2], - "selfie": null, "song_id": idMusic, "likes": 0 }; var postAdd = await MyApp.db.collection("posts").add(post); - + print("cc"); if (image != null) { - var imageUrl = FirebaseStorage.instance.ref(id + postAdd.id); - await imageUrl.putFile(image); + print("cc3"); + var imageRef = FirebaseStorage.instance.ref('$id${postAdd.id}.jpg'); + await imageRef.putFile(image); + var imageUrl = await imageRef.getDownloadURL(); + print(imageUrl); postAdd.update({"selfie": imageUrl}); } + print("cc2"); } deletePost() {}