diff --git a/covas_mobile/lib/ListItemMenu.dart b/covas_mobile/lib/ListItemMenu.dart index 834c92c..eea0e64 100644 --- a/covas_mobile/lib/ListItemMenu.dart +++ b/covas_mobile/lib/ListItemMenu.dart @@ -4,12 +4,14 @@ import 'package:http/http.dart' as http; import 'package:flutter/material.dart'; import 'classes/events.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import 'package:intl/intl.dart'; +import 'package:intl/date_symbol_data_local.dart'; import 'variable/globals.dart' as globals; // app starting point void main() { - runApp(const MyApp()); + initializeDateFormatting("fr_FR", null).then((_) => (const MyApp())); } class MyApp extends StatelessWidget { @@ -95,8 +97,13 @@ class _MyHomePageState extends State { itemCount: posts.length, itemBuilder: (context, index) { final post = posts[index]; + final startDate = DateTime.parse(post.startDate!); + final date = DateFormat.yMd().format(startDate); + final time = DateFormat.Hm().format(startDate); + return ListTile( - title: Text('${post.name!}'), subtitle: Text('${post.place!}')); + title: Text('${post.name!}'), + subtitle: Text('${post.place!}\n${date} ${time}')); }, separatorBuilder: (context, index) { return Divider(); diff --git a/covas_mobile/lib/classes/events.dart b/covas_mobile/lib/classes/events.dart index f40e1b9..c1cb070 100644 --- a/covas_mobile/lib/classes/events.dart +++ b/covas_mobile/lib/classes/events.dart @@ -2,12 +2,14 @@ class Events { String? id; String? name; String? place; + String? startDate; - Events({this.place, this.id, this.name}); + Events({this.place, this.id, this.name, this.startDate}); Events.fromJson(Map json) { id = json['id']; name = json['name']; place = json['place']; + startDate = json["start_date"]; } } diff --git a/covas_mobile/lib/classes/post.dart b/covas_mobile/lib/classes/post.dart deleted file mode 100644 index 69c1727..0000000 --- a/covas_mobile/lib/classes/post.dart +++ /dev/null @@ -1,17 +0,0 @@ -class Post { - int? albumId; - int? id; - String? title; - String? url; - String? thumbnailUrl; - - Post({this.albumId, this.id, this.title, this.url, this.thumbnailUrl}); - - Post.fromJson(Map json) { - albumId = json['albumId']; - id = json['id']; - title = json['title']; - url = json['url']; - thumbnailUrl = json['thumbnailUrl']; - } -} diff --git a/covas_mobile/pubspec.lock b/covas_mobile/pubspec.lock index 2cbf4e6..b873bf1 100644 --- a/covas_mobile/pubspec.lock +++ b/covas_mobile/pubspec.lock @@ -112,6 +112,14 @@ packages: url: "https://pub.dev" source: hosted version: "4.0.2" + intl: + dependency: "direct main" + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" leak_tracker: dependency: transitive description: diff --git a/covas_mobile/pubspec.yaml b/covas_mobile/pubspec.yaml index c1cb06c..1356f4a 100644 --- a/covas_mobile/pubspec.yaml +++ b/covas_mobile/pubspec.yaml @@ -36,6 +36,7 @@ dependencies: cupertino_icons: ^1.0.2 http: ^1.2.1 shared_preferences: ^2.2.3 + intl: ^0.19.0 dev_dependencies: flutter_test: