diff --git a/frontend/app_student/lib/class_groups/views/class_group.dart b/frontend/app_student/lib/class_groups/views/class_group.dart index e8a04d1..e7b0350 100644 --- a/frontend/app_student/lib/class_groups/views/class_group.dart +++ b/frontend/app_student/lib/class_groups/views/class_group.dart @@ -11,6 +11,7 @@ import '../../api/users/repositories/user_repository.dart'; import '../../shared_components/app_bar.dart'; import '../../shared_components/header_subtitle.dart'; import '../../shared_components/header_title.dart'; +import '../../shared_components/network_error.dart'; class ClassGroupPage extends StatelessWidget { const ClassGroupPage({super.key}); @@ -59,7 +60,7 @@ class ClassGroupPage extends StatelessWidget { ], ); } else if (classState is ClassGroupError) { - return Center(child: Text(classState.message)); + return const NetworkError(); } else { return const Center(child: CircularProgressIndicator()); } diff --git a/frontend/app_student/lib/l10n/app_fr.arb b/frontend/app_student/lib/l10n/app_fr.arb index 153c924..19e5757 100644 --- a/frontend/app_student/lib/l10n/app_fr.arb +++ b/frontend/app_student/lib/l10n/app_fr.arb @@ -80,21 +80,21 @@ "example": "Salle" }, "disconnectedMessage": "Vous avez été déconnecté", - "@disconnectedMessage": { - "description": "Message d'erreur pour une déconnexion" - }, + "@disconnectedMessage": { + "description": "Message d'erreur pour une déconnexion" + }, "disconnect": "Déconnexion", - "@disconnect": { - "description": "Texte du bouton de déconnexion" - }, + "@disconnect": { + "description": "Texte du bouton de déconnexion" + }, "schedule": "Emploi du temps", - "@schedule": { - "description": "Texte du bouton pour l'emploi du temps" - }, + "@schedule": { + "description": "Texte du bouton pour l'emploi du temps" + }, "profil": "Profil", - "@profil": { - "description": "Texte du bouton pour le profil" - }, + "@profil": { + "description": "Texte du bouton pour le profil" + }, "profilMessageTitle": "Quel beau profil {firstName} !", "@profilMessageTitle": { "description": "Message d'accueil de la page de profil", @@ -108,5 +108,9 @@ "profilChangeClassButton": "Changer de classe", "@profilChangeClassButton": { "description": "Texte du bouton pour changer de classe" + }, + "noConnectionMessage": "Pas de connexion", + "@noConnectionMessage": { + "description": "Message d'erreur pour une absence de connexion" } } \ No newline at end of file diff --git a/frontend/app_student/lib/shared_components/network_error.dart b/frontend/app_student/lib/shared_components/network_error.dart new file mode 100644 index 0000000..6293ad9 --- /dev/null +++ b/frontend/app_student/lib/shared_components/network_error.dart @@ -0,0 +1,27 @@ +import 'package:flutter/material.dart'; +import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + +import '../utils/custom_theme.dart'; + +class NetworkError extends StatelessWidget { + const NetworkError({super.key}); + + @override + Widget build(BuildContext context) { + WidgetsBinding.instance.addPostFrameCallback((_) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: Text(AppLocalizations.of(context)!.noConnectionMessage), + backgroundColor: CustomTheme.secondaryColor, + ), + ); + }); + return const Center( + child: Icon( + Icons.wifi_off, + size: 100, + color: CustomTheme.secondaryColor, + ), + ); + } +} diff --git a/frontend/app_student/lib/week_schedule/views/week_schedule.dart b/frontend/app_student/lib/week_schedule/views/week_schedule.dart index 27d8bdb..89ef0b6 100644 --- a/frontend/app_student/lib/week_schedule/views/week_schedule.dart +++ b/frontend/app_student/lib/week_schedule/views/week_schedule.dart @@ -1,4 +1,5 @@ import 'package:app_student/api/week_schedule/repositories/week_schedule_repository.dart'; +import 'package:app_student/shared_components/network_error.dart'; import 'package:app_student/users/cubit/user_cubit.dart'; import 'package:app_student/week_schedule/cubit/week_schedule_cubit.dart'; import 'package:app_student/week_schedule/views/widgets/components/datepicker_button.dart'; @@ -59,7 +60,7 @@ class WeekSchedulePage extends StatelessWidget { ), ); } else if (state is WeekScheduleError) { - return Center(child: Text(state.message)); + return const NetworkError(); } else { return const SizedBox.shrink(); }