EMPTY_LIST_LDE #30

Merged
emre.kartal merged 3 commits from EMPTY_LIST_LDE into master 2 years ago

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

@ -1,5 +1,4 @@
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/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
@ -336,7 +335,9 @@ class _PostComponentState extends State<PostComponent> with TickerProviderStateM
fit: BoxFit.fitHeight, fit: BoxFit.fitHeight,
width: double.infinity, width: double.infinity,
), ),
Padding( widget.post.description == null
? Container()
: Padding(
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
child: AutoSizeText( child: AutoSizeText(
'${widget.post.description}', '${widget.post.description}',

@ -1,5 +1,4 @@
import 'package:circular_reveal_animation/circular_reveal_animation.dart'; import 'package:circular_reveal_animation/circular_reveal_animation.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.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) { void changeFeed(bool choice) {
// Mettez ici le code pour l'action que vous souhaitez effectuer avec le paramètre // Mettez ici le code pour l'action que vous souhaitez effectuer avec le paramètre
if (choice) { if (choice) {
@ -120,9 +127,14 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
index: index, index: index,
), ),
Container(height: 5), Container(height: 5),
Text('${displayFeed[index].description ?? ""}', displayFeed[index].description == null
style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w200)), ? Container()
Container(height: 20), : Padding(
padding: const EdgeInsets.only(bottom: 20),
child: Text('${displayFeed[index].description ?? ""}',
style: GoogleFonts.plusJakartaSans(
color: Colors.white, fontWeight: FontWeight.w200)),
),
Align( Align(
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
@ -217,7 +229,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,
@ -229,6 +287,10 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
child: Container( child: Container(
constraints: BoxConstraints(maxWidth: 600), constraints: BoxConstraints(maxWidth: 600),
padding: EdgeInsets.fromLTRB(defaultPadding, 100.h, defaultPadding, 0), padding: EdgeInsets.fromLTRB(defaultPadding, 100.h, defaultPadding, 0),
child: RefreshIndicator(
displacement: 20,
triggerMode: RefreshIndicatorTriggerMode.onEdge,
onRefresh: _refresh,
child: ListView.builder( child: ListView.builder(
physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast), physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
clipBehavior: Clip.none, clipBehavior: Clip.none,
@ -237,9 +299,11 @@ 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 +329,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;
} }
} }

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

@ -209,6 +209,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.0.2" 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: fake_async:
dependency: transitive dependency: transitive
description: description:

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

Loading…
Cancel
Save