Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

♻️: l10n and add route profil page #44

Merged
merged 8 commits into from
Mar 15, 2024
6 changes: 5 additions & 1 deletion frontend/app_student/lib/l10n/app_fr.arb
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,9 @@
"@roomLabel": {
"description": "Label pour la salle",
"example": "Salle"
},
"profilMessageTitle": "Quel beau profil,",
"@profilMessageTitle": {
"description": "Message d'accueil de la page de profil"
}
}
}
38 changes: 31 additions & 7 deletions frontend/app_student/lib/profils/views/profil_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,44 @@ import 'package:app_student/menu/menu_view.dart';
import 'package:app_student/profils/views/widgets/class_group_button.dart';
import 'package:flutter/material.dart';
import 'package:app_student/login/widgets/header/header_logo.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:intl/intl.dart';

import '../../users/cubit/user_cubit.dart';

class ProfilPage extends StatelessWidget {
const ProfilPage({super.key});

@override
Widget build(BuildContext context) {
final userState = context.watch<UserCubit>().state;
String firstName = '';
String className = '';
String ine = '';
DateTime? birthDate;

if (userState is UserLoaded) {
firstName = userState.user.entity.firstName;
className = userState.user.entity.className!;
ine = userState.user.entity.ine;
birthDate = userState.user.entity.birthDate;
}

String birthDateString = birthDate != null
? DateFormat('dd/MM/yyyy').format(birthDate)
: 'error';

return Scaffold(
body: Column(
children: <Widget>[
const HeaderLogo(),
const Padding(
padding: EdgeInsets.all(15.0),
child: HeaderText('Quel beau profil ####### !'),
Padding(
padding: const EdgeInsets.all(15.0),
child: HeaderText(
'${AppLocalizations.of(context)!.profilMessageTitle} $firstName',
),
),
Padding(
padding: const EdgeInsets.all(30.0),
Expand All @@ -34,8 +58,8 @@ class ProfilPage extends StatelessWidget {
),
),
),
title: const Text('Classe'),
subtitle: const Text('Nom du user'),
title: Text(className),
subtitle: Text(firstName),
),
),
),
Expand All @@ -55,8 +79,8 @@ class ProfilPage extends StatelessWidget {
),
),
),
title: const Text('ISBN'),
subtitle: const Text('dd/mm/yyyy'),
title: Text(ine),
subtitle: Text(birthDateString),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:app_student/routes.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

Expand Down Expand Up @@ -32,7 +33,7 @@ class ClassGroupButton extends StatelessWidget {
),
),
onPressed: () {
GoRouter.of(context).go('/class-list');
GoRouter.of(context).go(AppRoutes.classListPage);
},
child: const Text('Changer de classe'),
),
Expand Down
19 changes: 14 additions & 5 deletions frontend/app_student/lib/routes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,19 @@ class AppRoutes {
),
))),
GoRoute(
path: profilPage,
pageBuilder: (context, state) => MaterialPage<void>(
key: state.pageKey,
child: const ProfilPage(),
)),
path: profilPage,
pageBuilder: (context, state) => MaterialPage<void>(
key: state.pageKey,
child: RepositoryProvider(
create: (context) => UserRepository(),
child: BlocProvider(
create: (context) =>
UserCubit(userRepository: context.read<UserRepository>())
..fetchUser(),
child: const ProfilPage(),
),
),
),
),
];
}
Loading