diff --git a/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml b/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml index 884d0be..bdbab72 100644 --- a/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml +++ b/Sources/justMUSIC/android/app/src/main/AndroidManifest.xml @@ -3,7 +3,7 @@ package="com.justdev.justmusic"> + android:icon="@mipmap/launcher_icon"> 0) { + return '${difference.inDays} jours'; + } else if (difference.inHours > 0) { + return '${difference.inHours} heures'; + } else if (difference.inMinutes > 0) { + return '${difference.inMinutes} minutes'; + } else { + return '${difference.inSeconds} secondes'; + } + } @override Widget build(BuildContext context) { - final now = DateTime.now(); - final difference = now.difference(comment.date); return Container( width: double.infinity, @@ -56,7 +66,7 @@ class CommentComponent extends StatelessWidget { Padding( padding: EdgeInsets.only(top: 6, left: 10), child: Text( - "il y a ${difference.inHours > 0 ? difference.inHours : difference.inMinutes}${difference.inHours > 0 ? "h" : "m"}", + "il y a ${calculateTimeDifference(comment.date)}", style: GoogleFonts.plusJakartaSans( color: Colors.white.withOpacity(0.6), fontWeight: FontWeight.w400, fontSize: 10), ), diff --git a/Sources/justMUSIC/lib/components/editable_post_component.dart b/Sources/justMUSIC/lib/components/editable_post_component.dart index 635ebf5..91a9fe1 100644 --- a/Sources/justMUSIC/lib/components/editable_post_component.dart +++ b/Sources/justMUSIC/lib/components/editable_post_component.dart @@ -284,6 +284,7 @@ class _EditablePostComponentState extends State with Tick child: SizedBox( width: double.infinity, child: TextFormField( + keyboardType: TextInputType.text, onChanged: (value) { _updateDescription(value); }, diff --git a/Sources/justMUSIC/lib/components/post_component.dart b/Sources/justMUSIC/lib/components/post_component.dart index e80649d..f9a5ade 100644 --- a/Sources/justMUSIC/lib/components/post_component.dart +++ b/Sources/justMUSIC/lib/components/post_component.dart @@ -29,21 +29,29 @@ class _PostComponentState extends State with TickerProviderStateM choice = !choice; }); } + String formatPostDate(DateTime postDate) { + DateTime now = DateTime.now(); + DateTime yesterday = DateTime(now.year, now.month, now.day - 1); - final List frenchMonths = [ - 'Janvier', - 'Février', - 'Mars', - 'Avril', - 'Mai', - 'Juin', - 'Juillet', - 'Août', - 'Septembre', - 'Octobre', - 'Novembre', - 'Décembre' - ]; + if (postDate.year == now.year && postDate.month == now.month && postDate.day == now.day) { + // Aujourd'hui + return "Aujourd'hui, ${postDate.hour}:${postDate.minute.toString().padLeft(2, '0')}"; + } else if (postDate.year == yesterday.year && postDate.month == yesterday.month && postDate.day == yesterday.day) { + // Hier + return 'hier, ${postDate.hour}:${postDate.minute.toString().padLeft(2, '0')}'; + } else { + // Autre date + return '${postDate.day} ${_getMonthAbbreviation(postDate.month)} ${postDate.hour}:${postDate.minute.toString().padLeft(2, '0')}'; + } + } + + String _getMonthAbbreviation(int month) { + const List monthsAbbreviation = [ + 'janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.', + ]; + + return monthsAbbreviation[month - 1]; + } @override void initState() { @@ -101,18 +109,11 @@ class _PostComponentState extends State with TickerProviderStateM ), ), ), - 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}:$mins", + Text( + formatPostDate(widget.post.date), style: GoogleFonts.plusJakartaSans( color: Colors.white.withOpacity(0.4), fontWeight: FontWeight.w300, fontSize: 13), ) - : Text( - '${widget.post.date.day} ${frenchMonths[widget.post.date.month - 1]}, ${widget.post.date.hour}:$mins', - style: GoogleFonts.plusJakartaSans( - color: Colors.white.withOpacity(0.4), fontWeight: FontWeight.w300, fontSize: 13), - ), ], ), SizedBox(height: 10), diff --git a/Sources/justMUSIC/lib/config/routes.dart b/Sources/justMUSIC/lib/config/routes.dart index 4b36efa..7c4c5a0 100644 --- a/Sources/justMUSIC/lib/config/routes.dart +++ b/Sources/justMUSIC/lib/config/routes.dart @@ -5,6 +5,7 @@ import 'package:justmusic/screens/change_password_screen.dart'; import 'package:justmusic/screens/feed_screen.dart'; import 'package:justmusic/screens/profile_screen.dart'; import 'package:justmusic/screens/user_screen.dart'; +import 'package:justmusic/screens/welcome_screen.dart'; import '../model/User.dart'; @@ -109,3 +110,15 @@ Route routeHistoric() { }, ); } + +Route routeWelcome() { + return PageRouteBuilder( + pageBuilder: (context, animation, secondaryAnimation) => const WellcomeScreen(), + transitionsBuilder: (context, animation, secondaryAnimation, child) { + return FadeTransition( + opacity: animation, + child: child, + ); + }, + ); +} diff --git a/Sources/justMUSIC/lib/screens/detail_post_screen.dart b/Sources/justMUSIC/lib/screens/detail_post_screen.dart index 34c6dcb..98615c0 100644 --- a/Sources/justMUSIC/lib/screens/detail_post_screen.dart +++ b/Sources/justMUSIC/lib/screens/detail_post_screen.dart @@ -67,15 +67,45 @@ class _DetailPostScreenState extends State { } final ScrollController _scrollController = ScrollController(); + String formatPostDate(DateTime postDate) { + DateTime now = DateTime.now(); + DateTime yesterday = DateTime(now.year, now.month, now.day - 1); - @override - Widget build(BuildContext context) { - var mins = "0"; - if (widget.post.date.minute < 10) { - mins = "0${widget.post.date.minute}"; + if (postDate.year == now.year && postDate.month == now.month && postDate.day == now.day) { + // Aujourd'hui + return "Aujourd'hui, ${postDate.hour}:${postDate.minute.toString().padLeft(2, '0')}"; + } else if (postDate.year == yesterday.year && postDate.month == yesterday.month && postDate.day == yesterday.day) { + // Hier + return 'hier, ${postDate.hour}:${postDate.minute.toString().padLeft(2, '0')}'; } else { - mins = widget.post.date.minute.toString(); + // Autre date + return '${postDate.day} ${_getMonthAbbreviation(postDate.month)} ${postDate.hour}:${postDate.minute.toString().padLeft(2, '0')}'; } + } + + + String _getMonthAbbreviation(int month) { + const List monthsAbbreviation = [ + 'janv.', 'févr.', 'mars', 'avr.', 'mai', 'juin', 'juil.', 'août', 'sept.', 'oct.', 'nov.', 'déc.', + ]; + + return monthsAbbreviation[month - 1]; + } + +// Exemple d'utilisation : + void main() { + DateTime postDate = DateTime(2023, 11, 17, 17, 55); // Remplacez par votre date + + String formattedDate = formatPostDate(postDate); + print(formattedDate); // Affichera "17 nov. 17:55" ou "hier, 17:55" selon la date + } + + + @override + Widget build(BuildContext context) { + _scrollController.addListener(() { + if (_scrollController.position.pixels < 0) _scrollController.jumpTo(0); + }); return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); @@ -86,6 +116,7 @@ class _DetailPostScreenState extends State { }, child: Container( height: 760.h, + color: bgAppBar, child: Column( children: [ Expanded( @@ -118,156 +149,140 @@ class _DetailPostScreenState extends State { Column( children: [ Container( - height: 200, - margin: EdgeInsets.only(top: 230), - width: double.infinity, - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Colors.transparent, - bgModal.withOpacity(0.5), - bgModal.withOpacity(0.75), - bgModal - ], - stops: [0, 0.2, 0.4, 0.8], + height: 200, + margin: EdgeInsets.only(top: 230), + width: double.infinity, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Colors.transparent, + bgModal.withOpacity(0.5), + bgModal.withOpacity(0.75), + bgModal + ], + stops: [0, 0.2, 0.4, 0.8], + ), ), - ), - child: Padding( - padding: const EdgeInsets.fromLTRB(20, 0, 20, 10), - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Padding( - padding: const EdgeInsets.only(right: 10), - child: choice - ? Padding( - padding: const EdgeInsets.all(4), - child: ClipOval( - child: SizedBox.fromSize( - // Image radius - child: ProfilPictureComponent(user: widget.post.user), - ), - ), - ) - : widget.post.music.previewUrl != null - ? ButtonPlayComponent(music: widget.post.music) - : Container(), - ), - Flexible( - child: Column( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Flexible( - child: Row( - crossAxisAlignment: CrossAxisAlignment.end, - children: [ - Expanded( - child: ScrollConfiguration( - behavior: ScrollBehavior().copyWith(scrollbars: false), - child: TextScroll( - choice ? widget.post.user.pseudo : widget.post.music.title!, - style: GoogleFonts.plusJakartaSans( - height: 1, - color: Colors.white, - fontWeight: FontWeight.w800, - fontSize: 22, + child: Padding( + padding: const EdgeInsets.fromLTRB(20, 0, 20, 10), + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Padding( + padding: const EdgeInsets.only(right: 10), + child: choice + ? Padding( + padding: const EdgeInsets.all(4), + child: ClipOval( + child: SizedBox.fromSize( + // Image radius + child: ProfilPictureComponent(user: widget.post.user), + ), + ), + ) + : widget.post.music.previewUrl != null + ? ButtonPlayComponent(music: widget.post.music) + : Container(), + ), + Flexible( + child: Column( + mainAxisAlignment: MainAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Flexible( + child: Row( + crossAxisAlignment: CrossAxisAlignment.end, + children: [ + Expanded( + child: ScrollConfiguration( + behavior: ScrollBehavior().copyWith(scrollbars: false), + child: TextScroll( + choice ? widget.post.user.pseudo : widget.post.music.title!, + style: GoogleFonts.plusJakartaSans( + height: 1, + color: Colors.white, + 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)), ), ), - ), - Padding( - padding: const EdgeInsets.only(left: 20.0), - child: choice - ? 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}:$mins", - style: GoogleFonts.plusJakartaSans( - height: 1, - color: Colors.white, - fontWeight: FontWeight.w900, - fontSize: 18, - ), - ) - : Text( - "hier, ${widget.post.date.hour}:$mins", - style: GoogleFonts.plusJakartaSans( - height: 1, - color: Colors.white, - fontWeight: FontWeight.w900, - fontSize: 18, - ), - ) - : Text( - widget.post.music.date.toString(), - style: GoogleFonts.plusJakartaSans( - height: 1, - color: Colors.white, - fontWeight: FontWeight.w900, - fontSize: 18, - ), - ), - ), - ], - ), - ), - choice - ? widget.post.location.item2 != null - ? Text( - "${widget.post.location.item1}, ${widget.post.location.item2}", + Padding( + padding: const EdgeInsets.only(left: 20.0), + child: choice + ? Text( + formatPostDate(widget.post.date), style: GoogleFonts.plusJakartaSans( - color: Colors.white.withOpacity(0.5), - fontWeight: FontWeight.w400, - fontSize: 15, + height: 1, + color: Colors.white, + fontWeight: FontWeight.w900, + fontSize: 18, ), ) - : Text( - "", + : Text( + widget.post.music.date.toString(), style: GoogleFonts.plusJakartaSans( - color: Colors.white.withOpacity(0.4), - fontWeight: FontWeight.w300, - fontSize: 13, + height: 1, + color: Colors.white, + fontWeight: FontWeight.w900, + fontSize: 18, ), - ) - : ScrollConfiguration( - behavior: ScrollBehavior().copyWith(scrollbars: false), - child: TextScroll( - widget.post.music.artists.first.name!, - style: GoogleFonts.plusJakartaSans( - height: 1, - color: Colors.white, - fontWeight: FontWeight.w500, - fontSize: 17, ), - mode: TextScrollMode.endless, - pauseBetween: Duration(milliseconds: 500), - velocity: Velocity(pixelsPerSecond: Offset(20, 0)), ), + ], + ), + ), + choice + ? widget.post.location.item2 != null + ? Text( + "${widget.post.location.item1}, ${widget.post.location.item2}", + style: GoogleFonts.plusJakartaSans( + color: Colors.white.withOpacity(0.5), + fontWeight: FontWeight.w400, + fontSize: 15, + ), + ) + : Text( + "", + style: GoogleFonts.plusJakartaSans( + color: Colors.white.withOpacity(0.4), + fontWeight: FontWeight.w300, + fontSize: 13, + ), + ) + : ScrollConfiguration( + behavior: ScrollBehavior().copyWith(scrollbars: false), + child: TextScroll( + widget.post.music.artists.first.name!, + style: GoogleFonts.plusJakartaSans( + height: 1, + color: Colors.white, + fontWeight: FontWeight.w500, + fontSize: 17, ), - ], + mode: TextScrollMode.endless, + pauseBetween: Duration(milliseconds: 500), + velocity: Velocity(pixelsPerSecond: Offset(20, 0)), + ), + ), + ], + ), ), - ), - ], + ], + ), ), ), - ), - widget.post.description != null - ? Align( + widget.post.description != null ? Align( alignment: Alignment.bottomLeft, - child: Padding( + child: Container( padding: const EdgeInsets.fromLTRB(50, 35, 50, 35), + color: bgModal, + width: double.infinity, child: Text( widget.post.description!, textAlign: TextAlign.left, @@ -281,7 +296,7 @@ class _DetailPostScreenState extends State { ), ) : Container( - height: 30, + height: 0, ), Container( width: double.infinity, @@ -630,12 +645,12 @@ class _DetailPostScreenState extends State { _textController.clear(); }); }, - icon: Icon( + icon: const Icon( Icons.send, color: primaryColor, size: 20, )), - focusedBorder: OutlineInputBorder( + focusedBorder: const OutlineInputBorder( borderSide: BorderSide(width: 1, color: grayText), borderRadius: BorderRadius.all(Radius.circular(100)), ), @@ -643,7 +658,7 @@ class _DetailPostScreenState extends State { fillColor: bgModal, filled: true, focusColor: Color.fromRGBO(255, 255, 255, 0.30), - enabledBorder: OutlineInputBorder( + enabledBorder: const OutlineInputBorder( borderSide: BorderSide(width: 1, color: grayText), borderRadius: BorderRadius.all(Radius.circular(100)), ), diff --git a/Sources/justMUSIC/lib/screens/profile_screen.dart b/Sources/justMUSIC/lib/screens/profile_screen.dart index d68a3ae..df3cf81 100644 --- a/Sources/justMUSIC/lib/screens/profile_screen.dart +++ b/Sources/justMUSIC/lib/screens/profile_screen.dart @@ -19,9 +19,9 @@ class ProfileScreen extends StatefulWidget { class _ProfileScreenState extends State { @override Widget build(BuildContext context) { - Future logout() async { - await MyApp.userViewModel.logout(); - Navigator.pushNamed(context, '/welcome'); + void logout() { + MyApp.userViewModel.logout(); + Navigator.of(context).push(routeWelcome()); } void _openHistoric() { diff --git a/Sources/justMUSIC/lib/values/constants.dart b/Sources/justMUSIC/lib/values/constants.dart index 8b3b4c4..af24e9d 100644 --- a/Sources/justMUSIC/lib/values/constants.dart +++ b/Sources/justMUSIC/lib/values/constants.dart @@ -13,7 +13,7 @@ const bgTextField = Color(0xFF1C1B23); const strokeTextField = Color(0xFF373546); const unactiveFeed = Color(0xFF848484); const gradiantPost = Color(0xFF0D0D0D); -const bgModal = Color(0xFF1E1E1E); +const bgModal = Color(0xFF222222); const textFieldMessage = Color(0xFF232323); const bgComment = Color(0xFF222222); const bgAppBar = Color(0xFF181818); diff --git a/Sources/justMUSIC/pubspec.lock b/Sources/justMUSIC/pubspec.lock index dcb150a..854df36 100644 --- a/Sources/justMUSIC/pubspec.lock +++ b/Sources/justMUSIC/pubspec.lock @@ -161,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.0" + checked_yaml: + dependency: transitive + description: + name: checked_yaml + sha256: feb6bed21949061731a7a75fc5d2aa727cf160b91af9a3e464c5e3a32e28b5ff + url: "https://pub.dev" + source: hosted + version: "2.0.3" circular_reveal_animation: dependency: "direct main" description: @@ -169,6 +177,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.0.1" + cli_util: + dependency: transitive + description: + name: cli_util + sha256: b8db3080e59b2503ca9e7922c3df2072cf13992354d5e944074ffa836fba43b7 + url: "https://pub.dev" + source: hosted + version: "0.4.0" clock: dependency: transitive description: @@ -494,6 +510,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + flutter_launcher_icons: + dependency: "direct main" + description: + name: flutter_launcher_icons + sha256: "526faf84284b86a4cb36d20a5e45147747b7563d921373d4ee0559c54fcdbcea" + url: "https://pub.dev" + source: hosted + version: "0.13.1" flutter_lints: dependency: "direct dev" description: @@ -688,6 +712,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + image: + dependency: transitive + description: + name: image + sha256: a72242c9a0ffb65d03de1b7113bc4e189686fc07c7147b8b41811d0dd0e0d9bf + url: "https://pub.dev" + source: hosted + version: "4.0.17" image_picker: dependency: "direct main" description: @@ -784,6 +816,14 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.7" + json_annotation: + dependency: transitive + description: + name: json_annotation + sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 + url: "https://pub.dev" + source: hosted + version: "4.8.1" lints: dependency: transitive description: @@ -1173,6 +1213,14 @@ packages: url: "https://pub.dev" source: hosted version: "6.3.0" + yaml: + dependency: transitive + description: + name: yaml + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" + source: hosted + version: "3.1.2" zoom_tap_animation: dependency: "direct main" description: diff --git a/Sources/justMUSIC/pubspec.yaml b/Sources/justMUSIC/pubspec.yaml index 494ee35..7909850 100644 --- a/Sources/justMUSIC/pubspec.yaml +++ b/Sources/justMUSIC/pubspec.yaml @@ -76,6 +76,7 @@ dependencies: firebase_messaging: ^14.6.5 cached_network_image: ^3.2.3 google_sign_in: ^6.1.4 + flutter_launcher_icons: ^0.13.1 dev_dependencies: flutter_test: @@ -88,6 +89,14 @@ dev_dependencies: # rules and activating additional ones. flutter_lints: ^2.0.0 + +flutter_launcher_icons: + android: "launcher_icon" + ios: true + image_path: "assets/images/logo-JustMusic.png" + remove_alpha_ios: true + min_sdk_android: 21 # android min sdk min:16, default 21 + # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec