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:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -336,16 +338,18 @@ class _PostComponentState extends State<PostComponent> with TickerProviderStateM
fit: BoxFit.fitHeight,
width: double.infinity,
),
Padding(
padding: EdgeInsets.all(15),
child: AutoSizeText(
'${widget.post.description}',
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w400, fontSize: 15.sp),
maxFontSize: 20,
maxLines: 1,
),
),
widget.post.description.isNull
? Container()
: Padding(
padding: EdgeInsets.all(15),
child: AutoSizeText(
'${widget.post.description}',
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w400, fontSize: 15.sp),
maxFontSize: 20,
maxLines: 1,
),
),
widget.post.selfie != null
? Positioned(
top: 0,

@ -214,58 +214,104 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
@override
Widget build(BuildContext context) {
return Scaffold(
resizeToAvoidBottomInset: true,
backgroundColor: bgColor,
extendBodyBehindAppBar: true,
body: Container(
width: double.infinity,
child: Stack(
fit: StackFit.expand,
children: [
Align(
child: CircularRevealAnimation(
animation: animation,
centerOffset: Offset(30.w, -100),
child: Container(
constraints: BoxConstraints(maxWidth: 600),
padding: EdgeInsets.fromLTRB(defaultPadding, 100.h, defaultPadding, 0),
child: ListView.builder(
physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
clipBehavior: Clip.none,
shrinkWrap: true,
itemCount: displayFeed.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.only(bottom: 40),
child: PostComponent(callback: openDetailPost, post: displayFeed[index], index: index),
);
},
)),
),
),
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)])),
resizeToAvoidBottomInset: true,
backgroundColor: bgColor,
extendBodyBehindAppBar: true,
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),
),
),
],
),
),
),
Align(
alignment: Alignment.topCenter,
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 800),
child: TopNavBarComponent(callback: changeFeed),
),
),
],
),
),
);
)
: Container(
width: double.infinity,
child: Stack(
fit: StackFit.expand,
children: [
Align(
child: CircularRevealAnimation(
animation: animation,
centerOffset: Offset(30.w, -100),
child: Container(
constraints: BoxConstraints(maxWidth: 600),
padding: EdgeInsets.fromLTRB(defaultPadding, 100.h, defaultPadding, 0),
child: ListView.builder(
physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
clipBehavior: Clip.none,
shrinkWrap: true,
itemCount: displayFeed.length,
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: const EdgeInsets.only(bottom: 40),
child:
PostComponent(callback: openDetailPost, post: displayFeed[index], index: index),
);
},
)),
),
),
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),
),
),
],
),
));
}
}

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

Loading…
Cancel
Save