Compare commits

..

No commits in common. "main" and "hotfix/duplicate-event" have entirely different histories.

5 changed files with 23 additions and 77 deletions

View File

@ -12,15 +12,10 @@ import 'package:intl/date_symbol_data_local.dart';
import '../variable/globals.dart' as globals; import '../variable/globals.dart' as globals;
import '../classes/MyDrawer.dart'; import '../classes/MyDrawer.dart';
import '../classes/auth_service.dart'; import '../classes/auth_service.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
// app starting point // app starting point
void main() async { void main() {
WidgetsFlutterBinding.ensureInitialized(); initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
await initializeDateFormatting("fr_FR", null);
runApp(const MyApp());
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@ -29,14 +24,6 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('fr', 'FR'),
],
home: const ListItemOrganizers(organizer: "default"), home: const ListItemOrganizers(organizer: "default"),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
); );
@ -94,8 +81,6 @@ class _MyHomePageState extends State<ListItemOrganizers> {
// function to fetch data from api and return future list of posts // function to fetch data from api and return future list of posts
static Future<List<Events>> getPosts(organizer, {count = 0}) async { static Future<List<Events>> getPosts(organizer, {count = 0}) async {
await initializeDateFormatting("fr_FR", null);
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
var accessToken = prefs.getString("access_token") ?? ""; var accessToken = prefs.getString("access_token") ?? "";
final List<Events> body = []; final List<Events> body = [];
@ -175,13 +160,12 @@ class _MyHomePageState extends State<ListItemOrganizers> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final post = posts[index]; final post = posts[index];
final startDate = DateTime.parse(post.startDate!); final startDate = DateTime.parse(post.startDate!);
final date = DateFormat.yMd().format(startDate);
final dateLongue = final time = DateFormat.Hm().format(startDate);
DateFormat('EEEE d MMMM y', 'fr_FR').format(startDate);
return ListTile( return ListTile(
title: Text('${post.name!}'), title: Text('${post.name!}'),
subtitle: Text('${post.place!}\n${dateLongue}'), subtitle: Text('${post.place!}\n${date} ${time}'),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,

View File

@ -13,15 +13,10 @@ import '../variable/globals.dart' as globals;
import '../classes/MyDrawer.dart'; import '../classes/MyDrawer.dart';
import '../classes/auth_service.dart'; import '../classes/auth_service.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
// app starting point // app starting point
void main() async { void main() {
WidgetsFlutterBinding.ensureInitialized(); initializeDateFormatting("fr_FR", null).then((_) => (const MyApp()));
await initializeDateFormatting("fr_FR", null);
runApp(const MyApp());
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@ -30,14 +25,6 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('fr', 'FR'),
],
home: const ListItemTags(tags: "default"), home: const ListItemTags(tags: "default"),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
); );
@ -95,8 +82,6 @@ class _MyHomePageState extends State<ListItemTags> {
// function to fetch data from api and return future list of posts // function to fetch data from api and return future list of posts
static Future<List<Events>> getPosts(tags, {count = 0}) async { static Future<List<Events>> getPosts(tags, {count = 0}) async {
await initializeDateFormatting("fr_FR", null);
SharedPreferences prefs = await SharedPreferences.getInstance(); SharedPreferences prefs = await SharedPreferences.getInstance();
var accessToken = prefs.getString("access_token") ?? ""; var accessToken = prefs.getString("access_token") ?? "";
final List<Events> body = []; final List<Events> body = [];
@ -177,12 +162,12 @@ class _MyHomePageState extends State<ListItemTags> {
itemBuilder: (context, index) { itemBuilder: (context, index) {
final post = posts[index]; final post = posts[index];
final startDate = DateTime.parse(post.startDate!); final startDate = DateTime.parse(post.startDate!);
final dateLongue = final date = DateFormat.yMd().format(startDate);
DateFormat('EEEE d MMMM y', 'fr_FR').format(startDate); final time = DateFormat.Hm().format(startDate);
return ListTile( return ListTile(
title: Text('${post.name!}'), title: Text('${post.name!}'),
subtitle: Text('${post.place!}\n${dateLongue}'), subtitle: Text('${post.place!}\n${date} ${time}'),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,

View File

@ -19,15 +19,11 @@ import 'package:camera/camera.dart';
import '../classes/ad_helper.dart'; import '../classes/ad_helper.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart'; import 'package:google_mobile_ads/google_mobile_ads.dart';
import '../classes/auth_service.dart'; import '../classes/auth_service.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await MobileAds.instance.initialize(); await MobileAds.instance.initialize();
await initializeDateFormatting("fr_FR", null); initializeDateFormatting("fr_FR", null).then((_) => runApp(const MyApp()));
runApp(const MyApp());
} }
class MyApp extends StatelessWidget { class MyApp extends StatelessWidget {
@ -36,14 +32,6 @@ class MyApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: [
const Locale('fr', 'FR'),
],
home: const ListItemMenu(), home: const ListItemMenu(),
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
); );
@ -86,7 +74,6 @@ class _MyHomePageState extends State<ListItemMenu> {
bool showInputTag = true; bool showInputTag = true;
// Fetching events from API // Fetching events from API
static Future<List<Events>> getPosts() async { static Future<List<Events>> getPosts() async {
await initializeDateFormatting("fr_FR");
PermissionStatus status = await Permission.location.status; PermissionStatus status = await Permission.location.status;
final List<Events> body = []; final List<Events> body = [];
var url = Uri.parse("${globals.api}/events"); var url = Uri.parse("${globals.api}/events");
@ -482,15 +469,15 @@ class _MyHomePageState extends State<ListItemMenu> {
print("results fetch : ${body}"); print("results fetch : ${body}");
print("fetch count : ${_fetchCount}"); print("fetch count : ${_fetchCount}");
// Update state after getting the response // Update state after getting the response
if (body.isEmpty) {
_fetchCount--;
}
setState(() { setState(() {
int counter = filteredPosts.length; if (body.isNotEmpty) {
// If we have results, map them to Events // If we have results, map them to Events
filteredPosts = body filteredPosts = body
.map((e) => Events.fromJson(e as Map<String, dynamic>)) .map((e) => Events.fromJson(e as Map<String, dynamic>))
.toList(); .toList();
if (counter == filteredPosts.length) {
_fetchCount--;
} }
}); });
} else { } else {
@ -853,13 +840,12 @@ class _MyHomePageState extends State<ListItemMenu> {
} }
final post = displayedPosts[index]; final post = displayedPosts[index];
final startDate = DateTime.parse(post.startDate!); final startDate = DateTime.parse(post.startDate!);
//final date = DateFormat.yMd().format(startDate); final date = DateFormat.yMd().format(startDate);
//final time = DateFormat.Hm().format(startDate); final time = DateFormat.Hm().format(startDate);
final dateLongue =
DateFormat('EEEE d MMMM y', 'fr_FR').format(startDate);
return ListTile( return ListTile(
title: Text('${post.name!}'), title: Text('${post.name!}'),
subtitle: Text('${post.place!}\n${dateLongue}'), subtitle: Text('${post.place!}\n${date} ${time}'),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,

View File

@ -270,11 +270,6 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "4.0.0" version: "4.0.0"
flutter_localizations:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_plugin_android_lifecycle: flutter_plugin_android_lifecycle:
dependency: transitive dependency: transitive
description: description:

View File

@ -29,9 +29,6 @@ environment:
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
flutter_localizations:
sdk: flutter
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
@ -72,7 +69,6 @@ dev_dependencies:
# The following section is specific to Flutter packages. # The following section is specific to Flutter packages.
flutter: flutter:
generate: true
# The following line ensures that the Material Icons font is # The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in # included with your application, so that you can use the icons in