From a20af84d5470e091a1ab132ee4289ed2ebc2cc22 Mon Sep 17 00:00:00 2001 From: Hugo Pointcheval Date: Tue, 21 Feb 2023 15:17:05 +0100 Subject: [PATCH] fix(ui): use multicolor in cards --- .../domain/entities/cards/card_component.dart | 5 ++-- .../cards/information_card_component.g.dart | 8 +++--- .../cards/portfolio_card_component.g.dart | 8 +++--- .../cards/quote_card_component.g.dart | 8 +++--- .../cards/skill_card_component.g.dart | 8 +++--- .../information_card/information_card.g.dart | 8 +++--- .../portfolio_card/portfolio_card.g.dart | 8 +++--- .../cards/quote_card/quote_card.g.dart | 8 +++--- .../cards/skill_card/skill_card.g.dart | 8 +++--- .../cards/widgets/card_wrapper.dart | 26 +++++++++---------- .../lib/src/core/helpers/helpers.dart | 1 + .../lib/src/core/helpers/theme_helper.dart | 2 +- 12 files changed, 49 insertions(+), 49 deletions(-) diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart index bafc5c9a..2085f99c 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/card_component.dart @@ -15,6 +15,7 @@ // along with this program. If not, see . import 'package:flutter/widgets.dart'; +import 'package:wyatt_ui_components/src/core/utils/multi_color.dart'; import 'package:wyatt_ui_components/src/domain/entities/component.dart'; abstract class CardComponent extends Component { @@ -41,10 +42,10 @@ abstract class CardComponent extends Component { final double? padding; /// Border gradient color (from left to right) - final List? borderColors; + final MultiColor? borderColors; /// Card background color - final List? backgroundColors; + final MultiColor? backgroundColors; /// Minimum size for this card final Size? minSize; diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart index 4802eb9e..59c9369e 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/information_card_component.g.dart @@ -14,8 +14,8 @@ abstract class $InformationCardComponentCWProxy { InformationCardComponent axis(Axis? axis); InformationCardComponent radius(double? radius); InformationCardComponent padding(double? padding); - InformationCardComponent borderColors(List? borderColors); - InformationCardComponent backgroundColors(List? backgroundColors); + InformationCardComponent borderColors(MultiColor? borderColors); + InformationCardComponent backgroundColors(MultiColor? backgroundColors); InformationCardComponent minSize(Size? minSize); InformationCardComponent maxSize(Size? maxSize); InformationCardComponent shadow(BoxShadow? shadow); @@ -29,8 +29,8 @@ abstract class $InformationCardComponentCWProxy { Axis? axis, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/portfolio_card_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/portfolio_card_component.g.dart index a21bd6bc..87ddefb6 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/cards/portfolio_card_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/portfolio_card_component.g.dart @@ -19,8 +19,8 @@ abstract class $PortfolioCardComponentCWProxy { PortfolioCardComponent assets(List? assets); PortfolioCardComponent radius(double? radius); PortfolioCardComponent padding(double? padding); - PortfolioCardComponent borderColors(List? borderColors); - PortfolioCardComponent backgroundColors(List? backgroundColors); + PortfolioCardComponent borderColors(MultiColor? borderColors); + PortfolioCardComponent backgroundColors(MultiColor? backgroundColors); PortfolioCardComponent minSize(Size? minSize); PortfolioCardComponent maxSize(Size? maxSize); PortfolioCardComponent shadow(BoxShadow? shadow); @@ -38,8 +38,8 @@ abstract class $PortfolioCardComponentCWProxy { List? assets, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart index 0ce84883..cef1cb7d 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/quote_card_component.g.dart @@ -16,8 +16,8 @@ abstract class $QuoteCardComponentCWProxy { QuoteCardComponent rightQuote(Widget? rightQuote); QuoteCardComponent radius(double? radius); QuoteCardComponent padding(double? padding); - QuoteCardComponent borderColors(List? borderColors); - QuoteCardComponent backgroundColors(List? backgroundColors); + QuoteCardComponent borderColors(MultiColor? borderColors); + QuoteCardComponent backgroundColors(MultiColor? backgroundColors); QuoteCardComponent minSize(Size? minSize); QuoteCardComponent maxSize(Size? maxSize); QuoteCardComponent shadow(BoxShadow? shadow); @@ -33,8 +33,8 @@ abstract class $QuoteCardComponentCWProxy { Widget? rightQuote, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_components/lib/src/domain/entities/cards/skill_card_component.g.dart b/packages/wyatt_ui_components/lib/src/domain/entities/cards/skill_card_component.g.dart index a69c819d..86094931 100644 --- a/packages/wyatt_ui_components/lib/src/domain/entities/cards/skill_card_component.g.dart +++ b/packages/wyatt_ui_components/lib/src/domain/entities/cards/skill_card_component.g.dart @@ -17,8 +17,8 @@ abstract class $SkillCardComponentCWProxy { Color? secondaryBackgroundColors); SkillCardComponent radius(double? radius); SkillCardComponent padding(double? padding); - SkillCardComponent borderColors(List? borderColors); - SkillCardComponent backgroundColors(List? backgroundColors); + SkillCardComponent borderColors(MultiColor? borderColors); + SkillCardComponent backgroundColors(MultiColor? backgroundColors); SkillCardComponent minSize(Size? minSize); SkillCardComponent maxSize(Size? maxSize); SkillCardComponent shadow(BoxShadow? shadow); @@ -34,8 +34,8 @@ abstract class $SkillCardComponentCWProxy { Color? secondaryBackgroundColors, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.g.dart b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.g.dart index 1378d99c..16365148 100644 --- a/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.g.dart +++ b/packages/wyatt_ui_kit/lib/src/components/cards/information_card/information_card.g.dart @@ -24,10 +24,10 @@ class $InformationCardCWProxyImpl implements $InformationCardComponentCWProxy { @override InformationCard padding(double? padding) => this(padding: padding); @override - InformationCard borderColors(List? borderColors) => + InformationCard borderColors(MultiColor? borderColors) => this(borderColors: borderColors); @override - InformationCard backgroundColors(List? backgroundColors) => + InformationCard backgroundColors(MultiColor? backgroundColors) => this(backgroundColors: backgroundColors); @override InformationCard minSize(Size? minSize) => this(minSize: minSize); @@ -49,8 +49,8 @@ class $InformationCardCWProxyImpl implements $InformationCardComponentCWProxy { Axis? axis, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/portfolio_card/portfolio_card.g.dart b/packages/wyatt_ui_kit/lib/src/components/cards/portfolio_card/portfolio_card.g.dart index 0142a408..735f8f58 100644 --- a/packages/wyatt_ui_kit/lib/src/components/cards/portfolio_card/portfolio_card.g.dart +++ b/packages/wyatt_ui_kit/lib/src/components/cards/portfolio_card/portfolio_card.g.dart @@ -36,10 +36,10 @@ class $PortfolioCardCWProxyImpl implements $PortfolioCardComponentCWProxy { @override PortfolioCard padding(double? padding) => this(padding: padding); @override - PortfolioCard borderColors(List? borderColors) => + PortfolioCard borderColors(MultiColor? borderColors) => this(borderColors: borderColors); @override - PortfolioCard backgroundColors(List? backgroundColors) => + PortfolioCard backgroundColors(MultiColor? backgroundColors) => this(backgroundColors: backgroundColors); @override PortfolioCard minSize(Size? minSize) => this(minSize: minSize); @@ -64,8 +64,8 @@ class $PortfolioCardCWProxyImpl implements $PortfolioCardComponentCWProxy { List? assets, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/quote_card/quote_card.g.dart b/packages/wyatt_ui_kit/lib/src/components/cards/quote_card/quote_card.g.dart index 548c0088..90c7d5f2 100644 --- a/packages/wyatt_ui_kit/lib/src/components/cards/quote_card/quote_card.g.dart +++ b/packages/wyatt_ui_kit/lib/src/components/cards/quote_card/quote_card.g.dart @@ -28,10 +28,10 @@ class $QuoteCardCWProxyImpl implements $QuoteCardComponentCWProxy { @override QuoteCard padding(double? padding) => this(padding: padding); @override - QuoteCard borderColors(List? borderColors) => + QuoteCard borderColors(MultiColor? borderColors) => this(borderColors: borderColors); @override - QuoteCard backgroundColors(List? backgroundColors) => + QuoteCard backgroundColors(MultiColor? backgroundColors) => this(backgroundColors: backgroundColors); @override QuoteCard minSize(Size? minSize) => this(minSize: minSize); @@ -54,8 +54,8 @@ class $QuoteCardCWProxyImpl implements $QuoteCardComponentCWProxy { Widget? rightQuote, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/skill_card/skill_card.g.dart b/packages/wyatt_ui_kit/lib/src/components/cards/skill_card/skill_card.g.dart index 96f74491..e66fe9e2 100644 --- a/packages/wyatt_ui_kit/lib/src/components/cards/skill_card/skill_card.g.dart +++ b/packages/wyatt_ui_kit/lib/src/components/cards/skill_card/skill_card.g.dart @@ -31,10 +31,10 @@ class $SkillCardCWProxyImpl implements $SkillCardComponentCWProxy { @override SkillCard padding(double? padding) => this(padding: padding); @override - SkillCard borderColors(List? borderColors) => + SkillCard borderColors(MultiColor? borderColors) => this(borderColors: borderColors); @override - SkillCard backgroundColors(List? backgroundColors) => + SkillCard backgroundColors(MultiColor? backgroundColors) => this(backgroundColors: backgroundColors); @override SkillCard minSize(Size? minSize) => this(minSize: minSize); @@ -57,8 +57,8 @@ class $SkillCardCWProxyImpl implements $SkillCardComponentCWProxy { Color? secondaryBackgroundColors, double? radius, double? padding, - List? borderColors, - List? backgroundColors, + MultiColor? borderColors, + MultiColor? backgroundColors, Size? minSize, Size? maxSize, BoxShadow? shadow, diff --git a/packages/wyatt_ui_kit/lib/src/components/cards/widgets/card_wrapper.dart b/packages/wyatt_ui_kit/lib/src/components/cards/widgets/card_wrapper.dart index 75473d0b..c2b91ca4 100644 --- a/packages/wyatt_ui_kit/lib/src/components/cards/widgets/card_wrapper.dart +++ b/packages/wyatt_ui_kit/lib/src/components/cards/widgets/card_wrapper.dart @@ -15,9 +15,9 @@ // along with this program. If not, see . import 'package:flutter/material.dart'; +import 'package:wyatt_ui_components/wyatt_wyatt_ui_components.dart'; import 'package:wyatt_ui_kit/src/components/cards/widgets/card_background.dart'; -import 'package:wyatt_ui_kit/src/components/gradients/gradient_box_border.dart'; -import 'package:wyatt_ui_kit/src/domain/card_theme_extension.dart'; +import 'package:wyatt_ui_kit/wyatt_ui_kit.dart'; class CardWrapper extends StatelessWidget { CardWrapper({ @@ -34,8 +34,8 @@ class CardWrapper extends StatelessWidget { final Widget? background; final Widget child; - final List? backgroundColors; - final List? borderColors; + final MultiColor? backgroundColors; + final MultiColor? borderColors; final BoxShadow? shadow; final Size? minSize; final Size? maxSize; @@ -67,8 +67,8 @@ class CardWrapper extends StatelessWidget { ); Gradient? _cardGradient(BuildContext context) { - if (backgroundColors != null && backgroundColors!.length >= 2) { - return LinearGradient(colors: backgroundColors!); + if (backgroundColors != null && backgroundColors!.isGradient) { + return LinearGradientHelper.fromMultiColor(backgroundColors!); } else { final extensionCardColor = Theme.of(context).extension(); @@ -85,8 +85,8 @@ class CardWrapper extends StatelessWidget { } Color? _cardColor(BuildContext context) { - if (backgroundColors != null && backgroundColors!.length == 1) { - return backgroundColors!.first; + if (backgroundColors != null && backgroundColors!.isColor) { + return backgroundColors!.color; } else { final extensionCardColor = Theme.of(context).extension(); @@ -101,15 +101,13 @@ class CardWrapper extends StatelessWidget { BoxBorder? _boxBorder(BuildContext context) { if (borderColors != null) { - if (borderColors!.length >= 2) { + if (borderColors!.isGradient) { return GradientBoxBorder( - gradient: LinearGradient( - colors: borderColors!, - ), + gradient: LinearGradientHelper.fromMultiColor(borderColors!), ); - } else if (borderColors!.isNotEmpty) { + } else if (borderColors!.isColor) { return Border.all( - color: borderColors!.first, + color: borderColors!.color, ); } } else { diff --git a/packages/wyatt_ui_kit/lib/src/core/helpers/helpers.dart b/packages/wyatt_ui_kit/lib/src/core/helpers/helpers.dart index 35d48e7f..0e95fe99 100644 --- a/packages/wyatt_ui_kit/lib/src/core/helpers/helpers.dart +++ b/packages/wyatt_ui_kit/lib/src/core/helpers/helpers.dart @@ -15,3 +15,4 @@ // along with this program. If not, see . export './linear_gradient_helper.dart'; +export './theme_helper.dart'; diff --git a/packages/wyatt_ui_kit/lib/src/core/helpers/theme_helper.dart b/packages/wyatt_ui_kit/lib/src/core/helpers/theme_helper.dart index f5164d65..5414bfce 100644 --- a/packages/wyatt_ui_kit/lib/src/core/helpers/theme_helper.dart +++ b/packages/wyatt_ui_kit/lib/src/core/helpers/theme_helper.dart @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with super program. If not, see . -class ThemeHelper { +abstract class ThemeHelper { static T? getThemeElement( List? styles, { required T? Function(P?)? transform,