137 lines
4.9 KiB
Dart
137 lines
4.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:provider/provider.dart';
|
|
import '../../providers/theme_provider.dart';
|
|
|
|
class SettingsThemeContent extends StatelessWidget {
|
|
const SettingsThemeContent({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: const Text('Thème'),
|
|
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
|
|
),
|
|
body: Consumer<ThemeProvider>(
|
|
builder: (context, themeProvider, child) {
|
|
return ListView(
|
|
padding: const EdgeInsets.all(16),
|
|
children: [
|
|
Text(
|
|
'Choisir le thème',
|
|
style: Theme.of(context).textTheme.headlineSmall,
|
|
),
|
|
const SizedBox(height: 20),
|
|
|
|
// Option Système
|
|
Card(
|
|
child: ListTile(
|
|
leading: Icon(
|
|
themeProvider.themeMode == ThemeMode.system
|
|
? Icons.radio_button_checked
|
|
: Icons.radio_button_unchecked,
|
|
color: themeProvider.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,
|
|
onTap: () {
|
|
themeProvider.setThemeMode(ThemeMode.system);
|
|
},
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
// Option Clair
|
|
Card(
|
|
child: ListTile(
|
|
leading: Icon(
|
|
themeProvider.themeMode == ThemeMode.light
|
|
? Icons.radio_button_checked
|
|
: Icons.radio_button_unchecked,
|
|
color: themeProvider.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,
|
|
onTap: () {
|
|
themeProvider.setThemeMode(ThemeMode.light);
|
|
},
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
// Option Sombre
|
|
Card(
|
|
child: ListTile(
|
|
leading: Icon(
|
|
themeProvider.themeMode == ThemeMode.dark
|
|
? Icons.radio_button_checked
|
|
: Icons.radio_button_unchecked,
|
|
color: themeProvider.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,
|
|
onTap: () {
|
|
themeProvider.setThemeMode(ThemeMode.dark);
|
|
},
|
|
),
|
|
),
|
|
|
|
const SizedBox(height: 30),
|
|
|
|
// Aperçu du thème actuel
|
|
Card(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'Aperçu',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const SizedBox(height: 10),
|
|
Row(
|
|
children: [
|
|
Icon(
|
|
themeProvider.isDarkMode
|
|
? Icons.dark_mode
|
|
: Icons.light_mode,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
const SizedBox(width: 10),
|
|
Text(
|
|
themeProvider.isDarkMode
|
|
? 'Mode sombre actif'
|
|
: 'Mode clair actif',
|
|
style: TextStyle(
|
|
color: Theme.of(context).colorScheme.onSurface,
|
|
),
|
|
),
|
|
],
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
],
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|