refactor(all): refactor

This commit is contained in:
alex
2024-07-09 17:50:32 +03:00
parent f79b9f03ae
commit e180ff16b6
37 changed files with 1706 additions and 1123 deletions

View File

@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../core/app_export.dart';
/// Helper class for managing themes and colors.
@@ -22,7 +23,8 @@ class ThemeHelper {
//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",);
"$_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
@@ -34,13 +36,50 @@ class ThemeHelper {
//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",);
"$_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;
var colorScheme = _supportedColorScheme[_appTheme] ?? ColorSchemes.primaryColorScheme;
return ThemeData(
textTheme: GoogleFonts.mulishTextTheme().copyWith(
bodyLarge: TextStyle(
color: appTheme.blueGray400,
fontSize: 18,
fontWeight: FontWeight.w400,
),
headlineSmall: TextStyle(
color: colorScheme.primary,
fontWeight: FontWeight.w600,
fontSize: 24,
),
titleMedium: TextStyle(
color: colorScheme.primary,
fontWeight: FontWeight.w700,
fontSize: 18,
),
titleSmall: TextStyle(
color: colorScheme.onPrimary,
fontWeight: FontWeight.w700,
fontSize: 15,
),
bodyMedium: TextStyle(
color: appTheme.blueGray400,
fontWeight: FontWeight.w400,
fontSize: 14,
),
bodySmall: TextStyle(
color: appTheme.gray500,
fontWeight: FontWeight.w400,
fontSize: 10,
),
labelLarge: TextStyle(
color: appTheme.blueGray800,
fontWeight: FontWeight.w600,
fontSize: 12,
),
),
pageTransitionsTheme: PageTransitionsTheme(
builders: {
TargetPlatform.android: CupertinoPageTransitionsBuilder(),
@@ -49,7 +88,6 @@ class ThemeHelper {
),
visualDensity: VisualDensity.standard,
colorScheme: colorScheme,
textTheme: TextThemes.textTheme(colorScheme),
scaffoldBackgroundColor: colorScheme.onPrimary,
appBarTheme: AppBarTheme(
systemOverlayStyle: SystemUiOverlayStyle(
@@ -85,54 +123,6 @@ class ThemeHelper {
ThemeData themeData() => _getThemeData();
}
/// Class containing the supported text theme styles.
class TextThemes {
static TextTheme textTheme(ColorScheme colorScheme) => TextTheme(
bodyLarge: TextStyle(
color: appTheme.blueGray400,
fontSize: 18.fSize,
fontFamily: 'Mulish',
fontWeight: FontWeight.w400,
),
headlineSmall: TextStyle(
color: colorScheme.primary,
fontSize: 24.fSize,
fontFamily: 'Segoe UI',
fontWeight: FontWeight.w600,
),
titleMedium: TextStyle(
color: colorScheme.primary,
fontSize: 18.fSize,
fontFamily: 'Mulish',
fontWeight: FontWeight.w700,
),
titleSmall: TextStyle(
color: colorScheme.onPrimary,
fontSize: 15.fSize,
fontFamily: 'Mulish',
fontWeight: FontWeight.w700,
),
bodyMedium: TextStyle(
color: appTheme.blueGray400,
fontSize: 14.fSize,
fontFamily: 'Mulish',
fontWeight: FontWeight.w400,
),
bodySmall: TextStyle(
color: appTheme.gray500,
fontSize: 10.fSize,
fontFamily: 'Mulish',
fontWeight: FontWeight.w400,
),
labelLarge: TextStyle(
color: appTheme.blueGray800,
fontSize: 12.fSize,
fontFamily: 'Mulish',
fontWeight: FontWeight.w600,
),
);
}
/// Class containing the supported color schemes.
class ColorSchemes {
static final primaryColorScheme = ColorScheme.light(
@@ -149,10 +139,12 @@ class ColorSchemes {
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
@@ -160,7 +152,9 @@ class PrimaryColors {
// BlueGray
Color get blueGray300 => Color(0XFF9AA5B1);
Color get blueGray800 => Color(0XFF323F4B);
Color get blueGray900 => Color(0XFF2A2F4C);
// DeepOrange
@@ -168,22 +162,33 @@ class PrimaryColors {
// 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
@@ -191,6 +196,7 @@ class PrimaryColors {
// Teal
Color get teal100 => Color(0XFFA6CEE3);
Color get teal900 => Color(0XFF0B3F56);
// White
@@ -200,4 +206,5 @@ class PrimaryColors {
}
PrimaryColors get appTheme => ThemeHelper().themeColor();
ThemeData get theme => ThemeHelper().themeData();