Add yellow to base colour & colour reset button in settings

This commit is contained in:
2025-07-09 20:40:30 +02:00
parent b835603a7c
commit 6957075f46
7 changed files with 89 additions and 71 deletions

View File

@ -210,5 +210,6 @@
"customColorSetting": "Button Color",
"selectButtonColor": "Select Button Primary Color",
"pickColor": "Pick a color",
"select": "Select"
"select": "Select",
"resetColor": "Reset Color"
}

View File

@ -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"
}

View File

@ -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<AppLocalizations> {

View File

@ -354,4 +354,7 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get select => 'Select';
@override
String get resetColor => 'Reset Color';
}

View File

@ -354,4 +354,7 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get select => 'Sélectionner';
@override
String get resetColor => 'Réinitialiser la couleur';
}

View File

@ -38,7 +38,6 @@ class _MyAppState extends State<MyApp> {
Widget build(BuildContext context) {
return Consumer3<LocaleProvider, ThemeProvider, ColorProvider>(
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<MyApp> {
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),

View File

@ -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<SettingsPage> {
// 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<ColorProvider>(context, listen: false).accentColor;
}
@ -36,9 +33,6 @@ class _SettingsPageState extends State<SettingsPage> {
final themeProvider = Provider.of<ThemeProvider>(context);
final colorProvider = Provider.of<ColorProvider>(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<SettingsPage> {
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: <Widget>[
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: <Widget>[
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]!;
});
},
),
],
),
),
],