// Copyright (C) 2023 WYATT GROUP // Please see the AUTHORS file for details. // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . import 'package:flutter/material.dart' hide CardTheme; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:google_fonts/google_fonts.dart'; import 'package:wyatt_ui_kit/wyatt_ui_kit.dart'; import 'package:wyatt_ui_kit_example/cubit/app_mode_cubit.dart'; /// Easely switch between Material and Studio themes. abstract class Themes { static int currentThemeIndex = 0; static List> get themes => [ {materialLight, materialDark}, {studioLight, studioDark}, ]; static ThemeData lightFromTheme(int themeId) { currentThemeIndex = themeId; return themes[themeId].first; } static ThemeData darkFromTheme(int themeId) { currentThemeIndex = themeId; return themes[themeId].last; } static void auto(BuildContext context) { if (currentThemeIndex == 1) { return studio(context); } return material(context); } static void material(BuildContext context) { context.read().changeTheme(0); } static void studio(BuildContext context) { context.read().changeTheme(1); } static ThemeData get materialLight => ThemeData.light().copyWith( textTheme: GoogleFonts.robotoTextTheme( ThemeData.light().textTheme, ), ); static ThemeData get studioLight { final theme = ThemeData.light().copyWith( appBarTheme: AppBarTheme( foregroundColor: const Color(0xFF24262A), backgroundColor: const Color(0xFFFFFFFF), titleTextStyle: GoogleFonts.montserrat( fontSize: 18, fontWeight: FontWeight.w500, color: const Color(0xFF24262A), ), ), scaffoldBackgroundColor: Colors.white, textTheme: GoogleFonts.montserratTextTheme( ThemeData.light().textTheme, ), ); return const WyattThemeExtensions().applyExtensionsTo(theme); } static ThemeData get materialDark => ThemeData.dark().copyWith( textTheme: GoogleFonts.robotoTextTheme( ThemeData.dark().textTheme, ), ); static ThemeData get studioDark { final theme = ThemeData.dark().copyWith( appBarTheme: AppBarTheme( foregroundColor: const Color(0xFFFFFFFF), backgroundColor: const Color(0xFF2B3139), titleTextStyle: GoogleFonts.montserrat( fontSize: 18, fontWeight: FontWeight.w500, color: const Color(0xFFFFFFFF), ), ), drawerTheme: const DrawerThemeData( backgroundColor: Color(0xFF383C40), ), scaffoldBackgroundColor: const Color(0xFF171A1E), textTheme: GoogleFonts.montserratTextTheme( ThemeData.dark().textTheme, ), ); return const WyattThemeExtensions().applyExtensionsTo(theme); } }