diff --git a/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml b/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml index 5fefc0b..5f9a1bc 100644 --- a/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml +++ b/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/Sources/justMUSIC/lib/components/button_play_component.dart b/Sources/justMUSIC/lib/components/button_play_component.dart index 2b252de..09393d3 100644 --- a/Sources/justMUSIC/lib/components/button_play_component.dart +++ b/Sources/justMUSIC/lib/components/button_play_component.dart @@ -44,7 +44,7 @@ class _ButtonPlayComponentState extends State { child: Icon( isPlaying ? Icons.pause_circle : Icons.play_circle, color: Colors.white, - size: 53, + size: 45, ), )); } diff --git a/Sources/justMUSIC/lib/components/post_component.dart b/Sources/justMUSIC/lib/components/post_component.dart index 7d17d20..2d0535c 100644 --- a/Sources/justMUSIC/lib/components/post_component.dart +++ b/Sources/justMUSIC/lib/components/post_component.dart @@ -40,162 +40,157 @@ class _PostComponentState extends State with TickerProviderStateM @override Widget build(BuildContext context) { return GestureDetector( - onTap: switchChoice, - child: LayoutBuilder( - builder: (BuildContext context, BoxConstraints constraints) { - if (widget.callback == null) { - return SizedBox( - width: double.infinity, - child: Column( + onTap: switchChoice, + child: SizedBox( + width: double.infinity, + child: Column( + children: [ + Row( + crossAxisAlignment: CrossAxisAlignment.end, children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - ProfilPictureComponent(user: widget.post.user), - Expanded( - flex: 8, - child: Padding( - padding: const EdgeInsets.only(left: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 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, - fontSize: 13), - ) - : Text( - "", - style: GoogleFonts.plusJakartaSans( - color: Colors.white.withOpacity(0.4), - fontWeight: FontWeight.w300, - fontSize: 13), - ) - ], + ProfilPictureComponent(user: widget.post.user), + Expanded( + flex: 8, + child: Padding( + padding: const EdgeInsets.only(left: 10), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + 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, + fontSize: 13), + ) + : Text( + "", + 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)) + ? 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( + "hier, ${widget.post.date.hour}:${widget.post.date.minute}", + style: GoogleFonts.plusJakartaSans( + color: Colors.white.withOpacity(0.4), fontWeight: FontWeight.w300, fontSize: 13), ), + ], + ), + SizedBox(height: 10), + ZoomTapAnimation( + onTap: () { + widget.callback!(widget.post); + }, + enableLongTapRepeatEvent: false, + longTapRepeatDuration: const Duration(milliseconds: 100), + begin: 1.0, + end: 0.99, + beginDuration: const Duration(milliseconds: 70), + endDuration: const Duration(milliseconds: 100), + beginCurve: Curves.decelerate, + endCurve: Curves.easeInOutSine, + child: AspectRatio( + aspectRatio: 1 / 1, + child: Container( + decoration: BoxDecoration( + // add border + border: const GradientBoxBorder( + gradient: LinearGradient(colors: [ + Colors.transparent, + Color(0xFF323232), + ], begin: Alignment.topCenter, end: Alignment.bottomCenter), + width: 2.5, + ), + // set border radius + borderRadius: BorderRadius.circular(20), ), - 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), - ) - : 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), + child: ClipRRect( + borderRadius: BorderRadius.circular(18), + // implement image + child: Stack( + alignment: Alignment.bottomCenter, + children: [ + Image( + image: NetworkImage(widget.post.music.cover!), + fit: BoxFit.cover, + width: double.infinity, ), - ], - ), - SizedBox(height: 10), - ZoomTapAnimation( - onTap: () { - if (widget.post.selfie != null) { - switchChoice(); - } - }, - enableLongTapRepeatEvent: false, - longTapRepeatDuration: const Duration(milliseconds: 100), - begin: 1.0, - end: 0.99, - beginDuration: const Duration(milliseconds: 70), - endDuration: const Duration(milliseconds: 100), - beginCurve: Curves.decelerate, - endCurve: Curves.easeInOutSine, - child: AspectRatio( - aspectRatio: 1 / 1, - child: Container( - decoration: BoxDecoration( - // add border - border: const GradientBoxBorder( - gradient: LinearGradient(colors: [ - Colors.transparent, - Color(0xFF323232), - ], begin: Alignment.topCenter, end: Alignment.bottomCenter), - width: 2.5, + Image( + image: AssetImage("assets/images/shadow_post.png"), + opacity: AnimationController(vsync: this, value: 0.7), + fit: BoxFit.fitHeight, + width: double.infinity, ), - // set border radius - borderRadius: BorderRadius.circular(20), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(18), - // implement image - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - Image( - image: NetworkImage(choice ? widget.post.selfie! : widget.post.music.cover!), - fit: BoxFit.cover, - width: double.infinity, - ), - widget.post.selfie != null - ? Positioned( - top: 0, - right: 0, - child: Padding( - padding: EdgeInsets.all(12), - child: Container( - 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), - // set border radius - borderRadius: BorderRadius.circular(15), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(13), - // implement image - child: Image( - image: NetworkImage( - choice ? widget.post.music.cover! : widget.post.selfie!), - fit: BoxFit.cover, - ), - ), + 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, + right: 0, + child: Padding( + padding: EdgeInsets.all(12), + child: Container( + 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), + // set border radius + borderRadius: BorderRadius.circular(15), + ), + child: ClipRRect( + borderRadius: BorderRadius.circular(13), + // implement image + child: Image( + image: NetworkImage(widget.post.selfie!), + fit: BoxFit.cover, ), - )) - : Container(), - ], - ), - ), + ), + ), + )) + : Container(), + ], ), - )), - SizedBox(height: 15), + ), + ), + )), + SizedBox(height: 15), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ Row( - crossAxisAlignment: CrossAxisAlignment.end, - mainAxisAlignment: MainAxisAlignment.spaceBetween, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, children: [ - Flexible( - flex: 8, - child: TextScroll( - widget.post.music.artists.first.name!, - style: GoogleFonts.plusJakartaSans( - height: 1, color: Colors.white, fontWeight: FontWeight.w600, fontSize: 26.h), - mode: TextScrollMode.endless, - pauseBetween: Duration(milliseconds: 500), - velocity: Velocity(pixelsPerSecond: Offset(20, 0)), - )), - Padding( - padding: EdgeInsets.only(bottom: 10.h, right: 5.w, left: 5.w), - child: ClipOval( - child: Container( - width: 5.h, - height: 5.h, - color: Colors.white, - ), - ), - ), Expanded( flex: 8, child: Padding( @@ -203,7 +198,7 @@ class _PostComponentState extends State with TickerProviderStateM child: TextScroll( 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.w600, fontSize: 26.h), mode: TextScrollMode.endless, velocity: Velocity(pixelsPerSecond: Offset(50, 20)), pauseBetween: Duration(milliseconds: 500), @@ -213,211 +208,23 @@ class _PostComponentState extends State with TickerProviderStateM AutoSizeText( widget.post.music.date.toString(), style: GoogleFonts.plusJakartaSans( - color: Colors.white.withOpacity(0.5), fontWeight: FontWeight.w300, fontSize: 16.h), + color: Colors.white, fontWeight: FontWeight.w600, fontSize: 26.h), textAlign: TextAlign.end, maxFontSize: 20, ), ], ), - ], - )); - } - - return SizedBox( - width: double.infinity, - child: Column( - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - ProfilPictureComponent(user: widget.post.user), - Expanded( - flex: 8, - child: Padding( - padding: const EdgeInsets.only(left: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - 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, - fontSize: 13), - ) - : Text( - "", - 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)) - ? 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( - "hier, ${widget.post.date.hour}:${widget.post.date.minute}", - style: GoogleFonts.plusJakartaSans( - color: Colors.white.withOpacity(0.4), fontWeight: FontWeight.w300, fontSize: 13), - ), - ], - ), - SizedBox(height: 10), - ZoomTapAnimation( - onTap: () { - widget.callback!(widget.post); - }, - enableLongTapRepeatEvent: false, - longTapRepeatDuration: const Duration(milliseconds: 100), - begin: 1.0, - end: 0.99, - beginDuration: const Duration(milliseconds: 70), - endDuration: const Duration(milliseconds: 100), - beginCurve: Curves.decelerate, - endCurve: Curves.easeInOutSine, - child: AspectRatio( - aspectRatio: 1 / 1, - child: Container( - decoration: BoxDecoration( - // add border - border: const GradientBoxBorder( - gradient: LinearGradient(colors: [ - Colors.transparent, - Color(0xFF323232), - ], begin: Alignment.topCenter, end: Alignment.bottomCenter), - width: 2.5, - ), - // set border radius - borderRadius: BorderRadius.circular(20), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(18), - // implement image - child: Stack( - alignment: Alignment.bottomCenter, - children: [ - Image( - image: NetworkImage(widget.post.music.cover!), - fit: BoxFit.cover, - width: double.infinity, - ), - Image( - image: AssetImage("assets/images/shadow_post.png"), - opacity: AnimationController(vsync: this, value: 0.7), - fit: BoxFit.fitHeight, - width: double.infinity, - ), - 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, - right: 0, - child: Padding( - padding: EdgeInsets.all(12), - child: Container( - 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), - // set border radius - borderRadius: BorderRadius.circular(15), - ), - child: ClipRRect( - borderRadius: BorderRadius.circular(13), - // implement image - child: Image( - image: NetworkImage(widget.post.selfie!), - fit: BoxFit.cover, - ), - ), - ), - )) - : Container(), - ], - ), - ), - ), - )), - SizedBox(height: 15), - SizedBox( - height: 40, - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Row( - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Expanded( - flex: 8, - child: Padding( - padding: EdgeInsets.only(bottom: 2), - child: TextScroll( - widget.post.music.title!, - style: GoogleFonts.plusJakartaSans( - height: 1, color: Colors.white, fontWeight: FontWeight.w600, fontSize: 26.h), - mode: TextScrollMode.endless, - velocity: Velocity(pixelsPerSecond: Offset(50, 20)), - pauseBetween: Duration(milliseconds: 500), - ), - )), - Container(width: 10), - AutoSizeText( - widget.post.music.date.toString(), - style: GoogleFonts.plusJakartaSans( - color: Colors.white, fontWeight: FontWeight.w600, fontSize: 26.h), - textAlign: TextAlign.end, - maxFontSize: 20, - ), - ], - ), - Expanded( - flex: 8, - child: TextScroll( - widget.post.music.artists.first.name!, - style: GoogleFonts.plusJakartaSans( - height: 1, - color: Colors.white.withOpacity(0.5), - fontWeight: FontWeight.w300, - fontSize: 16.h), - mode: TextScrollMode.endless, - pauseBetween: Duration(milliseconds: 500), - velocity: Velocity(pixelsPerSecond: Offset(20, 0)), - )), - ], + TextScroll( + widget.post.music.artists.first.name!, + style: GoogleFonts.plusJakartaSans( + height: 1, color: Colors.white.withOpacity(0.5), fontWeight: FontWeight.w300, fontSize: 16.h), + mode: TextScrollMode.endless, + pauseBetween: Duration(milliseconds: 500), + velocity: Velocity(pixelsPerSecond: Offset(20, 0)), ), - ) - ], - )); - }, - ), - ); + ], + ), + ], + ))); } } diff --git a/Sources/justMUSIC/lib/components/profile_list_component.dart b/Sources/justMUSIC/lib/components/profile_list_component.dart index ebb5363..9201a0c 100644 --- a/Sources/justMUSIC/lib/components/profile_list_component.dart +++ b/Sources/justMUSIC/lib/components/profile_list_component.dart @@ -1,6 +1,7 @@ import 'package:flutter/Material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:google_fonts/google_fonts.dart'; +import 'package:justmusic/components/profil_picture_component.dart'; import '../main.dart'; import '../model/User.dart'; import '../values/constants.dart'; @@ -23,13 +24,7 @@ class _ProfileListComponentState extends State { padding: const EdgeInsets.only(bottom: 5), child: Row( children: [ - ClipOval( - child: FadeInImage.assetNetwork( - height: 50, - width: 50, - fit: BoxFit.cover, - placeholder: "assets/images/loadingPlaceholder.gif", - image: widget.user.pp)), + ProfilPictureComponent(user: widget.user), const SizedBox( width: 10, ), diff --git a/Sources/justMUSIC/lib/screens/detail_post_screen.dart b/Sources/justMUSIC/lib/screens/detail_post_screen.dart index 0f1b875..33027e9 100644 --- a/Sources/justMUSIC/lib/screens/detail_post_screen.dart +++ b/Sources/justMUSIC/lib/screens/detail_post_screen.dart @@ -9,6 +9,7 @@ import 'package:text_scroll/text_scroll.dart'; import 'package:zoom_tap_animation/zoom_tap_animation.dart'; import '../components/button_play_component.dart'; import '../components/comment_component.dart'; +import '../components/profil_picture_component.dart'; import '../main.dart'; import '../model/Post.dart'; import '../model/Comment.dart'; @@ -115,10 +116,7 @@ class _DetailPostScreenState extends State { child: ClipOval( child: SizedBox.fromSize( // Image radius - child: Image( - image: NetworkImage(widget.post.user.pp), - width: 45, - ), + child: ProfilPictureComponent(user: widget.post.user), ), ), ) @@ -146,13 +144,9 @@ class _DetailPostScreenState extends State { fontWeight: FontWeight.w800, fontSize: 22, ), - mode: TextScrollMode - .endless, - pauseBetween: Duration( - milliseconds: 500), - velocity: Velocity( - pixelsPerSecond: - Offset(20, 0)), + mode: TextScrollMode.endless, + pauseBetween: Duration(milliseconds: 500), + velocity: Velocity(pixelsPerSecond: Offset(20, 0)), ), ), ), @@ -445,7 +439,7 @@ class _DetailPostScreenState extends State { focusNode: myFocusNode, onSubmitted: (value) async { if (value.isNotEmpty) { - await MyApp.commentViewModel.addComment(value, widget.post.id); + await MyApp.commentViewModel.addComment(value, widget.post.id, widget.post.user); } setState(() { _textController.clear(); @@ -455,11 +449,13 @@ class _DetailPostScreenState extends State { keyboardType: TextInputType.emailAddress, style: GoogleFonts.plusJakartaSans(color: Colors.white), decoration: InputDecoration( - suffixIcon: Icon( - Icons.send, - color: grayText, - size: 20, - ), + suffixIcon: IconButton( + onPressed: () {}, + icon: Icon( + Icons.send, + color: grayText, + size: 20, + )), focusedBorder: OutlineInputBorder( borderSide: BorderSide(width: 1, color: grayText), borderRadius: BorderRadius.all(Radius.circular(100)), @@ -491,8 +487,7 @@ class _DetailPostScreenState extends State { class MyBehavior extends ScrollBehavior { @override - Widget buildOverscrollIndicator( - BuildContext context, Widget child, ScrollableDetails details) { + Widget buildOverscrollIndicator(BuildContext context, Widget child, ScrollableDetails details) { return child; } } diff --git a/Sources/justMUSIC/lib/screens/feed_screen.dart b/Sources/justMUSIC/lib/screens/feed_screen.dart index c7b73dc..4382192 100644 --- a/Sources/justMUSIC/lib/screens/feed_screen.dart +++ b/Sources/justMUSIC/lib/screens/feed_screen.dart @@ -56,6 +56,7 @@ class _FeedScreenState extends State with SingleTickerProviderStateM @override void dispose() { + controller.dispose(); animationController.dispose(); super.dispose(); } @@ -120,7 +121,7 @@ class _FeedScreenState extends State with SingleTickerProviderStateM bool empty = (choiceFeed == true && displayFeed.item1.isEmpty) || (choiceFeed == false && displayFeed.item2.isEmpty); return Scaffold( - resizeToAvoidBottomInset: true, + resizeToAvoidBottomInset: false, backgroundColor: bgColor, extendBodyBehindAppBar: true, body: Container( diff --git a/Sources/justMUSIC/lib/view_model/CommentViewModel.dart b/Sources/justMUSIC/lib/view_model/CommentViewModel.dart index c3aa0a4..de2c0de 100644 --- a/Sources/justMUSIC/lib/view_model/CommentViewModel.dart +++ b/Sources/justMUSIC/lib/view_model/CommentViewModel.dart @@ -1,19 +1,24 @@ import 'package:justmusic/model/mapper/CommentMapper.dart'; import '../model/Comment.dart'; +import '../model/User.dart'; import '../services/CommentService.dart'; +import '../services/NotificationService.dart'; class CommentViewModel { List _comments = []; final CommentService _commentService = CommentService(); + final NotificationService _notificationService = NotificationService(); // Constructor CommentViewModel(); // Methods - addComment(String text, String idPost) async { + addComment(String text, String idPost, User receiver) async { try { + print(receiver.token); await _commentService.createComment(text, idPost); + _notificationService.sendNotifyComment(receiver.token, text); } catch (e) { print(e); rethrow;