Merge pull request 'EMPTY_LIST_LDE' (#30) from EMPTY_LIST_LDE into master

Reviewed-on: #30
pull/31/head
Emre KARTAL 2 years ago
commit 23433e799f

@ -156,13 +156,6 @@
</list>
</value>
</entry>
<entry key="convert">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/convert-3.1.1/lib" />
</list>
</value>
</entry>
<entry key="cross_file">
<value>
<list>
@ -191,6 +184,13 @@
</list>
</value>
</entry>
<entry key="custom_refresh_indicator">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/custom_refresh_indicator-2.2.1/lib" />
</list>
</value>
</entry>
<entry key="fake_async">
<value>
<list>
@ -324,13 +324,6 @@
</list>
</value>
</entry>
<entry key="flutter_countdown_timer">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_countdown_timer-4.1.0/lib" />
</list>
</value>
</entry>
<entry key="flutter_lints">
<value>
<list>
@ -527,13 +520,6 @@
</list>
</value>
</entry>
<entry key="intl">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/intl-0.18.1/lib" />
</list>
</value>
</entry>
<entry key="ionicons">
<value>
<list>
@ -562,13 +548,6 @@
</list>
</value>
</entry>
<entry key="lottie">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/lottie-2.5.0/lib" />
</list>
</value>
</entry>
<entry key="matcher">
<value>
<list>
@ -681,13 +660,6 @@
</list>
</value>
</entry>
<entry key="pointycastle">
<value>
<list>
<option value="$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/pointycastle-3.7.3/lib" />
</list>
</value>
</entry>
<entry key="sky_engine">
<value>
<list>
@ -850,6 +822,7 @@
<root url="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/crypto-3.0.3/lib" />
<root url="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/cupertino_icons-1.0.5/lib" />
<root url="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/custom_draggable_widget-0.0.2/lib" />
<root url="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/custom_refresh_indicator-2.2.1/lib" />
<root url="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/fake_async-1.3.1/lib" />
<root url="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/ffi-2.0.2/lib" />
<root url="file://$USER_HOME$/AppData/Local/Pub/Cache/hosted/pub.dev/file-6.1.4/lib" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 345 KiB

@ -35,8 +35,7 @@ class EditablePostComponent extends StatefulWidget {
State<EditablePostComponent> createState() => _EditablePostComponentState();
}
class _EditablePostComponentState extends State<EditablePostComponent>
with TickerProviderStateMixin {
class _EditablePostComponentState extends State<EditablePostComponent> with TickerProviderStateMixin {
final ImagePicker picker = ImagePicker();
late Animation<double> animation;
late AnimationController animationController;
@ -64,7 +63,10 @@ class _EditablePostComponentState extends State<EditablePostComponent>
Future pickImage(ImageSource source) async {
try {
final image = await ImagePicker().pickImage(source: source);
final image = await ImagePicker().pickImage(
source: source,
imageQuality: 25,
);
if (image == null) return;
final imageTemp = File(image.path);
setState(() {
@ -102,12 +104,10 @@ class _EditablePostComponentState extends State<EditablePostComponent>
isScrollControlled: true,
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20), topRight: Radius.circular(20))),
borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20))),
builder: ((context) {
return ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(20), topRight: Radius.circular(20)),
borderRadius: BorderRadius.only(topLeft: Radius.circular(20), topRight: Radius.circular(20)),
child: SearchCityScreen(callback: _selectLocation));
}),
);
@ -153,8 +153,7 @@ class _EditablePostComponentState extends State<EditablePostComponent>
width: double.infinity,
)
: Image(
image:
NetworkImage(widget.music?.cover ?? ""),
image: NetworkImage(widget.music?.cover ?? ""),
fit: BoxFit.cover,
width: double.infinity,
),
@ -178,10 +177,7 @@ class _EditablePostComponentState extends State<EditablePostComponent>
),
color: grayColor,
borderRadius: BorderRadius.circular(20),
border: Border.all(
style: BorderStyle.solid,
color: Colors.white,
width: 4)),
border: Border.all(style: BorderStyle.solid, color: Colors.white, width: 4)),
child: ClipRRect(
borderRadius: BorderRadius.circular(20),
child: InstaImageViewer(
@ -209,18 +205,13 @@ class _EditablePostComponentState extends State<EditablePostComponent>
child: TextScroll(
(widget.music?.title)!,
style: GoogleFonts.plusJakartaSans(
height: 1,
color: Colors.white,
fontWeight: FontWeight.w600,
fontSize: 26.h),
height: 1, color: Colors.white, fontWeight: FontWeight.w600, fontSize: 26.h),
mode: TextScrollMode.endless,
pauseBetween: Duration(milliseconds: 500),
velocity:
Velocity(pixelsPerSecond: Offset(20, 0)),
velocity: Velocity(pixelsPerSecond: Offset(20, 0)),
)),
Padding(
padding: EdgeInsets.only(
bottom: 10.h, right: 5.w, left: 5.w),
padding: EdgeInsets.only(bottom: 10.h, right: 5.w, left: 5.w),
child: ClipOval(
child: Container(
width: 5.h,
@ -236,13 +227,9 @@ class _EditablePostComponentState extends State<EditablePostComponent>
child: TextScroll(
(widget.music?.artists[0].name)!,
style: GoogleFonts.plusJakartaSans(
height: 1,
color: Colors.white,
fontWeight: FontWeight.w300,
fontSize: 16.h),
height: 1, color: Colors.white, fontWeight: FontWeight.w300, fontSize: 16.h),
mode: TextScrollMode.endless,
velocity:
Velocity(pixelsPerSecond: Offset(50, 20)),
velocity: Velocity(pixelsPerSecond: Offset(50, 20)),
pauseBetween: Duration(milliseconds: 500),
),
)),
@ -250,9 +237,7 @@ class _EditablePostComponentState extends State<EditablePostComponent>
AutoSizeText(
widget.music?.date.toString() ?? "unknown",
style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.5),
fontWeight: FontWeight.w300,
fontSize: 16.h),
color: Colors.white.withOpacity(0.5), fontWeight: FontWeight.w300, fontSize: 16.h),
textAlign: TextAlign.end,
maxFontSize: 20,
),
@ -306,35 +291,25 @@ class _EditablePostComponentState extends State<EditablePostComponent>
keyboardAppearance: Brightness.dark,
minLines: 1,
cursorColor: primaryColor,
style: GoogleFonts.plusJakartaSans(
color: Colors.white,
fontSize: 13,
fontWeight: FontWeight.w300),
style:
GoogleFonts.plusJakartaSans(color: Colors.white, fontSize: 13, fontWeight: FontWeight.w300),
maxLines: 4,
maxLength: 120,
decoration: InputDecoration(
counterStyle: GoogleFonts.plusJakartaSans(
color: grayText, fontSize: 9),
counterStyle: GoogleFonts.plusJakartaSans(color: grayText, fontSize: 9),
focusedBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent),
borderRadius:
BorderRadius.all(Radius.circular(10))),
contentPadding:
const EdgeInsets.only(top: 0, bottom: 0, left: 0),
borderSide: BorderSide(width: 0, color: Colors.transparent),
borderRadius: BorderRadius.all(Radius.circular(10))),
contentPadding: const EdgeInsets.only(top: 0, bottom: 0, left: 0),
fillColor: Colors.transparent,
filled: true,
focusColor: Colors.transparent,
enabledBorder: const OutlineInputBorder(
borderSide:
BorderSide(width: 0, color: Colors.transparent),
borderRadius:
BorderRadius.all(Radius.circular(10))),
borderSide: BorderSide(width: 0, color: Colors.transparent),
borderRadius: BorderRadius.all(Radius.circular(10))),
hintText: 'Description...',
hintStyle: GoogleFonts.plusJakartaSans(
color: grayText,
fontSize: 13,
fontWeight: FontWeight.w300),
hintStyle:
GoogleFonts.plusJakartaSans(color: grayText, fontSize: 13, fontWeight: FontWeight.w300),
),
),
)),

