|
|
@ -9,24 +9,26 @@ class PostService {
|
|
|
|
createPost(String? description, String idMusic, File? image,
|
|
|
|
createPost(String? description, String idMusic, File? image,
|
|
|
|
Tuple2<String, String>? location) async {
|
|
|
|
Tuple2<String, String>? location) async {
|
|
|
|
var id = MyApp.userViewModel.userCurrent.id;
|
|
|
|
var id = MyApp.userViewModel.userCurrent.id;
|
|
|
|
|
|
|
|
|
|
|
|
final post = <String, dynamic>{
|
|
|
|
final post = <String, dynamic>{
|
|
|
|
"user_id": id,
|
|
|
|
"user_id": id,
|
|
|
|
"description": description,
|
|
|
|
"description": description,
|
|
|
|
"date": DateTime.now(),
|
|
|
|
"date": DateTime.now(),
|
|
|
|
"place": [location?.item1, location?.item2],
|
|
|
|
"place": [location?.item1, location?.item2],
|
|
|
|
"selfie": null,
|
|
|
|
|
|
|
|
"song_id": idMusic,
|
|
|
|
"song_id": idMusic,
|
|
|
|
"likes": 0
|
|
|
|
"likes": 0
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var postAdd = await MyApp.db.collection("posts").add(post);
|
|
|
|
var postAdd = await MyApp.db.collection("posts").add(post);
|
|
|
|
|
|
|
|
print("cc");
|
|
|
|
if (image != null) {
|
|
|
|
if (image != null) {
|
|
|
|
var imageUrl = FirebaseStorage.instance.ref(id + postAdd.id);
|
|
|
|
print("cc3");
|
|
|
|
await imageUrl.putFile(image);
|
|
|
|
var imageRef = FirebaseStorage.instance.ref('$id${postAdd.id}.jpg');
|
|
|
|
|
|
|
|
await imageRef.putFile(image);
|
|
|
|
|
|
|
|
var imageUrl = await imageRef.getDownloadURL();
|
|
|
|
|
|
|
|
print(imageUrl);
|
|
|
|
postAdd.update({"selfie": imageUrl});
|
|
|
|
postAdd.update({"selfie": imageUrl});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
print("cc2");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
deletePost() {}
|
|
|
|
deletePost() {}
|
|
|
|