diff --git a/packages/remix/demo/lib/components/card_use_case.dart b/packages/remix/demo/lib/components/card_use_case.dart index 793678125..8eb85704c 100644 --- a/packages/remix/demo/lib/components/card_use_case.dart +++ b/packages/remix/demo/lib/components/card_use_case.dart @@ -15,30 +15,32 @@ Widget buildCard(BuildContext context) { variants: [ context.knobs.variant(FortalezaCardStyle.variants), ], - children: [ - Avatar( - fallbackBuilder: (spec) => spec('LF'), - variants: FortalezaCardStyle.variants, - ), - Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.start, - children: [ - StyledText( - 'Leo Farias', - style: Style($text.style.ref($rx.text.text3)), - ), - StyledText( - 'Flutter Engineer', - style: Style( - $text.style.ref($rx.text.text2), - $text.style.color.$neutral(10), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Avatar( + fallbackBuilder: (spec) => spec('LF'), + ), + Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.start, + children: [ + StyledText( + 'Leo Farias', + style: Style($text.style.ref($rx.text.text3)), ), - ), - ], - ), - ], + StyledText( + 'Flutter Engineer', + style: Style( + $text.style.ref($rx.text.text2), + $text.style.color.$neutral(10), + ), + ), + ], + ), + ], + ), ), ); } diff --git a/packages/remix/lib/src/components/badge/badge_style.dart b/packages/remix/lib/src/components/badge/badge_style.dart index 9a128d633..3ae329ff8 100644 --- a/packages/remix/lib/src/components/badge/badge_style.dart +++ b/packages/remix/lib/src/components/badge/badge_style.dart @@ -19,12 +19,8 @@ class BadgeStyle extends SpecStyle { final labelStyle = [ $.label.chain - ..textHeightBehavior( - const TextHeightBehavior( - applyHeightToFirstAscent: false, - applyHeightToLastDescent: true, - ), - ) + ..textHeightBehavior.heightToFirstAscent.off() + ..textHeightBehavior.heightToLastDescent.on() ..textAlign.center() ..style.height(1.5) ..style.fontWeight.w500() diff --git a/packages/remix/lib/src/components/button/button_style.dart b/packages/remix/lib/src/components/button/button_style.dart index dcf1dc828..9d8c69f97 100644 --- a/packages/remix/lib/src/components/button/button_style.dart +++ b/packages/remix/lib/src/components/button/button_style.dart @@ -23,12 +23,8 @@ class ButtonStyle extends SpecStyle { final labelStyle = [ $.label.chain - ..textHeightBehavior( - const TextHeightBehavior( - applyHeightToFirstAscent: false, - applyHeightToLastDescent: true, - ), - ) + ..textHeightBehavior.heightToFirstAscent.off() + ..textHeightBehavior.heightToLastDescent.on() ..style.fontSize(14) ..style.height(1.5) ..style.color.white() diff --git a/packages/remix/lib/src/components/card/card.dart b/packages/remix/lib/src/components/card/card.dart index 7bf85cb5a..eab016e73 100644 --- a/packages/remix/lib/src/components/card/card.dart +++ b/packages/remix/lib/src/components/card/card.dart @@ -16,8 +16,6 @@ part 'card_widget.dart'; base class CardSpec extends Spec with _$CardSpec, Diagnosticable { final BoxSpec container; - final FlexSpec flex; - /// {@macro card_spec_of} static const of = _$CardSpec.of; @@ -25,14 +23,12 @@ base class CardSpec extends Spec with _$CardSpec, Diagnosticable { const CardSpec({ BoxSpec? container, - FlexSpec? flex, super.modifiers, super.animated, - }) : container = container ?? const BoxSpec(), - flex = flex ?? const FlexSpec(); + }) : container = container ?? const BoxSpec(); - Widget call({Key? key, required List children}) { - return CardSpecWidget(key: key, spec: this, children: children); + Widget call({Key? key, required Widget child}) { + return CardSpecWidget(key: key, spec: this, child: child); } @override diff --git a/packages/remix/lib/src/components/card/card.g.dart b/packages/remix/lib/src/components/card/card.g.dart index a1ce8ab5e..fbf4b463f 100644 --- a/packages/remix/lib/src/components/card/card.g.dart +++ b/packages/remix/lib/src/components/card/card.g.dart @@ -34,13 +34,11 @@ mixin _$CardSpec on Spec { @override CardSpec copyWith({ BoxSpec? container, - FlexSpec? flex, WidgetModifiersData? modifiers, AnimatedData? animated, }) { return CardSpec( container: container ?? _$this.container, - flex: flex ?? _$this.flex, modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); @@ -58,7 +56,6 @@ mixin _$CardSpec on Spec { /// interpolation method: /// /// - [BoxSpec.lerp] for [container]. - /// - [FlexSpec.lerp] for [flex]. /// For [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [CardSpec] is used. Otherwise, the value @@ -72,7 +69,6 @@ mixin _$CardSpec on Spec { return CardSpec( container: _$this.container.lerp(other.container, t), - flex: _$this.flex.lerp(other.flex, t), modifiers: other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); @@ -85,7 +81,6 @@ mixin _$CardSpec on Spec { @override List get props => [ _$this.container, - _$this.flex, _$this.modifiers, _$this.animated, ]; @@ -95,8 +90,6 @@ mixin _$CardSpec on Spec { void _debugFillProperties(DiagnosticPropertiesBuilder properties) { properties.add( DiagnosticsProperty('container', _$this.container, defaultValue: null)); - properties - .add(DiagnosticsProperty('flex', _$this.flex, defaultValue: null)); properties.add( DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); properties.add( @@ -114,11 +107,9 @@ mixin _$CardSpec on Spec { base class CardSpecAttribute extends SpecAttribute with Diagnosticable { final BoxSpecAttribute? container; - final FlexSpecAttribute? flex; const CardSpecAttribute({ this.container, - this.flex, super.modifiers, super.animated, }); @@ -135,7 +126,6 @@ base class CardSpecAttribute extends SpecAttribute CardSpec resolve(MixData mix) { return CardSpec( container: container?.resolve(mix), - flex: flex?.resolve(mix), modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); @@ -155,7 +145,6 @@ base class CardSpecAttribute extends SpecAttribute return CardSpecAttribute( container: container?.merge(other.container) ?? other.container, - flex: flex?.merge(other.flex) ?? other.flex, modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); @@ -168,7 +157,6 @@ base class CardSpecAttribute extends SpecAttribute @override List get props => [ container, - flex, modifiers, animated, ]; @@ -178,7 +166,6 @@ base class CardSpecAttribute extends SpecAttribute super.debugFillProperties(properties); properties .add(DiagnosticsProperty('container', container, defaultValue: null)); - properties.add(DiagnosticsProperty('flex', flex, defaultValue: null)); properties .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); properties @@ -195,9 +182,6 @@ class CardSpecUtility /// Utility for defining [CardSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); - /// Utility for defining [CardSpecAttribute.flex] - late final flex = FlexSpecUtility((v) => only(flex: v)); - /// Utility for defining [CardSpecAttribute.modifiers] late final wrap = SpecModifierUtility((v) => only(modifiers: v)); @@ -216,13 +200,11 @@ class CardSpecUtility @override T only({ BoxSpecAttribute? container, - FlexSpecAttribute? flex, WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(CardSpecAttribute( container: container, - flex: flex, modifiers: modifiers, animated: animated, )); diff --git a/packages/remix/lib/src/components/card/card_style.dart b/packages/remix/lib/src/components/card/card_style.dart index bcc484632..b3145d2dd 100644 --- a/packages/remix/lib/src/components/card/card_style.dart +++ b/packages/remix/lib/src/components/card/card_style.dart @@ -15,13 +15,7 @@ class CardStyle extends SpecStyle { ..padding.all(8), ]; - final flexStyle = [ - $.flex.chain - ..mainAxisSize.min() - ..direction.vertical(), - ]; - - return Style.create([...containerStyle, ...flexStyle]); + return Style.create([...containerStyle]); } } diff --git a/packages/remix/lib/src/components/card/card_widget.dart b/packages/remix/lib/src/components/card/card_widget.dart index 62eef8afc..e81458991 100644 --- a/packages/remix/lib/src/components/card/card_widget.dart +++ b/packages/remix/lib/src/components/card/card_widget.dart @@ -3,13 +3,13 @@ part of 'card.dart'; class Card extends StatelessWidget { const Card({ super.key, - required this.children, + required this.child, this.style, this.variants = const [], }); /// The list of child widgets to be displayed inside the card. - final List children; + final Widget child; /// Additional custom styling for the card. /// @@ -28,7 +28,7 @@ class Card extends StatelessWidget { builder: (context) { final spec = CardSpec.of(context); - return CardSpecWidget(spec: spec, children: children); + return CardSpecWidget(spec: spec, child: child); }, ); } @@ -38,16 +38,16 @@ class CardSpecWidget extends StatelessWidget { const CardSpecWidget({ super.key, required this.spec, - required this.children, + required this.child, }); final CardSpec? spec; - final List children; + final Widget child; @override Widget build(BuildContext context) { return spec!.container( - child: spec!.flex(direction: Axis.vertical, children: children), + child: child, ); } } diff --git a/packages/remix/lib/src/components/radio/radio_style.dart b/packages/remix/lib/src/components/radio/radio_style.dart index 554fd0572..1c256cdbe 100644 --- a/packages/remix/lib/src/components/radio/radio_style.dart +++ b/packages/remix/lib/src/components/radio/radio_style.dart @@ -28,32 +28,23 @@ class RadioStyle extends SpecStyle { spec.on.disabled($.indicator.color.black45()), ]; - final textStyle = [ - $.text.chain - ..style.fontSize(14) - ..style.height(1) - ..style.fontWeight.w500() - ..textHeightBehavior( - const TextHeightBehavior( - applyHeightToFirstAscent: false, - applyHeightToLastDescent: false, - ), - ), - ]; + final textStyle = $.text.chain + ..style.fontSize(14) + ..style.height(1) + ..style.fontWeight.w500() + ..textHeightBehavior.heightToFirstAscent.off(); - final flexStyle = [ - $.flex.chain - ..row() - ..mainAxisAlignment.start() - ..crossAxisAlignment.center() - ..gap(8), - ]; + final flexStyle = $.flex.chain + ..row() + ..mainAxisAlignment.start() + ..crossAxisAlignment.center() + ..gap(8); return Style.create([ ...containerStyle, ...indicatorStyle, - ...textStyle, - ...flexStyle, + textStyle, + flexStyle, ]).animate( duration: const Duration(milliseconds: 100), curve: Curves.easeInOutQuad, diff --git a/packages/remix/test/components/card/card_widget_test.dart b/packages/remix/test/components/card/card_widget_test.dart index 2763f4101..fb74f6c49 100644 --- a/packages/remix/test/components/card/card_widget_test.dart +++ b/packages/remix/test/components/card/card_widget_test.dart @@ -10,7 +10,7 @@ void main() { const m.MaterialApp( home: Card( style: CardStyle(), - children: [m.Text('Test')], + child: m.Text('Test'), ), ), ); @@ -26,7 +26,7 @@ void main() { const m.MaterialApp( home: Card( style: FakeCardStyle(color), - children: [m.Text('Custom Style')], + child: m.Text('Custom Style'), ), ), ); @@ -40,18 +40,12 @@ void main() { const m.MaterialApp( home: Card( style: CardStyle(), - children: [ - m.Text('Child 1'), - m.Text('Child 2'), - m.Text('Child 3'), - ], + child: m.Text('Child 1'), ), ), ); expect(find.text('Child 1'), findsOneWidget); - expect(find.text('Child 2'), findsOneWidget); - expect(find.text('Child 3'), findsOneWidget); }); }); }