@ -1,5 +1,4 @@
import 'package:auto_size_text/auto_size_text.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
@ -336,16 +335,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 == null
? 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,

@ -1,5 +1,4 @@
import 'package:circular_reveal_animation/circular_reveal_animation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
@ -49,6 +48,14 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
);
}
Future _refresh() async {
print("refresh");
discoveryFeed = await MyApp.postViewModel.getBestPosts();
setState(() {
displayFeed = discoveryFeed.reversed.toList();
});
}
void changeFeed(bool choice) {
// Mettez ici le code pour l'action que vous souhaitez effectuer avec le paramètre
if (choice) {
@ -120,9 +127,14 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
index: index,
),
Container(height: 5),
Text('${displayFeed[index].description ?? ""}',
style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w200)),
Container(height: 20),
displayFeed[index].description == null
? Container()
: Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Text('${displayFeed[index].description ?? ""}',
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w200)),
),
Align(
child: RichText(
text: TextSpan(
@ -214,58 +226,109 @@ 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: RefreshIndicator(
displacement: 20,
triggerMode: RefreshIndicatorTriggerMode.onEdge,
onRefresh: _refresh,
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;
}
}

@ -34,7 +34,7 @@ class PostViewModel {
throw new Error();
}
getBestPosts() async {
Future<List<Post>> getBestPosts() async {
try {
var responseData = await _postService.getPopularPosts();
List<String> ids = [];
@ -47,8 +47,10 @@ class PostViewModel {
for (int i = 0; i < _bestPosts.length; i++) {
_bestPosts[i].music = musics[i];
}
return _bestPosts;
} catch (e) {
print(e);
return [];
}
}

@ -209,6 +209,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.0.2"
custom_refresh_indicator:
dependency: "direct main"
description:
name: custom_refresh_indicator
sha256: "65a463f09623f6baf75e45e0c9034e9304810be3f5dfb00a54edde7252f4a524"
url: "https://pub.dev"
source: hosted
version: "2.2.1"
fake_async:
dependency: transitive
description:

@ -68,6 +68,7 @@ dependencies:
flutter_countdown_timer: ^4.1.0
intl: ^0.18.1
lottie: ^2.5.0
custom_refresh_indicator: ^2.2.1
dev_dependencies:
flutter_test:

Loading…
Cancel
Save