From db48302aa01e51e228ce63fb2d6235e5ada90a2c Mon Sep 17 00:00:00 2001 From: Lucas Delanier Date: Wed, 23 Aug 2023 16:45:33 +0200 Subject: [PATCH] fix date 2 digits --- .../lib/components/post_component.dart | 12 +- Sources/justMUSIC/lib/main.dart | 107 +++++++----------- .../lib/screens/detail_post_screen.dart | 10 +- 3 files changed, 61 insertions(+), 68 deletions(-) diff --git a/Sources/justMUSIC/lib/components/post_component.dart b/Sources/justMUSIC/lib/components/post_component.dart index 8c1c979..d46f458 100644 --- a/Sources/justMUSIC/lib/components/post_component.dart +++ b/Sources/justMUSIC/lib/components/post_component.dart @@ -3,7 +3,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:intl/intl.dart'; import 'package:justmusic/components/profil_picture_component.dart'; import 'package:text_scroll/text_scroll.dart'; import 'package:zoom_tap_animation/zoom_tap_animation.dart'; @@ -55,6 +54,13 @@ class _PostComponentState extends State with TickerProviderStateM @override Widget build(BuildContext context) { + var mins = "0"; + if (widget.post.date.minute < 10) { + mins = "0${widget.post.date.minute}"; + } else { + mins = widget.post.date.minute.toString(); + } + return GestureDetector( onTap: switchChoice, child: SizedBox( @@ -98,12 +104,12 @@ 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}:${widget.post.date.minute}", + "Aujourd'hui, ${widget.post.date.hour}:$mins", 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}:${widget.post.date.minute}', + '${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), ), diff --git a/Sources/justMUSIC/lib/main.dart b/Sources/justMUSIC/lib/main.dart index 3c5ae57..cf342bd 100644 --- a/Sources/justMUSIC/lib/main.dart +++ b/Sources/justMUSIC/lib/main.dart @@ -8,7 +8,6 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:intl/date_symbol_data_file.dart'; import 'package:justmusic/screens/add_friend_screen.dart'; import 'package:justmusic/screens/explanations_screen.dart'; import 'package:justmusic/screens/feed_screen.dart'; @@ -78,68 +77,50 @@ class _MyAppState extends State { return ScreenUtilInit( useInheritedMediaQuery: true, builder: (context, child) { - return StreamBuilder( - stream: FirebaseAuth.instance.authStateChanges(), - builder: (context, snapshot) { - if (ConnectionState.waiting == snapshot.connectionState) { - return const CupertinoActivityIndicator(); - } - if (snapshot.hasData) { - return FutureBuilder( - future: MyApp.userViewModel.getUser(snapshot.data!.uid), - builder: (context, userSnapshot) { - if (userSnapshot.connectionState == ConnectionState.waiting) { - return const CupertinoActivityIndicator(); - } else { - if (userSnapshot.hasData) { - MyApp.userViewModel.userCurrent = userSnapshot.data!; - return MaterialApp( - routes: { - '/welcome': (context) => const WellcomeScreen(), - '/feed': (context) => const FeedScreen(), - '/login': (context) => const LoginScreen(), - '/register': (context) => const RegistrationScreen(), - '/post': (context) => const PostScreen(), - '/profile': (context) => const ProfileScreen(), - '/explanation': (context) => const ExplanationsScreen(), - '/addFriend': (context) => const AddFriendScreen(), - '/launchingRocket': (context) => const LaunchingRocketScreen(), - '/verifyEmail': (context) => const VerifyEmailScreen(), - '/forgetPassword': (context) => const ForgetPasswordScreen(), - }, - debugShowCheckedModeBanner: false, - theme: ThemeData( - primarySwatch: Colors.blue, - ), - home: FeedScreen()); - } else { - return const Text('User data not found'); - } - } - }, - ); - } else { - return MaterialApp( - routes: { - '/welcome': (context) => const WellcomeScreen(), - '/feed': (context) => const FeedScreen(), - '/login': (context) => const LoginScreen(), - '/register': (context) => const RegistrationScreen(), - '/post': (context) => const PostScreen(), - '/profile': (context) => const ProfileScreen(), - '/explanation': (context) => const ExplanationsScreen(), - '/addFriend': (context) => const AddFriendScreen(), - '/launchingRocket': (context) => const LaunchingRocketScreen(), - '/verifyEmail': (context) => const VerifyEmailScreen(), - '/forgetPassword': (context) => const ForgetPasswordScreen(), - }, - debugShowCheckedModeBanner: false, - theme: ThemeData( - primarySwatch: Colors.blue, - ), - home: WellcomeScreen()); - } - }); + return MaterialApp( + routes: { + '/welcome': (context) => const WellcomeScreen(), + '/feed': (context) => const FeedScreen(), + '/login': (context) => const LoginScreen(), + '/register': (context) => const RegistrationScreen(), + '/post': (context) => const PostScreen(), + '/profile': (context) => const ProfileScreen(), + '/explanation': (context) => const ExplanationsScreen(), + '/addFriend': (context) => const AddFriendScreen(), + '/launchingRocket': (context) => const LaunchingRocketScreen(), + '/verifyEmail': (context) => const VerifyEmailScreen(), + '/forgetPassword': (context) => const ForgetPasswordScreen(), + }, + debugShowCheckedModeBanner: false, + theme: ThemeData( + primarySwatch: Colors.blue, + ), + home: StreamBuilder( + stream: FirebaseAuth.instance.authStateChanges(), + builder: (context, snapshot) { + if (ConnectionState.waiting == snapshot.connectionState) { + return const CupertinoActivityIndicator(); + } + if (snapshot.hasData) { + return FutureBuilder( + future: MyApp.userViewModel.getUser(snapshot.data!.uid), + builder: (context, userSnapshot) { + if (userSnapshot.connectionState == ConnectionState.waiting) { + return const CupertinoActivityIndicator(); + } else { + if (userSnapshot.hasData) { + MyApp.userViewModel.userCurrent = userSnapshot.data!; + return FeedScreen(); + } else { + return const Text('User data not found'); + } + } + }, + ); + } else { + return WellcomeScreen(); + } + })); }, designSize: Size(390, 844), ); diff --git a/Sources/justMUSIC/lib/screens/detail_post_screen.dart b/Sources/justMUSIC/lib/screens/detail_post_screen.dart index a557036..28c73ea 100644 --- a/Sources/justMUSIC/lib/screens/detail_post_screen.dart +++ b/Sources/justMUSIC/lib/screens/detail_post_screen.dart @@ -70,6 +70,12 @@ class _DetailPostScreenState extends State { @override Widget build(BuildContext context) { + var mins = "0"; + if (widget.post.date.minute < 10) { + mins = "0${widget.post.date.minute}"; + } else { + mins = widget.post.date.minute.toString(); + } return GestureDetector( onTap: () { FocusScopeNode currentFocus = FocusScope.of(context); @@ -187,7 +193,7 @@ class _DetailPostScreenState extends State { ), ) ? Text( - "Aujourd'hui, ${widget.post.date.hour}:${widget.post.date.minute}", + "Aujourd'hui, ${widget.post.date.hour}:$mins", style: GoogleFonts.plusJakartaSans( height: 1, color: Colors.white, @@ -196,7 +202,7 @@ class _DetailPostScreenState extends State { ), ) : Text( - "hier, ${widget.post.date.hour}:${widget.post.date.minute}", + "hier, ${widget.post.date.hour}:$mins", style: GoogleFonts.plusJakartaSans( height: 1, color: Colors.white,