/* * This file is part of wger Workout Manager . * Copyright (c) 2026 wger Team * * wger Workout Manager is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) 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 Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ import 'package:flex_color_scheme/flex_color_scheme.dart'; import 'package:material_ui/material_ui.dart'; import 'package:table_calendar/table_calendar.dart'; // Color scheme, please consult // * https://pub.dev/packages/flex_color_scheme // * https://rydmike.com/flexseedscheme/demo-v1/#/ const Color wgerPrimaryColor = Color(0xff2a4c7d); const Color wgerPrimaryButtonColor = Color(0xff266dd3); const Color wgerPrimaryColorLight = Color(0xff94B2DB); const Color wgerSecondaryColor = Color(0xffe63946); const Color wgerSecondaryColorLight = Color(0xffF6B4BA); const Color wgerTertiaryColor = Color(0xFF6CA450); const FlexSubThemesData wgerSubThemeData = FlexSubThemesData( fabSchemeColor: SchemeColor.secondary, inputDecoratorBorderType: FlexInputBorderType.underline, inputDecoratorIsFilled: false, useMaterial3Typography: true, appBarScrolledUnderElevation: 4, navigationBarIndicatorOpacity: 0.24, navigationBarHeight: 56, ); const String wgerDisplayFont = 'RobotoCondensed'; const List displayFontBoldWeight = [FontVariation('wght', 600)]; const List displayFontHeavyWeight = [FontVariation('wght', 800)]; // Make a light ColorScheme from the seeds. final ColorScheme schemeLight = SeedColorScheme.fromSeeds( primary: wgerPrimaryColor, primaryKey: wgerPrimaryColor, secondaryKey: wgerSecondaryColor, secondary: wgerSecondaryColor, tertiaryKey: wgerTertiaryColor, brightness: Brightness.light, tones: FlexTones.vivid(Brightness.light), ); // Make a dark ColorScheme from the seeds. final ColorScheme schemeDark = SeedColorScheme.fromSeeds( // primary: wgerPrimaryColor, primaryKey: wgerPrimaryColor, secondaryKey: wgerSecondaryColor, secondary: wgerSecondaryColor, brightness: Brightness.dark, tones: FlexTones.vivid(Brightness.dark), ); // Make a high contrast light ColorScheme from the seeds final ColorScheme schemeLightHc = SeedColorScheme.fromSeeds( primaryKey: wgerPrimaryColor, secondaryKey: wgerSecondaryColor, brightness: Brightness.light, tones: FlexTones.ultraContrast(Brightness.light), ); // Make a ultra contrast dark ColorScheme from the seeds. final ColorScheme schemeDarkHc = SeedColorScheme.fromSeeds( primaryKey: wgerPrimaryColor, secondaryKey: wgerSecondaryColor, brightness: Brightness.dark, tones: FlexTones.ultraContrast(Brightness.dark), ); const wgerTextTheme = TextTheme( displayLarge: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontHeavyWeight, ), displayMedium: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontHeavyWeight, ), displaySmall: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontHeavyWeight, ), headlineLarge: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontBoldWeight, ), headlineMedium: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontBoldWeight, ), headlineSmall: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontBoldWeight, ), titleLarge: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontBoldWeight, ), titleMedium: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontBoldWeight, ), titleSmall: TextStyle( fontFamily: wgerDisplayFont, fontVariations: displayFontBoldWeight, ), ); final wgerLightTheme = FlexThemeData.light( colorScheme: schemeLight, useMaterial3: true, appBarStyle: FlexAppBarStyle.primary, subThemesData: wgerSubThemeData, textTheme: wgerTextTheme, ); final wgerDarkTheme = FlexThemeData.dark( colorScheme: schemeDark, useMaterial3: true, subThemesData: wgerSubThemeData, textTheme: wgerTextTheme, ); final wgerLightThemeHc = FlexThemeData.light( colorScheme: schemeLightHc, useMaterial3: true, appBarStyle: FlexAppBarStyle.primary, subThemesData: wgerSubThemeData, textTheme: wgerTextTheme, ); final wgerDarkThemeHc = FlexThemeData.dark( colorScheme: schemeDarkHc, useMaterial3: true, subThemesData: wgerSubThemeData, textTheme: wgerTextTheme, ); /// Builds a wger theme for [brightness] with the palette generated from [seed], /// e.g. the platform's dynamic color. Sub-themes, app bar style and typography /// match the fixed themes, so only the hues change. /// /// With [highContrast] the palette is spread over a wider tonal range, matching /// the fixed high contrast themes the OS accessibility setting switches to. ThemeData wgerThemeFromSeed( Color seed, Brightness brightness, { bool highContrast = false, }) { final isDark = brightness == Brightness.dark; return (isDark ? FlexThemeData.dark : FlexThemeData.light)( colorScheme: SeedColorScheme.fromSeeds( primaryKey: seed, brightness: brightness, tones: highContrast ? FlexTones.ultraContrast(brightness) : FlexTones.vivid(brightness), ), useMaterial3: true, appBarStyle: isDark ? null : FlexAppBarStyle.primary, subThemesData: wgerSubThemeData, textTheme: wgerTextTheme, ); } CalendarStyle getWgerCalendarStyle(ThemeData theme) { final scheme = theme.colorScheme; final selectedDecoration = BoxDecoration( color: scheme.secondary, shape: BoxShape.circle, ); // table_calendar defaults these to a near-white that only works on a dark // circle, and secondary is light in dark mode. final selectedTextStyle = TextStyle(color: scheme.onSecondary, fontSize: 16); return CalendarStyle( outsideDaysVisible: false, todayDecoration: const BoxDecoration( color: Colors.amber, shape: BoxShape.circle, ), markerDecoration: BoxDecoration( color: theme.textTheme.headlineLarge?.color, shape: BoxShape.circle, ), selectedDecoration: selectedDecoration, selectedTextStyle: selectedTextStyle, rangeStartDecoration: selectedDecoration, rangeStartTextStyle: selectedTextStyle, rangeEndDecoration: selectedDecoration, rangeEndTextStyle: selectedTextStyle, rangeHighlightColor: scheme.secondaryContainer, weekendTextStyle: TextStyle(color: scheme.secondary), ); }