117 lines
3.4 KiB
Dart
117 lines
3.4 KiB
Dart
// 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 <https://www.gnu.org/licenses/>.
|
|
|
|
import 'package:adaptive_theme/adaptive_theme.dart';
|
|
import 'package:flutter/material.dart' hide CardTheme;
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
import 'package:wyatt_ui_kit/wyatt_ui_kit.dart';
|
|
|
|
/// Easely switch between Material and Studio themes.
|
|
abstract class Themes {
|
|
static int currentThemeIndex = 0;
|
|
|
|
static List<Set<ThemeData>> 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) {
|
|
AdaptiveTheme.of(context).setTheme(
|
|
light: materialLight,
|
|
dark: materialDark,
|
|
);
|
|
}
|
|
|
|
static void studio(BuildContext context) {
|
|
AdaptiveTheme.of(context).setTheme(
|
|
light: studioLight,
|
|
dark: studioDark,
|
|
);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|