refactor: suppression des fichiers de thème non utilisés
This commit is contained in:
parent
c7ac3d9ebe
commit
e6d3c41ecc
@ -1,228 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:google_fonts/google_fonts.dart';
|
||||
|
||||
enum ThemeType {
|
||||
defaultTheme,
|
||||
pastelTheme,
|
||||
darkTheme,
|
||||
// Ajouter d'autres thèmes ici
|
||||
}
|
||||
|
||||
class AppTheme extends ChangeNotifier {
|
||||
static final AppTheme _instance = AppTheme._internal();
|
||||
factory AppTheme() => _instance;
|
||||
AppTheme._internal();
|
||||
|
||||
// Thème par défaut (P'titsPas)
|
||||
static const Color _defaultPrimaryColor = Color(0xFF2B6CB0);
|
||||
static const Color _defaultSecondaryColor = Color(0xFFF7FAFC);
|
||||
static const Color _defaultBackgroundColor = Color(0xFFFFFFFF);
|
||||
static const Color _defaultTextColor = Color(0xFF000000);
|
||||
static const Color _defaultErrorColor = Color(0xFFF4A28C);
|
||||
static const Color _defaultWarningColor = Color(0xFFF2D269);
|
||||
static const Color _defaultSuccessColor = Color(0xFF4CAF50);
|
||||
|
||||
// Thème Pastel
|
||||
static const Color _pastelPrimaryColor = Color(0xFF8AD0C8); // Turquoise
|
||||
static const Color _pastelSecondaryColor = Color(0xFFC6A3D8); // Violet Pastel
|
||||
static const Color _pastelBackgroundColor = Color(0xFFFFFEF9); // Ivoire BG
|
||||
static const Color _pastelTextColor = Color(0xFF2F2F2F); // Encre
|
||||
static const Color _pastelErrorColor = Color(0xFFFFB4AB); // Rose Pastel
|
||||
static const Color _pastelWarningColor = Color(0xFFFFE4B5); // Jaune Pastel
|
||||
static const Color _pastelSuccessColor = Color(0xFFA5D6A7); // Vert Pastel
|
||||
|
||||
// Couleurs pour le thème sombre
|
||||
static const Color _darkPrimaryColor = Color(0xFF4299E1);
|
||||
static const Color _darkSecondaryColor = Color(0xFF2D3748);
|
||||
static const Color _darkBackgroundColor = Color(0xFF1A202C);
|
||||
static const Color _darkTextColor = Color(0xFFF7FAFC);
|
||||
static const Color _darkErrorColor = Color(0xFFFEB2B2);
|
||||
static const Color _darkWarningColor = Color(0xFFFBD38D);
|
||||
static const Color _darkSuccessColor = Color(0xFF9AE6B4);
|
||||
|
||||
// Configuration du thème actuel
|
||||
ThemeType _currentTheme = ThemeType.defaultTheme;
|
||||
ThemeType get currentTheme => _currentTheme;
|
||||
|
||||
// Getters pour les couleurs du thème actuel
|
||||
Color get primaryColor {
|
||||
switch (_currentTheme) {
|
||||
case ThemeType.defaultTheme:
|
||||
return _defaultPrimaryColor;
|
||||
case ThemeType.pastelTheme:
|
||||
return _pastelPrimaryColor;
|
||||
case ThemeType.darkTheme:
|
||||
return _darkPrimaryColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color get secondaryColor {
|
||||
switch (_currentTheme) {
|
||||
case ThemeType.defaultTheme:
|
||||
return _defaultSecondaryColor;
|
||||
case ThemeType.pastelTheme:
|
||||
return _pastelSecondaryColor;
|
||||
case ThemeType.darkTheme:
|
||||
return _darkSecondaryColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color get backgroundColor {
|
||||
switch (_currentTheme) {
|
||||
case ThemeType.defaultTheme:
|
||||
return _defaultBackgroundColor;
|
||||
case ThemeType.pastelTheme:
|
||||
return _pastelBackgroundColor;
|
||||
case ThemeType.darkTheme:
|
||||
return _darkBackgroundColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color get textColor {
|
||||
switch (_currentTheme) {
|
||||
case ThemeType.defaultTheme:
|
||||
return _defaultTextColor;
|
||||
case ThemeType.pastelTheme:
|
||||
return _pastelTextColor;
|
||||
case ThemeType.darkTheme:
|
||||
return _darkTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color get errorColor {
|
||||
switch (_currentTheme) {
|
||||
case ThemeType.defaultTheme:
|
||||
return _defaultErrorColor;
|
||||
case ThemeType.pastelTheme:
|
||||
return _pastelErrorColor;
|
||||
case ThemeType.darkTheme:
|
||||
return _darkErrorColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color get warningColor {
|
||||
switch (_currentTheme) {
|
||||
case ThemeType.defaultTheme:
|
||||
return _defaultWarningColor;
|
||||
case ThemeType.pastelTheme:
|
||||
return _pastelWarningColor;
|
||||
case ThemeType.darkTheme:
|
||||
return _darkWarningColor;
|
||||
}
|
||||
}
|
||||
|
||||
Color get successColor {
|
||||
switch (_currentTheme) {
|
||||
case ThemeType.defaultTheme:
|
||||
return _defaultSuccessColor;
|
||||
case ThemeType.pastelTheme:
|
||||
return _pastelSuccessColor;
|
||||
case ThemeType.darkTheme:
|
||||
return _darkSuccessColor;
|
||||
}
|
||||
}
|
||||
|
||||
// Méthode pour changer de thème
|
||||
void setTheme(ThemeType theme) {
|
||||
_currentTheme = theme;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
// Thème Material 3
|
||||
ThemeData get lightTheme {
|
||||
return _buildTheme(_defaultPrimaryColor, _defaultSecondaryColor, _defaultBackgroundColor, _defaultTextColor, _defaultErrorColor, _defaultWarningColor, _defaultSuccessColor);
|
||||
}
|
||||
|
||||
// Thème Material 3 pastel
|
||||
ThemeData get pastelTheme {
|
||||
return _buildTheme(_pastelPrimaryColor, _pastelSecondaryColor, _pastelBackgroundColor, _pastelTextColor, _pastelErrorColor, _pastelWarningColor, _pastelSuccessColor);
|
||||
}
|
||||
|
||||
// Thème Material 3 sombre
|
||||
ThemeData get darkTheme {
|
||||
return _buildTheme(_darkPrimaryColor, _darkSecondaryColor, _darkBackgroundColor, _darkTextColor, _darkErrorColor, _darkWarningColor, _darkSuccessColor);
|
||||
}
|
||||
|
||||
ThemeData _buildTheme(Color primary, Color secondary, Color background, Color text, Color error, Color warning, Color success) {
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: ColorScheme.light(
|
||||
primary: primary,
|
||||
secondary: secondary,
|
||||
background: background,
|
||||
error: error,
|
||||
tertiary: warning,
|
||||
onPrimary: Colors.white,
|
||||
onSecondary: Colors.white,
|
||||
onBackground: text,
|
||||
onError: Colors.white,
|
||||
onTertiary: text,
|
||||
),
|
||||
scaffoldBackgroundColor: background,
|
||||
textTheme: TextTheme(
|
||||
displayLarge: _getTitleStyle(32, text),
|
||||
displayMedium: _getTitleStyle(28, text),
|
||||
displaySmall: _getTitleStyle(24, text),
|
||||
headlineMedium: _getTitleStyle(20, text),
|
||||
headlineSmall: _getTitleStyle(18, text),
|
||||
titleLarge: _getTitleStyle(16, text),
|
||||
bodyLarge: _getBodyStyle(16, text),
|
||||
bodyMedium: _getBodyStyle(14, text),
|
||||
bodySmall: _getBodyStyle(12, text),
|
||||
),
|
||||
appBarTheme: AppBarTheme(
|
||||
backgroundColor: primary,
|
||||
foregroundColor: Colors.white,
|
||||
titleTextStyle: _getTitleStyle(20, Colors.white),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ElevatedButton.styleFrom(
|
||||
backgroundColor: primary,
|
||||
foregroundColor: Colors.white,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 24, vertical: 12),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
),
|
||||
),
|
||||
inputDecorationTheme: InputDecorationTheme(
|
||||
filled: true,
|
||||
fillColor: secondary.withOpacity(0.5),
|
||||
border: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide.none,
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
borderSide: BorderSide(color: primary, width: 2),
|
||||
),
|
||||
contentPadding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
),
|
||||
snackBarTheme: SnackBarThemeData(
|
||||
backgroundColor: error,
|
||||
contentTextStyle: _getBodyStyle(14, Colors.white),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// Méthodes privées pour la typographie
|
||||
TextStyle _getTitleStyle(double fontSize, Color color) {
|
||||
return GoogleFonts.merienda(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
|
||||
TextStyle _getBodyStyle(double fontSize, Color color) {
|
||||
return GoogleFonts.merriweather(
|
||||
fontSize: fontSize,
|
||||
fontWeight: FontWeight.w300,
|
||||
color: color,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'app_theme.dart';
|
||||
|
||||
class ThemeProvider with ChangeNotifier {
|
||||
ThemeType _currentTheme = ThemeType.defaultTheme;
|
||||
static const String _themeKey = 'theme_type';
|
||||
|
||||
ThemeType get currentTheme => _currentTheme;
|
||||
|
||||
ThemeProvider() {
|
||||
_loadTheme();
|
||||
}
|
||||
|
||||
Future<void> _loadTheme() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
final themeIndex = prefs.getInt(_themeKey) ?? 0;
|
||||
_currentTheme = ThemeType.values[themeIndex];
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> setTheme(ThemeType theme) async {
|
||||
_currentTheme = theme;
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
await prefs.setInt(_themeKey, theme.index);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
bool get isDarkMode => _currentTheme == ThemeType.darkTheme;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user