forked from eatvio/eatvio_app
fix: refactor files
This commit is contained in:
144
lib/core/theme/app_decoration.dart
Normal file
144
lib/core/theme/app_decoration.dart
Normal file
@@ -0,0 +1,144 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class AppDecoration {
|
||||
// Fill decorations
|
||||
static BoxDecoration get fillOnPrimary => BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
);
|
||||
|
||||
// Outline decorations
|
||||
static BoxDecoration get outlineBlueA => BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
border: Border.all(
|
||||
color: appTheme.blueA400,
|
||||
width: 1,
|
||||
),
|
||||
);
|
||||
|
||||
static BoxDecoration get outlinePrimary => BoxDecoration(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
border: Border.all(
|
||||
color: theme.colorScheme.primary,
|
||||
width: 1,
|
||||
),
|
||||
);
|
||||
|
||||
static BoxDecoration get fillDeepOrange => BoxDecoration(
|
||||
color: appTheme.deepOrange900.withOpacity(0.8),
|
||||
);
|
||||
|
||||
static BoxDecoration get fillGray => BoxDecoration(
|
||||
color: appTheme.gray50,
|
||||
);
|
||||
|
||||
static BoxDecoration get fillGray100 => BoxDecoration(
|
||||
color: appTheme.gray100,
|
||||
);
|
||||
|
||||
static BoxDecoration get fillGray60002 => BoxDecoration(
|
||||
color: appTheme.gray60002,
|
||||
);
|
||||
|
||||
static BoxDecoration get fillGreenA => BoxDecoration(
|
||||
color: appTheme.greenA700.withOpacity(0.8),
|
||||
);
|
||||
|
||||
static BoxDecoration get fillPrimary => BoxDecoration(
|
||||
color: theme.colorScheme.primary,
|
||||
);
|
||||
|
||||
static BoxDecoration get fillWhiteA => BoxDecoration(
|
||||
color: appTheme.whiteA700,
|
||||
);
|
||||
|
||||
static BoxDecoration get outlineBlueGray => BoxDecoration(
|
||||
border: Border.all(
|
||||
color: appTheme.black,
|
||||
width: 1,
|
||||
strokeAlign: strokeAlignOutside,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
class BorderRadiusStyle {
|
||||
// Circle borders
|
||||
static BorderRadius get circleBorder8 => BorderRadius.circular(
|
||||
8,
|
||||
);
|
||||
|
||||
// Rounded borders
|
||||
static BorderRadius get roundedBorder1 => BorderRadius.circular(
|
||||
1,
|
||||
);
|
||||
|
||||
// Outline decorations
|
||||
static BoxDecoration get outlineBlack => BoxDecoration(
|
||||
color: appTheme.whiteA700,
|
||||
boxShadow: [
|
||||
BoxShadow(
|
||||
color: appTheme.black900.withOpacity(0.15),
|
||||
spreadRadius: 2,
|
||||
blurRadius: 2,
|
||||
offset: Offset(
|
||||
0,
|
||||
2,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
static BoxDecoration get outlineBlueGray => BoxDecoration(
|
||||
border: Border.all(
|
||||
color: appTheme.black,
|
||||
width: 1,
|
||||
strokeAlign: strokeAlignOutside,
|
||||
),
|
||||
);
|
||||
|
||||
// Circle borders
|
||||
static BorderRadius get circleBorder17 => BorderRadius.circular(
|
||||
17,
|
||||
);
|
||||
|
||||
static BorderRadius get circleBorder20 => BorderRadius.circular(
|
||||
20,
|
||||
);
|
||||
|
||||
static BorderRadius get circleBorder62 => BorderRadius.circular(
|
||||
62,
|
||||
);
|
||||
|
||||
// Custom borders
|
||||
static BorderRadius get customBorderBL8 => BorderRadius.only(
|
||||
bottomLeft: Radius.circular(8),
|
||||
);
|
||||
|
||||
static BorderRadius get customBorderTL5 => BorderRadius.vertical(
|
||||
top: Radius.circular(5),
|
||||
);
|
||||
|
||||
static BorderRadius get customBorderTL51 => BorderRadius.only(
|
||||
topLeft: Radius.circular(5),
|
||||
bottomRight: Radius.circular(5),
|
||||
);
|
||||
|
||||
// Rounded borders
|
||||
static BorderRadius get roundedBorder12 => BorderRadius.circular(
|
||||
12,
|
||||
);
|
||||
|
||||
static BorderRadius get roundedBorder5 => BorderRadius.circular(
|
||||
5,
|
||||
);
|
||||
|
||||
static BorderRadius get roundedBorder8 => BorderRadius.circular(
|
||||
8,
|
||||
);
|
||||
}
|
||||
|
||||
double get strokeAlignInside => BorderSide.strokeAlignInside;
|
||||
|
||||
double get strokeAlignCenter => BorderSide.strokeAlignCenter;
|
||||
|
||||
double get strokeAlignOutside => BorderSide.strokeAlignOutside;
|
||||
23
lib/core/theme/custom_button_style.dart
Normal file
23
lib/core/theme/custom_button_style.dart
Normal file
@@ -0,0 +1,23 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A class that offers pre-defined button styles for customizing button appearance.
|
||||
class CustomButtonStyles {
|
||||
// Outline button style
|
||||
static ButtonStyle get outlinePrimaryTL15 => OutlinedButton.styleFrom(
|
||||
backgroundColor: appTheme.blueA400,
|
||||
side: BorderSide(
|
||||
color: theme.colorScheme.primary,
|
||||
width: 0,
|
||||
),
|
||||
shape: RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(15),
|
||||
),
|
||||
);
|
||||
|
||||
// text button style
|
||||
static ButtonStyle get none => ButtonStyle(
|
||||
backgroundColor: WidgetStateProperty.all<Color>(Colors.transparent),
|
||||
elevation: WidgetStateProperty.all<double>(0),
|
||||
);
|
||||
}
|
||||
228
lib/core/theme/custom_text_style.dart
Normal file
228
lib/core/theme/custom_text_style.dart
Normal file
@@ -0,0 +1,228 @@
|
||||
import 'package:eatvio_app/core/theme/theme_helper.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/// A collection of pre-defined text styles for customizing text appearance,
|
||||
/// categorized by different font families and weights.
|
||||
/// Additionally, this class includes extensions on [TextStyle] to easily apply specific font families to text.
|
||||
|
||||
class CustomTextStyles {
|
||||
// Headline style
|
||||
static get headlineSmallMulish => theme.textTheme.headlineSmall!.mulish;
|
||||
|
||||
// Title text style
|
||||
static get titleMediumSegoeUI => theme.textTheme.titleMedium!.segoeUI.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
|
||||
static get bodyMediumBlack900 => theme.textTheme.bodyMedium!.copyWith(
|
||||
color: appTheme.black900,
|
||||
);
|
||||
|
||||
static get bodyMediumBlack90013 => theme.textTheme.bodyMedium!.copyWith(
|
||||
color: appTheme.black900,
|
||||
fontSize: 13,
|
||||
);
|
||||
|
||||
static get bodyMediumBluegray800 => theme.textTheme.bodyMedium!.copyWith(
|
||||
color: appTheme.black,
|
||||
);
|
||||
|
||||
static get bodyMediumBluegray800_1 => theme.textTheme.bodyMedium!.copyWith(
|
||||
color: appTheme.black,
|
||||
);
|
||||
|
||||
static get bodyMediumBluegray800_2 => theme.textTheme.bodyMedium!.copyWith(
|
||||
color: appTheme.black,
|
||||
);
|
||||
|
||||
static get bodyMediumWhiteA700 => theme.textTheme.bodyMedium!.copyWith(
|
||||
color: appTheme.whiteA700,
|
||||
);
|
||||
|
||||
static get bodySmallMulishBlack900 => theme.textTheme.bodySmall!.mulish.copyWith(
|
||||
color: appTheme.black900,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
static get bodySmallMulishBluegray800 => theme.textTheme.bodySmall!.mulish.copyWith(
|
||||
color: appTheme.black,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
static get bodySmallMulishBluegray80012 => theme.textTheme.bodySmall!.mulish.copyWith(
|
||||
color: appTheme.black,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
static get bodySmallMulishBluegray80012_1 => theme.textTheme.bodySmall!.mulish.copyWith(
|
||||
color: appTheme.black,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
static get bodySmallMulishBluegray900 => theme.textTheme.bodySmall!.mulish.copyWith(
|
||||
color: appTheme.blueGray900,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
static get bodySmallMulishGray600 => theme.textTheme.bodySmall!.mulish.copyWith(
|
||||
color: appTheme.gray600,
|
||||
);
|
||||
|
||||
static get bodySmallMulishPrimary => theme.textTheme.bodySmall!.mulish.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
static get bodySmallSegoeUIBlack900 => theme.textTheme.bodySmall!.segoeUI.copyWith(
|
||||
color: appTheme.black900,
|
||||
fontSize: 12,
|
||||
);
|
||||
|
||||
// Label text style
|
||||
static get labelLargeGray60003 => theme.textTheme.labelLarge!.copyWith(
|
||||
color: appTheme.gray60003,
|
||||
);
|
||||
|
||||
static get labelLargeWhiteA700 => theme.textTheme.labelLarge!.copyWith(
|
||||
color: appTheme.whiteA700,
|
||||
);
|
||||
|
||||
// Title text style
|
||||
static get titleMedium16 => theme.textTheme.titleMedium!.copyWith(
|
||||
fontSize: 16,
|
||||
);
|
||||
|
||||
static get titleMediumBlack => theme.textTheme.titleMedium!.copyWith(
|
||||
fontSize: 17,
|
||||
fontWeight: FontWeight.w900,
|
||||
);
|
||||
|
||||
static get titleMediumBlack900 => theme.textTheme.titleMedium!.copyWith(
|
||||
color: appTheme.black900,
|
||||
);
|
||||
|
||||
static get titleMediumSemiBold => theme.textTheme.titleMedium!.copyWith(
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
|
||||
static get titleMediumWhiteA700 => theme.textTheme.titleMedium!.copyWith(
|
||||
color: appTheme.whiteA700,
|
||||
fontWeight: FontWeight.w600,
|
||||
);
|
||||
|
||||
static get titleSmallBlue800 => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.blue800,
|
||||
fontWeight: FontWeight.w800,
|
||||
);
|
||||
|
||||
static get titleSmallBluegray800 => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.black,
|
||||
);
|
||||
|
||||
static get titleSmallBluegray800Bold => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.black,
|
||||
fontWeight: FontWeight.w700,
|
||||
);
|
||||
|
||||
static get titleSmallBluegray800ExtraBold => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.black,
|
||||
fontWeight: FontWeight.w800,
|
||||
);
|
||||
|
||||
static get titleSmallBold => theme.textTheme.titleSmall!.copyWith(
|
||||
fontSize: 15,
|
||||
fontWeight: FontWeight.w700,
|
||||
);
|
||||
|
||||
static get titleSmallGreenA70001 => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.greenA70001,
|
||||
);
|
||||
|
||||
static get titleSmallGreenA70001ExtraBold => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.greenA70001,
|
||||
fontWeight: FontWeight.w800,
|
||||
);
|
||||
|
||||
static get titleSmallLightgreen300 => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.lightGreen300,
|
||||
fontWeight: FontWeight.w800,
|
||||
);
|
||||
|
||||
static get titleSmallRed200 => theme.textTheme.titleSmall!.copyWith(
|
||||
color: appTheme.red200,
|
||||
fontWeight: FontWeight.w800,
|
||||
);
|
||||
|
||||
static get titleSmallSecondaryContainer => theme.textTheme.titleSmall!.copyWith(
|
||||
color: theme.colorScheme.secondaryContainer,
|
||||
fontWeight: FontWeight.w800,
|
||||
);
|
||||
|
||||
static get titleSmallSecondaryContainer_1 => theme.textTheme.titleSmall!.copyWith(
|
||||
color: theme.colorScheme.secondaryContainer,
|
||||
);
|
||||
|
||||
static get titleSmallSegoeUIOnPrimary => theme.textTheme.titleSmall!.segoeUI.copyWith(
|
||||
color: theme.colorScheme.onPrimary,
|
||||
);
|
||||
}
|
||||
|
||||
extension on TextStyle {
|
||||
TextStyle get mulish {
|
||||
return copyWith();
|
||||
}
|
||||
|
||||
TextStyle get segoeUI {
|
||||
return copyWith();
|
||||
}
|
||||
}
|
||||
|
||||
abstract class TextStyles {
|
||||
static const headingXLSemibold = TextStyle(
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.255,
|
||||
);
|
||||
|
||||
static const textLSemibold = TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.255,
|
||||
);
|
||||
|
||||
static const textMSemibold = TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.255,
|
||||
);
|
||||
|
||||
static const textMMedium = TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1,
|
||||
);
|
||||
|
||||
static const textMMediumAuto = TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.255,
|
||||
);
|
||||
|
||||
static const textSSemibold = TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w600,
|
||||
height: 1.255,
|
||||
);
|
||||
|
||||
static const textSMedium = TextStyle(
|
||||
fontSize: 14,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.255,
|
||||
);
|
||||
|
||||
static const textXSSemibold = TextStyle(
|
||||
fontSize: 12,
|
||||
fontWeight: FontWeight.w500,
|
||||
height: 1.255,
|
||||
);
|
||||
}
|
||||
185
lib/core/theme/theme_helper.dart
Normal file
185
lib/core/theme/theme_helper.dart
Normal file
@@ -0,0 +1,185 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user