forked from eatvio/eatvio_app
202 lines
6.1 KiB
Dart
202 lines
6.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
/// Helper class for managing themes and colors.
|
|
class ThemeHelper {
|
|
// The current app theme
|
|
final _appTheme = 'primary';
|
|
|
|
// A map of custom color themes supported by the app
|
|
final Map<String, PrimaryColors> _supportedCustomColor = {'primary': PrimaryColors()};
|
|
|
|
// A map of color schemes supported by the app
|
|
final Map<String, ColorScheme> _supportedColorScheme = {'primary': ColorSchemes.primaryColorScheme};
|
|
|
|
/// Returns the primary colors for the current theme.
|
|
PrimaryColors _getThemeColors() {
|
|
//throw exception to notify given theme is not found or not generated by the generator
|
|
if (!_supportedCustomColor.containsKey(_appTheme)) {
|
|
throw Exception("$_appTheme is not found.Make sure you have added this theme class in JSON Try running flutter pub run build_runner");
|
|
}
|
|
//return theme from map
|
|
|
|
return _supportedCustomColor[_appTheme] ?? PrimaryColors();
|
|
}
|
|
|
|
/// Returns the current theme data.
|
|
ThemeData _getThemeData() {
|
|
//throw exception to notify given theme is not found or not generated by the generator
|
|
if (!_supportedColorScheme.containsKey(_appTheme)) {
|
|
throw Exception("$_appTheme is not found.Make sure you have added this theme class in JSON Try running flutter pub run build_runner");
|
|
}
|
|
//return theme from map
|
|
|
|
var colorScheme = _supportedColorScheme[_appTheme] ?? ColorSchemes.primaryColorScheme;
|
|
return ThemeData(
|
|
textTheme: GoogleFonts.mulishTextTheme(),
|
|
visualDensity: VisualDensity.standard,
|
|
colorScheme: colorScheme,
|
|
scaffoldBackgroundColor: colorScheme.onPrimary,
|
|
appBarTheme: const AppBarTheme(
|
|
scrolledUnderElevation: 0,
|
|
elevation: 0,
|
|
systemOverlayStyle: SystemUiOverlayStyle(
|
|
statusBarIconBrightness: Brightness.dark,
|
|
statusBarBrightness: Brightness.light,
|
|
systemNavigationBarColor: Colors.white,
|
|
statusBarColor: Colors.white,
|
|
systemNavigationBarIconBrightness: Brightness.dark,
|
|
),
|
|
),
|
|
outlinedButtonTheme: OutlinedButtonThemeData(
|
|
style: OutlinedButton.styleFrom(
|
|
backgroundColor: Colors.transparent,
|
|
side: BorderSide(color: colorScheme.primary, width: 1),
|
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(20)),
|
|
visualDensity: const VisualDensity(vertical: -4, horizontal: -4),
|
|
padding: EdgeInsets.zero,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Returns the primary colors for the current theme.
|
|
PrimaryColors themeColor() => _getThemeColors();
|
|
|
|
/// Returns the current theme data.
|
|
ThemeData themeData() => _getThemeData();
|
|
}
|
|
|
|
/// Class containing the supported color schemes.
|
|
class ColorSchemes {
|
|
static const primaryColorScheme = ColorScheme.light(
|
|
// Primary colors
|
|
primary: Color(0XFF323F4B),
|
|
|
|
// On colors(text colors)
|
|
onPrimary: Color(0XFFFFFFFF),
|
|
onPrimaryContainer: Color(0XFF0B3F56),
|
|
);
|
|
}
|
|
|
|
/// Class containing custom colors for a primary theme.
|
|
class PrimaryColors {
|
|
// Blue
|
|
Color get blue400 => const Color(0XFF43A6F2);
|
|
|
|
Color get blueA400 => const Color(0XFF2F80ED);
|
|
// BlueGray
|
|
Color get blueGray400 => const Color(0XFF7B8794);
|
|
|
|
Color get black900 => const Color(0XFF000000);
|
|
|
|
// Blue
|
|
Color get blue800 => const Color(0XFF1F78B4);
|
|
|
|
// BlueGray
|
|
Color get blueGray300 => const Color(0XFF9AA5B1);
|
|
|
|
Color get black => const Color(0XFF323F4B);
|
|
|
|
Color get blueGray900 => const Color(0XFF2A2F4C);
|
|
|
|
// DeepOrange
|
|
Color get deepOrange900 => const Color(0XFF9A4A00);
|
|
|
|
// Gray
|
|
Color get gray100 => const Color(0XFFF0F2F5);
|
|
|
|
Color get gray200 => const Color(0XFFF0F0F0);
|
|
|
|
Color get gray400 => const Color(0XFFC1C1C1);
|
|
|
|
Color get gray40001 => const Color(0XFFC8C8C8);
|
|
|
|
Color get gray50 => const Color(0XFFF6FAFF);
|
|
|
|
Color get gray500 => const Color(0XFFA3A3A3);
|
|
|
|
Color get gray600 => const Color(0XFF6D6D6D);
|
|
|
|
Color get gray60001 => const Color(0XFF848484);
|
|
|
|
Color get gray60002 => const Color(0XFF757575);
|
|
|
|
Color get gray60003 => const Color(0XFF707070);
|
|
|
|
// Green
|
|
Color get greenA700 => const Color(0XFF019A3E);
|
|
|
|
Color get greenA70001 => const Color(0XFF00BE13);
|
|
|
|
Color get green => const Color(0XFF0BB450);
|
|
|
|
// LightGreen
|
|
Color get lightGreen300 => const Color(0XFFB2DF8A);
|
|
|
|
Color get lightGreenA700 => const Color(0XFF18FF14);
|
|
|
|
// Red
|
|
Color get red200 => const Color(0XFFE3A6A6);
|
|
|
|
// Teal
|
|
Color get teal100 => const Color(0XFFA6CEE3);
|
|
|
|
Color get teal900 => const Color(0XFF0B3F56);
|
|
|
|
// White
|
|
Color get whiteA700 => const Color(0XFFFFFFFF);
|
|
|
|
Color get backgroundAvatar => const Color(0xFFEBF4FF);
|
|
|
|
Color get cardBackground => const Color(0xFFF7FAFF);
|
|
|
|
Color get dividerColor => const Color(0xFFF1F2F6);
|
|
|
|
Color get gray => const Color(0xFF6D6F71);
|
|
|
|
Color get lightGray600 => const Color(0xFFB0B0B0);
|
|
|
|
Color get lightGray => const Color(0xFFCECECE);
|
|
|
|
Color get transparentBlue => const Color(0xFF2F80ED).withValues(alpha: 0.1);
|
|
|
|
Color get lightGray0 => const Color(0xFFF6F6F6);
|
|
|
|
Color get darkGrey => const Color(0xFF5B656F);
|
|
|
|
Color get lightGray00 => const Color(0xFFE9E9EA);
|
|
|
|
Color get dottedBorder => const Color(0xFFE6E6E6);
|
|
|
|
Color get red => const Color(0xFFCD4141);
|
|
Color get strongRed => const Color(0xFFD01717);
|
|
Color get lightRed => const Color(0XFFD01717).withValues(alpha: 0.1);
|
|
|
|
Color get transparentRed => const Color(0xFFCD4141).withValues(alpha: 0.75);
|
|
|
|
// ignore: use_full_hex_values_for_flutter_colors
|
|
Color get transparentBlack => const Color(0xff1313264).withValues(alpha: 0.3);
|
|
|
|
Color get gray60004 => const Color(0xFFD4DAE2).withValues(alpha: 0.2);
|
|
|
|
Color get blueGray => const Color(0xFF809CB9);
|
|
|
|
Color get dialogShadow => const Color.fromARGB(125, 0, 0, 0);
|
|
|
|
Color get darkGray => const Color(0XFFBBBCC0);
|
|
|
|
Color get commentBg => const Color(0XFFFFFDD8);
|
|
|
|
Color get cardNotificationsBG => const Color(0xFFA4A4A4);
|
|
|
|
Color get grey7B => const Color(0xFF7B7B7B);
|
|
|
|
Color get greyD9 => const Color(0xFFD9D9D9);
|
|
}
|
|
|
|
PrimaryColors get appTheme => ThemeHelper().themeColor();
|
|
|
|
ThemeData get theme => ThemeHelper().themeData();
|