beautifull app when empty friend list and fix empty description

pull/30/head
Lucas Delanier 2 years ago
parent b0ed6b3934
commit 0cebb7bbef

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

@ -1,3 +1,5 @@
import 'dart:js_interop';
import 'package:auto_size_text/auto_size_text.dart'; import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -336,7 +338,9 @@ class _PostComponentState extends State<PostComponent> with TickerProviderStateM
fit: BoxFit.fitHeight, fit: BoxFit.fitHeight,
width: double.infinity, width: double.infinity,
), ),
Padding( widget.post.description.isNull
? Container()
: Padding(
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
child: AutoSizeText( child: AutoSizeText(
'${widget.post.description}', '${widget.post.description}',

@ -217,7 +217,53 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
resizeToAvoidBottomInset: true, resizeToAvoidBottomInset: true,
backgroundColor: bgColor, backgroundColor: bgColor,
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
body: Container( body: displayFeed.isEmpty
? Container(
width: double.infinity,
child: Stack(
fit: StackFit.expand,
children: [
Container(
decoration: const BoxDecoration(
image: DecorationImage(
image: AssetImage("assets/images/empty_bg.png"), fit: BoxFit.cover, opacity: 0.3),
),
child: Padding(
padding: EdgeInsets.only(top: 140.h, left: defaultPadding),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Suis tes amis pour voir leurs capsules",
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontSize: 23, fontWeight: FontWeight.w800))
],
),
),
),
Align(
alignment: Alignment.topCenter,
child: IgnorePointer(
child: Container(
height: 240.h,
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topRight,
stops: [0.3, 1],
colors: [bgColor.withOpacity(0.9), bgColor.withOpacity(0)])),
),
),
),
Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 800),
child: TopNavBarComponent(callback: changeFeed),
),
),
],
),
)
: Container(
width: double.infinity, width: double.infinity,
child: Stack( child: Stack(
fit: StackFit.expand, fit: StackFit.expand,
@ -237,7 +283,8 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return Padding( return Padding(
padding: const EdgeInsets.only(bottom: 40), padding: const EdgeInsets.only(bottom: 40),
child: PostComponent(callback: openDetailPost, post: displayFeed[index], index: index), child:
PostComponent(callback: openDetailPost, post: displayFeed[index], index: index),
); );
}, },
)), )),
@ -265,7 +312,6 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
), ),
], ],
), ),
), ));
);
} }
} }

@ -8,8 +8,7 @@ import 'package:firebase_storage/firebase_storage.dart';
import '../main.dart'; import '../main.dart';
class PostService { 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,
@ -29,6 +28,7 @@ class PostService {
if (userSnapshot.exists) { if (userSnapshot.exists) {
int currentNbCapsules = userSnapshot.data()?['nbCapsules'] ?? 0; int currentNbCapsules = userSnapshot.data()?['nbCapsules'] ?? 0;
transaction.update(userRef, {'nbCapsules': currentNbCapsules + 1}); transaction.update(userRef, {'nbCapsules': currentNbCapsules + 1});
MyApp.userViewModel.userCurrent.capsules++;
} }
}); });
@ -44,13 +44,9 @@ class PostService {
getPostsById(String id) {} getPostsById(String id) {}
Future<List<QueryDocumentSnapshot<Map<String, dynamic>>>> getPopularPosts( Future<List<QueryDocumentSnapshot<Map<String, dynamic>>>> getPopularPosts({int limit = 10, int offset = 0}) async {
{int limit = 10, int offset = 0}) async { QuerySnapshot<Map<String, dynamic>> response =
QuerySnapshot<Map<String, dynamic>> response = await FirebaseFirestore.instance await FirebaseFirestore.instance.collection("posts").limit(limit).orderBy("likes").get();
.collection("posts")
.limit(limit)
.orderBy("likes").get();
return response.docs; return response.docs;
} }
} }

Loading…
Cancel
Save