Add UserStateWrapper and ProfileImageService for user state management and profile image handling

This commit is contained in:
Van Leemput Dayron
2025-11-05 09:31:58 +01:00
parent 30dca05e15
commit 75c12e35a5
6 changed files with 275 additions and 131 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:travel_mate/components/widgets/user_state_widget.dart';
import '../../blocs/user/user_bloc.dart';
import '../../blocs/user/user_state.dart' as user_state;
import '../../blocs/user/user_event.dart' as user_event;
@@ -10,22 +11,8 @@ class ProfileContent extends StatelessWidget {
@override
Widget build(BuildContext context) {
return BlocBuilder<UserBloc, user_state.UserState>(
builder: (context, state) {
if (state is user_state.UserLoading) {
return Center(child: CircularProgressIndicator());
}
if (state is user_state.UserError) {
return Center(child: Text('Erreur: ${state.message}'));
}
if (state is! user_state.UserLoaded) {
return Center(child: Text('Aucun utilisateur connecté'));
}
final user = state.user;
return UserStateWrapper(
builder: (context, user) {
return Column(
children: [
// Section titre
@@ -181,7 +168,10 @@ class ProfileContent extends StatelessWidget {
);
}
void _showChangePasswordDialog(BuildContext context, user_state.UserModel user) {
void _showChangePasswordDialog(
BuildContext context,
user_state.UserModel user,
) {
final currentPasswordController = TextEditingController();
final newPasswordController = TextEditingController();
final confirmPasswordController = TextEditingController();
@@ -210,7 +200,9 @@ class ProfileContent extends StatelessWidget {
TextField(
controller: confirmPasswordController,
obscureText: true,
decoration: InputDecoration(labelText: 'Confirmer le mot de passe'),
decoration: InputDecoration(
labelText: 'Confirmer le mot de passe',
),
),
],
),
@@ -233,7 +225,8 @@ class ProfileContent extends StatelessWidget {
return;
}
if (newPasswordController.text != confirmPasswordController.text) {
if (newPasswordController.text !=
confirmPasswordController.text) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('Les mots de passe ne correspondent pas'),
@@ -274,7 +267,10 @@ class ProfileContent extends StatelessWidget {
);
}
void _showDeleteAccountDialog(BuildContext context, user_state.UserModel user) {
void _showDeleteAccountDialog(
BuildContext context,
user_state.UserModel user,
) {
final passwordController = TextEditingController();
final authService = AuthService();