mirror of
https://bitbucket.org/FransoletThomas/tablet-app.git
synced 2025-12-06 08:31:19 +00:00
Prevent wrong data for agenda + add translations for month filter
This commit is contained in:
parent
5885053ea9
commit
4035e50190
@ -10,7 +10,11 @@ class Agenda {
|
||||
List<EventAgenda> events = [];
|
||||
|
||||
for (var eventData in jsonList) {
|
||||
events.add(EventAgenda.fromJson(eventData));
|
||||
try {
|
||||
events.add(EventAgenda.fromJson(eventData));
|
||||
} catch(e) {
|
||||
print("Erreur lors du parsing du json : ${e.toString()}");
|
||||
}
|
||||
}
|
||||
|
||||
return Agenda(events: events);
|
||||
@ -52,12 +56,12 @@ class EventAgenda {
|
||||
return EventAgenda(
|
||||
name: json['name'],
|
||||
description: json['description'],
|
||||
type: json['type'],
|
||||
dateAdded: DateTime.parse(json['date_added']),
|
||||
dateFrom: DateTime.parse(json['date_from']),
|
||||
dateTo: DateTime.parse(json['date_to']),
|
||||
type: json['type'] is !bool ? json['type'] : null,
|
||||
dateAdded: json['date_added'] != null && json['date_added'].isNotEmpty ? DateTime.parse(json['date_added']) : null,
|
||||
dateFrom: json['date_from'] != null && json['date_from'].isNotEmpty ? DateTime.parse(json['date_from']) : null,
|
||||
dateTo: json['date_to'] != null && json['date_to'].isNotEmpty ? DateTime.parse(json['date_to']) : null,
|
||||
dateHour: json['date_hour'],
|
||||
address: EventAddress.fromJson(json['address']),
|
||||
address: json['address'] is !bool ? EventAddress.fromJson(json['address']) : null,
|
||||
website: json['website'],
|
||||
phone: json['phone'],
|
||||
idVideoYoutube: json['id_video_youtube'],
|
||||
|
||||
@ -60,7 +60,7 @@ class _AgendaView extends State<AgendaView> {
|
||||
var jsonString = await response.transform(utf8.decoder).join();
|
||||
|
||||
agenda = Agenda.fromJson(jsonString);
|
||||
agenda.events = agenda.events.where((a) => a.dateFrom!.isAfter(DateTime.now())).toList();
|
||||
agenda.events = agenda.events.where((a) => a.dateFrom != null && a.dateFrom!.isAfter(DateTime.now())).toList();
|
||||
agenda.events.sort((a, b) => a.dateFrom!.compareTo(b.dateFrom!));
|
||||
filteredAgenda.value = agenda.events;
|
||||
|
||||
|
||||
@ -20,10 +20,16 @@ class _MonthFilterState extends State<MonthFilter> {
|
||||
String? _selectedMonth;
|
||||
|
||||
Map<String, List<String>> monthNames = {
|
||||
'fr': ['',
|
||||
'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'
|
||||
],
|
||||
// Ajoutez d'autres langues au besoin
|
||||
'fr': ['', 'Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],
|
||||
'en': ['', 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'],
|
||||
'de': ['', 'Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'],
|
||||
'nl': ['', 'Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December'],
|
||||
'it': ['', 'Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
|
||||
'es': ['', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre'],
|
||||
'pl': ['', 'Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
|
||||
'cn': ['', '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'],
|
||||
'uk': ['', 'Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень'],
|
||||
'ar': ['', 'يناير', 'فبراير', 'مارس', 'أبريل', 'مايو', 'يونيو', 'يوليو', 'أغسطس', 'سبتمبر', 'أكتوبر', 'نوفمبر', 'ديسمبر'],
|
||||
};
|
||||
|
||||
@override
|
||||
@ -48,7 +54,7 @@ class _MonthFilterState extends State<MonthFilter> {
|
||||
|
||||
// Vérifier si nbrEvents est supérieur à 0
|
||||
if (nbrEvents > 0) {
|
||||
String monthName = _getTranslatedMonthName(monthYear);
|
||||
String monthName = _getTranslatedMonthName(tabletAppContext, monthYear);
|
||||
RegExp regExp = RegExp(r'\d{4}');
|
||||
String annee = regExp.stringMatch(monthYear)!;
|
||||
|
||||
@ -78,11 +84,11 @@ class _MonthFilterState extends State<MonthFilter> {
|
||||
);
|
||||
}
|
||||
|
||||
String _getTranslatedMonthName(String monthYear) {
|
||||
String _getTranslatedMonthName(TabletAppContext tabletAppContext, String monthYear) {
|
||||
// Récupérez le numéro du mois à partir de la chaîne "monthYear"
|
||||
int monthIndex = int.parse(monthYear.split('-')[0]);
|
||||
// Récupérez le nom du mois traduit dans la langue sélectionnée
|
||||
String translatedMonthName = monthNames["fr"]![monthIndex];
|
||||
String translatedMonthName = monthNames[tabletAppContext.language!.toLowerCase()]![monthIndex];
|
||||
return translatedMonthName;
|
||||
}
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||
# Read more about iOS versioning at
|
||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||
version: 2.1.0+20
|
||||
version: 2.1.1+21
|
||||
|
||||
environment:
|
||||
sdk: ">=3.1.0 <4.0.0"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user