83 lines
2.6 KiB
Dart
83 lines
2.6 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';
|
|
|
|
/// Écran profil utilisateur et déconnexion.
|
|
class ProfileScreen extends ConsumerWidget {
|
|
const ProfileScreen({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context, WidgetRef ref) {
|
|
final authState = ref.watch(authProvider);
|
|
final user = authState.user;
|
|
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('Mon profil')),
|
|
body: ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(24),
|
|
child: Column(
|
|
children: [
|
|
CircleAvatar(
|
|
radius: 40,
|
|
child: Text(
|
|
user != null && user.firstName.isNotEmpty
|
|
? user.firstName.substring(0, 1).toUpperCase()
|
|
: '?',
|
|
style: const TextStyle(fontSize: 32),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
Text(
|
|
user?.fullName ?? 'Utilisateur',
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
if (user?.email != null) ...[
|
|
const SizedBox(height: 4),
|
|
Text(user!.email),
|
|
],
|
|
],
|
|
),
|
|
),
|
|
),
|
|
const SizedBox(height: 16),
|
|
ListTile(
|
|
leading: const Icon(Icons.language),
|
|
title: const Text('Langue'),
|
|
subtitle: Text(user?.locale ?? 'fr'),
|
|
),
|
|
ListTile(
|
|
leading: const Icon(Icons.notifications_outlined),
|
|
title: const Text('Notifications'),
|
|
onTap: () {
|
|
ScaffoldMessenger.of(context).showSnackBar(
|
|
const SnackBar(content: Text('Préférences — à implémenter')),
|
|
);
|
|
},
|
|
),
|
|
const Divider(),
|
|
ListTile(
|
|
leading: Icon(Icons.logout, color: Theme.of(context).colorScheme.error),
|
|
title: Text(
|
|
'Se déconnecter',
|
|
style: TextStyle(color: Theme.of(context).colorScheme.error),
|
|
),
|
|
onTap: () async {
|
|
await ref.read(authProvider.notifier).logout();
|
|
if (context.mounted) {
|
|
context.go(AppRoutes.login);
|
|
}
|
|
},
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|