119 lines
3.8 KiB
Dart
119 lines
3.8 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_example/theme/card_theme.dart';
|
|
import 'package:wyatt_ui_kit_example/theme/file_selection_button_theme.dart';
|
|
import 'package:wyatt_ui_kit_example/theme/flat_button_theme.dart';
|
|
import 'package:wyatt_ui_kit_example/theme/loader_theme.dart';
|
|
import 'package:wyatt_ui_kit_example/theme/simple_icon_button_theme.dart';
|
|
import 'package:wyatt_ui_kit_example/theme/symbol_button_theme.dart';
|
|
|
|
/// Easely switch between Material and Studio themes.
|
|
abstract class Themes {
|
|
static int currentThemeIndex = 0;
|
|
|
|
static List<Set<ThemeData>> 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();
|
|
|
|
static ThemeData get studioLight => materialLight.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,
|
|
extensions: <ThemeExtension<dynamic>>[
|
|
// Cards
|
|
CardTheme.light(),
|
|
// Buttons
|
|
FlatButtonTheme.light(),
|
|
SymbolButtonTheme.light(),
|
|
SimpleIconButtonTheme.light(),
|
|
FileSelectionButtonTheme.light(),
|
|
// Loader
|
|
LoaderTheme.light(),
|
|
],
|
|
);
|
|
|
|
static ThemeData get materialDark => ThemeData.dark();
|
|
|
|
static ThemeData get studioDark => materialDark.copyWith(
|
|
appBarTheme: AppBarTheme(
|
|
foregroundColor: const Color(0xFFFFFFFF),
|
|
backgroundColor: const Color(0xFF383C40),
|
|
titleTextStyle: GoogleFonts.montserrat(
|
|
fontSize: 18,
|
|
fontWeight: FontWeight.w500,
|
|
color: const Color(0xFFFFFFFF),
|
|
),
|
|
),
|
|
scaffoldBackgroundColor: const Color(0xFF383C40),
|
|
extensions: <ThemeExtension<dynamic>>[
|
|
// Cards
|
|
CardTheme.dark(),
|
|
// Buttons
|
|
FlatButtonTheme.dark(),
|
|
SymbolButtonTheme.dark(),
|
|
SimpleIconButtonTheme.dark(),
|
|
FileSelectionButtonTheme.dark(),
|
|
// Loader
|
|
LoaderTheme.dark(),
|
|
],
|
|
);
|
|
}
|