From 0e0b3b5edee3dfd68780b5d9812ae6de83d057b6 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:28:09 -0300 Subject: [PATCH] small changes in RemixCards --- lib/components/card/card.dart | 30 +++++++++++++++++++++-------- lib/components/card/card.style.dart | 9 +-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/lib/components/card/card.dart b/lib/components/card/card.dart index 72f5e12..8c3bd00 100644 --- a/lib/components/card/card.dart +++ b/lib/components/card/card.dart @@ -2,6 +2,8 @@ import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; import 'package:remix_ui/components/card/card.style.dart'; +import '../../utils/component_recipe.dart'; + class PresableRemixCard extends RemixCard { const PresableRemixCard({ super.key, @@ -11,16 +13,14 @@ class PresableRemixCard extends RemixCard { }); } -class RemixCard extends StatelessWidget { +class RemixCard extends StatelessWidget + implements RemixComponentRecipe { const RemixCard({ super.key, required this.child, - CardStyles? style, - }) : _customStyle = style; - - final Widget child; - - final CardStyles? _customStyle; + this.style, + this.variants = const [], + }); factory RemixCard.pressable( Widget child, { @@ -34,9 +34,23 @@ class RemixCard extends StatelessWidget { ); } + final Widget child; + + @override + final CardStyles? style; + + @override + final List variants; + + CardStyles buildStyle(List variants) { + final result = style == null ? CardStyles.base() : style!; + + return result.applyVariants(variants); + } + @override Widget build(BuildContext context) { - final style = CardStyles.build(_customStyle); + final style = buildStyle(variants); return Box( style: style.container, diff --git a/lib/components/card/card.style.dart b/lib/components/card/card.style.dart index 8a962fc..ead52ae 100644 --- a/lib/components/card/card.style.dart +++ b/lib/components/card/card.style.dart @@ -7,14 +7,7 @@ class CardStyles extends StyleRecipe { final Style container; - factory CardStyles.build([ - CardStyles? other, - List variants = const [], - ]) { - return CardStyles.defaults().merge(other).applyVariants(variants); - } - - factory CardStyles.defaults() { + factory CardStyles.base() { return CardStyles( container: Style( box.padding(16),