GET_CAPSULES_LDE-EKA
Lucas Delanier 2 years ago
parent 44b6477101
commit 50bee2f529

@ -4,15 +4,19 @@ 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';
import 'package:gradient_borders/box_borders/gradient_box_border.dart'; import 'package:gradient_borders/box_borders/gradient_box_border.dart';
import 'package:justmusic/main.dart';
import 'package:justmusic/model/Music.dart';
import 'package:justmusic/model/User.dart';
import 'package:text_scroll/text_scroll.dart'; import 'package:text_scroll/text_scroll.dart';
import 'package:zoom_tap_animation/zoom_tap_animation.dart'; import 'package:zoom_tap_animation/zoom_tap_animation.dart';
import '../model/Post.dart'; import '../model/Post.dart';
class PostComponent extends StatefulWidget { class PostComponent extends StatefulWidget {
final VoidCallback? callback; final Function(int)? callback;
final Post post; final Post post;
PostComponent({Key? key, required this.callback, required this.post}) : super(key: key); final int index;
PostComponent({Key? key, required this.callback, required this.post, required this.index}) : super(key: key);
@override @override
State<PostComponent> createState() => _PostComponentState(); State<PostComponent> createState() => _PostComponentState();
@ -20,6 +24,15 @@ class PostComponent extends StatefulWidget {
class _PostComponentState extends State<PostComponent> { class _PostComponentState extends State<PostComponent> {
bool choice = false; bool choice = false;
DateTime today = DateTime.now();
Future<User?> fetchUserData() async {
return await MyApp.userViewModel.getUser(widget.post.idUser);
}
Future<Music> fetchMusicData() async {
return await MyApp.musicViewModel.getMusic(widget.post.idMusic);
}
void switchChoice() { void switchChoice() {
setState(() { setState(() {
@ -27,6 +40,13 @@ class _PostComponentState extends State<PostComponent> {
}); });
} }
@override
void initState() {
print("post: ${widget.post.date.toString()}");
print("ajrd: ${DateTime.now().toString()}");
super.initState();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return GestureDetector(
@ -36,7 +56,13 @@ class _PostComponentState extends State<PostComponent> {
if (choice && widget.callback == null) { if (choice && widget.callback == null) {
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
child: Column( child: FutureBuilder(
future: Future.wait([fetchMusicData(), fetchUserData()]),
builder: (context, AsyncSnapshot<List<dynamic>> snapshot) {
if (snapshot.hasData) {
final music = snapshot.data![0] as Music;
final user = snapshot.data![1] as User;
return Column(
children: [ children: [
Row( Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
@ -44,9 +70,8 @@ class _PostComponentState extends State<PostComponent> {
ClipOval( ClipOval(
child: SizedBox.fromSize( child: SizedBox.fromSize(
// Image radius // Image radius
child: const Image( child: Image(
image: image: NetworkImage(user.pp),
AssetImage("assets/images/exemple_profile.png"),
width: 40, width: 40,
), ),
), ),
@ -59,13 +84,12 @@ class _PostComponentState extends State<PostComponent> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Melina", user.pseudo,
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, color: Colors.white, fontWeight: FontWeight.w600),
fontWeight: FontWeight.w600),
), ),
Text( Text(
"France, Lyon", "${widget.post.location.item1}, ${widget.post.location.item2}",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.4), color: Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
@ -75,8 +99,16 @@ class _PostComponentState extends State<PostComponent> {
), ),
), ),
), ),
Text( widget.post.date.isAtSameMomentAs(DateTime.now())
"Aujourdhui, 16:43", ? Text(
"Aujourd'hui, ${widget.post.date.hour}",
style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300,
fontSize: 13),
)
: Text(
"${widget.post.date.day}/${widget.post.date.month}/${widget.post.date.year}-${widget.post.date.hour}:${widget.post.date.minute}",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.4), color: Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
@ -86,7 +118,9 @@ class _PostComponentState extends State<PostComponent> {
), ),
SizedBox(height: 10), SizedBox(height: 10),
ZoomTapAnimation( ZoomTapAnimation(
onTap: widget.callback, onTap: () {
widget.callback!(widget.index);
},
enableLongTapRepeatEvent: false, enableLongTapRepeatEvent: false,
longTapRepeatDuration: const Duration(milliseconds: 100), longTapRepeatDuration: const Duration(milliseconds: 100),
begin: 1.0, begin: 1.0,
@ -101,13 +135,10 @@ class _PostComponentState extends State<PostComponent> {
decoration: BoxDecoration( decoration: BoxDecoration(
// add border // add border
border: const GradientBoxBorder( border: const GradientBoxBorder(
gradient: LinearGradient( gradient: LinearGradient(colors: [
colors: [
Colors.transparent, Colors.transparent,
Color(0xFF323232), Color(0xFF323232),
], ], begin: Alignment.topCenter, end: Alignment.bottomCenter),
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
width: 2.5, width: 2.5,
), ),
// set border radius // set border radius
@ -120,8 +151,7 @@ class _PostComponentState extends State<PostComponent> {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
children: [ children: [
Image( Image(
image: AssetImage( image: NetworkImage(user.pp),
"assets/images/exemple_profile.png"),
fit: BoxFit.cover, fit: BoxFit.cover,
width: double.infinity, width: double.infinity,
), ),
@ -131,26 +161,21 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
child: Container( child: Container(
constraints: BoxConstraints( constraints: BoxConstraints(maxWidth: 140, maxHeight: 140),
maxWidth: 140, maxHeight: 140),
width: 80.sp, width: 80.sp,
height: 80.sp, height: 80.sp,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
// add border // add border
border: Border.all( border: Border.all(width: 3, color: Colors.white),
width: 3, color: Colors.white),
// set border radius // set border radius
borderRadius: borderRadius: BorderRadius.circular(15),
BorderRadius.circular(15),
), ),
child: ClipRRect( child: ClipRRect(
borderRadius: borderRadius: BorderRadius.circular(13),
BorderRadius.circular(13),
// implement image // implement image
child: Image( child: Image(
image: AssetImage( image: NetworkImage(music.cover!),
'assets/images/exemple_cover.png'),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
@ -169,19 +194,15 @@ class _PostComponentState extends State<PostComponent> {
Flexible( Flexible(
flex: 8, flex: 8,
child: TextScroll( child: TextScroll(
"BOOBA", music.artists.first.name!,
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(pixelsPerSecond: Offset(20, 0)), velocity: 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,
@ -195,21 +216,20 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: EdgeInsets.only(bottom: 2), padding: EdgeInsets.only(bottom: 2),
child: TextScroll( child: TextScroll(
"A.C. Milan", music.title!,
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
height: 1, height: 1,
color: Colors.white, color: Colors.white,
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
fontSize: 16.h), 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),
), ),
)), )),
Container(width: 10), Container(width: 10),
AutoSizeText( AutoSizeText(
"2013", music.date.toString(),
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.5), color: Colors.white.withOpacity(0.5),
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
@ -220,12 +240,21 @@ class _PostComponentState extends State<PostComponent> {
], ],
), ),
], ],
),
); );
} else {
return CupertinoActivityIndicator();
}
}));
} }
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
child: Column( child: FutureBuilder(
future: Future.wait([fetchMusicData(), fetchUserData()]),
builder: (context, AsyncSnapshot<List<dynamic>> snapshot) {
if (snapshot.hasData) {
final music = snapshot.data![0] as Music;
final user = snapshot.data![1] as User;
return Column(
children: [ children: [
Row( Row(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
@ -234,8 +263,7 @@ class _PostComponentState extends State<PostComponent> {
child: SizedBox.fromSize( child: SizedBox.fromSize(
// Image radius // Image radius
child: const Image( child: const Image(
image: image: AssetImage("assets/images/exemple_profile.png"),
AssetImage("assets/images/exemple_profile.png"),
width: 40, width: 40,
), ),
), ),
@ -248,13 +276,12 @@ class _PostComponentState extends State<PostComponent> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"Melina", user.pseudo,
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, color: Colors.white, fontWeight: FontWeight.w600),
fontWeight: FontWeight.w600),
), ),
Text( Text(
"France, Lyon", "${widget.post.location.item1}, ${widget.post.location.item2}",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.4), color: Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
@ -264,8 +291,17 @@ class _PostComponentState extends State<PostComponent> {
), ),
), ),
), ),
Text( DateTime(today.year, today.month, today.day).isAtSameMomentAs(
"Aujourdhui, 16:43", DateTime(widget.post.date.year, widget.post.date.month, widget.post.date.day))
? Text(
"Aujourd'hui, ${widget.post.date.hour}:${widget.post.date.minute}",
style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300,
fontSize: 13),
)
: Text(
"${widget.post.date.day}/${widget.post.date.month}/${widget.post.date.year}-${widget.post.date.hour}:${widget.post.date.minute}",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white.withOpacity(0.4), color: Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300, fontWeight: FontWeight.w300,
@ -275,7 +311,9 @@ class _PostComponentState extends State<PostComponent> {
), ),
SizedBox(height: 10), SizedBox(height: 10),
ZoomTapAnimation( ZoomTapAnimation(
onTap: widget.callback, onTap: () {
widget.callback!(widget.index);
},
enableLongTapRepeatEvent: false, enableLongTapRepeatEvent: false,
longTapRepeatDuration: const Duration(milliseconds: 100), longTapRepeatDuration: const Duration(milliseconds: 100),
begin: 1.0, begin: 1.0,
@ -290,13 +328,10 @@ class _PostComponentState extends State<PostComponent> {
decoration: BoxDecoration( decoration: BoxDecoration(
// add border // add border
border: const GradientBoxBorder( border: const GradientBoxBorder(
gradient: LinearGradient( gradient: LinearGradient(colors: [
colors: [
Colors.transparent, Colors.transparent,
Color(0xFF323232), Color(0xFF323232),
], ], begin: Alignment.topCenter, end: Alignment.bottomCenter),
begin: Alignment.topCenter,
end: Alignment.bottomCenter),
width: 2.5, width: 2.5,
), ),
// set border radius // set border radius
@ -309,25 +344,21 @@ class _PostComponentState extends State<PostComponent> {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
children: [ children: [
Image( Image(
image: AssetImage( image: NetworkImage(music.cover!),
"assets/images/exemple_cover.png"),
fit: BoxFit.cover, fit: BoxFit.cover,
width: double.infinity, width: double.infinity,
), ),
Image( Image(
image: image: AssetImage("assets/images/shadow_post.png"),
AssetImage("assets/images/shadow_post.png"),
fit: BoxFit.fitHeight, fit: BoxFit.fitHeight,
width: double.infinity, width: double.infinity,
), ),
Padding( Padding(
padding: EdgeInsets.all(15), padding: EdgeInsets.all(15),
child: AutoSizeText( child: AutoSizeText(
'“Jécoute en boucle ce son. B2O<3', '${widget.post.description}',
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: Colors.white, color: Colors.white, fontWeight: FontWeight.w400, fontSize: 15.sp),
fontWeight: FontWeight.w400,
fontSize: 15.sp),
maxFontSize: 20, maxFontSize: 20,
maxLines: 1, maxLines: 1,
), ),
@ -338,15 +369,13 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
child: Container( child: Container(
constraints: BoxConstraints( constraints: BoxConstraints(maxWidth: 140, maxHeight: 140),
maxWidth: 140, maxHeight: 140),
width: 80.sp, width: 80.sp,
height: 80.sp, height: 80.sp,
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
// add border // add border
border: Border.all( border: Border.all(width: 3, color: Colors.white),
width: 3, color: Colors.white),
// set border radius // set border radius
borderRadius: BorderRadius.circular(15), borderRadius: BorderRadius.circular(15),
), ),
@ -354,8 +383,7 @@ class _PostComponentState extends State<PostComponent> {
borderRadius: BorderRadius.circular(13), borderRadius: BorderRadius.circular(13),
// implement image // implement image
child: Image( child: Image(
image: AssetImage( image: NetworkImage(user.pp),
'assets/images/exemple_profile.png'),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
@ -374,19 +402,15 @@ class _PostComponentState extends State<PostComponent> {
Flexible( Flexible(
flex: 8, flex: 8,
child: TextScroll( child: TextScroll(
"BOOBA", music.artists.first.name!,
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(pixelsPerSecond: Offset(20, 0)), velocity: Velocity(pixelsPerSecond: Offset(20, 0)),
)), )),
Padding( Padding(
padding: padding: EdgeInsets.only(bottom: 10.h, right: 5.w, left: 5.w),
EdgeInsets.only(bottom: 10.h, right: 5.w, left: 5.w),
child: ClipOval( child: ClipOval(
child: Container( child: Container(
width: 5.h, width: 5.h,
@ -400,12 +424,9 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: EdgeInsets.only(bottom: 2), padding: EdgeInsets.only(bottom: 2),
child: TextScroll( child: TextScroll(
"A.C. Milan", music.title!,
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(pixelsPerSecond: Offset(50, 20)), velocity: Velocity(pixelsPerSecond: Offset(50, 20)),
pauseBetween: Duration(milliseconds: 500), pauseBetween: Duration(milliseconds: 500),
@ -413,19 +434,20 @@ class _PostComponentState extends State<PostComponent> {
)), )),
Container(width: 10), Container(width: 10),
AutoSizeText( AutoSizeText(
"2013", music.date.toString(),
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,
), ),
], ],
), ),
], ],
),
); );
} else {
return CupertinoActivityIndicator();
}
}));
}, },
), ),
); );

@ -1,14 +1,13 @@
import 'package:another_flushbar/flushbar.dart';
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/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';
import 'package:google_fonts/google_fonts.dart'; import 'package:google_fonts/google_fonts.dart';
import 'package:justmusic/main.dart';
import '../components/comment_component.dart'; import '../components/comment_component.dart';
import '../components/post_component.dart'; import '../components/post_component.dart';
import '../components/top_nav_bar_component.dart'; import '../components/top_nav_bar_component.dart';
import '../main.dart';
import '../model/Post.dart'; import '../model/Post.dart';
import '../values/constants.dart'; import '../values/constants.dart';
@ -19,7 +18,7 @@ class FeedScreen extends StatefulWidget {
State<FeedScreen> createState() => _FeedScreenState(); State<FeedScreen> createState() => _FeedScreenState();
} }
class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin { class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateMixin {
late AnimationController animationController; late AnimationController animationController;
late Animation<double> animation; late Animation<double> animation;
late List<Post> friendFeed; late List<Post> friendFeed;
@ -29,9 +28,10 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
friendFeed = []; friendFeed = MyApp.postViewModel.postsFriends;
MyApp.postViewModel.getBestPosts();
discoveryFeed = MyApp.postViewModel.bestPosts; discoveryFeed = MyApp.postViewModel.bestPosts;
displayFeed = friendFeed; displayFeed = [];
animationController = AnimationController( animationController = AnimationController(
vsync: this, vsync: this,
duration: Duration(milliseconds: 400), duration: Duration(milliseconds: 400),
@ -54,19 +54,21 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
if (choice) { if (choice) {
setState(() { setState(() {
animationController.reset(); animationController.reset();
displayFeed = friendFeed; displayFeed = MyApp.postViewModel.postsFriends;
animationController.forward(); animationController.forward();
print(displayFeed.length);
}); });
} else { } else {
setState(() { setState(() {
animationController.reset(); animationController.reset();
displayFeed = discoveryFeed; displayFeed = MyApp.postViewModel.bestPosts;
print(displayFeed.length);
animationController.forward(); animationController.forward();
}); });
} }
} }
void openDetailPost() { void openDetailPost(int index) {
showModalBottomSheet( showModalBottomSheet(
backgroundColor: bgModal, backgroundColor: bgModal,
elevation: 1, elevation: 1,
@ -76,8 +78,7 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
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: ((BuildContext context) { builder: ((BuildContext context) {
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
@ -96,45 +97,40 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
child: Container( child: Container(
width: 60, width: 60,
height: 5, height: 5,
decoration: BoxDecoration( decoration:
color: Colors.white.withOpacity(0.3), BoxDecoration(color: Colors.white.withOpacity(0.3), borderRadius: BorderRadius.circular(20))),
borderRadius: BorderRadius.circular(20))),
), ),
const SizedBox( const SizedBox(
height: 20, height: 20,
), ),
Expanded( Expanded(
child: ClipRRect( child: ClipRRect(
borderRadius: BorderRadius.only( borderRadius: BorderRadius.only(topRight: Radius.circular(15), topLeft: Radius.circular(15)),
topRight: Radius.circular(15),
topLeft: Radius.circular(15)),
child: Padding( child: Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(left: defaultPadding, right: defaultPadding),
left: defaultPadding, right: defaultPadding),
child: SingleChildScrollView( child: SingleChildScrollView(
physics: BouncingScrollPhysics( physics: BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
decelerationRate: ScrollDecelerationRate.fast),
child: Wrap( child: Wrap(
// to apply margin in the main axis of the wrap // to apply margin in the main axis of the wrap
runSpacing: 10, runSpacing: 10,
children: [ children: [
PostComponent( PostComponent(
callback: null, callback: null,
post: displayFeed[index],
index: index,
), ),
Container(height: 10), Container(height: 10),
Align( Align(
child: RichText( child: RichText(
text: TextSpan( text: TextSpan(
text: "3", text: "3",
style: GoogleFonts.plusJakartaSans( style:
color: Colors.white, GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w600),
fontWeight: FontWeight.w600),
children: [ children: [
TextSpan( TextSpan(
text: " commentaires", text: " commentaires",
style: GoogleFonts.plusJakartaSans( style:
color: Colors.white, GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w300),
fontWeight: FontWeight.w300),
) )
])), ])),
), ),
@ -150,18 +146,12 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
), ),
), ),
Padding( Padding(
padding: EdgeInsets.only( padding: EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
bottom: MediaQuery
.of(context)
.viewInsets
.bottom),
child: Container( child: Container(
height: 70, height: 70,
width: double.infinity, width: double.infinity,
decoration: BoxDecoration( decoration: BoxDecoration(
border: Border( border: Border(top: BorderSide(color: grayColor, width: 2)), color: textFieldMessage),
top: BorderSide(color: grayColor, width: 2)),
color: textFieldMessage),
child: Center( child: Center(
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 20), padding: const EdgeInsets.symmetric(horizontal: 20),
@ -171,8 +161,7 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
child: SizedBox.fromSize( child: SizedBox.fromSize(
// Image radius // Image radius
child: const Image( child: const Image(
image: AssetImage( image: AssetImage("assets/images/exemple_profile.png"),
"assets/images/exemple_profile.png"),
width: 45, width: 45,
), ),
), ),
@ -185,8 +174,7 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
keyboardAppearance: Brightness.dark, keyboardAppearance: Brightness.dark,
cursorColor: primaryColor, cursorColor: primaryColor,
keyboardType: TextInputType.emailAddress, keyboardType: TextInputType.emailAddress,
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(color: Colors.white),
color: Colors.white),
decoration: InputDecoration( decoration: InputDecoration(
suffixIcon: Icon( suffixIcon: Icon(
Icons.send, Icons.send,
@ -194,27 +182,17 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
size: 20, size: 20,
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(width: 1, color: grayText),
width: 1, color: grayText), borderRadius: BorderRadius.all(Radius.circular(100))),
borderRadius: BorderRadius.all( contentPadding: EdgeInsets.only(top: 0, bottom: 0, left: 20, right: 20),
Radius.circular(100))),
contentPadding: EdgeInsets.only(
top: 0,
bottom: 0,
left: 20,
right: 20),
fillColor: bgModal, fillColor: bgModal,
filled: true, filled: true,
focusColor: focusColor: Color.fromRGBO(255, 255, 255, 0.30),
Color.fromRGBO(255, 255, 255, 0.30),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(
borderSide: BorderSide( borderSide: BorderSide(width: 1, color: grayText),
width: 1, color: grayText), borderRadius: BorderRadius.all(Radius.circular(100))),
borderRadius: BorderRadius.all(
Radius.circular(100))),
hintText: 'Ajoutez une réponse...', hintText: 'Ajoutez une réponse...',
hintStyle: GoogleFonts.plusJakartaSans( hintStyle: GoogleFonts.plusJakartaSans(color: grayText)),
color: grayText)),
), ),
) )
], ],
@ -240,47 +218,30 @@ class _FeedScreenState extends State<FeedScreen> with TickerProviderStateMixin {
CircularRevealAnimation( CircularRevealAnimation(
animation: animation, animation: animation,
centerOffset: Offset(30.w, -100), centerOffset: Offset(30.w, -100),
child: SingleChildScrollView(
physics: const BouncingScrollPhysics(
decelerationRate: ScrollDecelerationRate.fast),
child: SizedBox(
width: double.infinity,
child: Align(
child: ConstrainedBox(
constraints: BoxConstraints(maxWidth: 600),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: defaultPadding),
child: Container( child: Container(
width: double.infinity, constraints: BoxConstraints(maxWidth: 600),
child: Padding( padding: EdgeInsets.fromLTRB(defaultPadding, 100.h, defaultPadding, 0),
padding: EdgeInsets.only(top: 100.h),
child: SingleChildScrollView(
child: ListView.builder( child: ListView.builder(
itemBuilder: (BuildContext context, physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
int index) { clipBehavior: Clip.none,
return PostComponent(callback: openDetailPost,); 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),
);
}, },
),
)), )),
), ),
),
),
)),
),
),
IgnorePointer( IgnorePointer(
child: Container( child: Container(
height: 240.h, height: 240.h,
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient(begin: Alignment.topRight, stops: [ gradient: LinearGradient(
0.3, begin: Alignment.topRight,
1 stops: [0.3, 1],
], colors: [ colors: [bgColor.withOpacity(0.9), bgColor.withOpacity(0)])),
bgColor.withOpacity(0.9),
bgColor.withOpacity(0)
])),
), ),
), ),
Align( Align(

@ -20,8 +20,7 @@ class PostViewModel {
List<Post> get bestPosts => _bestPosts; List<Post> get bestPosts => _bestPosts;
// Methods // Methods
addPost(String? description, String idMusic, File? image, addPost(String? description, String idMusic, File? image, Tuple2<String, String>? location) async {
Tuple2<String, String>? location) async {
await _postService.createPost(description, idMusic, image, location); await _postService.createPost(description, idMusic, image, location);
} }
@ -37,8 +36,8 @@ class PostViewModel {
try { try {
var responseData = await _postService.getPopularPosts(); var responseData = await _postService.getPopularPosts();
_bestPosts = _bestPosts = responseData.map((value) => PostMapper.toModel(value)).toList();
responseData.map((value) => PostMapper.toModel(value)).toList(); print(_bestPosts.length);
} catch (e) { } catch (e) {
print(e); print(e);
} }

Loading…
Cancel
Save