GET_CAPSULES_LDE-EKA
Lucas Delanier 2 years ago
parent a46f6325ba
commit a00f9370f6

@ -4,9 +4,6 @@ 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';
@ -17,12 +14,7 @@ class PostComponent extends StatefulWidget {
final Post post; final Post post;
final int index; final int index;
PostComponent( PostComponent({Key? key, required this.callback, required this.post, required this.index}) : super(key: key);
{Key? key,
required this.callback,
required this.post,
required this.index})
: super(key: key);
@override @override
State<PostComponent> createState() => _PostComponentState(); State<PostComponent> createState() => _PostComponentState();
@ -32,14 +24,6 @@ class _PostComponentState extends State<PostComponent> {
bool choice = false; bool choice = false;
DateTime today = DateTime.now(); 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(() {
choice = !choice; choice = !choice;
@ -62,13 +46,7 @@ class _PostComponentState extends State<PostComponent> {
if (widget.callback == null) { if (widget.callback == null) {
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
child: FutureBuilder( child: Column(
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,
@ -77,7 +55,7 @@ class _PostComponentState extends State<PostComponent> {
child: SizedBox.fromSize( child: SizedBox.fromSize(
// Image radius // Image radius
child: Image( child: Image(
image: NetworkImage(user.pp), image: NetworkImage(widget.post.user.pp),
width: 40, width: 40,
), ),
), ),
@ -87,60 +65,42 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 10), padding: const EdgeInsets.only(left: 10),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [ children: [
Text( Text(
user.pseudo, widget.post.user.pseudo,
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w600),
color: Colors.white,
fontWeight: FontWeight.w600),
), ),
widget.post.location.item2 != null widget.post.location.item2 != null
? Text( ? Text(
"${widget.post.location?.item1}, ${widget.post.location?.item2}", "${widget.post.location.item1}, ${widget.post.location.item2}",
style: style: GoogleFonts.plusJakartaSans(
GoogleFonts.plusJakartaSans( color: Colors.white.withOpacity(0.4),
color: Colors.white fontWeight: FontWeight.w300,
.withOpacity(0.4),
fontWeight:
FontWeight.w300,
fontSize: 13), fontSize: 13),
) )
: Text( : Text(
"", "",
style: style: GoogleFonts.plusJakartaSans(
GoogleFonts.plusJakartaSans( color: Colors.white.withOpacity(0.4),
color: Colors.white fontWeight: FontWeight.w300,
.withOpacity(0.4),
fontWeight:
FontWeight.w300,
fontSize: 13), fontSize: 13),
) )
], ],
), ),
), ),
), ),
DateTime(today.year, today.month, today.day) DateTime(today.year, today.month, today.day).isAtSameMomentAs(
.isAtSameMomentAs(DateTime( DateTime(widget.post.date.year, widget.post.date.month, widget.post.date.day))
widget.post.date.year,
widget.post.date.month,
widget.post.date.day))
? Text( ? Text(
"Aujourd'hui, ${widget.post.date.hour}:${widget.post.date.minute}", "Aujourd'hui, ${widget.post.date.hour}:${widget.post.date.minute}",
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(
color: color: Colors.white.withOpacity(0.4), fontWeight: FontWeight.w300, fontSize: 13),
Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300,
fontSize: 13),
) )
: Text( : Text(
"${widget.post.date.day}/${widget.post.date.month}/${widget.post.date.year}-${widget.post.date.hour}:${widget.post.date.minute}", "${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: color: Colors.white.withOpacity(0.4), fontWeight: FontWeight.w300, fontSize: 13),
Colors.white.withOpacity(0.4),
fontWeight: FontWeight.w300,
fontSize: 13),
), ),
], ],
), ),
@ -152,8 +112,7 @@ class _PostComponentState extends State<PostComponent> {
} }
}, },
enableLongTapRepeatEvent: false, enableLongTapRepeatEvent: false,
longTapRepeatDuration: longTapRepeatDuration: const Duration(milliseconds: 100),
const Duration(milliseconds: 100),
begin: 1.0, begin: 1.0,
end: 0.99, end: 0.99,
beginDuration: const Duration(milliseconds: 70), beginDuration: const Duration(milliseconds: 70),
@ -166,13 +125,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
@ -185,9 +141,7 @@ class _PostComponentState extends State<PostComponent> {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
children: [ children: [
Image( Image(
image: NetworkImage(choice image: NetworkImage(choice ? widget.post.selfie! : widget.post.music.cover!),
? widget.post.selfie!
: music.cover!),
fit: BoxFit.cover, fit: BoxFit.cover,
width: double.infinity, width: double.infinity,
), ),
@ -198,35 +152,22 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: EdgeInsets.all(12), padding: EdgeInsets.all(12),
child: Container( child: Container(
constraints: constraints: BoxConstraints(maxWidth: 140, maxHeight: 140),
BoxConstraints(
maxWidth: 140,
maxHeight: 140),
width: 90.sp, width: 90.sp,
height: 90.sp, height: 90.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: NetworkImage( image: NetworkImage(
choice choice ? widget.post.music.cover! : widget.post.selfie!),
? music.cover!
: widget.post
.selfie!),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
@ -246,20 +187,15 @@ class _PostComponentState extends State<PostComponent> {
Flexible( Flexible(
flex: 8, flex: 8,
child: TextScroll( child: TextScroll(
music.artists.first.name!, widget.post.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( velocity: Velocity(pixelsPerSecond: Offset(20, 0)),
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,
@ -273,48 +209,31 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: EdgeInsets.only(bottom: 2), padding: EdgeInsets.only(bottom: 2),
child: TextScroll( child: TextScroll(
music.title!, widget.post.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( velocity: Velocity(pixelsPerSecond: Offset(50, 20)),
pixelsPerSecond: Offset(50, 20)), pauseBetween: Duration(milliseconds: 500),
pauseBetween:
Duration(milliseconds: 500),
), ),
)), )),
Container(width: 10), Container(width: 10),
AutoSizeText( AutoSizeText(
music.date.toString(), widget.post.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();
}
}));
} }
return SizedBox( return SizedBox(
width: double.infinity, width: double.infinity,
child: FutureBuilder( child: Column(
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,
@ -323,7 +242,7 @@ class _PostComponentState extends State<PostComponent> {
child: SizedBox.fromSize( child: SizedBox.fromSize(
// Image radius // Image radius
child: Image( child: Image(
image: NetworkImage(user.pp), image: NetworkImage(widget.post.user.pp),
width: 40, width: 40,
), ),
), ),
@ -333,58 +252,42 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: const EdgeInsets.only(left: 10), padding: const EdgeInsets.only(left: 10),
child: Column( child: Column(
crossAxisAlignment: crossAxisAlignment: CrossAxisAlignment.start,
CrossAxisAlignment.start,
children: [ children: [
Text( Text(
user.pseudo, widget.post.user.pseudo,
style: GoogleFonts.plusJakartaSans( style: GoogleFonts.plusJakartaSans(color: Colors.white, fontWeight: FontWeight.w600),
color: Colors.white,
fontWeight: FontWeight.w600),
), ),
widget.post.location.item2 != null widget.post.location.item2 != null
? Text( ? Text(
"${widget.post.location?.item1}, ${widget.post.location?.item2}", "${widget.post.location?.item1}, ${widget.post.location?.item2}",
style: style: GoogleFonts.plusJakartaSans(
GoogleFonts.plusJakartaSans( color: Colors.white.withOpacity(0.4),
color: Colors.white fontWeight: FontWeight.w300,
.withOpacity(0.4),
fontWeight:
FontWeight.w300,
fontSize: 13), fontSize: 13),
) )
: Text( : Text(
"", "",
style: style: GoogleFonts.plusJakartaSans(
GoogleFonts.plusJakartaSans( color: Colors.white.withOpacity(0.4),
color: Colors.white fontWeight: FontWeight.w300,
.withOpacity(0.4),
fontWeight:
FontWeight.w300,
fontSize: 13), fontSize: 13),
) )
], ],
), ),
), ),
), ),
DateTime(today.year, today.month, today.day) DateTime(today.year, today.month, today.day).isAtSameMomentAs(
.isAtSameMomentAs(DateTime( DateTime(widget.post.date.year, widget.post.date.month, widget.post.date.day))
widget.post.date.year,
widget.post.date.month,
widget.post.date.day))
? Text( ? Text(
"Aujourd'hui, ${widget.post.date.hour}:${widget.post.date.minute}", "Aujourd'hui, ${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, fontSize: 13),
fontWeight: FontWeight.w300,
fontSize: 13),
) )
: Text( : Text(
"${widget.post.date.day}/${widget.post.date.month}/${widget.post.date.year}-${widget.post.date.hour}:${widget.post.date.minute}", "${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, fontSize: 13),
fontWeight: FontWeight.w300,
fontSize: 13),
), ),
], ],
), ),
@ -394,8 +297,7 @@ class _PostComponentState extends State<PostComponent> {
widget.callback!(widget.index); widget.callback!(widget.index);
}, },
enableLongTapRepeatEvent: false, enableLongTapRepeatEvent: false,
longTapRepeatDuration: longTapRepeatDuration: const Duration(milliseconds: 100),
const Duration(milliseconds: 100),
begin: 1.0, begin: 1.0,
end: 0.99, end: 0.99,
beginDuration: const Duration(milliseconds: 70), beginDuration: const Duration(milliseconds: 70),
@ -408,13 +310,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
@ -427,13 +326,12 @@ class _PostComponentState extends State<PostComponent> {
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
children: [ children: [
Image( Image(
image: NetworkImage(music.cover!), image: NetworkImage(widget.post.music.cover!),
fit: BoxFit.cover, fit: BoxFit.cover,
width: double.infinity, width: double.infinity,
), ),
Image( Image(
image: AssetImage( image: AssetImage("assets/images/shadow_post.png"),
"assets/images/shadow_post.png"),
fit: BoxFit.fitHeight, fit: BoxFit.fitHeight,
width: double.infinity, width: double.infinity,
), ),
@ -442,9 +340,7 @@ class _PostComponentState extends State<PostComponent> {
child: AutoSizeText( child: AutoSizeText(
'${widget.post.description}', '${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,
), ),
@ -456,31 +352,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: 90.sp, width: 90.sp,
height: 90.sp, height: 90.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: NetworkImage( image: NetworkImage(widget.post.selfie!),
widget
.post.selfie!),
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
@ -500,20 +386,15 @@ class _PostComponentState extends State<PostComponent> {
Flexible( Flexible(
flex: 8, flex: 8,
child: TextScroll( child: TextScroll(
music.artists.first.name!, widget.post.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( velocity: Velocity(pixelsPerSecond: Offset(20, 0)),
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,
@ -527,36 +408,26 @@ class _PostComponentState extends State<PostComponent> {
child: Padding( child: Padding(
padding: EdgeInsets.only(bottom: 2), padding: EdgeInsets.only(bottom: 2),
child: TextScroll( child: TextScroll(
music.title!, widget.post.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( velocity: Velocity(pixelsPerSecond: Offset(50, 20)),
pixelsPerSecond: Offset(50, 20)),
pauseBetween: Duration(milliseconds: 500), pauseBetween: Duration(milliseconds: 500),
), ),
)), )),
Container(width: 10), Container(width: 10),
AutoSizeText( AutoSizeText(
music.date.toString(), widget.post.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();
}
}));
}, },
), ),
); );

@ -216,9 +216,14 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: true, resizeToAvoidBottomInset: true,
backgroundColor: bgColor, backgroundColor: bgColor,
body: Stack( extendBodyBehindAppBar: true,
body: Container(
width: double.infinity,
child: Stack(
fit: StackFit.expand,
children: [ children: [
CircularRevealAnimation( Align(
child: CircularRevealAnimation(
animation: animation, animation: animation,
centerOffset: Offset(30.w, -100), centerOffset: Offset(30.w, -100),
child: Container( child: Container(
@ -237,9 +242,10 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
}, },
)), )),
), ),
),
IgnorePointer( IgnorePointer(
child: Container( child: Container(
height: 240.h, height: 100.h,
decoration: BoxDecoration( decoration: BoxDecoration(
gradient: LinearGradient( gradient: LinearGradient(
begin: Alignment.topRight, begin: Alignment.topRight,
@ -256,6 +262,7 @@ class _FeedScreenState extends State<FeedScreen> with SingleTickerProviderStateM
), ),
], ],
), ),
),
); );
} }
} }

Loading…
Cancel
Save