Skip to content

Commit

Permalink
Merge pull request #44 from B3-3iL-DLW/ui/configuration_menu
Browse files Browse the repository at this point in the history
♻️: l10n and add route profil page
  • Loading branch information
julesartd authored Mar 15, 2024
2 parents 287f38d + a80da0c commit 3baaf3c
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 52 deletions.
16 changes: 15 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,19 @@
"@roomLabel": {
"description": "Label pour la salle",
"example": "Salle"
},
"profilMessageTitle": "Quel beau profil {firstName} !",
"@profilMessageTitle": {
"description": "Message d'accueil de la page de profil",
"placeholders": {
"firstName": {
"type": "String",
"example": "John"
}
}
},
"profilChangeClassButton": "Changer de classe",
"@profilChangeClassButton": {
"description": "Texte du bouton pour changer de classe"
}
}
}
73 changes: 29 additions & 44 deletions frontend/app_student/lib/profils/views/profil_page.dart
Original file line number Diff line number Diff line change
@@ -1,65 +1,50 @@
import 'package:app_student/class_groups/views/widgets/header/header_text.dart';
import 'package:app_student/menu/menu_view.dart';
import 'package:app_student/profils/views/widgets/class_group_button.dart';
import 'package:app_student/profils/views/widgets/user_class_card.dart';
import 'package:app_student/profils/views/widgets/user_info_card.dart';
import 'package:flutter/material.dart';
import 'package:app_student/login/widgets/header/header_logo.dart';
import 'package:flutter_svg/svg.dart';
import 'package:flutter_bloc/flutter_bloc.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(30.0),
child: Card(
child: ListTile(
leading: SizedBox(
width: 50,
child: ColorFiltered(
colorFilter: const ColorFilter.mode(
Color(0xFF005067), BlendMode.srcIn),
child: SvgPicture.asset(
'assets/images/user.svg',
width: 30,
height: 30,
),
),
),
title: const Text('Classe'),
subtitle: const Text('Nom du user'),
),
),
),
Padding(
padding: const EdgeInsets.all(30.0),
child: Card(
child: ListTile(
leading: SizedBox(
width: 50,
child: ColorFiltered(
colorFilter: const ColorFilter.mode(
Color(0xFF005067), BlendMode.srcIn),
child: SvgPicture.asset(
'assets/images/student-info.svg',
width: 30,
height: 30,
),
),
),
title: const Text('ISBN'),
subtitle: const Text('dd/mm/yyyy'),
),
padding: const EdgeInsets.all(15.0),
child: HeaderText(
AppLocalizations.of(context)!.profilMessageTitle(firstName),
),
),
UserClassCard(className: className, firstName: firstName),
UserInfoCard(ine: ine, birthDate: birthDateString),
const ClassGroupButton(),
],
),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'package:app_student/routes.dart';
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

class ClassGroupButton extends StatelessWidget {
const ClassGroupButton({super.key});
Expand Down Expand Up @@ -32,9 +34,10 @@ class ClassGroupButton extends StatelessWidget {
),
),
onPressed: () {
GoRouter.of(context).go('/class-list');
GoRouter.of(context).go(AppRoutes.classListPage);
},
child: const Text('Changer de classe'),
child:
Text(AppLocalizations.of(context)!.profilChangeClassButton),
),
),
],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class UserClassCard extends StatelessWidget {
final String className;
final String firstName;

const UserClassCard(
{super.key, required this.className, required this.firstName});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(30.0),
child: Card(
child: ListTile(
leading: SizedBox(
width: 50,
child: ColorFiltered(
colorFilter:
const ColorFilter.mode(Color(0xFF005067), BlendMode.srcIn),
child: SvgPicture.asset(
'assets/images/user.svg',
width: 30,
height: 30,
),
),
),
title: Text(className),
subtitle: Text(firstName),
),
),
);
}
}
34 changes: 34 additions & 0 deletions frontend/app_student/lib/profils/views/widgets/user_info_card.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';

class UserInfoCard extends StatelessWidget {
final String ine;
final String birthDate;

const UserInfoCard({super.key, required this.ine, required this.birthDate});

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(30.0),
child: Card(
child: ListTile(
leading: SizedBox(
width: 50,
child: ColorFiltered(
colorFilter:
const ColorFilter.mode(Color(0xFF005067), BlendMode.srcIn),
child: SvgPicture.asset(
'assets/images/student-info.svg',
width: 30,
height: 30,
),
),
),
title: Text(ine),
subtitle: Text(birthDate),
),
),
);
}
}
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(),
),
),
),
),
];
}

0 comments on commit 3baaf3c

Please sign in to comment.