Theme Mode #3

This commit is contained in:
2025-09-03 17:39:57 +05:30
parent 52534f9210
commit 57439f2acb
8 changed files with 132 additions and 114 deletions

View File

@@ -39,40 +39,83 @@ class AppThemes {
}*/
import 'dart:developer';
import 'package:flutter/material.dart';import 'theme_type.dart';
import 'package:google_fonts/google_fonts.dart';
class AppThemes {
static ThemeData getLightTheme(ThemeType type) {
static ThemeData getLightTheme(ThemeType type) {
print('inside get light theme');
final Color seedColor = _getSeedColor(type);
final colorScheme = ColorScheme.fromSeed(
seedColor: seedColor,
brightness: Brightness.light,
);
print(seedColor.toString());
return ThemeData.from(
colorScheme: colorScheme,
useMaterial3: true,
textTheme: GoogleFonts.rubikTextTheme(),
).copyWith(
scaffoldBackgroundColor: Colors.white,
bottomNavigationBarTheme: BottomNavigationBarThemeData(
backgroundColor: colorScheme.surface,
),
);
// .copyWith(
// scaffoldBackgroundColor: Colors.white,
// bottomNavigationBarTheme: BottomNavigationBarThemeData(
// backgroundColor: colorScheme.surface,
// ),
// );
}
static ThemeData getDarkTheme(ThemeType type) {
final Color seedColor = _getSeedColor(type);
final colorScheme = ColorScheme.fromSeed(
seedColor: seedColor,
brightness: Brightness.dark, // Use dark brightness
);
return ThemeData.from(
colorScheme: colorScheme,
useMaterial3: true,
textTheme: GoogleFonts.rubikTextTheme(
ThemeData(brightness: Brightness.dark).textTheme,
),
);
}
print('inside get dark theme');
final Color seedColor = _getSeedColor(type);
log(seedColor.toString());
final colorScheme = ColorScheme.fromSeed(
seedColor: seedColor,
brightness: Brightness.dark,
// Define custom background and surface colors for better contrast
// background: const Color(0xFF121212), // A common dark theme background c
// surface: const Color(0xFF1E1E1E), // A slightly lighter surface color
);
return ThemeData.from(
colorScheme: colorScheme,
useMaterial3: true,
textTheme: GoogleFonts.rubikTextTheme(
ThemeData(brightness: Brightness.dark).textTheme,
),
);
// .copyWith(
// Explicitly set scaffold background color
// scaffoldBackgroundColor: colorScheme.background,
// // Customize card theme for dark mode
// cardTheme: CardTheme(
// elevation: 2,
// color: colorScheme.surface,
// surfaceTintColor: colorScheme.surface,
// ),
// // Customize text input fields
// inputDecorationTheme: InputDecorationTheme(
// filled: true,
// fillColor: colorScheme.surface,
// border: OutlineInputBorder(
// borderRadius: BorderRadius.circular(8),
// borderSide: BorderSide.none,
// ),
// focusedBorder: OutlineInputBorder(
// borderRadius: BorderRadius.circular(8),
// borderSide: BorderSide(color: colorScheme.primary),
// ),
// ),
// Ensure icons have a contrasting color
// iconTheme: IconThemeData(color: colorScheme.onSurface),
// Adjust bottom navigation bar
// bottomNavigationBarTheme: BottomNavigationBarThemeData(
// backgroundColor: colorScheme.surface,
// selectedItemColor: colorScheme.primary,
// unselectedItemColor: colorScheme.onSurface.withOpacity(0.6),
// ),
// );
}
static Color _getSeedColor(ThemeType type) {
switch (type) {
case ThemeType.green: