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

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

Loading…
Cancel
Save