forked from eatvio/eatvio_app
186 lines
5.0 KiB
Dart
186 lines
5.0 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
|
|
var _appTheme = 'primary';
|
|
|
|
// A map of custom color themes supported by the app
|
|
Map<String, PrimaryColors> _supportedCustomColor = {
|
|
'primary': PrimaryColors(),
|
|
};
|
|
|
|
// A map of color schemes supported by the app
|
|
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: 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 final 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 => Color(0XFF43A6F2);
|
|
|
|
Color get blueA400 => Color(0XFF2F80ED);
|
|
|
|
// BlueGray
|
|
Color get blueGray400 => Color(0XFF7B8794);
|
|
|
|
Color get black900 => Color(0XFF000000);
|
|
|
|
// Blue
|
|
Color get blue800 => Color(0XFF1F78B4);
|
|
|
|
// BlueGray
|
|
Color get blueGray300 => Color(0XFF9AA5B1);
|
|
|
|
Color get black => Color(0XFF323F4B);
|
|
|
|
Color get blueGray900 => Color(0XFF2A2F4C);
|
|
|
|
// DeepOrange
|
|
Color get deepOrange900 => Color(0XFF9A4A00);
|
|
|
|
// Gray
|
|
Color get gray100 => Color(0XFFF0F2F5);
|
|
|
|
Color get gray200 => Color(0XFFF0F0F0);
|
|
|
|
Color get gray400 => Color(0XFFC1C1C1);
|
|
|
|
Color get gray40001 => Color(0XFFC8C8C8);
|
|
|
|
Color get gray50 => Color(0XFFF6FAFF);
|
|
|
|
Color get gray500 => Color(0XFFA3A3A3);
|
|
|
|
Color get gray600 => Color(0XFF6D6D6D);
|
|
|
|
Color get gray60001 => Color(0XFF848484);
|
|
|
|
Color get gray60002 => Color(0XFF757575);
|
|
|
|
Color get gray60003 => Color(0XFF707070);
|
|
|
|
// Green
|
|
Color get greenA700 => Color(0XFF019A3E);
|
|
|
|
Color get greenA70001 => Color(0XFF00BE13);
|
|
|
|
// LightGreen
|
|
Color get lightGreen300 => Color(0XFFB2DF8A);
|
|
|
|
Color get lightGreenA700 => Color(0XFF18FF14);
|
|
|
|
// Red
|
|
Color get red200 => Color(0XFFE3A6A6);
|
|
|
|
// Teal
|
|
Color get teal100 => Color(0XFFA6CEE3);
|
|
|
|
Color get teal900 => Color(0XFF0B3F56);
|
|
|
|
// White
|
|
Color get whiteA700 => Color(0XFFFFFFFF);
|
|
|
|
Color get backgroundAvatar => Color(0xFFEBF4FF);
|
|
|
|
Color get cardBackground => Color(0xFFF7FAFF);
|
|
|
|
Color get dividerColor => Color(0xFFF1F2F6);
|
|
|
|
Color get gray => Color(0xFF6D6F71);
|
|
|
|
Color get lightGray600 => Color(0xFFB0B0B0);
|
|
|
|
Color get lightGray => Color(0xFFCECECE);
|
|
|
|
Color get transparentBlue => Color(0xFF2F80ED).withOpacity(0.1);
|
|
|
|
Color get lightGray0 => Color(0xFFF6F6F6);
|
|
}
|
|
|
|
PrimaryColors get appTheme => ThemeHelper().themeColor();
|
|
|
|
ThemeData get theme => ThemeHelper().themeData();
|