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

@ -214,58 +214,104 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: true, resizeToAvoidBottomInset: true,
backgroundColor: bgColor, backgroundColor: bgColor,
extendBodyBehindAppBar: true, extendBodyBehindAppBar: true,
body: Container( body: displayFeed.isEmpty
width: double.infinity, ? Container(
child: Stack( width: double.infinity,
fit: StackFit.expand, child: Stack(
children: [ fit: StackFit.expand,
Align( children: [
child: CircularRevealAnimation( Container(
animation: animation, decoration: const BoxDecoration(
centerOffset: Offset(30.w, -100), image: DecorationImage(
child: Container( image: AssetImage("assets/images/empty_bg.png"), fit: BoxFit.cover, opacity: 0.3),
constraints: BoxConstraints(maxWidth: 600), ),
padding: EdgeInsets.fromLTRB(defaultPadding, 100.h, defaultPadding, 0), child: Padding(
child: ListView.builder( padding: EdgeInsets.only(top: 140.h, left: defaultPadding),
physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast), child: Column(
clipBehavior: Clip.none, crossAxisAlignment: CrossAxisAlignment.start,
shrinkWrap: true, children: [
itemCount: displayFeed.length, Text("Suis tes amis pour voir leurs capsules",
itemBuilder: (BuildContext context, int index) { style: GoogleFonts.plusJakartaSans(
return Padding( color: Colors.white, fontSize: 23, fontWeight: FontWeight.w800))
padding: const EdgeInsets.only(bottom: 40), ],
child: PostComponent(callback: openDetailPost, post: displayFeed[index], index: index), ),
); ),
}, ),
)), Align(
), alignment: Alignment.topCenter,
), child: IgnorePointer(
Align( child: Container(
alignment: Alignment.topCenter, height: 240.h,
child: IgnorePointer( decoration: BoxDecoration(
child: Container( gradient: LinearGradient(
height: 240.h, begin: Alignment.topRight,
decoration: BoxDecoration( stops: [0.3, 1],
gradient: LinearGradient( colors: [bgColor.withOpacity(0.9), bgColor.withOpacity(0)])),
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(
Align( width: double.infinity,
alignment: Alignment.topCenter, child: Stack(
child: ConstrainedBox( fit: StackFit.expand,
constraints: BoxConstraints(maxWidth: 800), children: [
child: TopNavBarComponent(callback: changeFeed), 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'; 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