Refactor user and theme management to use BLoC pattern; remove provider classes and integrate new services for user and group functionalities

This commit is contained in:
Dayron
2025-10-14 12:10:42 +02:00
parent c4588a65c0
commit 72ddb58a11
27 changed files with 1864 additions and 791 deletions

View File

@@ -1,6 +1,8 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../../providers/theme_provider.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../blocs/theme/theme_bloc.dart';
import '../../blocs/theme/theme_state.dart';
import '../../blocs/theme/theme_event.dart';
class SettingsThemeContent extends StatelessWidget {
const SettingsThemeContent({super.key});
@@ -12,8 +14,8 @@ class SettingsThemeContent extends StatelessWidget {
title: const Text('Thème'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: Consumer<ThemeProvider>(
builder: (context, themeProvider, child) {
body: BlocBuilder<ThemeBloc, ThemeState>(
builder: (context, state) {
return ListView(
padding: const EdgeInsets.all(16),
children: [
@@ -27,19 +29,21 @@ class SettingsThemeContent extends StatelessWidget {
Card(
child: ListTile(
leading: Icon(
themeProvider.themeMode == ThemeMode.system
state.themeMode == ThemeMode.system
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
color: themeProvider.themeMode == ThemeMode.system
color: state.themeMode == ThemeMode.system
? Theme.of(context).colorScheme.primary
: null,
),
title: const Text('Système'),
subtitle: const Text('Suit les paramètres de votre appareil'),
trailing: const Icon(Icons.brightness_auto),
selected: themeProvider.themeMode == ThemeMode.system,
selected: state.themeMode == ThemeMode.system,
onTap: () {
themeProvider.setThemeMode(ThemeMode.system);
context.read<ThemeBloc>().add(
const ThemeChanged(themeMode: ThemeMode.system),
);
},
),
),
@@ -50,19 +54,21 @@ class SettingsThemeContent extends StatelessWidget {
Card(
child: ListTile(
leading: Icon(
themeProvider.themeMode == ThemeMode.light
state.themeMode == ThemeMode.light
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
color: themeProvider.themeMode == ThemeMode.light
color: state.themeMode == ThemeMode.light
? Theme.of(context).colorScheme.primary
: null,
),
title: const Text('Clair'),
subtitle: const Text('Thème clair en permanence'),
trailing: const Icon(Icons.light_mode),
selected: themeProvider.themeMode == ThemeMode.light,
selected: state.themeMode == ThemeMode.light,
onTap: () {
themeProvider.setThemeMode(ThemeMode.light);
context.read<ThemeBloc>().add(
const ThemeChanged(themeMode: ThemeMode.light),
);
},
),
),
@@ -73,19 +79,21 @@ class SettingsThemeContent extends StatelessWidget {
Card(
child: ListTile(
leading: Icon(
themeProvider.themeMode == ThemeMode.dark
state.themeMode == ThemeMode.dark
? Icons.radio_button_checked
: Icons.radio_button_unchecked,
color: themeProvider.themeMode == ThemeMode.dark
color: state.themeMode == ThemeMode.dark
? Theme.of(context).colorScheme.primary
: null,
),
title: const Text('Sombre'),
subtitle: const Text('Thème sombre en permanence'),
trailing: const Icon(Icons.dark_mode),
selected: themeProvider.themeMode == ThemeMode.dark,
selected: state.themeMode == ThemeMode.dark,
onTap: () {
themeProvider.setThemeMode(ThemeMode.dark);
context.read<ThemeBloc>().add(
const ThemeChanged(themeMode: ThemeMode.dark),
);
},
),
),
@@ -107,14 +115,14 @@ class SettingsThemeContent extends StatelessWidget {
Row(
children: [
Icon(
themeProvider.isDarkMode
state.isDarkMode
? Icons.dark_mode
: Icons.light_mode,
color: Theme.of(context).colorScheme.primary,
),
const SizedBox(width: 10),
Text(
themeProvider.isDarkMode
state.isDarkMode
? 'Mode sombre actif'
: 'Mode clair actif',
style: TextStyle(