94 lines
3.2 KiB
Dart
94 lines
3.2 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
import '../../../core/auth/auth_provider.dart';
|
|
import '../../../core/router/app_router.dart';
|
|
import '../../../core/theme/app_colors.dart';
|
|
|
|
/// Écran profil utilisateur et déconnexion.
|
|
class ProfileScreen extends ConsumerWidget {
|
|
const ProfileScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final user = ref.watch(authProvider).user;
|
|
|
|
return ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(20),
|
|
child: Row(
|
|
children: [
|
|
CircleAvatar(
|
|
radius: 28,
|
|
backgroundColor: AppColors.primary.withValues(alpha: 0.1),
|
|
child: Text(
|
|
user != null && user.firstName.isNotEmpty
|
|
? user.firstName.substring(0, 1).toUpperCase()
|
|
: '?',
|
|
style: const TextStyle(
|
|
fontSize: 22,
|
|
fontWeight: FontWeight.w600,
|
|
color: AppColors.primary,
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(width: 16),
|
|
Expanded(
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(user?.fullName ?? 'Utilisateur', style: Theme.of(context).textTheme.titleMedium),
|
|
if (user?.email != null)
|
|
Text(user!.email, style: Theme.of(context).textTheme.bodyMedium),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Card(
|
|
child: Column(
|
|
children: [
|
|
ListTile(
|
|
leading: const Icon(Icons.language_outlined, color: AppColors.textSecondary),
|
|
title: const Text('Langue'),
|
|
trailing: Text(user?.locale ?? 'fr'),
|
|
),
|
|
const Divider(height: 1),
|
|
ListTile(
|
|
leading: const Icon(Icons.notifications_outlined, color: AppColors.textSecondary),
|
|
title: const Text('Notifications'),
|
|
trailing: const Icon(Icons.chevron_right, color: AppColors.textSecondary),
|
|
onTap: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Préférences — à implémenter')),
|
|
);
|
|
},
|
|
),
|
|
],
|
|
),
|
|
),
|
|
const SizedBox(height: 8),
|
|
Card(
|
|
child: ListTile(
|
|
leading: const Icon(Icons.logout, color: AppColors.error),
|
|
title: const Text('Se déconnecter', style: TextStyle(color: AppColors.error)),
|
|
onTap: () async {
|
|
await ref.read(authProvider.notifier).logout();
|
|
if (context.mounted) {
|
|
context.go(AppRoutes.login);
|
|
}
|
|
},
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|