Skip to content

Commit

Permalink
small changes in RemixCards
Browse files Browse the repository at this point in the history
  • Loading branch information
tilucasoli committed Feb 7, 2024
1 parent 7ebf90b commit 0e0b3b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
30 changes: 22 additions & 8 deletions lib/components/card/card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -11,16 +13,14 @@ class PresableRemixCard extends RemixCard {
});
}

class RemixCard extends StatelessWidget {
class RemixCard extends StatelessWidget
implements RemixComponentRecipe<CardStyles> {
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, {
Expand All @@ -34,9 +34,23 @@ class RemixCard extends StatelessWidget {
);
}

final Widget child;

@override
final CardStyles? style;

@override
final List<Variant> variants;

CardStyles buildStyle(List<Variant> 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,
Expand Down
9 changes: 1 addition & 8 deletions lib/components/card/card.style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,7 @@ class CardStyles extends StyleRecipe<CardStyles> {

final Style container;

factory CardStyles.build([
CardStyles? other,
List<Variant> variants = const [],
]) {
return CardStyles.defaults().merge(other).applyVariants(variants);
}

factory CardStyles.defaults() {
factory CardStyles.base() {
return CardStyles(
container: Style(
box.padding(16),
Expand Down

0 comments on commit 0e0b3b5

Please sign in to comment.