diff --git a/lib/common/mixin/theme_wm_mixin.dart b/lib/common/mixin/theme_wm_mixin.dart index 69dd2b39..0fdd962b 100644 --- a/lib/common/mixin/theme_wm_mixin.dart +++ b/lib/common/mixin/theme_wm_mixin.dart @@ -18,8 +18,8 @@ mixin ThemeWMMixin on Wid @override void didChangeDependencies() { super.didChangeDependencies(); - _colorScheme = AppColorScheme.of(context); - _textScheme = AppTextScheme.of(context); + _colorScheme = context.appColorScheme; + _textScheme = context.appTextScheme; } } diff --git a/lib/features/debug/presentation/ui_kit/ui_kit_screen.dart b/lib/features/debug/presentation/ui_kit/ui_kit_screen.dart index 045f17c4..a395bac5 100644 --- a/lib/features/debug/presentation/ui_kit/ui_kit_screen.dart +++ b/lib/features/debug/presentation/ui_kit/ui_kit_screen.dart @@ -170,7 +170,7 @@ class _ColorGrid extends StatelessWidget { @override Widget build(BuildContext context) { - final colorScheme = AppColorScheme.of(context); + final colorScheme = context.appColorScheme; final l10n = context.l10n; const crossAxisCount = 2; @@ -293,7 +293,7 @@ class _ColorCard extends StatelessWidget { @override Widget build(BuildContext context) { - final colorScheme = AppColorScheme.of(context); + final colorScheme = context.appColorScheme; return Card( color: color, diff --git a/lib/features/snack_queue/presentation/default_snack_controller.dart b/lib/features/snack_queue/presentation/default_snack_controller.dart index d9aa60f6..5a26f14e 100644 --- a/lib/features/snack_queue/presentation/default_snack_controller.dart +++ b/lib/features/snack_queue/presentation/default_snack_controller.dart @@ -20,8 +20,8 @@ class DefaultSnackController { required EasyDialogAnimationConfiguration animationConfiguration, Duration? autoHideDuration, }) { - final colorScheme = AppColorScheme.of(context); - final textScheme = AppTextScheme.of(context); + final colorScheme = context.appColorScheme; + final textScheme = context.appTextScheme; final topPadding = MediaQuery.of(context).viewPadding.top; return FlutterEasyDialogs.show( EasyDialog.positioned( diff --git a/lib/uikit/colors/app_color_scheme.dart b/lib/uikit/colors/app_color_scheme.dart index 3b717b5a..22190a6e 100644 --- a/lib/uikit/colors/app_color_scheme.dart +++ b/lib/uikit/colors/app_color_scheme.dart @@ -1,6 +1,8 @@ // ignore_for_file: avoid-non-null-assertion, prefer-correct-callback-field-name import 'package:flutter/material.dart'; -import 'package:flutter_template/uikit/colors/color_palette.dart'; +import 'package:theme_tailor_annotation/theme_tailor_annotation.dart'; + +part 'app_color_scheme.tailor.dart'; const _skeletonOpacity = 0.06; @@ -16,13 +18,16 @@ const _skeletonOpacity = 0.06; /// return Container(color: colorScheme.primary); /// ``` @immutable -class AppColorScheme extends ThemeExtension { +@TailorMixin(themeGetter: ThemeGetter.onBuildContext) +class AppColorScheme extends ThemeExtension with _$AppColorSchemeTailorMixin { /// Base branding color for the app. /// /// Can be used as an accent color for buttons, switches, labels, icons, etc. + @override final Color primary; /// The color of the text on [primary]. + @override final Color onPrimary; /// Secondary branding color for the app. @@ -30,50 +35,61 @@ class AppColorScheme extends ThemeExtension { /// Can be used as an accent color for buttons, switches, labels, icons, etc. /// /// Complements [primary] color. + @override final Color secondary; /// The color of the text on [secondary]. + @override final Color onSecondary; /// Surface color. /// /// Usually, the background color of cards, alerts, dialogs, bottom sheets, etc /// is considered a surface. + @override final Color surface; /// Secondary surface color. /// /// Usually, the background color of cards, alerts, dialogs, bottom sheets, etc /// is considered a surface. + @override final Color surfaceSecondary; /// The color of the text on [surface]. + @override final Color onSurface; /// Background color. /// /// Usually refers to the general background of the screen. + @override final Color background; /// Secondary background color. /// /// Usually refers to the general background of the screen. + @override final Color backgroundSecondary; /// Tertiary background color. /// /// Usually refers to the general background of the screen. + @override final Color backgroundTertiary; /// Tetradic background color. /// /// Usually refers to the general background of the screen. + @override final Color tetradicBackground; /// The color of the text on [background]. + @override final Color onBackground; /// The color of the text on [background]. Muted version. + @override final Color onBackgroundSecondary; /// Color of danger. @@ -81,6 +97,7 @@ class AppColorScheme extends ThemeExtension { /// Commonly used to display errors. /// /// Can be used as an accent color for text/background of an error message/destructive button. + @override final Color danger; /// Secondary color of danger. @@ -88,112 +105,65 @@ class AppColorScheme extends ThemeExtension { /// Commonly used to display errors. /// /// Can be used as an accent color for text/background of an error message/destructive button. + @override final Color dangerSecondary; /// The color of the text on [danger]. + @override final Color onDanger; /// Color of text in text field. + @override final Color textField; /// Color of label in text field. + @override final Color textFieldLabel; /// Color of helper text in text field. + @override final Color textFieldHelper; /// Color of border and cursor in text field. + @override final Color frameTextFieldSecondary; /// Color of inactive elements. + @override final Color inactive; /// Positive color. /// /// Typically used for informational success messages. + @override final Color positive; /// The color of the text on [positive]. + @override final Color onPositive; /// Primary skeleton color. + @override final Color skeletonPrimary; /// The color of the text on [skeletonPrimary]. + @override final Color skeletonOnPrimary; /// Secondary skeleton color. + @override final Color skeletonSecondary; /// Tertiary skeleton color. + @override final Color skeletonTertiary; /// The color of the shimmer. + @override final Color shimmer; - /// Base light theme version. - AppColorScheme.light() - : primary = ColorPalette.purple, - onPrimary = ColorPalette.white, - secondary = ColorPalette.greenYellow, - onSecondary = ColorPalette.chineseBlack, - surface = ColorPalette.white, - surfaceSecondary = ColorPalette.cultured, - onSurface = ColorPalette.chineseBlack, - background = ColorPalette.cultured, - backgroundSecondary = ColorPalette.darkScarlet, - backgroundTertiary = ColorPalette.cultured, - onBackground = ColorPalette.chineseBlack, - onBackgroundSecondary = ColorPalette.white, - danger = ColorPalette.folly, - dangerSecondary = ColorPalette.vividRaspberry, - onDanger = ColorPalette.white, - textField = ColorPalette.chineseBlack, - textFieldLabel = ColorPalette.black, - textFieldHelper = ColorPalette.black, - frameTextFieldSecondary = ColorPalette.chineseBlack, - inactive = ColorPalette.black, - positive = ColorPalette.greenYellow, - onPositive = ColorPalette.chineseBlack, - skeletonPrimary = ColorPalette.black.withOpacity(_skeletonOpacity), - skeletonOnPrimary = ColorPalette.white, - skeletonSecondary = ColorPalette.cultured, - skeletonTertiary = ColorPalette.lightSilver, - tetradicBackground = ColorPalette.lightGreen, - shimmer = ColorPalette.platinum; - - /// Base dark theme version. - AppColorScheme.dark() - : primary = DarkColorPalette.hanPurple, - onPrimary = DarkColorPalette.white, - secondary = DarkColorPalette.inchworm, - onSecondary = DarkColorPalette.black, - surface = DarkColorPalette.raisinBlack, - surfaceSecondary = DarkColorPalette.raisinBlack, - onSurface = DarkColorPalette.white, - background = DarkColorPalette.raisinBlack, - backgroundSecondary = DarkColorPalette.maroon, - backgroundTertiary = DarkColorPalette.raisinBlack, - onBackground = DarkColorPalette.white, - onBackgroundSecondary = DarkColorPalette.white, - danger = DarkColorPalette.brinkPink, - dangerSecondary = DarkColorPalette.cyclamen, - onDanger = DarkColorPalette.white, - textField = DarkColorPalette.lightSilver, - textFieldLabel = DarkColorPalette.white, - textFieldHelper = DarkColorPalette.black, - frameTextFieldSecondary = DarkColorPalette.lightSilver, - inactive = DarkColorPalette.black, - positive = DarkColorPalette.inchworm, - onPositive = DarkColorPalette.black, - skeletonPrimary = DarkColorPalette.black.withOpacity(_skeletonOpacity), - skeletonOnPrimary = DarkColorPalette.white, - skeletonSecondary = DarkColorPalette.raisinBlack, - skeletonTertiary = DarkColorPalette.lightSilver, - tetradicBackground = DarkColorPalette.etonBlue, - shimmer = ColorPalette.platinum; - - const AppColorScheme._({ + /// @nodoc + const AppColorScheme({ required this.primary, required this.onPrimary, required this.secondary, @@ -224,110 +194,65 @@ class AppColorScheme extends ThemeExtension { required this.shimmer, }); - @override - ThemeExtension copyWith({ - Color? primary, - Color? onPrimary, - Color? secondary, - Color? onSecondary, - Color? surface, - Color? surfaceSecondary, - Color? onSurface, - Color? background, - Color? backgroundSecondary, - Color? backgroundTertiary, - Color? onBackground, - Color? onBackgroundSecondary, - Color? danger, - Color? dangerSecondary, - Color? onDanger, - Color? textField, - Color? textFieldLabel, - Color? textFieldHelper, - Color? frameTextFieldSecondary, - Color? inactive, - Color? positive, - Color? onPositive, - Color? skeletonPrimary, - Color? skeletonOnPrimary, - Color? skeletonSecondary, - Color? skeletonTertiary, - Color? tetradicBackground, - Color? shimmer, - }) { - return AppColorScheme._( - primary: primary ?? this.primary, - onPrimary: onPrimary ?? this.onPrimary, - secondary: secondary ?? this.secondary, - onSecondary: onSecondary ?? this.onSecondary, - surface: surface ?? this.surface, - surfaceSecondary: surfaceSecondary ?? this.surfaceSecondary, - onSurface: onSurface ?? this.onSurface, - background: background ?? this.background, - backgroundSecondary: backgroundSecondary ?? this.backgroundSecondary, - backgroundTertiary: backgroundTertiary ?? this.backgroundTertiary, - onBackground: onBackground ?? this.onBackground, - onBackgroundSecondary: onBackgroundSecondary ?? this.onBackgroundSecondary, - danger: danger ?? this.danger, - dangerSecondary: dangerSecondary ?? this.dangerSecondary, - onDanger: onDanger ?? this.onDanger, - textField: textField ?? this.textField, - textFieldLabel: textFieldLabel ?? this.textFieldLabel, - textFieldHelper: textFieldHelper ?? this.textFieldHelper, - frameTextFieldSecondary: frameTextFieldSecondary ?? this.frameTextFieldSecondary, - inactive: inactive ?? this.inactive, - positive: positive ?? this.positive, - onPositive: onPositive ?? this.onPositive, - skeletonPrimary: skeletonPrimary ?? this.skeletonPrimary, - skeletonOnPrimary: skeletonOnPrimary ?? this.skeletonOnPrimary, - skeletonSecondary: skeletonSecondary ?? this.skeletonSecondary, - skeletonTertiary: skeletonTertiary ?? this.skeletonTertiary, - tetradicBackground: tetradicBackground ?? this.tetradicBackground, - shimmer: shimmer ?? this.shimmer, - ); - } + /// Base light theme version. + AppColorScheme.light() + : primary = const Color(0xFF9824F2), + onPrimary = const Color(0xFFFFFFFF), + secondary = const Color(0xFFBEFF3D), + onSecondary = const Color(0xFF171717), + surface = const Color(0xFFFFFFFF), + surfaceSecondary = const Color(0xFFF6F6F6), + onSurface = const Color(0xFF171717), + background = const Color(0xFFF6F6F6), + backgroundSecondary = const Color(0xFF7B0008), + backgroundTertiary = const Color(0xFFF6F6F6), + onBackground = const Color(0xFF171717), + onBackgroundSecondary = const Color(0xFFFFFFFF), + danger = const Color(0xFFFF004D), + dangerSecondary = const Color(0xFFFF176B), + onDanger = const Color(0xFFFFFFFF), + textField = const Color(0xFF171717), + textFieldLabel = const Color(0xFF000000), + textFieldHelper = const Color(0xFF000000), + frameTextFieldSecondary = const Color(0xFF171717), + inactive = const Color(0xFF000000), + positive = const Color(0xFFBEFF3D), + onPositive = const Color(0xFF171717), + skeletonPrimary = Colors.black.withOpacity(_skeletonOpacity), + skeletonOnPrimary = const Color(0xFFFFFFFF), + skeletonSecondary = const Color(0xFFF6F6F6), + skeletonTertiary = const Color(0xFFD6D6D6), + tetradicBackground = const Color(0xFFB5CCAE), + shimmer = const Color(0xFFE7E4E0); - @override - ThemeExtension lerp( - ThemeExtension? other, - double t, - ) { - if (other is! AppColorScheme) { - return this; - } - - return AppColorScheme._( - primary: Color.lerp(primary, other.primary, t)!, - onPrimary: Color.lerp(onPrimary, other.onPrimary, t)!, - secondary: Color.lerp(secondary, other.secondary, t)!, - onSecondary: Color.lerp(onSecondary, other.onSecondary, t)!, - surface: Color.lerp(surface, other.surface, t)!, - surfaceSecondary: Color.lerp(surfaceSecondary, other.surfaceSecondary, t)!, - onSurface: Color.lerp(onSurface, other.onSurface, t)!, - background: Color.lerp(background, other.background, t)!, - backgroundSecondary: Color.lerp(backgroundSecondary, other.backgroundSecondary, t)!, - backgroundTertiary: Color.lerp(backgroundTertiary, other.backgroundTertiary, t)!, - onBackground: Color.lerp(onBackground, other.onBackground, t)!, - onBackgroundSecondary: Color.lerp(onBackgroundSecondary, other.onBackgroundSecondary, t)!, - danger: Color.lerp(danger, other.danger, t)!, - dangerSecondary: Color.lerp(dangerSecondary, other.dangerSecondary, t)!, - onDanger: Color.lerp(onDanger, other.onDanger, t)!, - textField: Color.lerp(textField, other.textField, t)!, - textFieldLabel: Color.lerp(textFieldLabel, other.textFieldLabel, t)!, - textFieldHelper: Color.lerp(textFieldHelper, other.textFieldHelper, t)!, - frameTextFieldSecondary: Color.lerp(frameTextFieldSecondary, other.frameTextFieldSecondary, t)!, - inactive: Color.lerp(inactive, other.inactive, t)!, - positive: Color.lerp(positive, other.positive, t)!, - onPositive: Color.lerp(onPositive, other.onPositive, t)!, - skeletonPrimary: Color.lerp(skeletonPrimary, other.skeletonPrimary, t)!, - skeletonOnPrimary: Color.lerp(skeletonOnPrimary, other.skeletonOnPrimary, t)!, - skeletonSecondary: Color.lerp(skeletonSecondary, other.skeletonSecondary, t)!, - skeletonTertiary: Color.lerp(skeletonTertiary, other.skeletonTertiary, t)!, - tetradicBackground: Color.lerp(tetradicBackground, other.tetradicBackground, t)!, - shimmer: Color.lerp(shimmer, other.shimmer, t)!, - ); - } - - /// Returns [AppColorScheme] from [context]. - static AppColorScheme of(BuildContext context) => Theme.of(context).extension()!; + /// Base dark theme version. + AppColorScheme.dark() + : primary = const Color(0xFF6D38FF), + onPrimary = const Color(0xFFFFFFFF), + secondary = const Color(0xFFC6FF57), + onSecondary = const Color(0xFF000000), + surface = const Color(0xFF222222), + surfaceSecondary = const Color(0xFF222222), + onSurface = const Color(0xFFFFFFFF), + background = const Color(0xFF222222), + backgroundSecondary = const Color(0xFF7B0008), + backgroundTertiary = const Color(0xFF222222), + onBackground = const Color(0xFFFFFFFF), + onBackgroundSecondary = const Color(0xFFFFFFFF), + danger = const Color(0xFFFF607D), + dangerSecondary = const Color(0xFFFF79A8), + onDanger = const Color(0xFFFFFFFF), + textField = const Color(0xFFD6D6D6), + textFieldLabel = const Color(0xFFFFFFFF), + textFieldHelper = const Color(0xFF000000), + frameTextFieldSecondary = const Color(0xFFD6D6D6), + inactive = const Color(0xFF000000), + positive = const Color(0xFFC6FF57), + onPositive = const Color(0xFF000000), + skeletonPrimary = Colors.black.withOpacity(_skeletonOpacity), + skeletonOnPrimary = const Color(0xFFFFFFFF), + skeletonSecondary = const Color(0xFF222222), + skeletonTertiary = const Color(0xFFD6D6D6), + tetradicBackground = const Color(0xFF9CD29C), + shimmer = const Color(0xFFE7E4E0); } diff --git a/lib/uikit/colors/app_color_scheme.tailor.dart b/lib/uikit/colors/app_color_scheme.tailor.dart new file mode 100644 index 00000000..8682d26e --- /dev/null +++ b/lib/uikit/colors/app_color_scheme.tailor.dart @@ -0,0 +1,212 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, unused_element, unnecessary_cast + +part of 'app_color_scheme.dart'; + +// ************************************************************************** +// TailorAnnotationsGenerator +// ************************************************************************** + +mixin _$AppColorSchemeTailorMixin on ThemeExtension { + Color get primary; + Color get onPrimary; + Color get secondary; + Color get onSecondary; + Color get surface; + Color get surfaceSecondary; + Color get onSurface; + Color get background; + Color get backgroundSecondary; + Color get backgroundTertiary; + Color get tetradicBackground; + Color get onBackground; + Color get onBackgroundSecondary; + Color get danger; + Color get dangerSecondary; + Color get onDanger; + Color get textField; + Color get textFieldLabel; + Color get textFieldHelper; + Color get frameTextFieldSecondary; + Color get inactive; + Color get positive; + Color get onPositive; + Color get skeletonPrimary; + Color get skeletonOnPrimary; + Color get skeletonSecondary; + Color get skeletonTertiary; + Color get shimmer; + + @override + AppColorScheme copyWith({ + Color? primary, + Color? onPrimary, + Color? secondary, + Color? onSecondary, + Color? surface, + Color? surfaceSecondary, + Color? onSurface, + Color? background, + Color? backgroundSecondary, + Color? backgroundTertiary, + Color? tetradicBackground, + Color? onBackground, + Color? onBackgroundSecondary, + Color? danger, + Color? dangerSecondary, + Color? onDanger, + Color? textField, + Color? textFieldLabel, + Color? textFieldHelper, + Color? frameTextFieldSecondary, + Color? inactive, + Color? positive, + Color? onPositive, + Color? skeletonPrimary, + Color? skeletonOnPrimary, + Color? skeletonSecondary, + Color? skeletonTertiary, + Color? shimmer, + }) { + return AppColorScheme( + primary: primary ?? this.primary, + onPrimary: onPrimary ?? this.onPrimary, + secondary: secondary ?? this.secondary, + onSecondary: onSecondary ?? this.onSecondary, + surface: surface ?? this.surface, + surfaceSecondary: surfaceSecondary ?? this.surfaceSecondary, + onSurface: onSurface ?? this.onSurface, + background: background ?? this.background, + backgroundSecondary: backgroundSecondary ?? this.backgroundSecondary, + backgroundTertiary: backgroundTertiary ?? this.backgroundTertiary, + tetradicBackground: tetradicBackground ?? this.tetradicBackground, + onBackground: onBackground ?? this.onBackground, + onBackgroundSecondary: onBackgroundSecondary ?? this.onBackgroundSecondary, + danger: danger ?? this.danger, + dangerSecondary: dangerSecondary ?? this.dangerSecondary, + onDanger: onDanger ?? this.onDanger, + textField: textField ?? this.textField, + textFieldLabel: textFieldLabel ?? this.textFieldLabel, + textFieldHelper: textFieldHelper ?? this.textFieldHelper, + frameTextFieldSecondary: frameTextFieldSecondary ?? this.frameTextFieldSecondary, + inactive: inactive ?? this.inactive, + positive: positive ?? this.positive, + onPositive: onPositive ?? this.onPositive, + skeletonPrimary: skeletonPrimary ?? this.skeletonPrimary, + skeletonOnPrimary: skeletonOnPrimary ?? this.skeletonOnPrimary, + skeletonSecondary: skeletonSecondary ?? this.skeletonSecondary, + skeletonTertiary: skeletonTertiary ?? this.skeletonTertiary, + shimmer: shimmer ?? this.shimmer, + ); + } + + @override + AppColorScheme lerp(covariant ThemeExtension? other, double t) { + if (other is! AppColorScheme) return this as AppColorScheme; + return AppColorScheme( + primary: Color.lerp(primary, other.primary, t)!, + onPrimary: Color.lerp(onPrimary, other.onPrimary, t)!, + secondary: Color.lerp(secondary, other.secondary, t)!, + onSecondary: Color.lerp(onSecondary, other.onSecondary, t)!, + surface: Color.lerp(surface, other.surface, t)!, + surfaceSecondary: Color.lerp(surfaceSecondary, other.surfaceSecondary, t)!, + onSurface: Color.lerp(onSurface, other.onSurface, t)!, + background: Color.lerp(background, other.background, t)!, + backgroundSecondary: Color.lerp(backgroundSecondary, other.backgroundSecondary, t)!, + backgroundTertiary: Color.lerp(backgroundTertiary, other.backgroundTertiary, t)!, + tetradicBackground: Color.lerp(tetradicBackground, other.tetradicBackground, t)!, + onBackground: Color.lerp(onBackground, other.onBackground, t)!, + onBackgroundSecondary: Color.lerp(onBackgroundSecondary, other.onBackgroundSecondary, t)!, + danger: Color.lerp(danger, other.danger, t)!, + dangerSecondary: Color.lerp(dangerSecondary, other.dangerSecondary, t)!, + onDanger: Color.lerp(onDanger, other.onDanger, t)!, + textField: Color.lerp(textField, other.textField, t)!, + textFieldLabel: Color.lerp(textFieldLabel, other.textFieldLabel, t)!, + textFieldHelper: Color.lerp(textFieldHelper, other.textFieldHelper, t)!, + frameTextFieldSecondary: Color.lerp(frameTextFieldSecondary, other.frameTextFieldSecondary, t)!, + inactive: Color.lerp(inactive, other.inactive, t)!, + positive: Color.lerp(positive, other.positive, t)!, + onPositive: Color.lerp(onPositive, other.onPositive, t)!, + skeletonPrimary: Color.lerp(skeletonPrimary, other.skeletonPrimary, t)!, + skeletonOnPrimary: Color.lerp(skeletonOnPrimary, other.skeletonOnPrimary, t)!, + skeletonSecondary: Color.lerp(skeletonSecondary, other.skeletonSecondary, t)!, + skeletonTertiary: Color.lerp(skeletonTertiary, other.skeletonTertiary, t)!, + shimmer: Color.lerp(shimmer, other.shimmer, t)!, + ); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is AppColorScheme && + const DeepCollectionEquality().equals(primary, other.primary) && + const DeepCollectionEquality().equals(onPrimary, other.onPrimary) && + const DeepCollectionEquality().equals(secondary, other.secondary) && + const DeepCollectionEquality().equals(onSecondary, other.onSecondary) && + const DeepCollectionEquality().equals(surface, other.surface) && + const DeepCollectionEquality().equals(surfaceSecondary, other.surfaceSecondary) && + const DeepCollectionEquality().equals(onSurface, other.onSurface) && + const DeepCollectionEquality().equals(background, other.background) && + const DeepCollectionEquality().equals(backgroundSecondary, other.backgroundSecondary) && + const DeepCollectionEquality().equals(backgroundTertiary, other.backgroundTertiary) && + const DeepCollectionEquality().equals(tetradicBackground, other.tetradicBackground) && + const DeepCollectionEquality().equals(onBackground, other.onBackground) && + const DeepCollectionEquality().equals(onBackgroundSecondary, other.onBackgroundSecondary) && + const DeepCollectionEquality().equals(danger, other.danger) && + const DeepCollectionEquality().equals(dangerSecondary, other.dangerSecondary) && + const DeepCollectionEquality().equals(onDanger, other.onDanger) && + const DeepCollectionEquality().equals(textField, other.textField) && + const DeepCollectionEquality().equals(textFieldLabel, other.textFieldLabel) && + const DeepCollectionEquality().equals(textFieldHelper, other.textFieldHelper) && + const DeepCollectionEquality().equals(frameTextFieldSecondary, other.frameTextFieldSecondary) && + const DeepCollectionEquality().equals(inactive, other.inactive) && + const DeepCollectionEquality().equals(positive, other.positive) && + const DeepCollectionEquality().equals(onPositive, other.onPositive) && + const DeepCollectionEquality().equals(skeletonPrimary, other.skeletonPrimary) && + const DeepCollectionEquality().equals(skeletonOnPrimary, other.skeletonOnPrimary) && + const DeepCollectionEquality().equals(skeletonSecondary, other.skeletonSecondary) && + const DeepCollectionEquality().equals(skeletonTertiary, other.skeletonTertiary) && + const DeepCollectionEquality().equals(shimmer, other.shimmer)); + } + + @override + int get hashCode { + return Object.hashAll([ + runtimeType.hashCode, + const DeepCollectionEquality().hash(primary), + const DeepCollectionEquality().hash(onPrimary), + const DeepCollectionEquality().hash(secondary), + const DeepCollectionEquality().hash(onSecondary), + const DeepCollectionEquality().hash(surface), + const DeepCollectionEquality().hash(surfaceSecondary), + const DeepCollectionEquality().hash(onSurface), + const DeepCollectionEquality().hash(background), + const DeepCollectionEquality().hash(backgroundSecondary), + const DeepCollectionEquality().hash(backgroundTertiary), + const DeepCollectionEquality().hash(tetradicBackground), + const DeepCollectionEquality().hash(onBackground), + const DeepCollectionEquality().hash(onBackgroundSecondary), + const DeepCollectionEquality().hash(danger), + const DeepCollectionEquality().hash(dangerSecondary), + const DeepCollectionEquality().hash(onDanger), + const DeepCollectionEquality().hash(textField), + const DeepCollectionEquality().hash(textFieldLabel), + const DeepCollectionEquality().hash(textFieldHelper), + const DeepCollectionEquality().hash(frameTextFieldSecondary), + const DeepCollectionEquality().hash(inactive), + const DeepCollectionEquality().hash(positive), + const DeepCollectionEquality().hash(onPositive), + const DeepCollectionEquality().hash(skeletonPrimary), + const DeepCollectionEquality().hash(skeletonOnPrimary), + const DeepCollectionEquality().hash(skeletonSecondary), + const DeepCollectionEquality().hash(skeletonTertiary), + const DeepCollectionEquality().hash(shimmer), + ]); + } +} + +extension AppColorSchemeBuildContext on BuildContext { + AppColorScheme get appColorScheme => Theme.of(this).extension()!; +} diff --git a/lib/uikit/colors/color_palette.dart b/lib/uikit/colors/color_palette.dart deleted file mode 100644 index 3c6b1214..00000000 --- a/lib/uikit/colors/color_palette.dart +++ /dev/null @@ -1,163 +0,0 @@ -import 'package:flutter/material.dart'; - -/// IMPORTANT! Don't use this directly for UI elements decorating. -/// Use color scheme instead. -/// -/// App Light colors palette. -abstract class ColorPalette { - /// Purple (X11) - /// - /// https://www.color-name.com/hex/9824F2. - static const purple = Color(0xFF9824F2); - - /// Green-Yellow - /// - /// https://www.color-name.com/hex/BEFF3D. - static const greenYellow = Color(0xFFBEFF3D); - - /// Dark Scarlet - /// - /// https://www.color-name.com/hex/4D052A. - static const darkScarlet = Color(0xFF4D052A); - - /// Folly - /// - /// https://www.color-name.com/hex/FF004D. - static const folly = Color(0xFFFF004D); - - /// Cultured - /// - /// https://www.color-name.com/hex/F6F6F6. - static const cultured = Color(0xFFF6F6F6); - - /// Chinese Black - /// - /// https://www.color-name.com/hex/171717. - static const chineseBlack = Color(0xFF171717); - - /// White - /// - /// https://www.color-name.com/hex/FFFFFF. - static const white = Colors.white; - - /// Black - /// - /// https://www.color-name.com/hex/000000. - static const black = Colors.black; - - /// Vivid Raspberry - /// - /// https://www.color-name.com/hex/ff176b. - static const vividRaspberry = Color(0xFFFF176B); - - /// Light Silver - /// - /// https://www.color-name.com/hex/D9D9D9. - static const lightSilver = Color(0xFFD9D9D9); - - /// Light Green - /// - /// https://www.color-name.com/hex/B5CCAE. - static const lightGreen = Color(0xFFB5CCAE); - - /// Dark Green - /// - /// https://www.color-name.com/hex/84A58F. - static const darkGreen = Color(0xFF84A58F); - - /// Light Violet - /// - /// https://www.color-name.com/hex/74305B. - static const lightViolet = Color(0xFF74305B); - - /// Violet - /// - /// https://www.color-name.com/hex/4A194E. - static const violet = Color(0xFF4A194E); - - /// Green - /// - /// https://www.color-name.com/hex/83C000. - static const appleGreen = Color(0xFF83C000); - - /// Platinum - /// - /// https://www.color-name.com/hex/e7e4e0. - static const platinum = Color(0xFFE7E4E0); -} - -/// IMPORTANT! Don't use this directly for UI elements decorating. -/// Use color scheme instead. -/// -/// App Dark colors palette. -abstract class DarkColorPalette { - /// Han Purple - /// - /// https://www.color-name.com/hex/6D38FF. - static const hanPurple = Color(0xFF6D38FF); - - /// Inchworm - /// - /// https://www.color-name.com/hex/C6FF57. - static const inchworm = Color(0xFFC6FF57); - - /// Maroon - /// - /// https://www.color-name.com/hex/7B0008. - static const maroon = Color(0xFF7B0008); - - /// Brink Pink - /// - /// https://www.color-name.com/hex/FF607D. - static const brinkPink = Color(0xFFFF607D); - - /// Raisin Black - /// - /// https://www.color-name.com/hex/222222. - static const raisinBlack = Color(0xFF222222); - - /// Light Silver - /// - /// https://www.color-name.com/hex/D6D6D6. - static const lightSilver = Color(0xFFD6D6D6); - - /// Cyclamen - /// - /// https://www.color-name.com/hex/FF79A8. - static const cyclamen = Color(0xFFFF79A8); - - /// Eton Blue - /// - /// https://www.color-name.com/hex/9CD29C. - static const etonBlue = Color(0xFF9CD29C); - - /// Russian Green - /// - /// https://www.color-name.com/hex/628B6E. - static const russianGreen = Color(0xFF628B6E); - - /// Plum - /// - /// https://www.color-name.com/hex/9E478B. - static const plum = Color(0xFF9E478B); - - /// Brown Chocolate - /// - /// https://www.color-name.com/hex/561E43. - static const brownChocolate = Color(0xFF561E43); - - /// Vivid Lime Green - /// - /// https://www.color-name.com/hex/9ECF00. - static const vividLimeGreen = Color(0xFF9ECF00); - - /// White - /// - /// https://www.color-name.com/hex/FFFFFF. - static const white = Colors.white; - - /// Black - /// - /// https://www.color-name.com/hex/000000. - static const black = Colors.black; -} diff --git a/lib/uikit/others/shimmer.dart b/lib/uikit/others/shimmer.dart index c92a8550..d0dcc32a 100644 --- a/lib/uikit/others/shimmer.dart +++ b/lib/uikit/others/shimmer.dart @@ -18,7 +18,7 @@ class Shimmer extends StatelessWidget { @override Widget build(BuildContext context) { - final colorScheme = AppColorScheme.of(context); + final colorScheme = context.appColorScheme; return ConditionalWrapper( condition: loading, diff --git a/lib/uikit/text/app_text_scheme.dart b/lib/uikit/text/app_text_scheme.dart index 39311c01..821fcaa4 100644 --- a/lib/uikit/text/app_text_scheme.dart +++ b/lib/uikit/text/app_text_scheme.dart @@ -1,22 +1,30 @@ // ignore_for_file: avoid-non-null-assertion, prefer-correct-callback-field-name import 'package:flutter/material.dart'; import 'package:flutter_template/uikit/text/app_text_style.dart'; +import 'package:theme_tailor_annotation/theme_tailor_annotation.dart'; + +part 'app_text_scheme.tailor.dart'; /// App text style scheme. -class AppTextScheme extends ThemeExtension { +@TailorMixin(themeGetter: ThemeGetter.onBuildContext) +class AppTextScheme extends ThemeExtension with _$AppTextSchemeTailorMixin { /// Text style with a size of 45/52. /// Use for short, important text or numerals. + @override final TextStyle display; /// Text style with a size of 28/36. /// Use for marking primary passages of text or important regions of content. + @override final TextStyle headline; /// Text style with a size of 12/16. /// Use for things like the text inside components or for very small text in the content body. + @override final TextStyle label; - const AppTextScheme._({ + /// @odoc + const AppTextScheme({ required this.display, required this.headline, required this.label, @@ -27,41 +35,4 @@ class AppTextScheme extends ThemeExtension { : display = AppTextStyle.displayMedium.value, headline = AppTextStyle.headlineMedium.value, label = AppTextStyle.labelMedium.value; - - @override - ThemeExtension lerp( - ThemeExtension? other, - double t, - ) { - if (other is! AppTextScheme) { - return this; - } - - return AppTextScheme._( - display: TextStyle.lerp(display, other.display, t)!, - headline: TextStyle.lerp(headline, other.headline, t)!, - label: TextStyle.lerp(label, other.label, t)!, - ); - } - - /// Return text theme for app from context. - static AppTextScheme of(BuildContext context) { - return Theme.of(context).extension() ?? _throwThemeExceptionFromFunc(context); - } - - /// @nodoc. - @override - AppTextScheme copyWith({ - TextStyle? display, - TextStyle? headline, - TextStyle? label, - }) { - return AppTextScheme._( - display: display ?? this.display, - headline: headline ?? this.headline, - label: label ?? this.label, - ); - } } - -Never _throwThemeExceptionFromFunc(BuildContext context) => throw Exception('$AppTextScheme not found in $context'); diff --git a/lib/uikit/text/app_text_scheme.tailor.dart b/lib/uikit/text/app_text_scheme.tailor.dart new file mode 100644 index 00000000..8bd909bf --- /dev/null +++ b/lib/uikit/text/app_text_scheme.tailor.dart @@ -0,0 +1,62 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint, unused_element, unnecessary_cast + +part of 'app_text_scheme.dart'; + +// ************************************************************************** +// TailorAnnotationsGenerator +// ************************************************************************** + +mixin _$AppTextSchemeTailorMixin on ThemeExtension { + TextStyle get display; + TextStyle get headline; + TextStyle get label; + + @override + AppTextScheme copyWith({ + TextStyle? display, + TextStyle? headline, + TextStyle? label, + }) { + return AppTextScheme( + display: display ?? this.display, + headline: headline ?? this.headline, + label: label ?? this.label, + ); + } + + @override + AppTextScheme lerp(covariant ThemeExtension? other, double t) { + if (other is! AppTextScheme) return this as AppTextScheme; + return AppTextScheme( + display: TextStyle.lerp(display, other.display, t)!, + headline: TextStyle.lerp(headline, other.headline, t)!, + label: TextStyle.lerp(label, other.label, t)!, + ); + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is AppTextScheme && + const DeepCollectionEquality().equals(display, other.display) && + const DeepCollectionEquality().equals(headline, other.headline) && + const DeepCollectionEquality().equals(label, other.label)); + } + + @override + int get hashCode { + return Object.hash( + runtimeType.hashCode, + const DeepCollectionEquality().hash(display), + const DeepCollectionEquality().hash(headline), + const DeepCollectionEquality().hash(label), + ); + } +} + +extension AppTextSchemeBuildContext on BuildContext { + AppTextScheme get appTextScheme => Theme.of(this).extension()!; +} diff --git a/pubspec.lock b/pubspec.lock index a66cc3a3..927fde88 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -137,6 +137,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.3.0" + build_test: + dependency: transitive + description: + name: build_test + sha256: "260dbba934f41b0a42935e9cae1f5731b94f0c3e489dc97bcf8e281265aaa5ae" + url: "https://pub.dev" + source: hosted + version: "2.2.2" built_collection: dependency: transitive description: @@ -233,6 +241,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.1" + coverage: + dependency: transitive + description: + name: coverage + sha256: "3945034e86ea203af7a056d98e98e42a5518fff200d6e8e6647e1886b07e936e" + url: "https://pub.dev" + source: hosted + version: "1.8.0" crypto: dependency: transitive description: @@ -470,7 +486,7 @@ packages: source: sdk version: "0.0.0" freezed: - dependency: "direct main" + dependency: "direct dev" description: name: freezed sha256: "57247f692f35f068cae297549a46a9a097100685c6780fe67177503eea5ed4e5" @@ -717,6 +733,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + node_preamble: + dependency: transitive + description: + name: node_preamble + sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db" + url: "https://pub.dev" + source: hosted + version: "2.0.2" octo_image: dependency: transitive description: @@ -957,6 +981,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.4.1" + shelf_packages_handler: + dependency: transitive + description: + name: shelf_packages_handler + sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e" + url: "https://pub.dev" + source: hosted + version: "3.0.2" + shelf_static: + dependency: transitive + description: + name: shelf_static + sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e + url: "https://pub.dev" + source: hosted + version: "1.1.2" shelf_web_socket: dependency: transitive description: @@ -986,6 +1026,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.5.0" + source_gen_test: + dependency: transitive + description: + name: source_gen_test + sha256: "0929da347d2dd868fed3a278b52ab4bf4467cff9a8cae40b6abbd6e96e5c4840" + url: "https://pub.dev" + source: hosted + version: "1.0.6" source_helper: dependency: transitive description: @@ -994,6 +1042,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.3.4" + source_map_stack_trace: + dependency: transitive + description: + name: source_map_stack_trace + sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae" + url: "https://pub.dev" + source: hosted + version: "2.1.1" + source_maps: + dependency: transitive + description: + name: source_maps + sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703" + url: "https://pub.dev" + source: hosted + version: "0.10.12" source_span: dependency: transitive description: @@ -1114,6 +1178,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.1" + test: + dependency: transitive + description: + name: test + sha256: a1f7595805820fcc05e5c52e3a231aedd0b72972cb333e8c738a8b1239448b6f + url: "https://pub.dev" + source: hosted + version: "1.24.9" test_api: dependency: transitive description: @@ -1122,6 +1194,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.6.1" + test_core: + dependency: transitive + description: + name: test_core + sha256: a757b14fc47507060a162cc2530d9a4a2f92f5100a952c7443b5cad5ef5b106a + url: "https://pub.dev" + source: hosted + version: "0.5.9" + theme_tailor: + dependency: "direct dev" + description: + name: theme_tailor + sha256: "176c88b37f56996c2dc7b9e426a2db6fd66f95e1454288f7205ea4faa9380a3a" + url: "https://pub.dev" + source: hosted + version: "3.0.1" + theme_tailor_annotation: + dependency: "direct main" + description: + name: theme_tailor_annotation + sha256: "2990264653b700c7eece3557a5fe5f999cdcd32981aed67023a66004943db08d" + url: "https://pub.dev" + source: hosted + version: "3.0.1" timing: dependency: transitive description: @@ -1234,6 +1330,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.4.5" + webkit_inspection_protocol: + dependency: transitive + description: + name: webkit_inspection_protocol + sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572" + url: "https://pub.dev" + source: hosted + version: "1.2.1" win32: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 544934b8..01310729 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -19,7 +19,6 @@ dependencies: sdk: flutter flutter_secure_storage: 9.0.0 flutter_svg: 2.0.9 - freezed: 2.4.7 freezed_annotation: 2.4.1 fresh_dio: 0.4.1 intl: @@ -36,6 +35,7 @@ dependencies: shimmer: 3.0.0 surf_logger: 2.0.0 surf_widget_test_composer: 0.0.2 + theme_tailor_annotation: 3.0.1 union_state: 0.0.1 dev_dependencies: @@ -46,6 +46,7 @@ dev_dependencies: flutter_native_splash: 2.3.9 flutter_test: sdk: flutter + freezed: 2.4.7 golden_toolkit: 0.15.0 json_serializable: 6.7.1 mocktail: 1.0.3 @@ -53,6 +54,7 @@ dev_dependencies: spider: 4.2.2 surf_dcm_presets: 0.0.2 surf_lint_rules: 3.0.0 + theme_tailor: 3.0.1 environment: sdk: '>=3.2.5 <4.0.0'