From 909b32115825b086c868ad1d991b182fed4c29dd Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Mon, 23 Jun 2025 23:09:37 +0200 Subject: [PATCH] test date format french ok for first page --- covas_mobile/lib/pages/ListItemMenu.dart | 24 +++++++++++++++++++----- covas_mobile/pubspec.lock | 5 +++++ covas_mobile/pubspec.yaml | 4 ++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/covas_mobile/lib/pages/ListItemMenu.dart b/covas_mobile/lib/pages/ListItemMenu.dart index f418aa0..0feb5d1 100644 --- a/covas_mobile/lib/pages/ListItemMenu.dart +++ b/covas_mobile/lib/pages/ListItemMenu.dart @@ -19,11 +19,15 @@ import 'package:camera/camera.dart'; import '../classes/ad_helper.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart'; import '../classes/auth_service.dart'; +import 'package:flutter_localizations/flutter_localizations.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); + await MobileAds.instance.initialize(); - initializeDateFormatting("fr_FR", null).then((_) => runApp(const MyApp())); + await initializeDateFormatting("fr_FR", null); + + runApp(const MyApp()); } class MyApp extends StatelessWidget { @@ -32,6 +36,14 @@ class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( + localizationsDelegates: [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + supportedLocales: [ + const Locale('fr', 'FR'), + ], home: const ListItemMenu(), debugShowCheckedModeBanner: false, ); @@ -74,6 +86,7 @@ class _MyHomePageState extends State { bool showInputTag = true; // Fetching events from API static Future> getPosts() async { + await initializeDateFormatting("fr_FR"); PermissionStatus status = await Permission.location.status; final List body = []; var url = Uri.parse("${globals.api}/events"); @@ -842,12 +855,13 @@ class _MyHomePageState extends State { } final post = displayedPosts[index]; final startDate = DateTime.parse(post.startDate!); - final date = DateFormat.yMd().format(startDate); - final time = DateFormat.Hm().format(startDate); - + //final date = DateFormat.yMd().format(startDate); + //final time = DateFormat.Hm().format(startDate); + final dateLongue = + DateFormat('EEEE d MMMM y', 'fr_FR').format(startDate); return ListTile( title: Text('${post.name!}'), - subtitle: Text('${post.place!}\n${date} ${time}'), + subtitle: Text('${post.place!}\n${dateLongue}'), onTap: () { Navigator.push( context, diff --git a/covas_mobile/pubspec.lock b/covas_mobile/pubspec.lock index 770d04a..292dc71 100644 --- a/covas_mobile/pubspec.lock +++ b/covas_mobile/pubspec.lock @@ -270,6 +270,11 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.0" + flutter_localizations: + dependency: "direct main" + description: flutter + source: sdk + version: "0.0.0" flutter_plugin_android_lifecycle: dependency: transitive description: diff --git a/covas_mobile/pubspec.yaml b/covas_mobile/pubspec.yaml index 99c6d89..6e0737c 100644 --- a/covas_mobile/pubspec.yaml +++ b/covas_mobile/pubspec.yaml @@ -29,6 +29,9 @@ environment: dependencies: flutter: sdk: flutter + flutter_localizations: + sdk: flutter + # The following adds the Cupertino Icons font to your application. @@ -69,6 +72,7 @@ dev_dependencies: # The following section is specific to Flutter packages. flutter: + generate: true # The following line ensures that the Material Icons font is # included with your application, so that you can use the icons in