diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index 3ca3b50..07b18fe 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -210,5 +210,6 @@ "customColorSetting": "Button Color", "selectButtonColor": "Select Button Primary Color", "pickColor": "Pick a color", - "select": "Select" + "select": "Select", + "resetColor": "Reset Color" } diff --git a/lib/l10n/app_fr.arb b/lib/l10n/app_fr.arb index c6c4792..c80034c 100644 --- a/lib/l10n/app_fr.arb +++ b/lib/l10n/app_fr.arb @@ -210,5 +210,6 @@ "customColorSetting": "Couleur des Boutons", "selectButtonColor": "Sélectionner la couleur principale des boutons", "pickColor": "Choisir une couleur", - "select": "Sélectionner" + "select": "Sélectionner", + "resetColor": "Réinitialiser la couleur" } diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index d74d381..8917b67 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -736,6 +736,12 @@ abstract class AppLocalizations { /// In en, this message translates to: /// **'Select'** String get select; + + /// No description provided for @resetColor. + /// + /// In en, this message translates to: + /// **'Reset Color'** + String get resetColor; } class _AppLocalizationsDelegate extends LocalizationsDelegate { diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 678c58e..519eaff 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -354,4 +354,7 @@ class AppLocalizationsEn extends AppLocalizations { @override String get select => 'Select'; + + @override + String get resetColor => 'Reset Color'; } diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index a0b2081..41901e7 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -354,4 +354,7 @@ class AppLocalizationsFr extends AppLocalizations { @override String get select => 'Sélectionner'; + + @override + String get resetColor => 'Réinitialiser la couleur'; } diff --git a/lib/main.dart b/lib/main.dart index 9998230..ffb5a00 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -38,7 +38,6 @@ class _MyAppState extends State { Widget build(BuildContext context) { return Consumer3( builder: (context, localeProvider, themeProvider, colorProvider, child) { - // customAccentColor est toujours là si tu veux l'utiliser pour d'autres éléments final customAccentColor = colorProvider.accentColor; return MaterialApp( @@ -55,32 +54,32 @@ class _MyAppState extends State { Locale('fr', ''), ], theme: ThemeData( - primaryColor: Colors.white, + primaryColor: Colors.yellow[700], colorScheme: ColorScheme.light( - primary: Colors.blue, // Couleur primaire fixe pour le mode clair + primary: Colors.yellow[700]!, secondary: Colors.teal.shade400, surface: Colors.white, background: Colors.white, error: Colors.red.shade700, - onPrimary: Colors.white, + onPrimary: Colors.black87, onSecondary: Colors.white, onSurface: Colors.black87, onBackground: Colors.black87, ), scaffoldBackgroundColor: Colors.white, - appBarTheme: const AppBarTheme( - backgroundColor: Color(0xFFF5F5F5), + appBarTheme: AppBarTheme( + backgroundColor: Colors.yellow[700], foregroundColor: Colors.black87, elevation: 0.5, - iconTheme: IconThemeData(color: Colors.black87), - titleTextStyle: TextStyle( + iconTheme: const IconThemeData(color: Colors.black87), + titleTextStyle: const TextStyle( color: Colors.black, fontSize: 20, fontWeight: FontWeight.bold, ), ), floatingActionButtonTheme: FloatingActionButtonThemeData( - backgroundColor: customAccentColor, + backgroundColor: customAccentColor, foregroundColor: Colors.white, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(30.0), diff --git a/lib/pages/settings_page.dart b/lib/pages/settings_page.dart index 7d948d0..b5550d9 100644 --- a/lib/pages/settings_page.dart +++ b/lib/pages/settings_page.dart @@ -1,4 +1,3 @@ -// pages/settings_page.dart import 'package:flutter/material.dart'; import 'package:rtime/l10n/app_localizations.dart'; import 'package:provider/provider.dart'; @@ -15,13 +14,11 @@ class SettingsPage extends StatefulWidget { } class _SettingsPageState extends State { - // Initialize with a default color or the current accent color - late Color _pickerColor; // Use late to initialize in initState + late Color _pickerColor; @override void initState() { super.initState(); - // Initialize _pickerColor with the current accent color from the ColorProvider _pickerColor = Provider.of(context, listen: false).accentColor; } @@ -36,9 +33,6 @@ class _SettingsPageState extends State { final themeProvider = Provider.of(context); final colorProvider = Provider.of(context); - // REMOVE THIS LINE: - // _pickerColor = colorProvider.accentColor; - return Scaffold( backgroundColor: Theme.of(context).colorScheme.background, appBar: AppBar( @@ -133,61 +127,72 @@ class _SettingsPageState extends State { const SizedBox(height: 10), Card( color: Theme.of(context).cardTheme.color, - child: ListTile( - title: Text( - l10n.selectButtonColor, - style: Theme.of(context).textTheme.titleMedium, - ), - trailing: Container( - width: 30, - height: 30, - decoration: BoxDecoration( - // This should always reflect the current accent color from the provider - color: colorProvider.accentColor, - shape: BoxShape.circle, - border: Border.all(color: Theme.of(context).dividerColor), - ), - ), - onTap: () { - // When the dialog is opened, ensure _pickerColor reflects the *current* accent color - // so that the color picker starts with the color currently in use. - setState(() { - _pickerColor = colorProvider.accentColor; - }); - showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - title: Text(l10n.pickColor), - content: SingleChildScrollView( - child: ColorPicker( - pickerColor: _pickerColor, - onColorChanged: _onColorChanged, - pickerAreaHeightPercent: 0.8, - enableAlpha: false, - displayThumbColor: true, - paletteType: PaletteType.hsv, - ), - ), - actions: [ - TextButton( - child: Text(l10n.cancel), - onPressed: () { - Navigator.of(context).pop(); - }, - ), - TextButton( - child: Text(l10n.select), - onPressed: () { - colorProvider.setAccentColor(_pickerColor); - Navigator.of(context).pop(); - }, - ), - ], + child: Column( + children: [ + ListTile( + title: Text( + l10n.selectButtonColor, + style: Theme.of(context).textTheme.titleMedium, + ), + trailing: Container( + width: 30, + height: 30, + decoration: BoxDecoration( + color: colorProvider.accentColor, + shape: BoxShape.circle, + border: Border.all(color: Theme.of(context).dividerColor), + ), + ), + onTap: () { + setState(() { + _pickerColor = colorProvider.accentColor; + }); + showDialog( + context: context, + builder: (BuildContext context) { + return AlertDialog( + title: Text(l10n.pickColor), + content: SingleChildScrollView( + child: ColorPicker( + pickerColor: _pickerColor, + onColorChanged: _onColorChanged, + pickerAreaHeightPercent: 0.8, + enableAlpha: false, + displayThumbColor: true, + paletteType: PaletteType.hsv, + ), + ), + actions: [ + TextButton( + child: Text(l10n.cancel), + onPressed: () { + Navigator.of(context).pop(); + }, + ), + TextButton( + child: Text(l10n.select), + onPressed: () { + colorProvider.setAccentColor(_pickerColor); + Navigator.of(context).pop(); + }, + ), + ], + ); + }, ); }, - ); - }, + ), + ListTile( + title: Text(l10n.resetColor, style: Theme.of(context).textTheme.titleMedium), + trailing: const Icon(Icons.restore), + onTap: () { + colorProvider.setAccentColor(Colors.yellow[700]!); + setState(() { + _pickerColor = Colors.yellow[700]!; + }); + }, + ), + ], ), ), ],