From 9d909ed6bad43c23ca830771cfe7af638a737ded Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Thu, 25 Jul 2024 14:39:06 -0400 Subject: [PATCH 1/7] Updated folder structure --- .../widget_state/widget_state_controller.dart | 48 +++++++++++++- .../context_variant_util/on_util.dart | 3 + .../mix/lib/src/widgets/pressable_widget.dart | 11 +++- packages/remix/build.yaml | 4 +- .../demo/lib/components/button_use_case.dart | 32 ++++------ .../demo/lib/components/card_use_case.dart | 2 +- .../remix/demo/lib/main.directories.g.dart | 2 +- .../avatar/{avatar_spec.dart => avatar.dart} | 9 ++- .../{avatar_spec.g.dart => avatar.g.dart} | 19 +++--- .../lib/components/avatar/avatar_style.dart | 9 +-- .../components/avatar/avatar_variants.dart | 2 +- .../lib/components/avatar/avatar_widget.dart | 6 +- .../lib/components/badge/badge_spec.g.dart | 17 ++--- .../button/{button_spec.dart => button.dart} | 10 ++- .../{button_spec.g.dart => button.g.dart} | 21 ++++--- .../lib/components/button/button_style.dart | 12 +--- .../components/button/button_variants.dart | 2 +- .../lib/components/button/button_widget.dart | 6 +- .../components/callout/callout_spec.g.dart | 17 ++--- .../card/{card_spec.dart => card.dart} | 8 ++- .../card/{card_spec.g.dart => card.g.dart} | 19 +++--- .../remix/lib/components/card/card_style.dart | 5 +- .../lib/components/card/card_variants.dart | 2 +- .../lib/components/card/card_widget.dart | 6 +- .../{checkbox_spec.dart => checkbox.dart} | 11 +++- .../{checkbox_spec.g.dart => checkbox.g.dart} | 19 +++--- .../components/checkbox/checkbox_style.dart | 22 ++++--- .../checkbox/checkbox_variants.dart | 9 +-- .../components/checkbox/checkbox_widget.dart | 63 ++++++++++++++----- .../checkbox_group/checkbox_group.dart | 3 +- .../{progress_spec.dart => progress.dart} | 8 ++- .../{progress_spec.g.dart => progress.g.dart} | 19 +++--- .../components/progress/progress_style.dart | 7 +-- .../progress/progress_variants.dart | 4 +- .../components/progress/progress_widget.dart | 6 +- .../radio/{radio_spec.dart => radio.dart} | 11 +++- .../radio/{radio_spec.g.dart => radio.g.dart} | 19 +++--- .../lib/components/radio/radio_style.dart | 13 +--- .../lib/components/radio/radio_variants.dart | 2 +- .../lib/components/radio/radio_widget.dart | 6 +- .../{spinner_spec.dart => spinner.dart} | 12 +++- .../{spinner_spec.g.dart => spinner.g.dart} | 21 ++++--- .../components/spinner/spinner_painter.dart | 4 +- ...{spinner.style.dart => spinner_style.dart} | 5 +- ...er.variants.dart => spinner_variants.dart} | 2 +- .../components/spinner/spinner_widget.dart | 9 +-- .../switch/{switch_spec.dart => switch.dart} | 9 ++- .../{switch_spec.g.dart => switch.g.dart} | 19 +++--- .../lib/components/switch/switch_style.dart | 32 +++++----- .../components/switch/switch_variants.dart | 11 +--- .../lib/components/switch/switch_widget.dart | 7 +-- packages/remix/lib/remix.dart | 29 ++------- 52 files changed, 360 insertions(+), 294 deletions(-) rename packages/remix/lib/components/avatar/{avatar_spec.dart => avatar.dart} (73%) rename packages/remix/lib/components/avatar/{avatar_spec.g.dart => avatar.g.dart} (95%) rename packages/remix/lib/components/button/{button_spec.dart => button.dart} (78%) rename packages/remix/lib/components/button/{button_spec.g.dart => button.g.dart} (95%) rename packages/remix/lib/components/card/{card_spec.dart => card.dart} (75%) rename packages/remix/lib/components/card/{card_spec.g.dart => card.g.dart} (95%) rename packages/remix/lib/components/checkbox/{checkbox_spec.dart => checkbox.dart} (64%) rename packages/remix/lib/components/checkbox/{checkbox_spec.g.dart => checkbox.g.dart} (94%) rename packages/remix/lib/components/progress/{progress_spec.dart => progress.dart} (76%) rename packages/remix/lib/components/progress/{progress_spec.g.dart => progress.g.dart} (95%) rename packages/remix/lib/components/radio/{radio_spec.dart => radio.dart} (65%) rename packages/remix/lib/components/radio/{radio_spec.g.dart => radio.g.dart} (95%) rename packages/remix/lib/components/spinner/{spinner_spec.dart => spinner.dart} (83%) rename packages/remix/lib/components/spinner/{spinner_spec.g.dart => spinner.g.dart} (95%) rename packages/remix/lib/components/spinner/{spinner.style.dart => spinner_style.dart} (74%) rename packages/remix/lib/components/spinner/{spinner.variants.dart => spinner_variants.dart} (93%) rename packages/remix/lib/components/switch/{switch_spec.dart => switch.dart} (69%) rename packages/remix/lib/components/switch/{switch_spec.g.dart => switch.g.dart} (94%) diff --git a/packages/mix/lib/src/core/widget_state/widget_state_controller.dart b/packages/mix/lib/src/core/widget_state/widget_state_controller.dart index e3ba73b50..cabf4d2b4 100644 --- a/packages/mix/lib/src/core/widget_state/widget_state_controller.dart +++ b/packages/mix/lib/src/core/widget_state/widget_state_controller.dart @@ -15,28 +15,68 @@ enum MixWidgetState { static const hasStateOf = MixWidgetStateModel.hasStateOf; } +/// A controller that manages the state of a widget. +/// +/// [MixWidgetStateController] tracks various states of a widget, such as +/// [disabled], [hovered], [focused], [pressed], [dragged], [selected], and +/// [longPressed]. These states are stored in a [Set] called [value]. +/// +/// The controller extends [ChangeNotifier], allowing listeners to be notified +/// when the state of the widget changes. class MixWidgetStateController extends ChangeNotifier { + /// The current set of states for the widget. + /// + /// This is annotated with `@visibleForTesting` to indicate that it is + /// accessible for testing purposes. @visibleForTesting Set value = {}; + /// Whether the widget is currently in the disabled state. bool get disabled => value.contains(MixWidgetState.disabled); + + /// Whether the widget is currently being hovered over. bool get hovered => value.contains(MixWidgetState.hovered); + + /// Whether the widget currently has focus. bool get focused => value.contains(MixWidgetState.focused); + + /// Whether the widget is currently being pressed. bool get pressed => value.contains(MixWidgetState.pressed); + + /// Whether the widget is currently being dragged. bool get dragged => value.contains(MixWidgetState.dragged); + + /// Whether the widget is currently in the selected state. bool get selected => value.contains(MixWidgetState.selected); + + /// Whether the widget is currently being long-pressed. bool get longPressed => value.contains(MixWidgetState.longPressed); + /// Sets whether the widget is in the disabled state. set disabled(bool value) => update(MixWidgetState.disabled, value); + + /// Sets whether the widget is being hovered over. set hovered(bool value) => update(MixWidgetState.hovered, value); + + /// Sets whether the widget has focus. set focused(bool value) => update(MixWidgetState.focused, value); + + /// Sets whether the widget is being pressed. set pressed(bool value) => update(MixWidgetState.pressed, value); + + /// Sets whether the widget is being dragged. set dragged(bool value) => update(MixWidgetState.dragged, value); + + /// Sets whether the widget is in the selected state. set selected(bool value) => update(MixWidgetState.selected, value); + /// Sets whether the widget is being long-pressed. set longPressed(bool value) => update(MixWidgetState.longPressed, value); - // ignore: prefer-named-boolean-parameters + /// Updates the state of the widget for a given [key]. + /// + /// If [add] is true, the [key] state is added to [value]. If false, it is + /// removed. Listeners are notified if the state has changed. void update(MixWidgetState key, bool add) { final valueHasChanged = add ? value.add(key) : value.remove(key); @@ -45,6 +85,11 @@ class MixWidgetStateController extends ChangeNotifier { } } + /// Batch updates the state of the widget with multiple state changes. + /// + /// [updates] is a list of tuples, where each tuple contains a state [key] + /// and a boolean [add] indicating whether to add or remove the state. + /// Listeners are notified if any state has changed. void batch(List<(MixWidgetState, bool)> updates) { var valueHasChanged = false; for (final update in updates) { @@ -62,5 +107,6 @@ class MixWidgetStateController extends ChangeNotifier { } } + /// Checks if the widget is currently in the given state [key]. bool has(MixWidgetState key) => value.contains(key); } diff --git a/packages/mix/lib/src/variants/context_variant_util/on_util.dart b/packages/mix/lib/src/variants/context_variant_util/on_util.dart index 3e9ff05c2..9b0dd8d51 100644 --- a/packages/mix/lib/src/variants/context_variant_util/on_util.dart +++ b/packages/mix/lib/src/variants/context_variant_util/on_util.dart @@ -35,6 +35,9 @@ class OnContextVariantUtility { late final enabled = const OnNotVariant(OnDisabledVariant()); late final disabled = const OnDisabledVariant(); late final longPress = const OnLongPressVariant(); + late final selected = const OnSelectedVariant(); + late final unselected = const OnNotVariant(OnSelectedVariant()); + late final dragged = const OnDraggedVariant(); /// Creates an [OnNotVariant] with the specified [variant]. /// diff --git a/packages/mix/lib/src/widgets/pressable_widget.dart b/packages/mix/lib/src/widgets/pressable_widget.dart index cf15fbe49..c6878ba64 100644 --- a/packages/mix/lib/src/widgets/pressable_widget.dart +++ b/packages/mix/lib/src/widgets/pressable_widget.dart @@ -87,6 +87,7 @@ class Pressable extends StatefulWidget { this.semanticButtonLabel, this.onKeyEvent, this.unpressDelay = kDefaultAnimationDuration, + this.controller, this.actions, }); @@ -143,6 +144,8 @@ class Pressable extends StatefulWidget { /// Actions to be bound to the widget final Map>? actions; + final MixWidgetStateController? controller; + /// The duration to wait after the press is released before the state of pressed is removed final Duration unpressDelay; @@ -152,7 +155,13 @@ class Pressable extends StatefulWidget { @visibleForTesting class PressableWidgetState extends State { - final _controller = MixWidgetStateController(); + late final MixWidgetStateController _controller; + + @override + void initState() { + super.initState(); + _controller = widget.controller ?? MixWidgetStateController(); + } @override void dispose() { diff --git a/packages/remix/build.yaml b/packages/remix/build.yaml index 22a345582..ed7f3fc57 100644 --- a/packages/remix/build.yaml +++ b/packages/remix/build.yaml @@ -3,7 +3,7 @@ targets: builders: mix_generator|spec: generate_for: - - lib/**/*_spec.dart + - lib/components/**/*.dart mix_generator|dto: generate_for: - - lib/**/*_dto.dart \ No newline at end of file + - lib/components/**/*.dart \ No newline at end of file diff --git a/packages/remix/demo/lib/components/button_use_case.dart b/packages/remix/demo/lib/components/button_use_case.dart index b89c06383..8b25faf30 100644 --- a/packages/remix/demo/lib/components/button_use_case.dart +++ b/packages/remix/demo/lib/components/button_use_case.dart @@ -4,46 +4,36 @@ import 'package:remix/remix.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; +final _key = GlobalKey(); @widgetbook.UseCase( name: 'Button Component', - type: RxButton, + type: CustomButton, ) Widget buildButtonUseCase(BuildContext context) { Widget buildButton(ButtonVariant type) { - return RxButton( + return CustomButton( label: context.knobs.string( label: 'Title', initialValue: 'Button', ), onPressed: () {}, - size: context.knobs.list( - label: 'Size', - options: ButtonSize.values, - initialOption: ButtonSize.medium, - labelBuilder: (value) => value.name.split('.').last, - ), - loading: context.knobs.boolean( - label: 'Is loading', - initialValue: false, - ), disabled: context.knobs.boolean( label: 'Disabled', initialValue: false, ), - iconLeft: context.knobs.iconData( + icon: context.knobs.iconData( label: 'Icon left', initialValue: null, ), - iconRight: context.knobs.iconData( - label: 'Icon right', - initialValue: null, - ), - type: type, + variant: type, ); } - return Wrap( - spacing: 12, - children: ButtonVariant.values.map(buildButton).toList(), + return KeyedSubtree( + key: _key, + child: Wrap( + spacing: 12, + children: ButtonVariant.values.map(buildButton).toList(), + ), ); } diff --git a/packages/remix/demo/lib/components/card_use_case.dart b/packages/remix/demo/lib/components/card_use_case.dart index 7c8bf34b5..ebf045445 100644 --- a/packages/remix/demo/lib/components/card_use_case.dart +++ b/packages/remix/demo/lib/components/card_use_case.dart @@ -43,7 +43,7 @@ Widget buildRadioUseCase(BuildContext context) { children: const [StyledText('Hi'), StyledText('This is a test')], ), const SizedBox(height: 10), - RxButton( + CustomButton( label: 'Click me', onPressed: () {}, ), diff --git a/packages/remix/demo/lib/main.directories.g.dart b/packages/remix/demo/lib/main.directories.g.dart index c2a5e7634..679c83de3 100644 --- a/packages/remix/demo/lib/main.directories.g.dart +++ b/packages/remix/demo/lib/main.directories.g.dart @@ -39,7 +39,7 @@ final directories = <_i1.WidgetbookNode>[ name: 'button', children: [ _i1.WidgetbookLeafComponent( - name: 'RxButton', + name: 'CustomButton', useCase: _i1.WidgetbookUseCase( name: 'Button Component', builder: _i3.buildButtonUseCase, diff --git a/packages/remix/lib/components/avatar/avatar_spec.dart b/packages/remix/lib/components/avatar/avatar.dart similarity index 73% rename from packages/remix/lib/components/avatar/avatar_spec.dart rename to packages/remix/lib/components/avatar/avatar.dart index 24922f58f..d6979f69c 100644 --- a/packages/remix/lib/components/avatar/avatar_spec.dart +++ b/packages/remix/lib/components/avatar/avatar.dart @@ -1,8 +1,15 @@ import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; +import 'package:remix/helpers/utility_extension.dart'; -part 'avatar_spec.g.dart'; +import '../../helpers/variant.dart'; +import '../../tokens/remix_tokens.dart'; + +part 'avatar.g.dart'; +part 'avatar_style.dart'; +part 'avatar_variants.dart'; +part 'avatar_widget.dart'; @MixableSpec() base class AvatarSpec extends Spec with _$AvatarSpec { diff --git a/packages/remix/lib/components/avatar/avatar_spec.g.dart b/packages/remix/lib/components/avatar/avatar.g.dart similarity index 95% rename from packages/remix/lib/components/avatar/avatar_spec.g.dart rename to packages/remix/lib/components/avatar/avatar.g.dart index ed5e99c57..5898caa1c 100644 --- a/packages/remix/lib/components/avatar/avatar_spec.g.dart +++ b/packages/remix/lib/components/avatar/avatar.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'avatar_spec.dart'; +part of 'avatar.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$AvatarSpec on Spec { +mixin _$AvatarSpec on Spec { static AvatarSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const AvatarSpec(); @@ -103,7 +101,7 @@ base mixin _$AvatarSpec on Spec { /// /// Use this class to configure the attributes of a [AvatarSpec] and pass it to /// the [AvatarSpec] constructor. -final class AvatarSpecAttribute extends SpecAttribute { +base class AvatarSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final ImageSpecAttribute? image; final TextSpecAttribute? fallback; @@ -170,7 +168,7 @@ final class AvatarSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [AvatarSpecAttribute]. /// Use the methods of this class to configure specific properties of a [AvatarSpecAttribute]. -base class AvatarSpecUtility +class AvatarSpecUtility extends SpecUtility { /// Utility for defining [AvatarSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -217,8 +215,13 @@ class AvatarSpecTween extends Tween { @override AvatarSpec lerp(double t) { - if (begin == null && end == null) return const AvatarSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const AvatarSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/avatar/avatar_style.dart b/packages/remix/lib/components/avatar/avatar_style.dart index cbb6fcb90..769eec2f2 100644 --- a/packages/remix/lib/components/avatar/avatar_style.dart +++ b/packages/remix/lib/components/avatar/avatar_style.dart @@ -1,11 +1,4 @@ -// ignore_for_file: camel_case_types - -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/avatar/avatar_spec.dart'; -import 'package:remix/components/avatar/avatar_variants.dart'; -import 'package:remix/helpers/utility_extension.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'avatar.dart'; final _avatar = AvatarSpecUtility.self; final _container = _avatar.container; diff --git a/packages/remix/lib/components/avatar/avatar_variants.dart b/packages/remix/lib/components/avatar/avatar_variants.dart index 04c79efbe..e7f07bbc1 100644 --- a/packages/remix/lib/components/avatar/avatar_variants.dart +++ b/packages/remix/lib/components/avatar/avatar_variants.dart @@ -1,4 +1,4 @@ -import 'package:remix/helpers/variant.dart'; +part of 'avatar.dart'; abstract interface class IAvatarVariant extends RemixVariant { const IAvatarVariant(String name) : super('avatar.$name'); diff --git a/packages/remix/lib/components/avatar/avatar_widget.dart b/packages/remix/lib/components/avatar/avatar_widget.dart index 14eb51503..b948d3656 100644 --- a/packages/remix/lib/components/avatar/avatar_widget.dart +++ b/packages/remix/lib/components/avatar/avatar_widget.dart @@ -1,8 +1,4 @@ -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/avatar/avatar_spec.dart'; -import 'package:remix/components/avatar/avatar_style.dart'; -import 'package:remix/components/avatar/avatar_variants.dart'; +part of 'avatar.dart'; class RxAvatar extends StatelessWidget { const RxAvatar({ diff --git a/packages/remix/lib/components/badge/badge_spec.g.dart b/packages/remix/lib/components/badge/badge_spec.g.dart index 5d53385c9..6b4e6e4e7 100644 --- a/packages/remix/lib/components/badge/badge_spec.g.dart +++ b/packages/remix/lib/components/badge/badge_spec.g.dart @@ -6,9 +6,7 @@ part of 'badge_spec.dart'; // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$BadgeSpec on Spec { +mixin _$BadgeSpec on Spec { static BadgeSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const BadgeSpec(); @@ -98,7 +96,7 @@ base mixin _$BadgeSpec on Spec { /// /// Use this class to configure the attributes of a [BadgeSpec] and pass it to /// the [BadgeSpec] constructor. -final class BadgeSpecAttribute extends SpecAttribute { +base class BadgeSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final TextSpecAttribute? label; @@ -160,7 +158,7 @@ final class BadgeSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [BadgeSpecAttribute]. /// Use the methods of this class to configure specific properties of a [BadgeSpecAttribute]. -base class BadgeSpecUtility +class BadgeSpecUtility extends SpecUtility { /// Utility for defining [BadgeSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -202,8 +200,13 @@ class BadgeSpecTween extends Tween { @override BadgeSpec lerp(double t) { - if (begin == null && end == null) return const BadgeSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const BadgeSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/button/button_spec.dart b/packages/remix/lib/components/button/button.dart similarity index 78% rename from packages/remix/lib/components/button/button_spec.dart rename to packages/remix/lib/components/button/button.dart index e3216dfe6..f1bb4ce66 100644 --- a/packages/remix/lib/components/button/button_spec.dart +++ b/packages/remix/lib/components/button/button.dart @@ -1,9 +1,15 @@ import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; -import 'package:remix/components/spinner/spinner_spec.dart'; +import 'package:remix/components/spinner/spinner.dart'; -part 'button_spec.g.dart'; +import '../../helpers/variant.dart'; +import '../../tokens/remix_tokens.dart'; + +part 'button.g.dart'; +part 'button_style.dart'; +part 'button_variants.dart'; +part 'button_widget.dart'; @MixableSpec() base class ButtonSpec extends Spec with _$ButtonSpec { diff --git a/packages/remix/lib/components/button/button_spec.g.dart b/packages/remix/lib/components/button/button.g.dart similarity index 95% rename from packages/remix/lib/components/button/button_spec.g.dart rename to packages/remix/lib/components/button/button.g.dart index f8ce7da0a..054467f62 100644 --- a/packages/remix/lib/components/button/button_spec.g.dart +++ b/packages/remix/lib/components/button/button.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'button_spec.dart'; +part of 'button.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$ButtonSpec on Spec { +mixin _$ButtonSpec on Spec { static ButtonSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const ButtonSpec(); @@ -83,7 +81,7 @@ base mixin _$ButtonSpec on Spec { flex: _$this.flex.lerp(other.flex, t), icon: _$this.icon.lerp(other.icon, t), label: _$this.label.lerp(other.label, t), - spinner: t < 0.5 ? _$this.spinner : other.spinner, + spinner: _$this.spinner.lerp(other.spinner, t), animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -112,7 +110,7 @@ base mixin _$ButtonSpec on Spec { /// /// Use this class to configure the attributes of a [ButtonSpec] and pass it to /// the [ButtonSpec] constructor. -final class ButtonSpecAttribute extends SpecAttribute { +base class ButtonSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; final IconSpecAttribute? icon; @@ -189,7 +187,7 @@ final class ButtonSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [ButtonSpecAttribute]. /// Use the methods of this class to configure specific properties of a [ButtonSpecAttribute]. -base class ButtonSpecUtility +class ButtonSpecUtility extends SpecUtility { /// Utility for defining [ButtonSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -246,8 +244,13 @@ class ButtonSpecTween extends Tween { @override ButtonSpec lerp(double t) { - if (begin == null && end == null) return const ButtonSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const ButtonSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/button/button_style.dart b/packages/remix/lib/components/button/button_style.dart index 9a07a3a30..83629b468 100644 --- a/packages/remix/lib/components/button/button_style.dart +++ b/packages/remix/lib/components/button/button_style.dart @@ -1,10 +1,4 @@ -// ignore_for_file: camel_case_types - -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/button/button_spec.dart'; -import 'package:remix/components/button/button_variants.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'button.dart'; final _util = ButtonSpecUtility.self; final _label = _util.label; @@ -60,7 +54,7 @@ Style get _softVariant => Style( ); Style get _outlineVariant => Style( - _container.color(Colors.transparent), + _container.color.transparent(), _container.border.width(1.5), _container.border.strokeAlign(0), _container.border.color.ref($rx.color.accentAlpha(8)), @@ -87,7 +81,7 @@ Style get _surfaceVariant => Style( Style get _ghostVariant => Style( _container.border.style.none(), - _container.color(Colors.transparent), + _container.color.transparent(), _items.color.ref($rx.color.accentAlpha(11)), $on.hover( _container.color.ref($rx.color.accentAlpha(3)), diff --git a/packages/remix/lib/components/button/button_variants.dart b/packages/remix/lib/components/button/button_variants.dart index 2047c2739..cff719354 100644 --- a/packages/remix/lib/components/button/button_variants.dart +++ b/packages/remix/lib/components/button/button_variants.dart @@ -1,4 +1,4 @@ -import 'package:remix/helpers/variant.dart'; +part of 'button.dart'; interface class IButtonVariant extends RemixVariant { const IButtonVariant(String name) : super('button.$name'); diff --git a/packages/remix/lib/components/button/button_widget.dart b/packages/remix/lib/components/button/button_widget.dart index df7672aa5..647be8c0f 100644 --- a/packages/remix/lib/components/button/button_widget.dart +++ b/packages/remix/lib/components/button/button_widget.dart @@ -1,8 +1,4 @@ -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/button/button_spec.dart'; -import 'package:remix/components/button/button_style.dart'; -import 'package:remix/components/button/button_variants.dart'; +part of 'button.dart'; /// A customizable button component with various styling options. /// diff --git a/packages/remix/lib/components/callout/callout_spec.g.dart b/packages/remix/lib/components/callout/callout_spec.g.dart index 22c716db1..3f45a5687 100644 --- a/packages/remix/lib/components/callout/callout_spec.g.dart +++ b/packages/remix/lib/components/callout/callout_spec.g.dart @@ -6,9 +6,7 @@ part of 'callout_spec.dart'; // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$CalloutSpec on Spec { +mixin _$CalloutSpec on Spec { static CalloutSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const CalloutSpec(); @@ -108,7 +106,7 @@ base mixin _$CalloutSpec on Spec { /// /// Use this class to configure the attributes of a [CalloutSpec] and pass it to /// the [CalloutSpec] constructor. -final class CalloutSpecAttribute extends SpecAttribute { +base class CalloutSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; final IconSpecAttribute? icon; @@ -180,7 +178,7 @@ final class CalloutSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [CalloutSpecAttribute]. /// Use the methods of this class to configure specific properties of a [CalloutSpecAttribute]. -base class CalloutSpecUtility +class CalloutSpecUtility extends SpecUtility { /// Utility for defining [CalloutSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -232,8 +230,13 @@ class CalloutSpecTween extends Tween { @override CalloutSpec lerp(double t) { - if (begin == null && end == null) return const CalloutSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const CalloutSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/card/card_spec.dart b/packages/remix/lib/components/card/card.dart similarity index 75% rename from packages/remix/lib/components/card/card_spec.dart rename to packages/remix/lib/components/card/card.dart index f7d7f4889..9584b4542 100644 --- a/packages/remix/lib/components/card/card_spec.dart +++ b/packages/remix/lib/components/card/card.dart @@ -2,7 +2,13 @@ import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; -part 'card_spec.g.dart'; +import '../../helpers/variant.dart'; +import '../../tokens/remix_tokens.dart'; + +part 'card.g.dart'; +part 'card_style.dart'; +part 'card_variants.dart'; +part 'card_widget.dart'; @MixableSpec() base class CardSpec extends Spec with _$CardSpec { diff --git a/packages/remix/lib/components/card/card_spec.g.dart b/packages/remix/lib/components/card/card.g.dart similarity index 95% rename from packages/remix/lib/components/card/card_spec.g.dart rename to packages/remix/lib/components/card/card.g.dart index d85e89a76..edfc4eb23 100644 --- a/packages/remix/lib/components/card/card_spec.g.dart +++ b/packages/remix/lib/components/card/card.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'card_spec.dart'; +part of 'card.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$CardSpec on Spec { +mixin _$CardSpec on Spec { static CardSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const CardSpec(); @@ -98,7 +96,7 @@ base mixin _$CardSpec on Spec { /// /// Use this class to configure the attributes of a [CardSpec] and pass it to /// the [CardSpec] constructor. -final class CardSpecAttribute extends SpecAttribute { +base class CardSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; @@ -160,7 +158,7 @@ final class CardSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [CardSpecAttribute]. /// Use the methods of this class to configure specific properties of a [CardSpecAttribute]. -base class CardSpecUtility +class CardSpecUtility extends SpecUtility { /// Utility for defining [CardSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -202,8 +200,13 @@ class CardSpecTween extends Tween { @override CardSpec lerp(double t) { - if (begin == null && end == null) return const CardSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const CardSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/card/card_style.dart b/packages/remix/lib/components/card/card_style.dart index 472eb2f71..a6244b9ba 100644 --- a/packages/remix/lib/components/card/card_style.dart +++ b/packages/remix/lib/components/card/card_style.dart @@ -1,7 +1,4 @@ -import 'package:mix/mix.dart'; -import 'package:remix/components/card/card_spec.dart'; -import 'package:remix/components/card/card_variants.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'card.dart'; final _util = CardSpecUtility.self; final _container = _util.container; diff --git a/packages/remix/lib/components/card/card_variants.dart b/packages/remix/lib/components/card/card_variants.dart index ddb325d8a..84eeec1a3 100644 --- a/packages/remix/lib/components/card/card_variants.dart +++ b/packages/remix/lib/components/card/card_variants.dart @@ -1,4 +1,4 @@ -import 'package:remix/helpers/variant.dart'; +part of 'card.dart'; interface class ICardVariant extends RemixVariant { const ICardVariant(String name) : super('card.$name'); diff --git a/packages/remix/lib/components/card/card_widget.dart b/packages/remix/lib/components/card/card_widget.dart index 9c0b3108a..8b730bcec 100644 --- a/packages/remix/lib/components/card/card_widget.dart +++ b/packages/remix/lib/components/card/card_widget.dart @@ -1,8 +1,4 @@ -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/card/card_spec.dart'; -import 'package:remix/components/card/card_style.dart'; -import 'package:remix/components/card/card_variants.dart'; +part of 'card.dart'; class RxCard extends StatelessWidget { const RxCard({ diff --git a/packages/remix/lib/components/checkbox/checkbox_spec.dart b/packages/remix/lib/components/checkbox/checkbox.dart similarity index 64% rename from packages/remix/lib/components/checkbox/checkbox_spec.dart rename to packages/remix/lib/components/checkbox/checkbox.dart index 99fe7be47..d8ce5c0da 100644 --- a/packages/remix/lib/components/checkbox/checkbox_spec.dart +++ b/packages/remix/lib/components/checkbox/checkbox.dart @@ -1,8 +1,15 @@ -import 'package:flutter/widgets.dart'; +import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; +import 'package:remix/helpers/utility_extension.dart'; +import 'package:remix/helpers/variant.dart'; -part 'checkbox_spec.g.dart'; +import '../../tokens/remix_tokens.dart'; + +part 'checkbox.g.dart'; +part 'checkbox_style.dart'; +part 'checkbox_variants.dart'; +part 'checkbox_widget.dart'; @MixableSpec() base class CheckboxSpec extends Spec with _$CheckboxSpec { diff --git a/packages/remix/lib/components/checkbox/checkbox_spec.g.dart b/packages/remix/lib/components/checkbox/checkbox.g.dart similarity index 94% rename from packages/remix/lib/components/checkbox/checkbox_spec.g.dart rename to packages/remix/lib/components/checkbox/checkbox.g.dart index 596dcdac7..ec70fd154 100644 --- a/packages/remix/lib/components/checkbox/checkbox_spec.g.dart +++ b/packages/remix/lib/components/checkbox/checkbox.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'checkbox_spec.dart'; +part of 'checkbox.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$CheckboxSpec on Spec { +mixin _$CheckboxSpec on Spec { static CheckboxSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const CheckboxSpec(); @@ -98,7 +96,7 @@ base mixin _$CheckboxSpec on Spec { /// /// Use this class to configure the attributes of a [CheckboxSpec] and pass it to /// the [CheckboxSpec] constructor. -final class CheckboxSpecAttribute extends SpecAttribute { +base class CheckboxSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final IconSpecAttribute? indicator; @@ -160,7 +158,7 @@ final class CheckboxSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [CheckboxSpecAttribute]. /// Use the methods of this class to configure specific properties of a [CheckboxSpecAttribute]. -base class CheckboxSpecUtility +class CheckboxSpecUtility extends SpecUtility { /// Utility for defining [CheckboxSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -202,8 +200,13 @@ class CheckboxSpecTween extends Tween { @override CheckboxSpec lerp(double t) { - if (begin == null && end == null) return const CheckboxSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const CheckboxSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/checkbox/checkbox_style.dart b/packages/remix/lib/components/checkbox/checkbox_style.dart index 04776a86f..86bb5eaa1 100644 --- a/packages/remix/lib/components/checkbox/checkbox_style.dart +++ b/packages/remix/lib/components/checkbox/checkbox_style.dart @@ -1,11 +1,6 @@ // ignore_for_file: camel_case_types -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/checkbox/checkbox_spec.dart'; -import 'package:remix/components/checkbox/checkbox_variants.dart'; -import 'package:remix/helpers/utility_extension.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'checkbox.dart'; final _util = CheckboxSpecUtility.self; final _container = _util.container; @@ -98,7 +93,7 @@ Style get _largeVariant => Style( _indicator.size(20), ); -Style buildDefaultCheckboxStyle() { +Style _buildDefaultCheckboxStyle() { return Style( _baseStyle(), @@ -118,3 +113,16 @@ Style buildDefaultCheckboxStyle() { $on.disabled(_disabledVariant()), ); } + +class RxCheckboxStyle { + const RxCheckboxStyle(); + + Style apply( + Style? style, + List? variants, + ) { + return _buildDefaultCheckboxStyle() + .merge(style) + .applyVariants(variants ?? []); + } +} diff --git a/packages/remix/lib/components/checkbox/checkbox_variants.dart b/packages/remix/lib/components/checkbox/checkbox_variants.dart index d3f84d275..d6125d7d2 100644 --- a/packages/remix/lib/components/checkbox/checkbox_variants.dart +++ b/packages/remix/lib/components/checkbox/checkbox_variants.dart @@ -1,16 +1,9 @@ -import 'package:remix/helpers/variant.dart'; +part of 'checkbox.dart'; abstract interface class ICheckboxVariant extends RemixVariant { const ICheckboxVariant(String name) : super('checkbox.$name'); } -class CheckboxStatus extends ICheckboxVariant { - const CheckboxStatus._(String name) : super('status.$name'); - - static const checked = CheckboxStatus._('checked'); - static const unchecked = CheckboxStatus._('unchecked'); -} - class CheckboxVariant extends ICheckboxVariant { const CheckboxVariant(String name) : super('variant.$name'); diff --git a/packages/remix/lib/components/checkbox/checkbox_widget.dart b/packages/remix/lib/components/checkbox/checkbox_widget.dart index 444754993..b3fe61c8c 100644 --- a/packages/remix/lib/components/checkbox/checkbox_widget.dart +++ b/packages/remix/lib/components/checkbox/checkbox_widget.dart @@ -1,10 +1,6 @@ -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/checkbox/checkbox_spec.dart'; -import 'package:remix/components/checkbox/checkbox_style.dart'; -import 'package:remix/components/checkbox/checkbox_variants.dart'; +part of 'checkbox.dart'; -class RxCheckbox extends StatelessWidget { +class RxCheckbox extends StatefulWidget { const RxCheckbox({ super.key, this.disabled = false, @@ -31,23 +27,54 @@ class RxCheckbox extends StatelessWidget { final CheckboxSize size; final CheckboxVariant variant; - void _handleOnPress() => onChanged?.call(!value); + @override + State createState() => _RxCheckboxState(); +} + +class _RxCheckboxState extends State { + late final MixWidgetStateController _controller; + + void _handleOnPress() => widget.onChanged?.call(!widget.value); - Style _buildStyle() { - return buildDefaultCheckboxStyle().merge(style).applyVariants([ - size, - variant, - value ? CheckboxStatus.checked : CheckboxStatus.unchecked - ]).animate(); + @visibleForTesting + List get variants => [widget.size, widget.variant]; + + @visibleForTesting + Style get style => _buildDefaultCheckboxStyle().merge(widget.style); + + @override + void initState() { + super.initState(); + _controller = MixWidgetStateController(); + } + + @override + void didUpdateWidget(RxCheckbox oldWidget) { + super.didUpdateWidget(oldWidget); + + if (oldWidget.value != widget.value) { + _controller.selected = widget.value; + } + + if (oldWidget.disabled != widget.disabled) { + _controller.disabled = widget.disabled; + } + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); } @override Widget build(BuildContext context) { return Pressable( - onPress: disabled ? null : _handleOnPress, - enabled: !disabled, + onPress: widget.disabled ? null : _handleOnPress, + enabled: !widget.disabled, child: SpecBuilder( - style: _buildStyle(), + controller: _controller, + style: style.applyVariants(variants), builder: (context) { final spec = CheckboxSpec.of(context); @@ -56,7 +83,9 @@ class RxCheckbox extends StatelessWidget { return ContainerWidget( child: IconWidget( - value ? iconChecked : iconUnchecked, + widget.value + ? widget.iconChecked + : widget.iconUnchecked ?? widget.iconChecked, ), ); }, diff --git a/packages/remix/lib/components/checkbox_group/checkbox_group.dart b/packages/remix/lib/components/checkbox_group/checkbox_group.dart index 28b9c3ba1..363e0095b 100644 --- a/packages/remix/lib/components/checkbox_group/checkbox_group.dart +++ b/packages/remix/lib/components/checkbox_group/checkbox_group.dart @@ -1,7 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; -import 'package:remix/components/checkbox/checkbox_variants.dart'; -import 'package:remix/components/checkbox/checkbox_widget.dart'; +import 'package:remix/components/checkbox/checkbox.dart'; class RxCheckboxGroup extends StatefulWidget { const RxCheckboxGroup({ diff --git a/packages/remix/lib/components/progress/progress_spec.dart b/packages/remix/lib/components/progress/progress.dart similarity index 76% rename from packages/remix/lib/components/progress/progress_spec.dart rename to packages/remix/lib/components/progress/progress.dart index d087d7016..92d77455b 100644 --- a/packages/remix/lib/components/progress/progress_spec.dart +++ b/packages/remix/lib/components/progress/progress.dart @@ -1,8 +1,14 @@ import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; +import 'package:remix/helpers/variant.dart'; -part 'progress_spec.g.dart'; +import '../../tokens/remix_tokens.dart'; + +part 'progress.g.dart'; +part 'progress_style.dart'; +part 'progress_variants.dart'; +part 'progress_widget.dart'; @MixableSpec() base class ProgressSpec extends Spec with _$ProgressSpec { diff --git a/packages/remix/lib/components/progress/progress_spec.g.dart b/packages/remix/lib/components/progress/progress.g.dart similarity index 95% rename from packages/remix/lib/components/progress/progress_spec.g.dart rename to packages/remix/lib/components/progress/progress.g.dart index 6d66148d2..9c6d1b5b4 100644 --- a/packages/remix/lib/components/progress/progress_spec.g.dart +++ b/packages/remix/lib/components/progress/progress.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'progress_spec.dart'; +part of 'progress.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$ProgressSpec on Spec { +mixin _$ProgressSpec on Spec { static ProgressSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const ProgressSpec(); @@ -101,7 +99,7 @@ base mixin _$ProgressSpec on Spec { /// /// Use this class to configure the attributes of a [ProgressSpec] and pass it to /// the [ProgressSpec] constructor. -final class ProgressSpecAttribute extends SpecAttribute { +base class ProgressSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final BoxSpecAttribute? track; final BoxSpecAttribute? fill; @@ -168,7 +166,7 @@ final class ProgressSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [ProgressSpecAttribute]. /// Use the methods of this class to configure specific properties of a [ProgressSpecAttribute]. -base class ProgressSpecUtility +class ProgressSpecUtility extends SpecUtility { /// Utility for defining [ProgressSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -215,8 +213,13 @@ class ProgressSpecTween extends Tween { @override ProgressSpec lerp(double t) { - if (begin == null && end == null) return const ProgressSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const ProgressSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/progress/progress_style.dart b/packages/remix/lib/components/progress/progress_style.dart index 572ab6a71..4b64b9660 100644 --- a/packages/remix/lib/components/progress/progress_style.dart +++ b/packages/remix/lib/components/progress/progress_style.dart @@ -1,9 +1,4 @@ -// ignore_for_file: camel_case_types - -import 'package:mix/mix.dart'; -import 'package:remix/components/progress/progress_spec.dart'; -import 'package:remix/components/progress/progress_variants.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'progress.dart'; final _progress = ProgressSpecUtility.self; final _container = _progress.container; diff --git a/packages/remix/lib/components/progress/progress_variants.dart b/packages/remix/lib/components/progress/progress_variants.dart index 45026588b..2b886bde8 100644 --- a/packages/remix/lib/components/progress/progress_variants.dart +++ b/packages/remix/lib/components/progress/progress_variants.dart @@ -1,6 +1,6 @@ -import 'package:mix/mix.dart'; +part of 'progress.dart'; -abstract interface class IProgressVariant extends Variant { +abstract interface class IProgressVariant extends RemixVariant { const IProgressVariant(super.name); } diff --git a/packages/remix/lib/components/progress/progress_widget.dart b/packages/remix/lib/components/progress/progress_widget.dart index 550d606e8..7179a4425 100644 --- a/packages/remix/lib/components/progress/progress_widget.dart +++ b/packages/remix/lib/components/progress/progress_widget.dart @@ -1,8 +1,4 @@ -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/progress/progress_spec.dart'; -import 'package:remix/components/progress/progress_style.dart'; -import 'package:remix/components/progress/progress_variants.dart'; +part of 'progress.dart'; class RxProgress extends StatelessWidget { const RxProgress({ diff --git a/packages/remix/lib/components/radio/radio_spec.dart b/packages/remix/lib/components/radio/radio.dart similarity index 65% rename from packages/remix/lib/components/radio/radio_spec.dart rename to packages/remix/lib/components/radio/radio.dart index 9da3047c5..864abcd9c 100644 --- a/packages/remix/lib/components/radio/radio_spec.dart +++ b/packages/remix/lib/components/radio/radio.dart @@ -1,8 +1,15 @@ -import 'package:flutter/cupertino.dart'; +import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; +import 'package:remix/helpers/utility_extension.dart'; -part 'radio_spec.g.dart'; +import '../../helpers/variant.dart'; +import '../../tokens/remix_tokens.dart'; + +part 'radio.g.dart'; +part 'radio_style.dart'; +part 'radio_variants.dart'; +part 'radio_widget.dart'; @MixableSpec() base class RadioSpec extends Spec with _$RadioSpec { diff --git a/packages/remix/lib/components/radio/radio_spec.g.dart b/packages/remix/lib/components/radio/radio.g.dart similarity index 95% rename from packages/remix/lib/components/radio/radio_spec.g.dart rename to packages/remix/lib/components/radio/radio.g.dart index 72e145e23..b742c878d 100644 --- a/packages/remix/lib/components/radio/radio_spec.g.dart +++ b/packages/remix/lib/components/radio/radio.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'radio_spec.dart'; +part of 'radio.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$RadioSpec on Spec { +mixin _$RadioSpec on Spec { static RadioSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const RadioSpec(); @@ -97,7 +95,7 @@ base mixin _$RadioSpec on Spec { /// /// Use this class to configure the attributes of a [RadioSpec] and pass it to /// the [RadioSpec] constructor. -final class RadioSpecAttribute extends SpecAttribute { +base class RadioSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final BoxSpecAttribute? indicator; @@ -159,7 +157,7 @@ final class RadioSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [RadioSpecAttribute]. /// Use the methods of this class to configure specific properties of a [RadioSpecAttribute]. -base class RadioSpecUtility +class RadioSpecUtility extends SpecUtility { /// Utility for defining [RadioSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -201,8 +199,13 @@ class RadioSpecTween extends Tween { @override RadioSpec lerp(double t) { - if (begin == null && end == null) return const RadioSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const RadioSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/radio/radio_style.dart b/packages/remix/lib/components/radio/radio_style.dart index 7dc526d47..0ee7d7d95 100644 --- a/packages/remix/lib/components/radio/radio_style.dart +++ b/packages/remix/lib/components/radio/radio_style.dart @@ -1,11 +1,4 @@ -// ignore_for_file: camel_case_types - -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/radio/radio_spec.dart'; -import 'package:remix/components/radio/radio_variants.dart'; -import 'package:remix/helpers/utility_extension.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'radio.dart'; final _radio = RadioSpecUtility.self; final _container = _radio.container; @@ -40,7 +33,7 @@ Style get _softVariant => Style( ); Style get _outlineVariant => Style( - _container.color(Colors.transparent), + _container.color.transparent(), _container.border.color.ref($rx.color.accentAlpha(8)), _container.border.width(1.5), _indicator.color.ref($rx.color.accentAlpha(11)), @@ -67,7 +60,7 @@ Style get _surfaceVariant => Style( Style get _ghostVariant => Style( _container.border.style.none(), - _container.color(Colors.transparent), + _container.color.transparent(), _indicator.color.ref($rx.color.accentAlpha(11)), $on.hover( _container.color.ref($rx.color.accentAlpha(3)), diff --git a/packages/remix/lib/components/radio/radio_variants.dart b/packages/remix/lib/components/radio/radio_variants.dart index fb2f3991b..cf62660b2 100644 --- a/packages/remix/lib/components/radio/radio_variants.dart +++ b/packages/remix/lib/components/radio/radio_variants.dart @@ -1,4 +1,4 @@ -import 'package:remix/helpers/variant.dart'; +part of 'radio.dart'; abstract interface class IRadioVariant extends RemixVariant { const IRadioVariant(String name) : super('radio.$name'); diff --git a/packages/remix/lib/components/radio/radio_widget.dart b/packages/remix/lib/components/radio/radio_widget.dart index 47ce07722..3aa359a78 100644 --- a/packages/remix/lib/components/radio/radio_widget.dart +++ b/packages/remix/lib/components/radio/radio_widget.dart @@ -1,8 +1,4 @@ -import 'package:flutter/widgets.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/radio/radio_spec.dart'; -import 'package:remix/components/radio/radio_style.dart'; -import 'package:remix/components/radio/radio_variants.dart'; +part of 'radio.dart'; class RxRadio extends StatelessWidget { const RxRadio({ diff --git a/packages/remix/lib/components/spinner/spinner_spec.dart b/packages/remix/lib/components/spinner/spinner.dart similarity index 83% rename from packages/remix/lib/components/spinner/spinner_spec.dart rename to packages/remix/lib/components/spinner/spinner.dart index bb47a05c8..0d4da8b5e 100644 --- a/packages/remix/lib/components/spinner/spinner_spec.dart +++ b/packages/remix/lib/components/spinner/spinner.dart @@ -1,9 +1,17 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; -import 'package:remix/components/spinner/spinner_widget.dart'; +import 'package:remix/helpers/variant.dart'; + +import '../../tokens/remix_tokens.dart'; -part 'spinner_spec.g.dart'; +part 'spinner.g.dart'; +part 'spinner_painter.dart'; +part 'spinner_style.dart'; +part 'spinner_variants.dart'; +part 'spinner_widget.dart'; enum SpinnerStyle { solid, diff --git a/packages/remix/lib/components/spinner/spinner_spec.g.dart b/packages/remix/lib/components/spinner/spinner.g.dart similarity index 95% rename from packages/remix/lib/components/spinner/spinner_spec.g.dart rename to packages/remix/lib/components/spinner/spinner.g.dart index 7392543ad..e424ac09a 100644 --- a/packages/remix/lib/components/spinner/spinner_spec.g.dart +++ b/packages/remix/lib/components/spinner/spinner.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'spinner_spec.dart'; +part of 'spinner.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$SpinnerSpec on Spec { +mixin _$SpinnerSpec on Spec { static SpinnerSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const SpinnerSpec(); @@ -77,10 +75,10 @@ base mixin _$SpinnerSpec on Spec { if (other == null) return _$this; return SpinnerSpec( - size: MixHelpers.lerpDouble(_$this.size, other.size, t), + size: MixHelpers.lerpDouble(_$this.size, other.size, t)!, strokeWidth: MixHelpers.lerpDouble(_$this.strokeWidth, other.strokeWidth, t), - color: Color.lerp(_$this.color, other.color, t), + color: Color.lerp(_$this.color, other.color, t)!, duration: t < 0.5 ? _$this.duration : other.duration, style: t < 0.5 ? _$this.style : other.style, animated: t < 0.5 ? _$this.animated : other.animated, @@ -188,7 +186,7 @@ final class SpinnerSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [SpinnerSpecAttribute]. /// Use the methods of this class to configure specific properties of a [SpinnerSpecAttribute]. -base class SpinnerSpecUtility +class SpinnerSpecUtility extends SpecUtility { /// Utility for defining [SpinnerSpecAttribute.size] late final size = DoubleUtility((v) => only(size: v)); @@ -245,8 +243,13 @@ class SpinnerSpecTween extends Tween { @override SpinnerSpec lerp(double t) { - if (begin == null && end == null) return const SpinnerSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const SpinnerSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/spinner/spinner_painter.dart b/packages/remix/lib/components/spinner/spinner_painter.dart index 41bde9267..6f0c0a39f 100644 --- a/packages/remix/lib/components/spinner/spinner_painter.dart +++ b/packages/remix/lib/components/spinner/spinner_painter.dart @@ -1,6 +1,4 @@ -import 'dart:math'; - -import 'package:flutter/material.dart'; +part of 'spinner.dart'; abstract interface class SpinnerPainter extends CustomPainter { final Animation animation; diff --git a/packages/remix/lib/components/spinner/spinner.style.dart b/packages/remix/lib/components/spinner/spinner_style.dart similarity index 74% rename from packages/remix/lib/components/spinner/spinner.style.dart rename to packages/remix/lib/components/spinner/spinner_style.dart index 2e14e9800..5ac6a5f0d 100644 --- a/packages/remix/lib/components/spinner/spinner.style.dart +++ b/packages/remix/lib/components/spinner/spinner_style.dart @@ -1,7 +1,4 @@ -import 'package:mix/mix.dart'; -import 'package:remix/components/spinner/spinner.variants.dart'; -import 'package:remix/components/spinner/spinner_spec.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'spinner.dart'; final _util = SpinnerSpecUtility.self; diff --git a/packages/remix/lib/components/spinner/spinner.variants.dart b/packages/remix/lib/components/spinner/spinner_variants.dart similarity index 93% rename from packages/remix/lib/components/spinner/spinner.variants.dart rename to packages/remix/lib/components/spinner/spinner_variants.dart index 918d07336..cf1f5e98c 100644 --- a/packages/remix/lib/components/spinner/spinner.variants.dart +++ b/packages/remix/lib/components/spinner/spinner_variants.dart @@ -1,4 +1,4 @@ -import 'package:remix/helpers/variant.dart'; +part of 'spinner.dart'; interface class ISpinnerVariant extends RemixVariant { const ISpinnerVariant(String name) : super('spinner.$name'); diff --git a/packages/remix/lib/components/spinner/spinner_widget.dart b/packages/remix/lib/components/spinner/spinner_widget.dart index 8a40ca44d..12e44446d 100644 --- a/packages/remix/lib/components/spinner/spinner_widget.dart +++ b/packages/remix/lib/components/spinner/spinner_widget.dart @@ -1,11 +1,4 @@ -// ignore_for_file: library_private_types_in_public_api - -import 'package:flutter/material.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/spinner/spinner.style.dart'; -import 'package:remix/components/spinner/spinner.variants.dart'; -import 'package:remix/components/spinner/spinner_painter.dart'; -import 'package:remix/components/spinner/spinner_spec.dart'; +part of 'spinner.dart'; class RxSpinner extends StatelessWidget { const RxSpinner({ diff --git a/packages/remix/lib/components/switch/switch_spec.dart b/packages/remix/lib/components/switch/switch.dart similarity index 69% rename from packages/remix/lib/components/switch/switch_spec.dart rename to packages/remix/lib/components/switch/switch.dart index 2b4a90d01..79ecc7521 100644 --- a/packages/remix/lib/components/switch/switch_spec.dart +++ b/packages/remix/lib/components/switch/switch.dart @@ -1,8 +1,15 @@ import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; +import 'package:remix/helpers/utility_extension.dart'; -part 'switch_spec.g.dart'; +import '../../helpers/variant.dart'; +import '../../tokens/remix_tokens.dart'; + +part 'switch.g.dart'; +part 'switch_style.dart'; +part 'switch_variants.dart'; +part 'switch_widget.dart'; @MixableSpec() base class SwitchSpec extends Spec with _$SwitchSpec { diff --git a/packages/remix/lib/components/switch/switch_spec.g.dart b/packages/remix/lib/components/switch/switch.g.dart similarity index 94% rename from packages/remix/lib/components/switch/switch_spec.g.dart rename to packages/remix/lib/components/switch/switch.g.dart index 4ec9f523b..7c7df07c6 100644 --- a/packages/remix/lib/components/switch/switch_spec.g.dart +++ b/packages/remix/lib/components/switch/switch.g.dart @@ -1,14 +1,12 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'switch_spec.dart'; +part of 'switch.dart'; // ************************************************************************** // MixableSpecGenerator // ************************************************************************** -// ignore_for_file: deprecated_member_use_from_same_package - -base mixin _$SwitchSpec on Spec { +mixin _$SwitchSpec on Spec { static SwitchSpec from(MixData mix) { return mix.attributeOf()?.resolve(mix) ?? const SwitchSpec(); @@ -97,7 +95,7 @@ base mixin _$SwitchSpec on Spec { /// /// Use this class to configure the attributes of a [SwitchSpec] and pass it to /// the [SwitchSpec] constructor. -final class SwitchSpecAttribute extends SpecAttribute { +base class SwitchSpecAttribute extends SpecAttribute { final BoxSpecAttribute? container; final BoxSpecAttribute? indicator; @@ -159,7 +157,7 @@ final class SwitchSpecAttribute extends SpecAttribute { /// /// This class provides methods to set individual properties of a [SwitchSpecAttribute]. /// Use the methods of this class to configure specific properties of a [SwitchSpecAttribute]. -base class SwitchSpecUtility +class SwitchSpecUtility extends SpecUtility { /// Utility for defining [SwitchSpecAttribute.container] late final container = BoxSpecUtility((v) => only(container: v)); @@ -201,8 +199,13 @@ class SwitchSpecTween extends Tween { @override SwitchSpec lerp(double t) { - if (begin == null && end == null) return const SwitchSpec(); - if (begin == null) return end!; + if (begin == null && end == null) { + return const SwitchSpec(); + } + + if (begin == null) { + return end!; + } return begin!.lerp(end!, t); } diff --git a/packages/remix/lib/components/switch/switch_style.dart b/packages/remix/lib/components/switch/switch_style.dart index f5c74c3d5..c98f48cf4 100644 --- a/packages/remix/lib/components/switch/switch_style.dart +++ b/packages/remix/lib/components/switch/switch_style.dart @@ -1,8 +1,4 @@ -import 'package:mix/mix.dart'; -import 'package:remix/components/switch/switch_spec.dart'; -import 'package:remix/components/switch/switch_variants.dart'; -import 'package:remix/helpers/utility_extension.dart'; -import 'package:remix/tokens/remix_tokens.dart'; +part of 'switch.dart'; final _util = SwitchSpecUtility.self; @@ -12,20 +8,20 @@ final _indicator = _util.indicator; Style get _baseStyle => Style( _container.borderRadius(99), _indicator.borderRadius(99), - SwitchStatus.on( + $on.selected( _container.alignment.centerRight(), ), - SwitchStatus.off( + $on.unselected( _container.alignment.centerLeft(), ), ); Style get _solidVariant => Style( _indicator.color.ref($rx.color.white()), - SwitchStatus.on( + $on.selected( _container.color.ref($rx.color.accent()), ), - SwitchStatus.off( + $on.unselected( _container.color.ref($rx.color.neutral(3)), ), $on.disabled( @@ -36,10 +32,10 @@ Style get _solidVariant => Style( Style get _softVariant => Style( _indicator.color.ref($rx.color.accentAlpha(11)), - SwitchStatus.on( + $on.selected( _container.color.ref($rx.color.accentAlpha(3)), ), - SwitchStatus.off( + $on.unselected( _container.color.ref($rx.color.neutral(4)), ), $on.disabled( @@ -53,10 +49,10 @@ Style get _outlineVariant => Style( _container.border.width(1.5), _container.border.strokeAlign(1), _indicator.color.ref($rx.color.accentAlpha(11)), - SwitchStatus.on( + $on.selected( _container.border.color.ref($rx.color.accentAlpha(8)), ), - SwitchStatus.off( + $on.unselected( _container.border.color.ref($rx.color.neutral(4)), ), $on.disabled( @@ -67,10 +63,10 @@ Style get _outlineVariant => Style( Style get _surfaceVariant => Style( _outlineVariant(), - SwitchStatus.on( + $on.selected( _container.color.ref($rx.color.accentAlpha(3)), ), - SwitchStatus.off( + $on.unselected( _container.color.ref($rx.color.neutralAlpha(3)), _container.border.color.ref($rx.color.neutral(4)), ), @@ -84,7 +80,7 @@ Style get _smallVariant => Style( _container.padding.horizontal(2), _container.height(16), _indicator.size(12), - SwitchStatus.off( + $on.unselected( _indicator.size(8), _container.padding.horizontal(2), ), @@ -95,7 +91,7 @@ Style get _mediumVariant => Style( _container.padding.horizontal(3), _container.height(20), _indicator.size(14), - SwitchStatus.off( + $on.unselected( _indicator.size(12), ), ); @@ -105,7 +101,7 @@ Style get _largeVariant => Style( _container.padding.horizontal(3), _container.height(24), _indicator.size(18), - SwitchStatus.off(_indicator.size(16)), + $on.unselected(_indicator.size(16)), ); Style buildSwitchStyle() { diff --git a/packages/remix/lib/components/switch/switch_variants.dart b/packages/remix/lib/components/switch/switch_variants.dart index cd1f8a4b2..9856eb80c 100644 --- a/packages/remix/lib/components/switch/switch_variants.dart +++ b/packages/remix/lib/components/switch/switch_variants.dart @@ -1,18 +1,9 @@ -import 'package:remix/helpers/variant.dart'; +part of 'switch.dart'; interface class ISwitchVariant extends RemixVariant { const ISwitchVariant(String name) : super('switch.$name'); } -class SwitchStatus extends ISwitchVariant { - const SwitchStatus(String name) : super('status.$name'); - - static const on = SwitchStatus('on'); - static const off = SwitchStatus('off'); - - static List get values => [on, off]; -} - class SwitchSize extends ISwitchVariant { const SwitchSize(String name) : super('size.$name'); diff --git a/packages/remix/lib/components/switch/switch_widget.dart b/packages/remix/lib/components/switch/switch_widget.dart index 2d53e9c17..0ed8f605a 100644 --- a/packages/remix/lib/components/switch/switch_widget.dart +++ b/packages/remix/lib/components/switch/switch_widget.dart @@ -1,8 +1,4 @@ -import 'package:flutter/widgets.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/components/switch/switch_spec.dart'; -import 'package:remix/components/switch/switch_style.dart'; -import 'package:remix/components/switch/switch_variants.dart'; +part of 'switch.dart'; class RxSwitch extends StatelessWidget { const RxSwitch({ @@ -28,7 +24,6 @@ class RxSwitch extends StatelessWidget { return buildSwitchStyle().merge(style).applyVariants([ size, variant, - value ? SwitchStatus.on : SwitchStatus.off, ]).animate(); } diff --git a/packages/remix/lib/remix.dart b/packages/remix/lib/remix.dart index 26ab54451..bd5f944c7 100644 --- a/packages/remix/lib/remix.dart +++ b/packages/remix/lib/remix.dart @@ -1,26 +1,9 @@ library remix; -export 'components/button/button_spec.dart'; -export 'components/button/button_style.dart'; -export 'components/button/button_variants.dart'; -export 'components/button/button_widget.dart'; -export 'components/card/card_spec.dart'; -export 'components/card/card_style.dart'; -export 'components/card/card_variants.dart'; -export 'components/card/card_widget.dart'; -export 'components/checkbox/checkbox_spec.dart'; -export 'components/checkbox/checkbox_style.dart'; -export 'components/checkbox/checkbox_variants.dart'; -export 'components/checkbox/checkbox_widget.dart'; -export 'components/radio/radio_spec.dart'; -export 'components/radio/radio_style.dart'; -export 'components/radio/radio_variants.dart'; -export 'components/spinner/spinner.style.dart'; -export 'components/spinner/spinner.variants.dart'; -export 'components/spinner/spinner_spec.dart'; -export 'components/spinner/spinner_widget.dart'; -export 'components/switch/switch_spec.dart'; -export 'components/switch/switch_style.dart'; -export 'components/switch/switch_variants.dart'; -export 'components/switch/switch_widget.dart'; +export 'components/button/button.dart'; +export 'components/card/card.dart'; +export 'components/checkbox/checkbox.dart'; +export 'components/radio/radio.dart'; +export 'components/spinner/spinner.dart'; +export 'components/switch/switch.dart'; export 'tokens/remix_tokens.dart'; From 64ec0bb43c9fa704aad2765b4e3c9b9ea3b935d8 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Thu, 25 Jul 2024 18:53:47 -0400 Subject: [PATCH 2/7] Improvements --- .../src/attributes/spacing/spacing_util.dart | 3 +- .../demo/lib/components/avatar_use_case.dart | 3 +- .../demo/lib/components/button_use_case.dart | 13 +- .../demo/lib/components/card_use_case.dart | 6 +- .../demo/lib/components/radio_use_case.dart | 3 +- .../demo/lib/components/spinner_use_case.dart | 4 +- .../demo/lib/components/switch_use_case.dart | 3 +- .../lib/components/avatar/avatar_style.dart | 8 +- .../lib/components/badge/badge_style.dart | 91 ++++--- .../remix/lib/components/button/button.dart | 10 +- .../remix/lib/components/button/button.g.dart | 23 +- .../lib/components/button/button_style.dart | 235 ++++++++++-------- .../lib/components/button/button_widget.dart | 23 +- .../lib/components/callout/callout_style.dart | 59 +++-- packages/remix/lib/components/card/card.dart | 8 +- .../remix/lib/components/card/card.g.dart | 17 +- .../remix/lib/components/card/card_style.dart | 51 ++-- .../lib/components/card/card_widget.dart | 10 +- .../lib/components/checkbox/checkbox.dart | 10 +- .../lib/components/checkbox/checkbox.g.dart | 17 +- .../components/checkbox/checkbox_style.dart | 190 +++++++------- .../components/checkbox/checkbox_widget.dart | 9 +- packages/remix/lib/components/context.md | 0 .../lib/components/progress/progress.dart | 10 +- .../lib/components/progress/progress.g.dart | 19 +- .../components/progress/progress_style.dart | 134 ++++++---- .../components/progress/progress_widget.dart | 16 +- .../remix/lib/components/radio/radio.dart | 9 +- .../remix/lib/components/radio/radio.g.dart | 17 +- .../lib/components/radio/radio_style.dart | 167 +++++++------ .../remix/lib/components/spinner/spinner.dart | 10 +- .../lib/components/spinner/spinner.g.dart | 23 +- .../lib/components/spinner/spinner_style.dart | 42 ++-- .../components/spinner/spinner_widget.dart | 6 +- .../remix/lib/components/switch/switch.dart | 10 +- .../remix/lib/components/switch/switch.g.dart | 17 +- .../lib/components/switch/switch_style.dart | 200 ++++++++------- .../lib/components/switch/switch_widget.dart | 47 +++- packages/remix/lib/tokens/color_tokens.dart | 4 +- packages/remix/lib/tokens/radius_tokens.dart | 3 +- packages/remix/lib/tokens/remix_tokens.dart | 32 ++- packages/remix/lib/tokens/space_tokens.dart | 38 +-- .../remix/lib/tokens/text_style_tokens.dart | 18 +- 43 files changed, 974 insertions(+), 644 deletions(-) delete mode 100644 packages/remix/lib/components/context.md diff --git a/packages/mix/lib/src/attributes/spacing/spacing_util.dart b/packages/mix/lib/src/attributes/spacing/spacing_util.dart index 50a0b9887..7ceaa38d2 100644 --- a/packages/mix/lib/src/attributes/spacing/spacing_util.dart +++ b/packages/mix/lib/src/attributes/spacing/spacing_util.dart @@ -105,8 +105,7 @@ final class SpacingDirectionalUtility } @immutable -final class SpacingSideUtility - extends MixUtility { +class SpacingSideUtility extends MixUtility { const SpacingSideUtility(super.builder); T call(double value) => builder(value); diff --git a/packages/remix/demo/lib/components/avatar_use_case.dart b/packages/remix/demo/lib/components/avatar_use_case.dart index 0b85249ef..3955d684e 100644 --- a/packages/remix/demo/lib/components/avatar_use_case.dart +++ b/packages/remix/demo/lib/components/avatar_use_case.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:remix/components/avatar/avatar_variants.dart'; -import 'package:remix/components/avatar/avatar_widget.dart'; +import 'package:remix/components/avatar/avatar.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; diff --git a/packages/remix/demo/lib/components/button_use_case.dart b/packages/remix/demo/lib/components/button_use_case.dart index 8b25faf30..a591bef36 100644 --- a/packages/remix/demo/lib/components/button_use_case.dart +++ b/packages/remix/demo/lib/components/button_use_case.dart @@ -1,5 +1,6 @@ import 'package:demo/addons/icon_data_knob.dart'; import 'package:flutter/material.dart'; +import 'package:remix/components/button/button.dart'; import 'package:remix/remix.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; @@ -7,11 +8,11 @@ import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; final _key = GlobalKey(); @widgetbook.UseCase( name: 'Button Component', - type: CustomButton, + type: RxButton, ) Widget buildButtonUseCase(BuildContext context) { Widget buildButton(ButtonVariant type) { - return CustomButton( + return RxButton( label: context.knobs.string( label: 'Title', initialValue: 'Button', @@ -21,11 +22,15 @@ Widget buildButtonUseCase(BuildContext context) { label: 'Disabled', initialValue: false, ), - icon: context.knobs.iconData( + iconLeft: context.knobs.iconData( label: 'Icon left', initialValue: null, ), - variant: type, + iconRight: context.knobs.iconData( + label: 'Icon right', + initialValue: null, + ), + type: type, ); } diff --git a/packages/remix/demo/lib/components/card_use_case.dart b/packages/remix/demo/lib/components/card_use_case.dart index ebf045445..af1df703d 100644 --- a/packages/remix/demo/lib/components/card_use_case.dart +++ b/packages/remix/demo/lib/components/card_use_case.dart @@ -14,7 +14,7 @@ Widget buildCard(BuildContext context) { Text(variant.label), const SizedBox(height: 10), RxCard( - variant: variant, + type: variant, children: const [StyledText('Hi'), StyledText('This is a test')], ), ], @@ -39,11 +39,11 @@ Widget buildRadioUseCase(BuildContext context) { Text(variant.label), const SizedBox(height: 10), RxCard( - variant: variant, + type: variant, children: const [StyledText('Hi'), StyledText('This is a test')], ), const SizedBox(height: 10), - CustomButton( + RxButton( label: 'Click me', onPressed: () {}, ), diff --git a/packages/remix/demo/lib/components/radio_use_case.dart b/packages/remix/demo/lib/components/radio_use_case.dart index 60ba33ec1..90e468926 100644 --- a/packages/remix/demo/lib/components/radio_use_case.dart +++ b/packages/remix/demo/lib/components/radio_use_case.dart @@ -1,7 +1,6 @@ import 'package:demo/helpers/use_case_state.dart'; import 'package:flutter/material.dart'; -import 'package:remix/components/radio/radio_variants.dart'; -import 'package:remix/components/radio/radio_widget.dart'; +import 'package:remix/components/radio/radio.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; diff --git a/packages/remix/demo/lib/components/spinner_use_case.dart b/packages/remix/demo/lib/components/spinner_use_case.dart index ea080d910..ccf84eec6 100644 --- a/packages/remix/demo/lib/components/spinner_use_case.dart +++ b/packages/remix/demo/lib/components/spinner_use_case.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; -import 'package:remix/components/spinner/spinner.variants.dart'; -import 'package:remix/components/spinner/spinner_spec.dart'; -import 'package:remix/components/spinner/spinner_widget.dart'; +import 'package:remix/components/spinner/spinner.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; diff --git a/packages/remix/demo/lib/components/switch_use_case.dart b/packages/remix/demo/lib/components/switch_use_case.dart index 8ca9d6a0f..bb6d46665 100644 --- a/packages/remix/demo/lib/components/switch_use_case.dart +++ b/packages/remix/demo/lib/components/switch_use_case.dart @@ -1,7 +1,6 @@ import 'package:demo/helpers/use_case_state.dart'; import 'package:flutter/material.dart'; -import 'package:remix/components/switch/switch_variants.dart'; -import 'package:remix/components/switch/switch_widget.dart'; +import 'package:remix/components/switch/switch.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; diff --git a/packages/remix/lib/components/avatar/avatar_style.dart b/packages/remix/lib/components/avatar/avatar_style.dart index 769eec2f2..8f35fc7b1 100644 --- a/packages/remix/lib/components/avatar/avatar_style.dart +++ b/packages/remix/lib/components/avatar/avatar_style.dart @@ -9,16 +9,16 @@ Style get _baseStyle => Style( _image.fit.cover(), _container.alignment.center(), _fallback.textAlign.center(), - _fallback.style.fontWeight(FontWeight.bold), - _fallback.style.color.ref($rx.color.neutral(1)), + _fallback.style.fontWeight.bold(), + _fallback.style.color.$neutral(1), ); Style get _solidVariant => Style( - _container.color.ref($rx.color.accent()), + _container.color.$accent(), ); Style get _softVariant => Style( - _container.color.ref($rx.color.accent(4)), + _container.color.$accent(4), ); Style get _size1 => Style( diff --git a/packages/remix/lib/components/badge/badge_style.dart b/packages/remix/lib/components/badge/badge_style.dart index 5bd0df0a1..87eaea661 100644 --- a/packages/remix/lib/components/badge/badge_style.dart +++ b/packages/remix/lib/components/badge/badge_style.dart @@ -1,6 +1,5 @@ // ignore_for_file: camel_case_types -import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; import 'package:remix/components/badge/badge_spec.dart'; import 'package:remix/components/badge/badge_variants.dart'; @@ -10,50 +9,66 @@ final _badge = BadgeSpecUtility.self; final _container = _badge.container; final _label = _badge.label; -Style get _baseStyle => Style( - _container.borderRadius(99), - _label.style.fontWeight(FontWeight.w500), - ); +Style get _baseStyle { + return Style( + _container.borderRadius(99), + _label.style.fontWeight.w500(), + ); +} -Style get _solidVariant => Style( - _container.color.ref($rx.color.accent()), - _label.style.color.ref($rx.color.neutral(1)), - ); +Style get _solidVariant { + return Style( + _container.color.$accent(), + _label.style.color.$neutral(1), + ); +} -Style get _softVariant => Style( - _container.color.ref($rx.color.accentAlpha(3)), - _label.style.color.ref($rx.color.accentAlpha(11)), - ); +Style get _softVariant { + return Style( + _container.color.$accentAlpha(3), + _label.style.color.$accentAlpha(11), + ); +} -Style get _surfaceVariant => Style( - _container.color.ref($rx.color.accentAlpha(2)), - _label.style.color.ref($rx.color.accentAlpha(11)), - ); +Style get _surfaceVariant { + return Style( + _container.color.$accentAlpha(2), + _label.style.color.$accentAlpha(11), + ); +} -Style get _outlineVariant => Style( - _container.color(Colors.transparent), - _container.border.width(1), - _container.border.color.ref($rx.color.accentAlpha(8)), - _label.style.color.ref($rx.color.accentAlpha(11)), - ); +Style get _outlineVariant { + return Style( + _container.color.transparent(), + _container.border.width(1), + _container.border.color.$accentAlpha(8), + _label.style.color.$accentAlpha(11), + ); +} -final _smallVariant = Style( - _container.padding.vertical.ref($rx.space.space1), - _container.padding.horizontal.ref($rx.space.space2), - _label.style.as($rx.text.text1()), -); +Style get _smallVariant { + return Style( + _container.padding.vertical.$space(1), + _container.padding.horizontal.$space(2), + _label.style.$text(1), + ); +} -final _mediumVariant = Style( - _container.padding.vertical.ref($rx.space.space1), - _container.padding.horizontal.ref($rx.space.space3), - _label.style.as($rx.text.text2()), -); +Style get _mediumVariant { + return Style( + _container.padding.vertical.$space(1), + _container.padding.horizontal.$space(3), + _label.style.$text(2), + ); +} -final _largeVariant = Style( - _container.padding.vertical.ref($rx.space.space2), - _container.padding.horizontal.ref($rx.space.space4), - _label.style.as($rx.text.text3()), -); +Style get _largeVariant { + return Style( + _container.padding.vertical.$space(2), + _container.padding.horizontal.$space(4), + _label.style.$text(3), + ); +} Style badgeStyle(Style? style, List variants) { return Style( diff --git a/packages/remix/lib/components/button/button.dart b/packages/remix/lib/components/button/button.dart index f1bb4ce66..aa70a1dd6 100644 --- a/packages/remix/lib/components/button/button.dart +++ b/packages/remix/lib/components/button/button.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; @@ -12,7 +13,8 @@ part 'button_variants.dart'; part 'button_widget.dart'; @MixableSpec() -base class ButtonSpec extends Spec with _$ButtonSpec { +base class ButtonSpec extends Spec + with _$ButtonSpec, Diagnosticable { final FlexSpec flex; final BoxSpec container; final IconSpec icon; @@ -38,4 +40,10 @@ base class ButtonSpec extends Spec with _$ButtonSpec { icon = icon ?? const IconSpec(), label = label ?? const TextSpec(), spinner = spinner ?? const SpinnerSpec(); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + _debugFillProperties(properties); + } } diff --git a/packages/remix/lib/components/button/button.g.dart b/packages/remix/lib/components/button/button.g.dart index 054467f62..a8064f4bf 100644 --- a/packages/remix/lib/components/button/button.g.dart +++ b/packages/remix/lib/components/button/button.g.dart @@ -101,6 +101,15 @@ mixin _$ButtonSpec on Spec { ]; ButtonSpec get _$this => this as ButtonSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add(DiagnosticsProperty('container', _$this.container)); + properties.add(DiagnosticsProperty('flex', _$this.flex)); + properties.add(DiagnosticsProperty('icon', _$this.icon)); + properties.add(DiagnosticsProperty('label', _$this.label)); + properties.add(DiagnosticsProperty('spinner', _$this.spinner)); + properties.add(DiagnosticsProperty('animated', _$this.animated)); + } } /// Represents the attributes of a [ButtonSpec]. @@ -110,7 +119,8 @@ mixin _$ButtonSpec on Spec { /// /// Use this class to configure the attributes of a [ButtonSpec] and pass it to /// the [ButtonSpec] constructor. -base class ButtonSpecAttribute extends SpecAttribute { +base class ButtonSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; final IconSpecAttribute? icon; @@ -181,6 +191,17 @@ base class ButtonSpecAttribute extends SpecAttribute { spinner, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('container', container)); + properties.add(DiagnosticsProperty('flex', flex)); + properties.add(DiagnosticsProperty('icon', icon)); + properties.add(DiagnosticsProperty('label', label)); + properties.add(DiagnosticsProperty('spinner', spinner)); + properties.add(DiagnosticsProperty('animated', animated)); + } } /// Utility class for configuring [ButtonSpecAttribute] properties. diff --git a/packages/remix/lib/components/button/button_style.dart b/packages/remix/lib/components/button/button_style.dart index 83629b468..70e6eba19 100644 --- a/packages/remix/lib/components/button/button_style.dart +++ b/packages/remix/lib/components/button/button_style.dart @@ -9,118 +9,141 @@ final _flex = _util.flex; /// This applies to the icon, label, and spinner final _items = _util.items; -Style get _baseStyle => Style( - _flex.gap(0), - _flex.mainAxisAlignment.center(), - _flex.crossAxisAlignment.center(), - _flex.mainAxisSize.min(), - _container.borderRadius(6), - _spinner.strokeWidth(1), - _label.style.fontWeight(FontWeight.w500), - _label.textHeightBehavior( - const TextHeightBehavior( - applyHeightToFirstAscent: false, - applyHeightToLastDescent: true, - ), +Style get _baseStyle { + return Style( + _flex.gap(0), + _flex.mainAxisAlignment.center(), + _flex.crossAxisAlignment.center(), + _flex.mainAxisSize.min(), + _container.borderRadius(6), + _spinner.strokeWidth(1), + _label.style.fontWeight.w500(), + _label.textHeightBehavior( + const TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: true, ), - ); + ), + ); +} -Style get _onDisabledForeground => Style( - $on.disabled( - _items.color.ref($rx.color.neutralAlpha(7)), - ), - ); +Style get _onDisabledForeground { + return Style( + $on.disabled( + _items.color.$neutralAlpha(7), + ), + ); +} -Style get _solidVariant => Style( - _container.color.ref($rx.color.accent()), - _items.color.ref($rx.color.white()), - $on.hover( - _container.color.ref($rx.color.accent(10)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - ), - ); +Style get _solidVariant { + return Style( + _container.color.$accent(), + _items.color.white(), + $on.hover( + _container.color.$accent(10), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + ), + ); +} -Style get _softVariant => Style( - _container.color.ref($rx.color.accentAlpha(3)), - _items.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(4)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - ), - ); +Style get _softVariant { + return Style( + _container.color.$accentAlpha(3), + _items.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(4), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + ), + ); +} -Style get _outlineVariant => Style( +Style get _outlineVariant { + return Style( + _container.color.transparent(), + _container.border.width(1.5), + _container.border.strokeAlign(0), + _container.border.color.$accentAlpha(8), + _items.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(2), + ), + $on.disabled( + _container.border.color.$neutralAlpha(8), _container.color.transparent(), - _container.border.width(1.5), - _container.border.strokeAlign(0), - _container.border.color.ref($rx.color.accentAlpha(8)), - _items.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(2)), - ), - $on.disabled( - _container.border.color.ref($rx.color.neutralAlpha(8)), - _container.color.transparent(), - ), - ); -Style get _surfaceVariant => Style( - _outlineVariant(), - _container.color.ref($rx.color.accentAlpha(3)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(4)), - _container.border.color.ref($rx.color.accentAlpha(8)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(2)), - ), - ); + ), + ); +} -Style get _ghostVariant => Style( - _container.border.style.none(), - _container.color.transparent(), - _items.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(3)), - ), - ); - -Style get _smallVariant => Style( - _label.style.ref($rx.text.text1), - _container.padding.vertical.ref($rx.space(1)), - _container.padding.horizontal.ref($rx.space(2)), - _flex.gap.ref($rx.space(1)), - _items.size(12), - ); - -Style get _mediumVariant => Style( - _container.padding.vertical.ref($rx.space(2)), - _container.padding.horizontal.ref($rx.space(3)), - _flex.gap.ref($rx.space(2)), - _label.style.ref($rx.text.text2), - _items.size(14), - ); - -Style get _largeVariant => Style( - _container.padding.vertical.ref($rx.space(2)), - _container.padding.horizontal.ref($rx.space(4)), - _flex.gap.ref($rx.space(3)), - _label.style.ref($rx.text.text3), - _items.size(16), - ); - -Style get _xLargeVariant => Style( - _container.padding.vertical.ref($rx.space(3)), - _container.padding.horizontal.ref($rx.space(5)), - _flex.gap.ref($rx.space(3)), - _label.style.ref($rx.text.text4), - _items.size(18), - ); - -Style buildDefaultButtonStyle() { +Style get _surfaceVariant { + return Style( + _outlineVariant(), + _container.color.$accentAlpha(3), + $on.hover( + _container.color.$accentAlpha(4), + _container.border.color.$accentAlpha(8), + ), + $on.disabled( + _container.color.$neutralAlpha(2), + ), + ); +} + +Style get _ghostVariant { + return Style( + _container.border.style.none(), + _container.color.transparent(), + _items.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(3), + ), + ); +} + +Style get _smallVariant { + return Style( + _label.style.$text(1), + _container.padding.vertical.$space(1), + _container.padding.horizontal.$space(2), + _flex.gap.$space(1), + _items.size(12), + ); +} + +Style get _mediumVariant { + return Style( + _container.padding.vertical.$space(2), + _container.padding.horizontal.$space(3), + _flex.gap.$space(2), + _label.style.$text(2), + _items.size(14), + ); +} + +Style get _largeVariant { + return Style( + _container.padding.vertical.$space(2), + _container.padding.horizontal.$space(4), + _flex.gap.$space(3), + _label.style.$text(3), + _items.size(16), + ); +} + +Style get _xLargeVariant { + return Style( + _container.padding.vertical.$space(3), + _container.padding.horizontal.$space(5), + _flex.gap.$space(3), + _label.style.$text(4), + _items.size(18), + ); +} + +Style _buildButtonStyle(Style? style, List variants) { return Style( _baseStyle(), @@ -138,7 +161,7 @@ Style buildDefaultButtonStyle() { ButtonVariant.soft(_softVariant()), ButtonVariant.outline(_outlineVariant()), ButtonVariant.ghost(_ghostVariant()), - ); + ).merge(style).applyVariants(variants); } extension ButtonSpecUtilityX on ButtonSpecUtility { diff --git a/packages/remix/lib/components/button/button_widget.dart b/packages/remix/lib/components/button/button_widget.dart index 647be8c0f..be6ffb8fe 100644 --- a/packages/remix/lib/components/button/button_widget.dart +++ b/packages/remix/lib/components/button/button_widget.dart @@ -66,12 +66,6 @@ class RxButton extends StatelessWidget { bool get _hasIcon => iconLeft != null || iconRight != null; - Style _buildStyle() { - return buildDefaultButtonStyle() - .merge(style) - .applyVariants([size, type]).animate(); - } - Widget _buildLoadingOverlay(ButtonSpec spec, Widget child) { return loading ? Stack( @@ -105,14 +99,15 @@ class RxButton extends StatelessWidget { onPress: disabled || loading ? null : onPressed, enabled: !isDisabled, child: SpecBuilder( - style: _buildStyle(), - builder: (context) { - final spec = ButtonSpec.of(context); - - return spec.container( - child: _buildChildren(spec), - ); - }), + style: _buildButtonStyle(style, [size, type]), + builder: (context) { + final spec = ButtonSpec.of(context); + + return spec.container( + child: _buildChildren(spec), + ); + }, + ), ); } } diff --git a/packages/remix/lib/components/callout/callout_style.dart b/packages/remix/lib/components/callout/callout_style.dart index c9ae9ae44..16a9445c0 100644 --- a/packages/remix/lib/components/callout/callout_style.dart +++ b/packages/remix/lib/components/callout/callout_style.dart @@ -1,6 +1,5 @@ // ignore_for_file: camel_case_types -import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; import 'package:remix/components/callout/callout_spec.dart'; import 'package:remix/components/callout/callout_variants.dart'; @@ -12,31 +11,39 @@ final _flex = _callout.flex; final _icon = _callout.icon; final _text = _callout.text; -Style get _baseStyle => Style( - _container.borderRadius(8), - _container.padding(16), - _flex.gap(16), - _icon.size(24), - _icon.color.ref($rx.color.accentAlpha(11)), - _text.style.color.ref($rx.color.accentAlpha(11)), - _icon.size(20), - ); - -Style get _softVariant => Style( - _container.color.ref($rx.color.accentAlpha(3)), - ); - -Style get _surfaceVariant => Style( - _container.color.ref($rx.color.accentAlpha(2)), - _container.border.width(1), - _container.border.color.ref($rx.color.accentAlpha(5)), - ); - -Style get _outlineVariant => Style( - _container.color(Colors.transparent), - _container.border.width(1), - _container.border.color.ref($rx.color.accentAlpha(8)), - ); +Style get _baseStyle { + return Style( + _container.borderRadius(8), + _container.padding(16), + _flex.gap(16), + _icon.size(24), + _icon.color.$accentAlpha(11), + _text.style.color.$accentAlpha(11), + _icon.size(20), + ); +} + +Style get _softVariant { + return Style( + _container.color.$accentAlpha(3), + ); +} + +Style get _surfaceVariant { + return Style( + _container.color.$accentAlpha(2), + _container.border.width(1), + _container.border.color.$accentAlpha(5), + ); +} + +Style get _outlineVariant { + return Style( + _container.color.transparent(), + _container.border.width(1), + _container.border.color.$accentAlpha(8), + ); +} Style calloutStyle(Style? style, List variants) { return Style( diff --git a/packages/remix/lib/components/card/card.dart b/packages/remix/lib/components/card/card.dart index 9584b4542..24f44f6e3 100644 --- a/packages/remix/lib/components/card/card.dart +++ b/packages/remix/lib/components/card/card.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; @@ -11,7 +12,7 @@ part 'card_variants.dart'; part 'card_widget.dart'; @MixableSpec() -base class CardSpec extends Spec with _$CardSpec { +base class CardSpec extends Spec with _$CardSpec, Diagnosticable { final BoxSpec container; final FlexSpec flex; @@ -27,4 +28,9 @@ base class CardSpec extends Spec with _$CardSpec { super.animated, }) : container = container ?? const BoxSpec(), flex = flex ?? const FlexSpec(); + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + _debugFillProperties(properties); + } } diff --git a/packages/remix/lib/components/card/card.g.dart b/packages/remix/lib/components/card/card.g.dart index edfc4eb23..08c8fed03 100644 --- a/packages/remix/lib/components/card/card.g.dart +++ b/packages/remix/lib/components/card/card.g.dart @@ -87,6 +87,12 @@ mixin _$CardSpec on Spec { ]; CardSpec get _$this => this as CardSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add(DiagnosticsProperty('container', _$this.container)); + properties.add(DiagnosticsProperty('flex', _$this.flex)); + properties.add(DiagnosticsProperty('animated', _$this.animated)); + } } /// Represents the attributes of a [CardSpec]. @@ -96,7 +102,8 @@ mixin _$CardSpec on Spec { /// /// Use this class to configure the attributes of a [CardSpec] and pass it to /// the [CardSpec] constructor. -base class CardSpecAttribute extends SpecAttribute { +base class CardSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; @@ -152,6 +159,14 @@ base class CardSpecAttribute extends SpecAttribute { flex, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('container', container)); + properties.add(DiagnosticsProperty('flex', flex)); + properties.add(DiagnosticsProperty('animated', animated)); + } } /// Utility class for configuring [CardSpecAttribute] properties. diff --git a/packages/remix/lib/components/card/card_style.dart b/packages/remix/lib/components/card/card_style.dart index a6244b9ba..826d08f59 100644 --- a/packages/remix/lib/components/card/card_style.dart +++ b/packages/remix/lib/components/card/card_style.dart @@ -3,34 +3,45 @@ part of 'card.dart'; final _util = CardSpecUtility.self; final _container = _util.container; final _flex = _util.flex; -Style get _baseStyle => Style( - _container.padding(16), - _flex.column(), - _flex.gap(24), - _container.borderRadius(8), - ); +Style get _baseStyle { + return Style( + _container.padding(16), + _flex.column(), + _flex.gap(24), + _container.borderRadius(8), + ); +} + +Style get _solidVariant { + return Style( + _container.border.color.$neutral(1), + ); +} -Style get _solidVariant => Style( - _container.border.color.ref($rx.color.neutral(1)), - ); +Style get _softVariant { + return Style( + _container.color.$neutralAlpha(3), + ); +} -Style get _softVariant => Style( - _container.color.ref($rx.color.neutralAlpha(3)), - ); +Style get _surfaceVariant { + return Style( + _container.color.$neutralAlpha(3), + _container.border.color.$neutralAlpha(7), + _container.border.strokeAlign(1), + ); +} -Style get _surfaceVariant => Style( - _container.color.ref($rx.color.neutralAlpha(3)), - _container.border.color.ref($rx.color.neutralAlpha(7)), - _container.border.strokeAlign(1), - ); +Style get _ghostVariant { + return Style(); +} -Style get _ghostVariant => Style(); -Style buildCardstyle(Style? style) { +Style _buildCustomCardStyle(Style? style, List variants) { return Style( _baseStyle(), CardVariant.solid(_solidVariant()), CardVariant.soft(_softVariant()), CardVariant.ghost(_ghostVariant()), CardVariant.surface(_surfaceVariant()), - ).merge(style); + ).merge(style).applyVariants(variants); } diff --git a/packages/remix/lib/components/card/card_widget.dart b/packages/remix/lib/components/card/card_widget.dart index 8b730bcec..1ad8f6c89 100644 --- a/packages/remix/lib/components/card/card_widget.dart +++ b/packages/remix/lib/components/card/card_widget.dart @@ -4,28 +4,24 @@ class RxCard extends StatelessWidget { const RxCard({ super.key, required this.children, - this.variant = CardVariant.solid, + this.type = CardVariant.solid, this.style, }); /// The list of child widgets to be displayed inside the card. final List children; - final CardVariant variant; + final CardVariant type; /// Additional custom styling for the card. /// /// This allows you to override or extend the default card styling. final Style? style; - Style _buildStyle() { - return buildCardstyle(style).applyVariant(variant).animate(); - } - @override Widget build(BuildContext context) { return SpecBuilder( - style: _buildStyle(), + style: _buildCustomCardStyle(style, [type]), builder: (context) { final spec = CardSpec.of(context); diff --git a/packages/remix/lib/components/checkbox/checkbox.dart b/packages/remix/lib/components/checkbox/checkbox.dart index d8ce5c0da..17fc109cd 100644 --- a/packages/remix/lib/components/checkbox/checkbox.dart +++ b/packages/remix/lib/components/checkbox/checkbox.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; @@ -12,7 +13,8 @@ part 'checkbox_variants.dart'; part 'checkbox_widget.dart'; @MixableSpec() -base class CheckboxSpec extends Spec with _$CheckboxSpec { +base class CheckboxSpec extends Spec + with _$CheckboxSpec, Diagnosticable { final BoxSpec container; final IconSpec indicator; @@ -27,4 +29,10 @@ base class CheckboxSpec extends Spec with _$CheckboxSpec { super.animated, }) : container = container ?? const BoxSpec(), indicator = indicator ?? const IconSpec(); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + _debugFillProperties(properties); + } } diff --git a/packages/remix/lib/components/checkbox/checkbox.g.dart b/packages/remix/lib/components/checkbox/checkbox.g.dart index ec70fd154..ed81cadb7 100644 --- a/packages/remix/lib/components/checkbox/checkbox.g.dart +++ b/packages/remix/lib/components/checkbox/checkbox.g.dart @@ -87,6 +87,12 @@ mixin _$CheckboxSpec on Spec { ]; CheckboxSpec get _$this => this as CheckboxSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add(DiagnosticsProperty('container', _$this.container)); + properties.add(DiagnosticsProperty('indicator', _$this.indicator)); + properties.add(DiagnosticsProperty('animated', _$this.animated)); + } } /// Represents the attributes of a [CheckboxSpec]. @@ -96,7 +102,8 @@ mixin _$CheckboxSpec on Spec { /// /// Use this class to configure the attributes of a [CheckboxSpec] and pass it to /// the [CheckboxSpec] constructor. -base class CheckboxSpecAttribute extends SpecAttribute { +base class CheckboxSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final IconSpecAttribute? indicator; @@ -152,6 +159,14 @@ base class CheckboxSpecAttribute extends SpecAttribute { indicator, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('container', container)); + properties.add(DiagnosticsProperty('indicator', indicator)); + properties.add(DiagnosticsProperty('animated', animated)); + } } /// Utility class for configuring [CheckboxSpecAttribute] properties. diff --git a/packages/remix/lib/components/checkbox/checkbox_style.dart b/packages/remix/lib/components/checkbox/checkbox_style.dart index 86bb5eaa1..ce5a4121e 100644 --- a/packages/remix/lib/components/checkbox/checkbox_style.dart +++ b/packages/remix/lib/components/checkbox/checkbox_style.dart @@ -6,94 +6,115 @@ final _util = CheckboxSpecUtility.self; final _container = _util.container; final _indicator = _util.indicator; -Style get _baseStyle => Style( - _container.borderRadius(4), - ); - -Style get _onDisabledForeground => Style( - $on.disabled( - _indicator.color.ref($rx.color.neutralAlpha(7)), - ), - ); - -Style get _solidVariant => Style( - _container.color.ref($rx.color.accent()), - _indicator.color.ref($rx.color.white()), - $on.hover( - _container.color.ref($rx.color.accent(10)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - ), - ); - -Style get _softVariant => Style( - _container.color.ref($rx.color.accentAlpha(3)), - _indicator.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(4)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - ), - ); -Style get _outlineVariant => Style( - _container.color(Colors.transparent), - _container.border.color.ref($rx.color.accentAlpha(8)), - _container.border.width(1.5), - _indicator.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(2)), - ), - $on.disabled( - _container.border.color.ref($rx.color.neutralAlpha(8)), - _container.color.transparent(), - ), - ); - -Style get _surfaceVariant => Style( - _outlineVariant(), - _container.color.ref($rx.color.accentAlpha(3)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(4)), - _container.border.color.ref($rx.color.accentAlpha(8)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(2)), - ), - ); +Style get _baseStyle { + return Style( + _container.borderRadius(4), + ); +} + +Style get _onDisabledForeground { + return Style( + $on.disabled( + _indicator.color.$neutralAlpha(7), + ), + ); +} + +Style get _solidVariant { + return Style( + _container.color.$accent(), + _indicator.color.white(), + $on.hover( + _container.color.$accent(10), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + ), + ); +} + +Style get _softVariant { + return Style( + _container.color.$accentAlpha(3), + _indicator.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(4), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + ), + ); +} + +Style get _outlineVariant { + return Style( + _container.color.transparent(), + _container.border.color.$accentAlpha(8), + _container.border.width(1.5), + _indicator.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(2), + ), + $on.disabled( + _container.border.color.$neutralAlpha(8), + _container.color.transparent(), + ), + ); +} + +Style get _surfaceVariant { + return Style( + _outlineVariant(), + _container.color.$accentAlpha(3), + $on.hover( + _container.color.$accentAlpha(4), + _container.border.color.$accentAlpha(8), + ), + $on.disabled( + _container.color.$neutralAlpha(2), + ), + ); +} final _ghostVariant = Style( _container.border.style.none(), - _container.color(Colors.transparent), - _indicator.color.ref($rx.color.accentAlpha(11)), + _container.color.transparent(), + _indicator.color.$accentAlpha(11), $on.hover( - _container.color.ref($rx.color.accentAlpha(3)), + _container.color.$accentAlpha(3), ), ); -Style get _disabledVariant => Style( - _container.color.ref($rx.color.neutralAlpha(3)), - _container.border.color.ref($rx.color.neutralAlpha(5)), - _indicator.color.ref($rx.color.neutralAlpha(7)), - ); +Style get _disabledVariant { + return Style( + _container.color.$neutralAlpha(3), + _container.border.color.$neutralAlpha(5), + _indicator.color.$neutralAlpha(7), + ); +} -Style get _smallVariant => Style( - _container.size(16), - _indicator.size(12), - ); +Style get _smallVariant { + return Style( + _container.size(16), + _indicator.size(12), + ); +} -Style get _mediumVariant => Style( - _container.size(20), - _indicator.size(16), - ); +Style get _mediumVariant { + return Style( + _container.size(20), + _indicator.size(16), + ); +} -Style get _largeVariant => Style( - _container.size(24), - _indicator.size(20), - ); +Style get _largeVariant { + return Style( + _container.size(24), + _indicator.size(20), + ); +} -Style _buildDefaultCheckboxStyle() { +Style _buildCheckboxStyle(Style? style, List variants) { return Style( _baseStyle(), @@ -111,18 +132,5 @@ Style _buildDefaultCheckboxStyle() { CheckboxVariant.outline(_outlineVariant()), CheckboxVariant.ghost(_ghostVariant()), $on.disabled(_disabledVariant()), - ); -} - -class RxCheckboxStyle { - const RxCheckboxStyle(); - - Style apply( - Style? style, - List? variants, - ) { - return _buildDefaultCheckboxStyle() - .merge(style) - .applyVariants(variants ?? []); - } + ).merge(style).applyVariants(variants); } diff --git a/packages/remix/lib/components/checkbox/checkbox_widget.dart b/packages/remix/lib/components/checkbox/checkbox_widget.dart index b3fe61c8c..a62bfb793 100644 --- a/packages/remix/lib/components/checkbox/checkbox_widget.dart +++ b/packages/remix/lib/components/checkbox/checkbox_widget.dart @@ -36,12 +36,6 @@ class _RxCheckboxState extends State { void _handleOnPress() => widget.onChanged?.call(!widget.value); - @visibleForTesting - List get variants => [widget.size, widget.variant]; - - @visibleForTesting - Style get style => _buildDefaultCheckboxStyle().merge(widget.style); - @override void initState() { super.initState(); @@ -69,12 +63,13 @@ class _RxCheckboxState extends State { @override Widget build(BuildContext context) { + final variants = [widget.size, widget.variant]; return Pressable( onPress: widget.disabled ? null : _handleOnPress, enabled: !widget.disabled, child: SpecBuilder( controller: _controller, - style: style.applyVariants(variants), + style: _buildCheckboxStyle(widget.style, variants), builder: (context) { final spec = CheckboxSpec.of(context); diff --git a/packages/remix/lib/components/context.md b/packages/remix/lib/components/context.md deleted file mode 100644 index e69de29bb..000000000 diff --git a/packages/remix/lib/components/progress/progress.dart b/packages/remix/lib/components/progress/progress.dart index 92d77455b..cdeb0862c 100644 --- a/packages/remix/lib/components/progress/progress.dart +++ b/packages/remix/lib/components/progress/progress.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; @@ -11,7 +12,8 @@ part 'progress_variants.dart'; part 'progress_widget.dart'; @MixableSpec() -base class ProgressSpec extends Spec with _$ProgressSpec { +base class ProgressSpec extends Spec + with _$ProgressSpec, Diagnosticable { final BoxSpec container; final BoxSpec track; final BoxSpec fill; @@ -29,4 +31,10 @@ base class ProgressSpec extends Spec with _$ProgressSpec { }) : container = container ?? const BoxSpec(), track = track ?? const BoxSpec(), fill = fill ?? const BoxSpec(); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + _debugFillProperties(properties); + } } diff --git a/packages/remix/lib/components/progress/progress.g.dart b/packages/remix/lib/components/progress/progress.g.dart index 9c6d1b5b4..5f8501636 100644 --- a/packages/remix/lib/components/progress/progress.g.dart +++ b/packages/remix/lib/components/progress/progress.g.dart @@ -90,6 +90,13 @@ mixin _$ProgressSpec on Spec { ]; ProgressSpec get _$this => this as ProgressSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add(DiagnosticsProperty('container', _$this.container)); + properties.add(DiagnosticsProperty('track', _$this.track)); + properties.add(DiagnosticsProperty('fill', _$this.fill)); + properties.add(DiagnosticsProperty('animated', _$this.animated)); + } } /// Represents the attributes of a [ProgressSpec]. @@ -99,7 +106,8 @@ mixin _$ProgressSpec on Spec { /// /// Use this class to configure the attributes of a [ProgressSpec] and pass it to /// the [ProgressSpec] constructor. -base class ProgressSpecAttribute extends SpecAttribute { +base class ProgressSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final BoxSpecAttribute? track; final BoxSpecAttribute? fill; @@ -160,6 +168,15 @@ base class ProgressSpecAttribute extends SpecAttribute { fill, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('container', container)); + properties.add(DiagnosticsProperty('track', track)); + properties.add(DiagnosticsProperty('fill', fill)); + properties.add(DiagnosticsProperty('animated', animated)); + } } /// Utility class for configuring [ProgressSpecAttribute] properties. diff --git a/packages/remix/lib/components/progress/progress_style.dart b/packages/remix/lib/components/progress/progress_style.dart index 4b64b9660..0b24af102 100644 --- a/packages/remix/lib/components/progress/progress_style.dart +++ b/packages/remix/lib/components/progress/progress_style.dart @@ -5,60 +5,84 @@ final _container = _progress.container; final _track = _progress.track; final _fill = _progress.fill; -Style get _baseStyle => Style( - _container.borderRadius(99), - _track.color.ref($rx.color.neutralAlpha(3)), - _fill.color.ref($rx.color.accent()), - ); - -final _smallVariant = Style( - _container.height(4), -); - -final _mediumVariant = Style( - _container.height(8), -); - -final _largeVariant = Style( - _container.height(12), -); - -final _classicVariant = Style( - _track.color.ref($rx.color.neutralAlpha(3)), - _fill.color.ref($rx.color.accent()), -); - -final _surfaceVariant = Style( - _track.color.ref($rx.color.neutralAlpha(2)), - _fill.color.ref($rx.color.accent()), -); - -final _softVariant = Style( - _track.color.ref($rx.color.accentAlpha(3)), - _fill.color.ref($rx.color.accent()), -); - -final _noneRadiusVariant = Style( - _container.borderRadius(0), -); - -final _smallRadiusVariant = Style( - _container.borderRadius(4), -); - -final _mediumRadiusVariant = Style( - _container.borderRadius(8), -); - -final _largeRadiusVariant = Style( - _container.borderRadius(12), -); - -final _fullRadiusVariant = Style( - _container.borderRadius(99), -); - -Style buildDefaultProgressStyle() { +Style get _baseStyle { + return Style( + _container.borderRadius(99), + _track.color.$neutralAlpha(3), + _fill.color.$accent(), + ); +} + +Style get _smallVariant { + return Style( + _container.height(4), + ); +} + +Style get _mediumVariant { + return Style( + _container.height(8), + ); +} + +Style get _largeVariant { + return Style( + _container.height(12), + ); +} + +Style get _classicVariant { + return Style( + _track.color.$neutralAlpha(3), + _fill.color.$accent(), + ); +} + +Style get _surfaceVariant { + return Style( + _track.color.$neutralAlpha(2), + _fill.color.$accent(), + ); +} + +Style get _softVariant { + return Style( + _track.color.$accentAlpha(3), + _fill.color.$accent(), + ); +} + +Style get _noneRadiusVariant { + return Style( + _container.borderRadius(0), + ); +} + +Style get _smallRadiusVariant { + return Style( + _container.borderRadius(4), + ); +} + +Style get _mediumRadiusVariant { + return Style( + _container.borderRadius(8), + ); +} + +Style get _largeRadiusVariant { + return Style( + _container.borderRadius(12), + ); +} + +Style get _fullRadiusVariant { + return Style( + _container.borderRadius(99), + ); +} + +Style _buildProgressStyle(Style? style, List variants) { return Style( _baseStyle(), @@ -78,5 +102,5 @@ Style buildDefaultProgressStyle() { ProgressRadius.medium(_mediumRadiusVariant()), ProgressRadius.large(_largeRadiusVariant()), ProgressRadius.full(_fullRadiusVariant()), - ); + ).merge(style).applyVariants(variants); } diff --git a/packages/remix/lib/components/progress/progress_widget.dart b/packages/remix/lib/components/progress/progress_widget.dart index 7179a4425..559556f98 100644 --- a/packages/remix/lib/components/progress/progress_widget.dart +++ b/packages/remix/lib/components/progress/progress_widget.dart @@ -5,30 +5,24 @@ class RxProgress extends StatelessWidget { super.key, this.value = 0.0, this.size = ProgressSize.medium, - this.variant = ProgressVariant.surface, - this.highContrast = false, + this.type = ProgressVariant.surface, this.radius = ProgressRadius.none, + this.style, this.duration, }); final double value; final ProgressSize size; - final ProgressVariant variant; + final ProgressVariant type; + final Style? style; - final bool highContrast; final ProgressRadius radius; final Duration? duration; - Style _buildStyle() { - return buildDefaultProgressStyle().applyVariants( - [size, variant, radius], - ).animate(); - } - @override Widget build(BuildContext context) { return SpecBuilder( - style: _buildStyle(), + style: _buildProgressStyle(style, [size, type, radius]), builder: (context) { final spec = ProgressSpec.of(context); diff --git a/packages/remix/lib/components/radio/radio.dart b/packages/remix/lib/components/radio/radio.dart index 864abcd9c..dbb104858 100644 --- a/packages/remix/lib/components/radio/radio.dart +++ b/packages/remix/lib/components/radio/radio.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; @@ -12,7 +13,7 @@ part 'radio_variants.dart'; part 'radio_widget.dart'; @MixableSpec() -base class RadioSpec extends Spec with _$RadioSpec { +base class RadioSpec extends Spec with _$RadioSpec, Diagnosticable { final BoxSpec container; final BoxSpec indicator; @@ -27,4 +28,10 @@ base class RadioSpec extends Spec with _$RadioSpec { super.animated, }) : container = container ?? const BoxSpec(), indicator = indicator ?? const BoxSpec(); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + _debugFillProperties(properties); + } } diff --git a/packages/remix/lib/components/radio/radio.g.dart b/packages/remix/lib/components/radio/radio.g.dart index b742c878d..073394b2b 100644 --- a/packages/remix/lib/components/radio/radio.g.dart +++ b/packages/remix/lib/components/radio/radio.g.dart @@ -86,6 +86,12 @@ mixin _$RadioSpec on Spec { ]; RadioSpec get _$this => this as RadioSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add(DiagnosticsProperty('container', _$this.container)); + properties.add(DiagnosticsProperty('indicator', _$this.indicator)); + properties.add(DiagnosticsProperty('animated', _$this.animated)); + } } /// Represents the attributes of a [RadioSpec]. @@ -95,7 +101,8 @@ mixin _$RadioSpec on Spec { /// /// Use this class to configure the attributes of a [RadioSpec] and pass it to /// the [RadioSpec] constructor. -base class RadioSpecAttribute extends SpecAttribute { +base class RadioSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final BoxSpecAttribute? indicator; @@ -151,6 +158,14 @@ base class RadioSpecAttribute extends SpecAttribute { indicator, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('container', container)); + properties.add(DiagnosticsProperty('indicator', indicator)); + properties.add(DiagnosticsProperty('animated', animated)); + } } /// Utility class for configuring [RadioSpecAttribute] properties. diff --git a/packages/remix/lib/components/radio/radio_style.dart b/packages/remix/lib/components/radio/radio_style.dart index 0ee7d7d95..c07e66ced 100644 --- a/packages/remix/lib/components/radio/radio_style.dart +++ b/packages/remix/lib/components/radio/radio_style.dart @@ -4,88 +4,109 @@ final _radio = RadioSpecUtility.self; final _container = _radio.container; final _indicator = _radio.indicator; -Style get _baseStyle => Style( - _container.borderRadius(99), - _container.alignment.center(), - _indicator.borderRadius(99), - ); +Style get _baseStyle { + return Style( + _container.borderRadius(99), + _container.alignment.center(), + _indicator.borderRadius(99), + ); +} -Style get _solidVariant => Style( - _container.color.ref($rx.color.accent()), - _indicator.color.ref($rx.color.white()), - $on.hover( - _container.color.ref($rx.color.accent(10)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - ), - ); +Style get _solidVariant { + return Style( + _container.color.$accent(), + _indicator.color.white(), + $on.hover( + _container.color.$accent(10), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + ), + ); +} -Style get _softVariant => Style( - _container.color.ref($rx.color.accentAlpha(3)), - _indicator.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(4)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - ), - ); +Style get _softVariant { + return Style( + _container.color.$accentAlpha(3), + _indicator.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(4), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + ), + ); +} -Style get _outlineVariant => Style( +Style get _outlineVariant { + return Style( + _container.color.transparent(), + _container.border.color.$accentAlpha(8), + _container.border.width(1.5), + _indicator.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(2), + ), + $on.disabled( + _container.border.color.$neutralAlpha(8), _container.color.transparent(), - _container.border.color.ref($rx.color.accentAlpha(8)), - _container.border.width(1.5), - _indicator.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(2)), - ), - $on.disabled( - _container.border.color.ref($rx.color.neutralAlpha(8)), - _container.color.transparent(), - ), - ); + ), + ); +} -Style get _surfaceVariant => Style( - _outlineVariant(), - _container.color.ref($rx.color.accentAlpha(3)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(4)), - _container.border.color.ref($rx.color.accentAlpha(8)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - ), - ); +Style get _surfaceVariant { + return Style( + _outlineVariant(), + _container.color.$accentAlpha(3), + $on.hover( + _container.color.$accentAlpha(4), + _container.border.color.$accentAlpha(8), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + ), + ); +} -Style get _ghostVariant => Style( - _container.border.style.none(), - _container.color.transparent(), - _indicator.color.ref($rx.color.accentAlpha(11)), - $on.hover( - _container.color.ref($rx.color.accentAlpha(3)), - ), - ); -Style get _smallVariant => Style( - _container.size(16), - _indicator.size(8), - ); +Style get _ghostVariant { + return Style( + _container.border.style.none(), + _container.color.transparent(), + _indicator.color.$accentAlpha(11), + $on.hover( + _container.color.$accentAlpha(3), + ), + ); +} + +Style get _smallVariant { + return Style( + _container.size(16), + _indicator.size(8), + ); +} -Style get _mediumVariant => Style( - _container.size(20), - _indicator.size(10), - ); +Style get _mediumVariant { + return Style( + _container.size(20), + _indicator.size(10), + ); +} -Style get _largeVariant => Style( - _container.size(24), - _indicator.size(12), - ); +Style get _largeVariant { + return Style( + _container.size(24), + _indicator.size(12), + ); +} -Style get _disabledVariant => Style( - _container.color.ref($rx.color.neutralAlpha(3)), - _container.border.color.ref($rx.color.neutralAlpha(5)), - _indicator.color.ref($rx.color.neutralAlpha(7)), - ); +Style get _disabledVariant { + return Style( + _container.color.$neutralAlpha(3), + _container.border.color.$neutralAlpha(5), + _indicator.color.$neutralAlpha(7), + ); +} Style buildDefaultRadioStyle() { return Style( diff --git a/packages/remix/lib/components/spinner/spinner.dart b/packages/remix/lib/components/spinner/spinner.dart index 0d4da8b5e..71541a544 100644 --- a/packages/remix/lib/components/spinner/spinner.dart +++ b/packages/remix/lib/components/spinner/spinner.dart @@ -1,5 +1,6 @@ import 'dart:math'; +import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; @@ -19,7 +20,8 @@ enum SpinnerStyle { } @MixableSpec() -final class SpinnerSpec extends Spec with _$SpinnerSpec { +final class SpinnerSpec extends Spec + with _$SpinnerSpec, Diagnosticable { /// Size of the spinner final double size; @@ -38,6 +40,12 @@ final class SpinnerSpec extends Spec with _$SpinnerSpec { static const of = _$SpinnerSpec.of; static const from = _$SpinnerSpec.from; + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + _debugFillProperties(properties); + } + const SpinnerSpec({ double? size, this.strokeWidth, diff --git a/packages/remix/lib/components/spinner/spinner.g.dart b/packages/remix/lib/components/spinner/spinner.g.dart index e424ac09a..3ab77fd10 100644 --- a/packages/remix/lib/components/spinner/spinner.g.dart +++ b/packages/remix/lib/components/spinner/spinner.g.dart @@ -100,6 +100,15 @@ mixin _$SpinnerSpec on Spec { ]; SpinnerSpec get _$this => this as SpinnerSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add(DiagnosticsProperty('size', _$this.size)); + properties.add(DiagnosticsProperty('strokeWidth', _$this.strokeWidth)); + properties.add(DiagnosticsProperty('color', _$this.color)); + properties.add(DiagnosticsProperty('duration', _$this.duration)); + properties.add(DiagnosticsProperty('style', _$this.style)); + properties.add(DiagnosticsProperty('animated', _$this.animated)); + } } /// Represents the attributes of a [SpinnerSpec]. @@ -109,7 +118,8 @@ mixin _$SpinnerSpec on Spec { /// /// Use this class to configure the attributes of a [SpinnerSpec] and pass it to /// the [SpinnerSpec] constructor. -final class SpinnerSpecAttribute extends SpecAttribute { +final class SpinnerSpecAttribute extends SpecAttribute + with Diagnosticable { final double? size; final double? strokeWidth; final ColorDto? color; @@ -180,6 +190,17 @@ final class SpinnerSpecAttribute extends SpecAttribute { style, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('size', size)); + properties.add(DiagnosticsProperty('strokeWidth', strokeWidth)); + properties.add(DiagnosticsProperty('color', color)); + properties.add(DiagnosticsProperty('duration', duration)); + properties.add(DiagnosticsProperty('style', style, expandableValue: true)); + properties.add(DiagnosticsProperty('animated', animated)); + } } /// Utility class for configuring [SpinnerSpecAttribute] properties. diff --git a/packages/remix/lib/components/spinner/spinner_style.dart b/packages/remix/lib/components/spinner/spinner_style.dart index 5ac6a5f0d..86ef90af2 100644 --- a/packages/remix/lib/components/spinner/spinner_style.dart +++ b/packages/remix/lib/components/spinner/spinner_style.dart @@ -2,30 +2,38 @@ part of 'spinner.dart'; final _util = SpinnerSpecUtility.self; -Style get _baseStyle => Style( - _util.color.ref($rx.color.accent()), - ); +Style get _baseStyle { + return Style( + _util.color.$accent(), + ); +} -Style get _smallVariant => Style( - _util.size(16), - _util.strokeWidth(1), - ); +Style get _smallVariant { + return Style( + _util.size(16), + _util.strokeWidth(1), + ); +} -Style get _mediumVariant => Style( - _util.size(24), - _util.strokeWidth(1.5), - ); +Style get _mediumVariant { + return Style( + _util.size(24), + _util.strokeWidth(1.5), + ); +} -Style get _largeVariant => Style( - _util.size(32), - _util.strokeWidth(2), - ); +Style get _largeVariant { + return Style( + _util.size(32), + _util.strokeWidth(2), + ); +} -Style buildSpinnerStyle() { +Style _buildSpinnerStyle(Style? style, List variants) { return Style( _baseStyle(), SpinnerSize.small(_smallVariant()), SpinnerSize.medium(_mediumVariant()), SpinnerSize.large(_largeVariant()), - ); + ).merge(style).applyVariants(variants); } diff --git a/packages/remix/lib/components/spinner/spinner_widget.dart b/packages/remix/lib/components/spinner/spinner_widget.dart index 12e44446d..f3554c725 100644 --- a/packages/remix/lib/components/spinner/spinner_widget.dart +++ b/packages/remix/lib/components/spinner/spinner_widget.dart @@ -10,14 +10,10 @@ class RxSpinner extends StatelessWidget { final Style? style; final SpinnerSize size; - Style _buildStyle() { - return buildSpinnerStyle().merge(style).applyVariant(size).animate(); - } - @override Widget build(BuildContext context) { return SpecBuilder( - style: _buildStyle(), + style: _buildSpinnerStyle(style, [size]), builder: (context) { final SpinnerWidget = SpinnerSpec.of(context); return SpinnerWidget(); diff --git a/packages/remix/lib/components/switch/switch.dart b/packages/remix/lib/components/switch/switch.dart index 79ecc7521..69e839b07 100644 --- a/packages/remix/lib/components/switch/switch.dart +++ b/packages/remix/lib/components/switch/switch.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; @@ -12,7 +13,8 @@ part 'switch_variants.dart'; part 'switch_widget.dart'; @MixableSpec() -base class SwitchSpec extends Spec with _$SwitchSpec { +base class SwitchSpec extends Spec + with _$SwitchSpec, Diagnosticable { final BoxSpec container; final BoxSpec indicator; @@ -26,4 +28,10 @@ base class SwitchSpec extends Spec with _$SwitchSpec { super.animated, }) : container = container ?? const BoxSpec(), indicator = indicator ?? const BoxSpec(); + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + _debugFillProperties(properties); + } } diff --git a/packages/remix/lib/components/switch/switch.g.dart b/packages/remix/lib/components/switch/switch.g.dart index 7c7df07c6..cb6e48c1c 100644 --- a/packages/remix/lib/components/switch/switch.g.dart +++ b/packages/remix/lib/components/switch/switch.g.dart @@ -86,6 +86,12 @@ mixin _$SwitchSpec on Spec { ]; SwitchSpec get _$this => this as SwitchSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add(DiagnosticsProperty('container', _$this.container)); + properties.add(DiagnosticsProperty('indicator', _$this.indicator)); + properties.add(DiagnosticsProperty('animated', _$this.animated)); + } } /// Represents the attributes of a [SwitchSpec]. @@ -95,7 +101,8 @@ mixin _$SwitchSpec on Spec { /// /// Use this class to configure the attributes of a [SwitchSpec] and pass it to /// the [SwitchSpec] constructor. -base class SwitchSpecAttribute extends SpecAttribute { +base class SwitchSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final BoxSpecAttribute? indicator; @@ -151,6 +158,14 @@ base class SwitchSpecAttribute extends SpecAttribute { indicator, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties.add(DiagnosticsProperty('container', container)); + properties.add(DiagnosticsProperty('indicator', indicator)); + properties.add(DiagnosticsProperty('animated', animated)); + } } /// Utility class for configuring [SwitchSpecAttribute] properties. diff --git a/packages/remix/lib/components/switch/switch_style.dart b/packages/remix/lib/components/switch/switch_style.dart index c98f48cf4..3839d3ed5 100644 --- a/packages/remix/lib/components/switch/switch_style.dart +++ b/packages/remix/lib/components/switch/switch_style.dart @@ -5,106 +5,122 @@ final _util = SwitchSpecUtility.self; final _container = _util.container; final _indicator = _util.indicator; -Style get _baseStyle => Style( - _container.borderRadius(99), - _indicator.borderRadius(99), - $on.selected( - _container.alignment.centerRight(), - ), - $on.unselected( - _container.alignment.centerLeft(), - ), - ); +Style get _baseStyle { + return Style( + _container.borderRadius(99), + _indicator.borderRadius(99), + $on.selected( + _container.alignment.centerRight(), + ), + $on.unselected( + _container.alignment.centerLeft(), + ), + ); +} -Style get _solidVariant => Style( - _indicator.color.ref($rx.color.white()), - $on.selected( - _container.color.ref($rx.color.accent()), - ), - $on.unselected( - _container.color.ref($rx.color.neutral(3)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - _indicator.color.ref($rx.color.neutralAlpha(7)), - ), - ); +Style get _solidVariant { + return Style( + _indicator.color.white(), + $on.selected( + _container.color.$accent(), + ), + $on.unselected( + _container.color.$neutral(3), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + _indicator.color.$neutralAlpha(7), + ), + ); +} -Style get _softVariant => Style( - _indicator.color.ref($rx.color.accentAlpha(11)), - $on.selected( - _container.color.ref($rx.color.accentAlpha(3)), - ), - $on.unselected( - _container.color.ref($rx.color.neutral(4)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(3)), - _indicator.color.ref($rx.color.neutralAlpha(7)), - ), - ); +Style get _softVariant { + return Style( + _indicator.color.$accentAlpha(11), + $on.selected( + _container.color.$accentAlpha(3), + ), + $on.unselected( + _container.color.$neutral(4), + ), + $on.disabled( + _container.color.$neutralAlpha(3), + _indicator.color.$neutralAlpha(7), + ), + ); +} -Style get _outlineVariant => Style( - _container.color.transparent(), - _container.border.width(1.5), - _container.border.strokeAlign(1), - _indicator.color.ref($rx.color.accentAlpha(11)), - $on.selected( - _container.border.color.ref($rx.color.accentAlpha(8)), - ), - $on.unselected( - _container.border.color.ref($rx.color.neutral(4)), - ), - $on.disabled( - _container.border.color.ref($rx.color.neutralAlpha(8)), - _indicator.color.ref($rx.color.neutralAlpha(7)), - ), - ); +Style get _outlineVariant { + return Style( + _container.color.transparent(), + _container.border.width(1.5), + _container.border.strokeAlign(1), + _indicator.color.$accentAlpha(11), + $on.selected( + _container.border.color.$accentAlpha(8), + ), + $on.unselected( + _container.border.color.$neutral(4), + ), + $on.disabled( + _container.border.color.$neutralAlpha(8), + _indicator.color.$neutralAlpha(7), + ), + ); +} -Style get _surfaceVariant => Style( - _outlineVariant(), - $on.selected( - _container.color.ref($rx.color.accentAlpha(3)), - ), - $on.unselected( - _container.color.ref($rx.color.neutralAlpha(3)), - _container.border.color.ref($rx.color.neutral(4)), - ), - $on.disabled( - _container.color.ref($rx.color.neutralAlpha(2)), - ), - ); +Style get _surfaceVariant { + return Style( + _outlineVariant(), + $on.selected( + _container.color.$accentAlpha(3), + ), + $on.unselected( + _container.color.$neutralAlpha(3), + _container.border.color.$neutral(4), + ), + $on.disabled( + _container.color.$neutralAlpha(2), + ), + ); +} -Style get _smallVariant => Style( - _container.width(24), +Style get _smallVariant { + return Style( + _container.width(24), + _container.padding.horizontal(2), + _container.height(16), + _indicator.size(12), + $on.unselected( + _indicator.size(8), _container.padding.horizontal(2), - _container.height(16), - _indicator.size(12), - $on.unselected( - _indicator.size(8), - _container.padding.horizontal(2), - ), - ); + ), + ); +} -Style get _mediumVariant => Style( - _container.width(32), - _container.padding.horizontal(3), - _container.height(20), - _indicator.size(14), - $on.unselected( - _indicator.size(12), - ), - ); +Style get _mediumVariant { + return Style( + _container.width(32), + _container.padding.horizontal(3), + _container.height(20), + _indicator.size(14), + $on.unselected( + _indicator.size(12), + ), + ); +} -Style get _largeVariant => Style( - _container.width(40), - _container.padding.horizontal(3), - _container.height(24), - _indicator.size(18), - $on.unselected(_indicator.size(16)), - ); +Style get _largeVariant { + return Style( + _container.width(40), + _container.padding.horizontal(3), + _container.height(24), + _indicator.size(18), + $on.unselected(_indicator.size(16)), + ); +} -Style buildSwitchStyle() { +Style _buildSwitchStyle(Style? style, List variants) { return Style( _baseStyle(), // Sizes @@ -115,5 +131,5 @@ Style buildSwitchStyle() { SwitchVariant.soft(_softVariant()), SwitchVariant.outline(_outlineVariant()), SwitchVariant.surface(_surfaceVariant()), - ); + ).merge(style).applyVariants(variants); } diff --git a/packages/remix/lib/components/switch/switch_widget.dart b/packages/remix/lib/components/switch/switch_widget.dart index 0ed8f605a..782287407 100644 --- a/packages/remix/lib/components/switch/switch_widget.dart +++ b/packages/remix/lib/components/switch/switch_widget.dart @@ -1,6 +1,6 @@ part of 'switch.dart'; -class RxSwitch extends StatelessWidget { +class RxSwitch extends StatefulWidget { const RxSwitch({ super.key, required this.value, @@ -18,22 +18,49 @@ class RxSwitch extends StatelessWidget { final Style? style; final bool disabled; - void _handleOnPress() => onChanged.call(!value); + @override + State createState() => _RxSwitchState(); +} + +class _RxSwitchState extends State { + late final MixWidgetStateController _controller; + void _handleOnPress() => widget.onChanged.call(!widget.value); + + @override + void initState() { + super.initState(); + _controller = MixWidgetStateController(); + } - Style _buildStyle() { - return buildSwitchStyle().merge(style).applyVariants([ - size, - variant, - ]).animate(); + @override + void didUpdateWidget(RxSwitch oldWidget) { + super.didUpdateWidget(oldWidget); + + if (oldWidget.value != widget.value) { + _controller.selected = widget.value; + } + + if (oldWidget.disabled != widget.disabled) { + _controller.disabled = widget.disabled; + } + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); } @override Widget build(BuildContext context) { return Pressable( - onPress: disabled ? null : _handleOnPress, - enabled: !disabled, + onPress: widget.disabled ? null : _handleOnPress, + enabled: !widget.disabled, child: SpecBuilder( - style: _buildStyle(), + style: _buildSwitchStyle(widget.style, [ + widget.size, + widget.variant, + ]), builder: (context) { final spec = SwitchSpec.of(context); diff --git a/packages/remix/lib/tokens/color_tokens.dart b/packages/remix/lib/tokens/color_tokens.dart index fb20539dc..c31decd64 100644 --- a/packages/remix/lib/tokens/color_tokens.dart +++ b/packages/remix/lib/tokens/color_tokens.dart @@ -1,6 +1,4 @@ -import 'package:flutter/rendering.dart'; -import 'package:mix/mix.dart'; -import 'package:remix/helpers/color_palette.dart'; +part of 'remix_tokens.dart'; class RemixColor { const RemixColor(this.value); diff --git a/packages/remix/lib/tokens/radius_tokens.dart b/packages/remix/lib/tokens/radius_tokens.dart index 1d4bdfb0e..78f446902 100644 --- a/packages/remix/lib/tokens/radius_tokens.dart +++ b/packages/remix/lib/tokens/radius_tokens.dart @@ -1,5 +1,4 @@ -import 'package:flutter/rendering.dart'; -import 'package:mix/mix.dart'; +part of 'remix_tokens.dart'; class RemixRadius { RemixRadius(); diff --git a/packages/remix/lib/tokens/remix_tokens.dart b/packages/remix/lib/tokens/remix_tokens.dart index 24de66fca..7005af80f 100644 --- a/packages/remix/lib/tokens/remix_tokens.dart +++ b/packages/remix/lib/tokens/remix_tokens.dart @@ -1,9 +1,12 @@ import 'package:flutter/material.dart'; import 'package:mix/mix.dart'; -import 'package:remix/tokens/color_tokens.dart'; -import 'package:remix/tokens/radius_tokens.dart'; -import 'package:remix/tokens/space_tokens.dart'; -import 'package:remix/tokens/text_style_tokens.dart'; + +import '../helpers/color_palette.dart'; + +part 'color_tokens.dart'; +part 'radius_tokens.dart'; +part 'space_tokens.dart'; +part 'text_style_tokens.dart'; final $rx = _RemixTokenRef(); @@ -48,3 +51,24 @@ class RemixTokens extends StatelessWidget { ); } } + +extension ColorUtilityX on ColorUtility { + T $black() => ref($rx.color.black()); + T $white() => ref($rx.color.white()); + T $neutral([int? step]) => ref($rx.color.neutral(step)); + T $neutralAlpha([int? step]) => ref($rx.color.neutralAlpha(step)); + T $accent([int? step]) => ref($rx.color.accent(step)); + T $accentAlpha([int? step]) => ref($rx.color.accentAlpha(step)); +} + +extension SpacingSideUtilityX on SpacingSideUtility { + T $space(int step) => ref($rx.space(step)); +} + +extension GapUtilityX on GapUtility { + T $space(int step) => ref($rx.space(step)); +} + +extension TextStyleUtilityX on TextStyleUtility { + T $text(int level) => ref($rx.text(level)); +} diff --git a/packages/remix/lib/tokens/space_tokens.dart b/packages/remix/lib/tokens/space_tokens.dart index de2435ed6..8fd666548 100644 --- a/packages/remix/lib/tokens/space_tokens.dart +++ b/packages/remix/lib/tokens/space_tokens.dart @@ -1,4 +1,4 @@ -import 'package:mix/mix.dart'; +part of 'remix_tokens.dart'; class RemixSpace { RemixSpace(); @@ -18,30 +18,18 @@ class RemixSpace { } SpaceToken call(int step) { - switch (step) { - case 1: - return space1; - case 2: - return space2; - case 3: - return space3; - case 4: - return space4; - case 5: - return space5; - case 6: - return space6; - case 7: - return space7; - case 8: - return space8; - case 9: - return space9; - default: - throw Exception( - 'Invalid space step: $step found. Space step should be between 1 and 9.', - ); - } + return switch (step) { + 1 => space1, + 2 => space2, + 3 => space3, + 4 => space4, + 5 => space5, + 6 => space6, + 7 => space7, + 8 => space8, + 9 => space9, + _ => throw ArgumentError('Invalid space step: $step'), + }; } } diff --git a/packages/remix/lib/tokens/text_style_tokens.dart b/packages/remix/lib/tokens/text_style_tokens.dart index 90c32f5dd..e08523b1d 100644 --- a/packages/remix/lib/tokens/text_style_tokens.dart +++ b/packages/remix/lib/tokens/text_style_tokens.dart @@ -1,9 +1,23 @@ -import 'package:flutter/widgets.dart'; -import 'package:mix/mix.dart'; +part of 'remix_tokens.dart'; class RemixTypography { RemixTypography(); + TextStyleToken call(int level) { + return switch (level) { + 1 => text1, + 2 => text2, + 3 => text3, + 4 => text4, + 5 => text5, + 6 => text6, + 7 => text7, + 8 => text8, + 9 => text9, + _ => throw ArgumentError('Invalid text level: $level'), + }; + } + final text1 = const TextStyleToken('--text-1'); final text2 = const TextStyleToken('--text-2'); final text3 = const TextStyleToken('--text-3'); From be99760718624c69bc4d3254ff113fdbe9d76f16 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Fri, 26 Jul 2024 13:33:32 -0400 Subject: [PATCH 3/7] improvements for remix --- .gitignore | 3 +- lints.yaml | 53 +++ melos.yaml | 5 + packages/mix/analysis_options.yaml | 59 +-- packages/mix/pubspec.yaml | 4 +- .../mix_annotations/analysis_options.yaml | 33 +- packages/mix_generator/analysis_options.yaml | 3 + packages/mix_generator/pubspec.yaml | 2 +- packages/mix_lint/analysis_options.yaml | 3 + packages/remix/analysis_options.yaml | 9 +- packages/remix/build.yaml | 2 +- .../ephemeral/FlutterInputs.xcfilelist | 137 ++++-- packages/remix/demo/pubspec.yaml | 4 +- .../remix/lib/components/button/button.dart | 6 +- .../remix/lib/components/button/button.g.dart | 19 +- .../lib/components/button/button_style.dart | 9 +- .../lib/components/callout/callout_spec.dart | 1 + .../components/callout/callout_spec.g.dart | 15 +- packages/remix/lib/components/card/card.dart | 1 + .../remix/lib/components/card/card.g.dart | 17 +- .../lib/components/checkbox/checkbox.dart | 1 + .../lib/components/checkbox/checkbox.g.dart | 17 +- .../components/checkbox/checkbox_widget.dart | 11 +- .../lib/components/progress/progress.dart | 1 + .../lib/components/progress/progress.g.dart | 17 +- .../remix/lib/components/radio/radio.dart | 1 + .../remix/lib/components/radio/radio.g.dart | 17 +- .../remix/lib/components/spinner/spinner.dart | 1 + .../lib/components/spinner/spinner.g.dart | 17 +- .../remix/lib/components/switch/switch.dart | 1 + .../remix/lib/components/switch/switch.g.dart | 17 +- .../remix/lib/modifiers/flutter_animate.dart | 84 ++++ .../lib/modifiers/flutter_animate.g.dart | 222 +++++++++ packages/remix/pubspec.yaml | 5 +- packages/remix/scripts/markdown.dart | 11 +- schemas/melos.yaml.schema.json | 435 ++++++++++++++++++ 36 files changed, 1101 insertions(+), 142 deletions(-) create mode 100644 lints.yaml create mode 100644 packages/remix/lib/modifiers/flutter_animate.dart create mode 100644 packages/remix/lib/modifiers/flutter_animate.g.dart mode change 100644 => 100755 packages/remix/scripts/markdown.dart create mode 100644 schemas/melos.yaml.schema.json diff --git a/.gitignore b/.gitignore index 96ec726a7..ab294c0b5 100644 --- a/.gitignore +++ b/.gitignore @@ -95,4 +95,5 @@ pubspec_overrides.yaml pubspec.lock # FVM Version Cache -.fvm/ \ No newline at end of file +.fvm/ +packages/remix/context.md diff --git a/lints.yaml b/lints.yaml new file mode 100644 index 000000000..a2f40db53 --- /dev/null +++ b/lints.yaml @@ -0,0 +1,53 @@ +analyzer: + exclude: +linter: + rules: + # TODO: Turn this to true when all public apis are documented + public_member_api_docs: false + prefer_relative_imports: true + +dart_code_metrics: + extends: + - package:dart_code_metrics_presets/recommended.yaml + - package:dart_code_metrics_presets/metrics_recommended.yaml + metrics-exclude: + - test/** + rules-exclude: + - test/** + rules: + # avoid-collection-mutating-methods: true + newline-before-return: true + avoid-importing-entrypoint-exports: + only-in-src: true + prefer-match-file-name: false + prefer-overriding-parent-equality: false + prefer-correct-callback-field-name: false + prefer-single-widget-per-file: false + match-getter-setter-field-names: false + prefer-dedicated-media-query-methods: false + avoid-shadowing: false + enum-constants-ordering: false + avoid-unsafe-collection-methods: false + prefer-prefixed-global-constants: false + avoid-returning-widgets: false + arguments-ordering: + child-last: true + avoid-nested-conditional-expressions: + acceptable-level: 3 + member-ordering: + order: + - public-fields + - private-fields + - constructors + - static-methods + - private-methods + - private-getters + - private-setters + - public-getters + - public-setters + - public-methods + - overridden-public-methods + - overridden-public-getters + - build-method + prefer-named-boolean-parameters: + ignore-single: true \ No newline at end of file diff --git a/melos.yaml b/melos.yaml index 59481657d..889e92937 100644 --- a/melos.yaml +++ b/melos.yaml @@ -1,3 +1,4 @@ +# yaml-language-server: $schema=./schemas/melos.yaml.schema.json name: mix_workspace sdkPath: .fvm/flutter_sdk @@ -12,6 +13,10 @@ command: environment: sdk: ">=3.3.0 <4.0.0" flutter: ">=3.19.0" + dev_dependencies: + flutter_lints: ^4.0.0 + dart_code_metrics_presets: ^2.14.0 + build_runner: ^2.4.9 publish: hooks: pre: melos run gen:build diff --git a/packages/mix/analysis_options.yaml b/packages/mix/analysis_options.yaml index 59107ac57..944da7902 100644 --- a/packages/mix/analysis_options.yaml +++ b/packages/mix/analysis_options.yaml @@ -1,57 +1,4 @@ -include: package:flutter_lints/flutter.yaml - -analyzer: - exclude: - # - "**/*.g.dart -linter: - rules: - # TODO: Turn this to true when all public apis are documented - public_member_api_docs: false - prefer_relative_imports: true - -dart_code_metrics: - extends: - - package:dart_code_metrics_presets/recommended.yaml - - package:dart_code_metrics_presets/metrics_recommended.yaml - metrics-exclude: - - test/** - rules-exclude: - - test/** - rules: - # avoid-collection-mutating-methods: true - newline-before-return: true - avoid-importing-entrypoint-exports: - only-in-src: true - prefer-match-file-name: false - prefer-overriding-parent-equality: false - prefer-correct-callback-field-name: false - prefer-single-widget-per-file: false - match-getter-setter-field-names: false - prefer-dedicated-media-query-methods: false - avoid-shadowing: false - enum-constants-ordering: false - avoid-unsafe-collection-methods: false - prefer-prefixed-global-constants: false - avoid-returning-widgets: false - arguments-ordering: - child-last: true - avoid-nested-conditional-expressions: - acceptable-level: 3 - member-ordering: - order: - - public-fields - - private-fields - - constructors - - static-methods - - private-methods - - private-getters - - private-setters - - public-getters - - public-setters - - public-methods - - overridden-public-methods - - overridden-public-getters - - build-method - prefer-named-boolean-parameters: - ignore-single: true \ No newline at end of file +includes: + - ../../lints.yaml + - package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/packages/mix/pubspec.yaml b/packages/mix/pubspec.yaml index fe6aebe53..3ddc43b19 100644 --- a/packages/mix/pubspec.yaml +++ b/packages/mix/pubspec.yaml @@ -14,10 +14,10 @@ dependencies: dev_dependencies: flutter_lints: ^4.0.0 + dart_code_metrics_presets: ^2.14.0 + build_runner: ^2.4.9 flutter_test: sdk: flutter - dart_code_metrics_presets: ^2.13.0 - build_runner: ^2.4.9 mix_generator: ^0.2.1 # flutter: diff --git a/packages/mix_annotations/analysis_options.yaml b/packages/mix_annotations/analysis_options.yaml index dee8927aa..c8c1ce08f 100644 --- a/packages/mix_annotations/analysis_options.yaml +++ b/packages/mix_annotations/analysis_options.yaml @@ -1,30 +1,3 @@ -# This file configures the static analysis results for your project (errors, -# warnings, and lints). -# -# This enables the 'recommended' set of lints from `package:lints`. -# This set helps identify many issues that may lead to problems when running -# or consuming Dart code, and enforces writing Dart using a single, idiomatic -# style and format. -# -# If you want a smaller set of lints you can change this to specify -# 'package:lints/core.yaml'. These are just the most critical lints -# (the recommended set includes the core lints). -# The core lints are also what is used by pub.dev for scoring packages. - -include: package:lints/recommended.yaml - -# Uncomment the following section to specify additional rules. - -# linter: -# rules: -# - camel_case_types - -# analyzer: -# exclude: -# - path/to/excluded/files/** - -# For more information about the core and recommended set of lints, see -# https://dart.dev/go/core-lints - -# For additional information about configuring this file, see -# https://dart.dev/guides/language/analysis-options +includes: + - ../../lints.yaml + - package:lints/recommended.yaml diff --git a/packages/mix_generator/analysis_options.yaml b/packages/mix_generator/analysis_options.yaml index e69de29bb..c8c1ce08f 100644 --- a/packages/mix_generator/analysis_options.yaml +++ b/packages/mix_generator/analysis_options.yaml @@ -0,0 +1,3 @@ +includes: + - ../../lints.yaml + - package:lints/recommended.yaml diff --git a/packages/mix_generator/pubspec.yaml b/packages/mix_generator/pubspec.yaml index c4143b6de..3a13653b1 100644 --- a/packages/mix_generator/pubspec.yaml +++ b/packages/mix_generator/pubspec.yaml @@ -19,7 +19,7 @@ dependencies: dev_dependencies: test: ^1.24.4 - dart_code_metrics_presets: ^2.13.0 + dart_code_metrics_presets: ^2.14.0 build_runner: ^2.4.9 build_test: ^2.2.2 source_gen_test: ^1.0.6 \ No newline at end of file diff --git a/packages/mix_lint/analysis_options.yaml b/packages/mix_lint/analysis_options.yaml index e69de29bb..41548f82e 100644 --- a/packages/mix_lint/analysis_options.yaml +++ b/packages/mix_lint/analysis_options.yaml @@ -0,0 +1,3 @@ +includes: + - ../../lints.yaml + - package:lints/recommended.yaml \ No newline at end of file diff --git a/packages/remix/analysis_options.yaml b/packages/remix/analysis_options.yaml index 099c1131f..982a5daec 100644 --- a/packages/remix/analysis_options.yaml +++ b/packages/remix/analysis_options.yaml @@ -1,6 +1,3 @@ -include: package:flutter_lints/flutter.yaml - -linter: - rules: - library_private_types_in_public_api: false - non_constant_identifier_names: false +includes: + - ../../lints.yaml + - package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/packages/remix/build.yaml b/packages/remix/build.yaml index ed7f3fc57..8cf4d8a06 100644 --- a/packages/remix/build.yaml +++ b/packages/remix/build.yaml @@ -3,7 +3,7 @@ targets: builders: mix_generator|spec: generate_for: - - lib/components/**/*.dart + - lib/**/*.dart mix_generator|dto: generate_for: - lib/components/**/*.dart \ No newline at end of file diff --git a/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist b/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist index 390c10104..acb13711d 100644 --- a/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist +++ b/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist @@ -212,7 +212,57 @@ /Users/leofarias/.pub-cache/hosted/pub.dev/fake_async-1.3.1/lib/fake_async.dart /Users/leofarias/.pub-cache/hosted/pub.dev/file-7.0.0/LICENSE /Users/leofarias/.pub-cache/hosted/pub.dev/fixnum-1.1.0/LICENSE +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/LICENSE +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/flutter_animate.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/adapters/adapter.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/adapters/adapters.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/adapters/change_notifier_adapter.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/adapters/scroll_adapter.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/adapters/value_adapter.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/adapters/value_notifier_adapter.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/animate.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/animate_list.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effect_list.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/align_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/blur_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/box_shadow_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/callback_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/color_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/crossfade_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/custom_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/effects.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/elevation_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/fade_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/flip_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/follow_path_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/listen_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/move_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/rotate_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/saturate_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/scale_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/shader_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/shake_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/shimmer_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/slide_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/swap_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/then_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/tint_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/toggle_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/effects/visibility_effect.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/extensions/animation_controller_loop_extensions.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/extensions/extensions.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/extensions/num_duration_extensions.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/extensions/offset_copy_with_extensions.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/flutter_animate.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_animate-4.5.0/lib/src/warn.dart /Users/leofarias/.pub-cache/hosted/pub.dev/flutter_lints-2.0.3/LICENSE +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_shaders-0.1.2/LICENSE +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_shaders-0.1.2/lib/flutter_shaders.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_shaders-0.1.2/lib/src/animated_sampler.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_shaders-0.1.2/lib/src/inkwell_shader.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_shaders-0.1.2/lib/src/set_uniforms.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/flutter_shaders-0.1.2/lib/src/shader_builder.dart /Users/leofarias/.pub-cache/hosted/pub.dev/freezed_annotation-2.4.3/LICENSE /Users/leofarias/.pub-cache/hosted/pub.dev/freezed_annotation-2.4.3/lib/freezed_annotation.dart /Users/leofarias/.pub-cache/hosted/pub.dev/freezed_annotation-2.4.3/lib/freezed_annotation.g.dart @@ -492,6 +542,30 @@ /Users/leofarias/.pub-cache/hosted/pub.dev/timing-1.0.1/LICENSE /Users/leofarias/.pub-cache/hosted/pub.dev/typed_data-1.3.2/LICENSE /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/LICENSE +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/aabb2.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/aabb3.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/colors.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/constants.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/error_helpers.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/frustum.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/intersection_result.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/matrix2.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/matrix3.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/matrix4.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/noise.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/obb3.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/opengl.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/plane.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/quad.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/quaternion.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/ray.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/sphere.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/triangle.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/utilities.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/vector.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/vector2.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/vector3.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math/vector4.dart /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math_64/aabb2.dart /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math_64/aabb3.dart /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math_64/colors.dart @@ -516,6 +590,7 @@ /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math_64/vector2.dart /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math_64/vector3.dart /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/src/vector_math_64/vector4.dart +/Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/vector_math.dart /Users/leofarias/.pub-cache/hosted/pub.dev/vector_math-2.1.4/lib/vector_math_64.dart /Users/leofarias/.pub-cache/hosted/pub.dev/vm_service-13.0.0/LICENSE /Users/leofarias/.pub-cache/hosted/pub.dev/vm_service-13.0.0/lib/src/dart_io_extensions.dart @@ -714,7 +789,6 @@ /Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/animated/animated_data.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/animated/animated_data_dto.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/animated/animated_util.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/attributes.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/border/border_dto.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/border/border_dto.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/border/border_radius_dto.dart @@ -759,7 +833,6 @@ /Users/leofarias/Projects/mix/packages/mix/lib/src/attributes/text_style/text_style_util.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/attribute.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/attributes_map.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/core/core.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/deprecation_notices.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/directive.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/dto.dart @@ -768,14 +841,16 @@ /Users/leofarias/Projects/mix/packages/mix/lib/src/core/factory/style_mix.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/factory/style_widgets_ext.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/helpers.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/core/internal/widget_state/gesturable_builder.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/core/internal/widget_state/interactive_widget.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/core/internal/widget_state/widget_state.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/modifier.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/spec.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/styled_widget.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/utility.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/core/variant.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/core/widget_state/internal/gesture_mix_state.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/core/widget_state/internal/interactive_mix_state.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/core/widget_state/internal/mix_widget_state_builder.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/core/widget_state/internal/mouse_region_mix_state.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/core/widget_state/widget_state_controller.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/internal/build_context_ext.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/internal/compare_mixin.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/internal/constants.dart @@ -783,22 +858,32 @@ /Users/leofarias/Projects/mix/packages/mix/lib/src/internal/diagnostic_properties_builder_ext.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/internal/helper_util.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/internal/iterable_ext.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/internal/lerp_helpers.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/internal/string_ext.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/align_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/align_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/aspect_ratio_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/aspect_ratio_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/clip_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/clip_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/flexible_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/flexible_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/fractionally_sized_box_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/fractionally_sized_box_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/internal/render_widget_modifier.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/intrinsic_widget_modifier.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/modifiers.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/intrinsic_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/opacity_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/opacity_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/padding_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/padding_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/rotated_box_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/rotated_box_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/sized_box_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/sized_box_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/transform_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/transform_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/visibility_widget_modifier.dart +/Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/visibility_widget_modifier.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/modifiers/widget_modifiers_util.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/box/box_spec.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/box/box_spec.g.dart @@ -813,7 +898,6 @@ /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/image/image_spec.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/image/image_widget.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/spec_util.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/specs/specs.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/stack/stack_spec.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/stack/stack_spec.g.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/specs/stack/stack_widget.dart @@ -824,7 +908,6 @@ /Users/leofarias/Projects/mix/packages/mix/lib/src/theme/material/material_theme.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/theme/material/material_tokens.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/theme/mix/mix_theme.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/theme/theme.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/theme/tokens/breakpoints_token.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/theme/tokens/color_token.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/theme/tokens/mix_token.dart @@ -841,10 +924,8 @@ /Users/leofarias/Projects/mix/packages/mix/lib/src/variants/context_variant_util/on_orientation_util.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/variants/context_variant_util/on_util.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/variants/variant_attribute.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/variants/variants.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/variants/widget_state_variant.dart /Users/leofarias/Projects/mix/packages/mix/lib/src/widgets/pressable_widget.dart -/Users/leofarias/Projects/mix/packages/mix/lib/src/widgets/widgets.dart /Users/leofarias/Projects/mix/packages/mix_annotations/LICENSE /Users/leofarias/Projects/mix/packages/mix_annotations/lib/mix_annotations.dart /Users/leofarias/Projects/mix/packages/mix_annotations/lib/src/annotations.dart @@ -862,13 +943,13 @@ /Users/leofarias/Projects/mix/packages/remix/demo/lib/main.dart /Users/leofarias/Projects/mix/packages/remix/demo/lib/main.directories.g.dart /Users/leofarias/Projects/mix/packages/remix/demo/pubspec.yaml -/Users/leofarias/Projects/mix/packages/remix/lib/components/avatar/avatar_spec.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/avatar/avatar_spec.g.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/avatar/avatar.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/avatar/avatar.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/avatar/avatar_style.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/avatar/avatar_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/avatar/avatar_widget.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/button/button_spec.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/button/button_spec.g.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/button/button.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/button/button.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/button/button_style.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/button/button_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/button/button_widget.dart @@ -877,35 +958,37 @@ /Users/leofarias/Projects/mix/packages/remix/lib/components/callout/callout_style.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/callout/callout_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/callout/callout_widget.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/card/card_spec.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/card/card_spec.g.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/card/card.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/card/card.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/card/card_style.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/card/card_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/card/card_widget.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/checkbox/checkbox_spec.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/checkbox/checkbox_spec.g.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/checkbox/checkbox.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/checkbox/checkbox.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/checkbox/checkbox_style.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/checkbox/checkbox_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/checkbox/checkbox_widget.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/radio/radio_spec.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/radio/radio_spec.g.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/radio/radio.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/radio/radio.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/radio/radio_style.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/radio/radio_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/radio/radio_widget.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner.style.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner.variants.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner_painter.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner_spec.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner_spec.g.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner_style.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/spinner/spinner_widget.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/switch/switch_spec.dart -/Users/leofarias/Projects/mix/packages/remix/lib/components/switch/switch_spec.g.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/switch/switch.dart +/Users/leofarias/Projects/mix/packages/remix/lib/components/switch/switch.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/switch/switch_style.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/switch/switch_variants.dart /Users/leofarias/Projects/mix/packages/remix/lib/components/switch/switch_widget.dart /Users/leofarias/Projects/mix/packages/remix/lib/helpers/color_palette.dart /Users/leofarias/Projects/mix/packages/remix/lib/helpers/utility_extension.dart /Users/leofarias/Projects/mix/packages/remix/lib/helpers/variant.dart +/Users/leofarias/Projects/mix/packages/remix/lib/modifiers/flutter_animate.dart +/Users/leofarias/Projects/mix/packages/remix/lib/modifiers/flutter_animate.g.dart /Users/leofarias/Projects/mix/packages/remix/lib/remix.dart /Users/leofarias/Projects/mix/packages/remix/lib/tokens/color_tokens.dart /Users/leofarias/Projects/mix/packages/remix/lib/tokens/radius_tokens.dart diff --git a/packages/remix/demo/pubspec.yaml b/packages/remix/demo/pubspec.yaml index 0756b1bc7..feee88abd 100644 --- a/packages/remix/demo/pubspec.yaml +++ b/packages/remix/demo/pubspec.yaml @@ -24,9 +24,9 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^4.0.0 widgetbook_generator: ^3.8.0 - build_runner: ^2.4.8 + build_runner: ^2.4.9 flutter: uses-material-design: true diff --git a/packages/remix/lib/components/button/button.dart b/packages/remix/lib/components/button/button.dart index aa70a1dd6..61cfcbdf6 100644 --- a/packages/remix/lib/components/button/button.dart +++ b/packages/remix/lib/components/button/button.dart @@ -1,8 +1,10 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_animate/flutter_animate.dart'; import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; import 'package:remix/components/spinner/spinner.dart'; +import 'package:remix/modifiers/flutter_animate.dart'; import '../../helpers/variant.dart'; import '../../tokens/remix_tokens.dart'; @@ -13,8 +15,7 @@ part 'button_variants.dart'; part 'button_widget.dart'; @MixableSpec() -base class ButtonSpec extends Spec - with _$ButtonSpec, Diagnosticable { +class ButtonSpec extends Spec with _$ButtonSpec, Diagnosticable { final FlexSpec flex; final BoxSpec container; final IconSpec icon; @@ -33,6 +34,7 @@ base class ButtonSpec extends Spec FlexSpec? flex, IconSpec? icon, TextSpec? label, + super.modifiers, SpinnerSpec? spinner, super.animated, }) : flex = flex ?? const FlexSpec(), diff --git a/packages/remix/lib/components/button/button.g.dart b/packages/remix/lib/components/button/button.g.dart index a8064f4bf..759514360 100644 --- a/packages/remix/lib/components/button/button.g.dart +++ b/packages/remix/lib/components/button/button.g.dart @@ -37,6 +37,7 @@ mixin _$ButtonSpec on Spec { FlexSpec? flex, IconSpec? icon, TextSpec? label, + WidgetModifiersData? modifiers, SpinnerSpec? spinner, AnimatedData? animated, }) { @@ -45,6 +46,7 @@ mixin _$ButtonSpec on Spec { flex: flex ?? _$this.flex, icon: icon ?? _$this.icon, label: label ?? _$this.label, + modifiers: modifiers ?? _$this.modifiers, spinner: spinner ?? _$this.spinner, animated: animated ?? _$this.animated, ); @@ -66,7 +68,7 @@ mixin _$ButtonSpec on Spec { /// - [IconSpec.lerp] for [icon]. /// - [TextSpec.lerp] for [label]. - /// For [spinner] and [animated], the interpolation is performed using a step function. + /// For [modifiers] and [spinner] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [ButtonSpec] is used. Otherwise, the value /// from the [other] [ButtonSpec] is used. /// @@ -81,6 +83,7 @@ mixin _$ButtonSpec on Spec { flex: _$this.flex.lerp(other.flex, t), icon: _$this.icon.lerp(other.icon, t), label: _$this.label.lerp(other.label, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, spinner: _$this.spinner.lerp(other.spinner, t), animated: t < 0.5 ? _$this.animated : other.animated, ); @@ -96,6 +99,7 @@ mixin _$ButtonSpec on Spec { _$this.flex, _$this.icon, _$this.label, + _$this.modifiers, _$this.spinner, _$this.animated, ]; @@ -107,6 +111,7 @@ mixin _$ButtonSpec on Spec { properties.add(DiagnosticsProperty('flex', _$this.flex)); properties.add(DiagnosticsProperty('icon', _$this.icon)); properties.add(DiagnosticsProperty('label', _$this.label)); + properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); properties.add(DiagnosticsProperty('spinner', _$this.spinner)); properties.add(DiagnosticsProperty('animated', _$this.animated)); } @@ -119,7 +124,7 @@ mixin _$ButtonSpec on Spec { /// /// Use this class to configure the attributes of a [ButtonSpec] and pass it to /// the [ButtonSpec] constructor. -base class ButtonSpecAttribute extends SpecAttribute +class ButtonSpecAttribute extends SpecAttribute with Diagnosticable { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; @@ -132,6 +137,7 @@ base class ButtonSpecAttribute extends SpecAttribute this.flex, this.icon, this.label, + super.modifiers, this.spinner, super.animated, }); @@ -151,6 +157,7 @@ base class ButtonSpecAttribute extends SpecAttribute flex: flex?.resolve(mix), icon: icon?.resolve(mix), label: label?.resolve(mix), + modifiers: modifiers?.resolve(mix), spinner: spinner?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); @@ -173,6 +180,7 @@ base class ButtonSpecAttribute extends SpecAttribute flex: flex?.merge(other.flex) ?? other.flex, icon: icon?.merge(other.icon) ?? other.icon, label: label?.merge(other.label) ?? other.label, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, spinner: spinner?.merge(other.spinner) ?? other.spinner, animated: animated?.merge(other.animated) ?? other.animated, ); @@ -188,6 +196,7 @@ base class ButtonSpecAttribute extends SpecAttribute flex, icon, label, + modifiers, spinner, animated, ]; @@ -199,6 +208,7 @@ base class ButtonSpecAttribute extends SpecAttribute properties.add(DiagnosticsProperty('flex', flex)); properties.add(DiagnosticsProperty('icon', icon)); properties.add(DiagnosticsProperty('label', label)); + properties.add(DiagnosticsProperty('modifiers', modifiers)); properties.add(DiagnosticsProperty('spinner', spinner)); properties.add(DiagnosticsProperty('animated', animated)); } @@ -222,6 +232,9 @@ class ButtonSpecUtility /// Utility for defining [ButtonSpecAttribute.label] late final label = TextSpecUtility((v) => only(label: v)); + /// Utility for defining [ButtonSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [ButtonSpecAttribute.spinner] late final spinner = SpinnerSpecUtility((v) => only(spinner: v)); @@ -239,6 +252,7 @@ class ButtonSpecUtility FlexSpecAttribute? flex, IconSpecAttribute? icon, TextSpecAttribute? label, + WidgetModifiersDataDto? modifiers, SpinnerSpecAttribute? spinner, AnimatedDataDto? animated, }) { @@ -247,6 +261,7 @@ class ButtonSpecUtility flex: flex, icon: icon, label: label, + modifiers: modifiers, spinner: spinner, animated: animated, )); diff --git a/packages/remix/lib/components/button/button_style.dart b/packages/remix/lib/components/button/button_style.dart index 70e6eba19..7b7b9bd90 100644 --- a/packages/remix/lib/components/button/button_style.dart +++ b/packages/remix/lib/components/button/button_style.dart @@ -5,13 +5,20 @@ final _label = _util.label; final _spinner = _util.spinner; final _container = _util.container; final _flex = _util.flex; +final $animate = FlutterAnimateUtility.self; /// This applies to the icon, label, and spinner final _items = _util.items; Style get _baseStyle { return Style( - _flex.gap(0), + $animate() + .fadeIn(duration: 600.ms) + .then( + delay: 200.ms, + ) + .slide(), + $on.press($animate().scale()), _flex.mainAxisAlignment.center(), _flex.crossAxisAlignment.center(), _flex.mainAxisSize.min(), diff --git a/packages/remix/lib/components/callout/callout_spec.dart b/packages/remix/lib/components/callout/callout_spec.dart index 7625053c0..581cea34f 100644 --- a/packages/remix/lib/components/callout/callout_spec.dart +++ b/packages/remix/lib/components/callout/callout_spec.dart @@ -21,6 +21,7 @@ base class CalloutSpec extends Spec with _$CalloutSpec { FlexSpec? flex, IconSpec? icon, TextSpec? text, + super.modifiers, super.animated, }) : container = container ?? const BoxSpec(), flex = flex ?? const FlexSpec(), diff --git a/packages/remix/lib/components/callout/callout_spec.g.dart b/packages/remix/lib/components/callout/callout_spec.g.dart index 3f45a5687..b4aa82c82 100644 --- a/packages/remix/lib/components/callout/callout_spec.g.dart +++ b/packages/remix/lib/components/callout/callout_spec.g.dart @@ -37,6 +37,7 @@ mixin _$CalloutSpec on Spec { FlexSpec? flex, IconSpec? icon, TextSpec? text, + WidgetModifiersData? modifiers, AnimatedData? animated, }) { return CalloutSpec( @@ -44,6 +45,7 @@ mixin _$CalloutSpec on Spec { flex: flex ?? _$this.flex, icon: icon ?? _$this.icon, text: text ?? _$this.text, + modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); } @@ -64,7 +66,7 @@ mixin _$CalloutSpec on Spec { /// - [IconSpec.lerp] for [icon]. /// - [TextSpec.lerp] for [text]. - /// For [animated], the interpolation is performed using a step function. + /// For [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [CalloutSpec] is used. Otherwise, the value /// from the [other] [CalloutSpec] is used. /// @@ -79,6 +81,7 @@ mixin _$CalloutSpec on Spec { flex: _$this.flex.lerp(other.flex, t), icon: _$this.icon.lerp(other.icon, t), text: _$this.text.lerp(other.text, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -93,6 +96,7 @@ mixin _$CalloutSpec on Spec { _$this.flex, _$this.icon, _$this.text, + _$this.modifiers, _$this.animated, ]; @@ -117,6 +121,7 @@ base class CalloutSpecAttribute extends SpecAttribute { this.flex, this.icon, this.text, + super.modifiers, super.animated, }); @@ -135,6 +140,7 @@ base class CalloutSpecAttribute extends SpecAttribute { flex: flex?.resolve(mix), icon: icon?.resolve(mix), text: text?.resolve(mix), + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -156,6 +162,7 @@ base class CalloutSpecAttribute extends SpecAttribute { flex: flex?.merge(other.flex) ?? other.flex, icon: icon?.merge(other.icon) ?? other.icon, text: text?.merge(other.text) ?? other.text, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); } @@ -170,6 +177,7 @@ base class CalloutSpecAttribute extends SpecAttribute { flex, icon, text, + modifiers, animated, ]; } @@ -192,6 +200,9 @@ class CalloutSpecUtility /// Utility for defining [CalloutSpecAttribute.text] late final text = TextSpecUtility((v) => only(text: v)); + /// Utility for defining [CalloutSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [CalloutSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -206,6 +217,7 @@ class CalloutSpecUtility FlexSpecAttribute? flex, IconSpecAttribute? icon, TextSpecAttribute? text, + WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(CalloutSpecAttribute( @@ -213,6 +225,7 @@ class CalloutSpecUtility flex: flex, icon: icon, text: text, + modifiers: modifiers, animated: animated, )); } diff --git a/packages/remix/lib/components/card/card.dart b/packages/remix/lib/components/card/card.dart index 24f44f6e3..baf37c36b 100644 --- a/packages/remix/lib/components/card/card.dart +++ b/packages/remix/lib/components/card/card.dart @@ -25,6 +25,7 @@ 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(); diff --git a/packages/remix/lib/components/card/card.g.dart b/packages/remix/lib/components/card/card.g.dart index 08c8fed03..6ba035e48 100644 --- a/packages/remix/lib/components/card/card.g.dart +++ b/packages/remix/lib/components/card/card.g.dart @@ -35,11 +35,13 @@ mixin _$CardSpec on Spec { 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 +60,7 @@ mixin _$CardSpec on Spec { /// - [BoxSpec.lerp] for [container]. /// - [FlexSpec.lerp] for [flex]. - /// For [animated], the interpolation is performed using a step function. + /// 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 /// from the [other] [CardSpec] is used. /// @@ -71,6 +73,7 @@ mixin _$CardSpec on Spec { return CardSpec( container: _$this.container.lerp(other.container, t), flex: _$this.flex.lerp(other.flex, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -83,6 +86,7 @@ mixin _$CardSpec on Spec { List get props => [ _$this.container, _$this.flex, + _$this.modifiers, _$this.animated, ]; @@ -91,6 +95,7 @@ mixin _$CardSpec on Spec { void _debugFillProperties(DiagnosticPropertiesBuilder properties) { properties.add(DiagnosticsProperty('container', _$this.container)); properties.add(DiagnosticsProperty('flex', _$this.flex)); + properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); properties.add(DiagnosticsProperty('animated', _$this.animated)); } } @@ -110,6 +115,7 @@ base class CardSpecAttribute extends SpecAttribute const CardSpecAttribute({ this.container, this.flex, + super.modifiers, super.animated, }); @@ -126,6 +132,7 @@ base class CardSpecAttribute extends SpecAttribute return CardSpec( container: container?.resolve(mix), flex: flex?.resolve(mix), + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -145,6 +152,7 @@ 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, ); } @@ -157,6 +165,7 @@ base class CardSpecAttribute extends SpecAttribute List get props => [ container, flex, + modifiers, animated, ]; @@ -165,6 +174,7 @@ base class CardSpecAttribute extends SpecAttribute super.debugFillProperties(properties); properties.add(DiagnosticsProperty('container', container)); properties.add(DiagnosticsProperty('flex', flex)); + properties.add(DiagnosticsProperty('modifiers', modifiers)); properties.add(DiagnosticsProperty('animated', animated)); } } @@ -181,6 +191,9 @@ class CardSpecUtility /// 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)); + /// Utility for defining [CardSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -193,11 +206,13 @@ class CardSpecUtility 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/components/checkbox/checkbox.dart b/packages/remix/lib/components/checkbox/checkbox.dart index 17fc109cd..df91ea491 100644 --- a/packages/remix/lib/components/checkbox/checkbox.dart +++ b/packages/remix/lib/components/checkbox/checkbox.dart @@ -26,6 +26,7 @@ base class CheckboxSpec extends Spec const CheckboxSpec({ BoxSpec? container, IconSpec? indicator, + super.modifiers, super.animated, }) : container = container ?? const BoxSpec(), indicator = indicator ?? const IconSpec(); diff --git a/packages/remix/lib/components/checkbox/checkbox.g.dart b/packages/remix/lib/components/checkbox/checkbox.g.dart index ed81cadb7..3d86d15c4 100644 --- a/packages/remix/lib/components/checkbox/checkbox.g.dart +++ b/packages/remix/lib/components/checkbox/checkbox.g.dart @@ -35,11 +35,13 @@ mixin _$CheckboxSpec on Spec { CheckboxSpec copyWith({ BoxSpec? container, IconSpec? indicator, + WidgetModifiersData? modifiers, AnimatedData? animated, }) { return CheckboxSpec( container: container ?? _$this.container, indicator: indicator ?? _$this.indicator, + modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); } @@ -58,7 +60,7 @@ mixin _$CheckboxSpec on Spec { /// - [BoxSpec.lerp] for [container]. /// - [IconSpec.lerp] for [indicator]. - /// For [animated], the interpolation is performed using a step function. + /// For [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [CheckboxSpec] is used. Otherwise, the value /// from the [other] [CheckboxSpec] is used. /// @@ -71,6 +73,7 @@ mixin _$CheckboxSpec on Spec { return CheckboxSpec( container: _$this.container.lerp(other.container, t), indicator: _$this.indicator.lerp(other.indicator, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -83,6 +86,7 @@ mixin _$CheckboxSpec on Spec { List get props => [ _$this.container, _$this.indicator, + _$this.modifiers, _$this.animated, ]; @@ -91,6 +95,7 @@ mixin _$CheckboxSpec on Spec { void _debugFillProperties(DiagnosticPropertiesBuilder properties) { properties.add(DiagnosticsProperty('container', _$this.container)); properties.add(DiagnosticsProperty('indicator', _$this.indicator)); + properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); properties.add(DiagnosticsProperty('animated', _$this.animated)); } } @@ -110,6 +115,7 @@ base class CheckboxSpecAttribute extends SpecAttribute const CheckboxSpecAttribute({ this.container, this.indicator, + super.modifiers, super.animated, }); @@ -126,6 +132,7 @@ base class CheckboxSpecAttribute extends SpecAttribute return CheckboxSpec( container: container?.resolve(mix), indicator: indicator?.resolve(mix), + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -145,6 +152,7 @@ base class CheckboxSpecAttribute extends SpecAttribute return CheckboxSpecAttribute( container: container?.merge(other.container) ?? other.container, indicator: indicator?.merge(other.indicator) ?? other.indicator, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); } @@ -157,6 +165,7 @@ base class CheckboxSpecAttribute extends SpecAttribute List get props => [ container, indicator, + modifiers, animated, ]; @@ -165,6 +174,7 @@ base class CheckboxSpecAttribute extends SpecAttribute super.debugFillProperties(properties); properties.add(DiagnosticsProperty('container', container)); properties.add(DiagnosticsProperty('indicator', indicator)); + properties.add(DiagnosticsProperty('modifiers', modifiers)); properties.add(DiagnosticsProperty('animated', animated)); } } @@ -181,6 +191,9 @@ class CheckboxSpecUtility /// Utility for defining [CheckboxSpecAttribute.indicator] late final indicator = IconSpecUtility((v) => only(indicator: v)); + /// Utility for defining [CheckboxSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [CheckboxSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -193,11 +206,13 @@ class CheckboxSpecUtility T only({ BoxSpecAttribute? container, IconSpecAttribute? indicator, + WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(CheckboxSpecAttribute( container: container, indicator: indicator, + modifiers: modifiers, animated: animated, )); } diff --git a/packages/remix/lib/components/checkbox/checkbox_widget.dart b/packages/remix/lib/components/checkbox/checkbox_widget.dart index a62bfb793..4dffd20a8 100644 --- a/packages/remix/lib/components/checkbox/checkbox_widget.dart +++ b/packages/remix/lib/components/checkbox/checkbox_widget.dart @@ -33,6 +33,7 @@ class RxCheckbox extends StatefulWidget { class _RxCheckboxState extends State { late final MixWidgetStateController _controller; + late Style _style; void _handleOnPress() => widget.onChanged?.call(!widget.value); @@ -40,6 +41,7 @@ class _RxCheckboxState extends State { void initState() { super.initState(); _controller = MixWidgetStateController(); + _style = _buildCheckboxStyle(widget.style, [widget.size, widget.variant]); } @override @@ -53,6 +55,12 @@ class _RxCheckboxState extends State { if (oldWidget.disabled != widget.disabled) { _controller.disabled = widget.disabled; } + + if (oldWidget.style != widget.style || + oldWidget.size != widget.size || + oldWidget.variant != widget.variant) { + _style = _buildCheckboxStyle(widget.style, [widget.size, widget.variant]); + } } @override @@ -63,13 +71,12 @@ class _RxCheckboxState extends State { @override Widget build(BuildContext context) { - final variants = [widget.size, widget.variant]; return Pressable( onPress: widget.disabled ? null : _handleOnPress, enabled: !widget.disabled, child: SpecBuilder( controller: _controller, - style: _buildCheckboxStyle(widget.style, variants), + style: _style, builder: (context) { final spec = CheckboxSpec.of(context); diff --git a/packages/remix/lib/components/progress/progress.dart b/packages/remix/lib/components/progress/progress.dart index cdeb0862c..11e1d9443 100644 --- a/packages/remix/lib/components/progress/progress.dart +++ b/packages/remix/lib/components/progress/progress.dart @@ -28,6 +28,7 @@ base class ProgressSpec extends Spec BoxSpec? track, BoxSpec? fill, super.animated, + super.modifiers, }) : container = container ?? const BoxSpec(), track = track ?? const BoxSpec(), fill = fill ?? const BoxSpec(); diff --git a/packages/remix/lib/components/progress/progress.g.dart b/packages/remix/lib/components/progress/progress.g.dart index 5f8501636..c1395fdb0 100644 --- a/packages/remix/lib/components/progress/progress.g.dart +++ b/packages/remix/lib/components/progress/progress.g.dart @@ -37,12 +37,14 @@ mixin _$ProgressSpec on Spec { BoxSpec? track, BoxSpec? fill, AnimatedData? animated, + WidgetModifiersData? modifiers, }) { return ProgressSpec( container: container ?? _$this.container, track: track ?? _$this.track, fill: fill ?? _$this.fill, animated: animated ?? _$this.animated, + modifiers: modifiers ?? _$this.modifiers, ); } @@ -59,7 +61,7 @@ mixin _$ProgressSpec on Spec { /// /// - [BoxSpec.lerp] for [container] and [track] and [fill]. - /// For [animated], the interpolation is performed using a step function. + /// For [animated] and [modifiers], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [ProgressSpec] is used. Otherwise, the value /// from the [other] [ProgressSpec] is used. /// @@ -74,6 +76,7 @@ mixin _$ProgressSpec on Spec { track: _$this.track.lerp(other.track, t), fill: _$this.fill.lerp(other.fill, t), animated: t < 0.5 ? _$this.animated : other.animated, + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, ); } @@ -87,6 +90,7 @@ mixin _$ProgressSpec on Spec { _$this.track, _$this.fill, _$this.animated, + _$this.modifiers, ]; ProgressSpec get _$this => this as ProgressSpec; @@ -96,6 +100,7 @@ mixin _$ProgressSpec on Spec { properties.add(DiagnosticsProperty('track', _$this.track)); properties.add(DiagnosticsProperty('fill', _$this.fill)); properties.add(DiagnosticsProperty('animated', _$this.animated)); + properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); } } @@ -117,6 +122,7 @@ base class ProgressSpecAttribute extends SpecAttribute this.track, this.fill, super.animated, + super.modifiers, }); /// Resolves to [ProgressSpec] using the provided [MixData]. @@ -134,6 +140,7 @@ base class ProgressSpecAttribute extends SpecAttribute track: track?.resolve(mix), fill: fill?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, + modifiers: modifiers?.resolve(mix), ); } @@ -154,6 +161,7 @@ base class ProgressSpecAttribute extends SpecAttribute track: track?.merge(other.track) ?? other.track, fill: fill?.merge(other.fill) ?? other.fill, animated: animated?.merge(other.animated) ?? other.animated, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, ); } @@ -167,6 +175,7 @@ base class ProgressSpecAttribute extends SpecAttribute track, fill, animated, + modifiers, ]; @override @@ -176,6 +185,7 @@ base class ProgressSpecAttribute extends SpecAttribute properties.add(DiagnosticsProperty('track', track)); properties.add(DiagnosticsProperty('fill', fill)); properties.add(DiagnosticsProperty('animated', animated)); + properties.add(DiagnosticsProperty('modifiers', modifiers)); } } @@ -197,6 +207,9 @@ class ProgressSpecUtility /// Utility for defining [ProgressSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); + /// Utility for defining [ProgressSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + ProgressSpecUtility(super.builder); static final self = ProgressSpecUtility((v) => v); @@ -208,12 +221,14 @@ class ProgressSpecUtility BoxSpecAttribute? track, BoxSpecAttribute? fill, AnimatedDataDto? animated, + WidgetModifiersDataDto? modifiers, }) { return builder(ProgressSpecAttribute( container: container, track: track, fill: fill, animated: animated, + modifiers: modifiers, )); } } diff --git a/packages/remix/lib/components/radio/radio.dart b/packages/remix/lib/components/radio/radio.dart index dbb104858..f68b6920c 100644 --- a/packages/remix/lib/components/radio/radio.dart +++ b/packages/remix/lib/components/radio/radio.dart @@ -25,6 +25,7 @@ base class RadioSpec extends Spec with _$RadioSpec, Diagnosticable { const RadioSpec({ BoxSpec? container, BoxSpec? indicator, + super.modifiers, super.animated, }) : container = container ?? const BoxSpec(), indicator = indicator ?? const BoxSpec(); diff --git a/packages/remix/lib/components/radio/radio.g.dart b/packages/remix/lib/components/radio/radio.g.dart index 073394b2b..8a9582b1b 100644 --- a/packages/remix/lib/components/radio/radio.g.dart +++ b/packages/remix/lib/components/radio/radio.g.dart @@ -35,11 +35,13 @@ mixin _$RadioSpec on Spec { RadioSpec copyWith({ BoxSpec? container, BoxSpec? indicator, + WidgetModifiersData? modifiers, AnimatedData? animated, }) { return RadioSpec( container: container ?? _$this.container, indicator: indicator ?? _$this.indicator, + modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); } @@ -57,7 +59,7 @@ mixin _$RadioSpec on Spec { /// /// - [BoxSpec.lerp] for [container] and [indicator]. - /// For [animated], the interpolation is performed using a step function. + /// For [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [RadioSpec] is used. Otherwise, the value /// from the [other] [RadioSpec] is used. /// @@ -70,6 +72,7 @@ mixin _$RadioSpec on Spec { return RadioSpec( container: _$this.container.lerp(other.container, t), indicator: _$this.indicator.lerp(other.indicator, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -82,6 +85,7 @@ mixin _$RadioSpec on Spec { List get props => [ _$this.container, _$this.indicator, + _$this.modifiers, _$this.animated, ]; @@ -90,6 +94,7 @@ mixin _$RadioSpec on Spec { void _debugFillProperties(DiagnosticPropertiesBuilder properties) { properties.add(DiagnosticsProperty('container', _$this.container)); properties.add(DiagnosticsProperty('indicator', _$this.indicator)); + properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); properties.add(DiagnosticsProperty('animated', _$this.animated)); } } @@ -109,6 +114,7 @@ base class RadioSpecAttribute extends SpecAttribute const RadioSpecAttribute({ this.container, this.indicator, + super.modifiers, super.animated, }); @@ -125,6 +131,7 @@ base class RadioSpecAttribute extends SpecAttribute return RadioSpec( container: container?.resolve(mix), indicator: indicator?.resolve(mix), + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -144,6 +151,7 @@ base class RadioSpecAttribute extends SpecAttribute return RadioSpecAttribute( container: container?.merge(other.container) ?? other.container, indicator: indicator?.merge(other.indicator) ?? other.indicator, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); } @@ -156,6 +164,7 @@ base class RadioSpecAttribute extends SpecAttribute List get props => [ container, indicator, + modifiers, animated, ]; @@ -164,6 +173,7 @@ base class RadioSpecAttribute extends SpecAttribute super.debugFillProperties(properties); properties.add(DiagnosticsProperty('container', container)); properties.add(DiagnosticsProperty('indicator', indicator)); + properties.add(DiagnosticsProperty('modifiers', modifiers)); properties.add(DiagnosticsProperty('animated', animated)); } } @@ -180,6 +190,9 @@ class RadioSpecUtility /// Utility for defining [RadioSpecAttribute.indicator] late final indicator = BoxSpecUtility((v) => only(indicator: v)); + /// Utility for defining [RadioSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [RadioSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -192,11 +205,13 @@ class RadioSpecUtility T only({ BoxSpecAttribute? container, BoxSpecAttribute? indicator, + WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(RadioSpecAttribute( container: container, indicator: indicator, + modifiers: modifiers, animated: animated, )); } diff --git a/packages/remix/lib/components/spinner/spinner.dart b/packages/remix/lib/components/spinner/spinner.dart index 71541a544..24e97d2f5 100644 --- a/packages/remix/lib/components/spinner/spinner.dart +++ b/packages/remix/lib/components/spinner/spinner.dart @@ -52,6 +52,7 @@ final class SpinnerSpec extends Spec Color? color, Duration? duration, SpinnerStyle? style, + super.modifiers, super.animated, }) : size = size ?? 24, color = color ?? Colors.white, diff --git a/packages/remix/lib/components/spinner/spinner.g.dart b/packages/remix/lib/components/spinner/spinner.g.dart index 3ab77fd10..1a30c9447 100644 --- a/packages/remix/lib/components/spinner/spinner.g.dart +++ b/packages/remix/lib/components/spinner/spinner.g.dart @@ -38,6 +38,7 @@ mixin _$SpinnerSpec on Spec { Color? color, Duration? duration, SpinnerStyle? style, + WidgetModifiersData? modifiers, AnimatedData? animated, }) { return SpinnerSpec( @@ -46,6 +47,7 @@ mixin _$SpinnerSpec on Spec { color: color ?? _$this.color, duration: duration ?? _$this.duration, style: style ?? _$this.style, + modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); } @@ -64,7 +66,7 @@ mixin _$SpinnerSpec on Spec { /// - [MixHelpers.lerpDouble] for [size] and [strokeWidth]. /// - [Color.lerp] for [color]. - /// For [duration] and [style] and [animated], the interpolation is performed using a step function. + /// For [duration] and [style] and [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [SpinnerSpec] is used. Otherwise, the value /// from the [other] [SpinnerSpec] is used. /// @@ -81,6 +83,7 @@ mixin _$SpinnerSpec on Spec { color: Color.lerp(_$this.color, other.color, t)!, duration: t < 0.5 ? _$this.duration : other.duration, style: t < 0.5 ? _$this.style : other.style, + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -96,6 +99,7 @@ mixin _$SpinnerSpec on Spec { _$this.color, _$this.duration, _$this.style, + _$this.modifiers, _$this.animated, ]; @@ -107,6 +111,7 @@ mixin _$SpinnerSpec on Spec { properties.add(DiagnosticsProperty('color', _$this.color)); properties.add(DiagnosticsProperty('duration', _$this.duration)); properties.add(DiagnosticsProperty('style', _$this.style)); + properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); properties.add(DiagnosticsProperty('animated', _$this.animated)); } } @@ -132,6 +137,7 @@ final class SpinnerSpecAttribute extends SpecAttribute this.color, this.duration, this.style, + super.modifiers, super.animated, }); @@ -151,6 +157,7 @@ final class SpinnerSpecAttribute extends SpecAttribute color: color?.resolve(mix), duration: duration, style: style, + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -173,6 +180,7 @@ final class SpinnerSpecAttribute extends SpecAttribute color: color?.merge(other.color) ?? other.color, duration: other.duration ?? duration, style: other.style ?? style, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); } @@ -188,6 +196,7 @@ final class SpinnerSpecAttribute extends SpecAttribute color, duration, style, + modifiers, animated, ]; @@ -199,6 +208,7 @@ final class SpinnerSpecAttribute extends SpecAttribute properties.add(DiagnosticsProperty('color', color)); properties.add(DiagnosticsProperty('duration', duration)); properties.add(DiagnosticsProperty('style', style, expandableValue: true)); + properties.add(DiagnosticsProperty('modifiers', modifiers)); properties.add(DiagnosticsProperty('animated', animated)); } } @@ -224,6 +234,9 @@ class SpinnerSpecUtility /// Utility for defining [SpinnerSpecAttribute.style] late final style = SpinnerStyleUtility((v) => only(style: v)); + /// Utility for defining [SpinnerSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [SpinnerSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -239,6 +252,7 @@ class SpinnerSpecUtility ColorDto? color, Duration? duration, SpinnerStyle? style, + WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(SpinnerSpecAttribute( @@ -247,6 +261,7 @@ class SpinnerSpecUtility color: color, duration: duration, style: style, + modifiers: modifiers, animated: animated, )); } diff --git a/packages/remix/lib/components/switch/switch.dart b/packages/remix/lib/components/switch/switch.dart index 69e839b07..1e567a60f 100644 --- a/packages/remix/lib/components/switch/switch.dart +++ b/packages/remix/lib/components/switch/switch.dart @@ -26,6 +26,7 @@ base class SwitchSpec extends Spec BoxSpec? container, BoxSpec? indicator, super.animated, + super.modifiers, }) : container = container ?? const BoxSpec(), indicator = indicator ?? const BoxSpec(); diff --git a/packages/remix/lib/components/switch/switch.g.dart b/packages/remix/lib/components/switch/switch.g.dart index cb6e48c1c..e4a2eb150 100644 --- a/packages/remix/lib/components/switch/switch.g.dart +++ b/packages/remix/lib/components/switch/switch.g.dart @@ -36,11 +36,13 @@ mixin _$SwitchSpec on Spec { BoxSpec? container, BoxSpec? indicator, AnimatedData? animated, + WidgetModifiersData? modifiers, }) { return SwitchSpec( container: container ?? _$this.container, indicator: indicator ?? _$this.indicator, animated: animated ?? _$this.animated, + modifiers: modifiers ?? _$this.modifiers, ); } @@ -57,7 +59,7 @@ mixin _$SwitchSpec on Spec { /// /// - [BoxSpec.lerp] for [container] and [indicator]. - /// For [animated], the interpolation is performed using a step function. + /// For [animated] and [modifiers], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [SwitchSpec] is used. Otherwise, the value /// from the [other] [SwitchSpec] is used. /// @@ -71,6 +73,7 @@ mixin _$SwitchSpec on Spec { container: _$this.container.lerp(other.container, t), indicator: _$this.indicator.lerp(other.indicator, t), animated: t < 0.5 ? _$this.animated : other.animated, + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, ); } @@ -83,6 +86,7 @@ mixin _$SwitchSpec on Spec { _$this.container, _$this.indicator, _$this.animated, + _$this.modifiers, ]; SwitchSpec get _$this => this as SwitchSpec; @@ -91,6 +95,7 @@ mixin _$SwitchSpec on Spec { properties.add(DiagnosticsProperty('container', _$this.container)); properties.add(DiagnosticsProperty('indicator', _$this.indicator)); properties.add(DiagnosticsProperty('animated', _$this.animated)); + properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); } } @@ -110,6 +115,7 @@ base class SwitchSpecAttribute extends SpecAttribute this.container, this.indicator, super.animated, + super.modifiers, }); /// Resolves to [SwitchSpec] using the provided [MixData]. @@ -126,6 +132,7 @@ base class SwitchSpecAttribute extends SpecAttribute container: container?.resolve(mix), indicator: indicator?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, + modifiers: modifiers?.resolve(mix), ); } @@ -145,6 +152,7 @@ base class SwitchSpecAttribute extends SpecAttribute container: container?.merge(other.container) ?? other.container, indicator: indicator?.merge(other.indicator) ?? other.indicator, animated: animated?.merge(other.animated) ?? other.animated, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, ); } @@ -157,6 +165,7 @@ base class SwitchSpecAttribute extends SpecAttribute container, indicator, animated, + modifiers, ]; @override @@ -165,6 +174,7 @@ base class SwitchSpecAttribute extends SpecAttribute properties.add(DiagnosticsProperty('container', container)); properties.add(DiagnosticsProperty('indicator', indicator)); properties.add(DiagnosticsProperty('animated', animated)); + properties.add(DiagnosticsProperty('modifiers', modifiers)); } } @@ -183,6 +193,9 @@ class SwitchSpecUtility /// Utility for defining [SwitchSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); + /// Utility for defining [SwitchSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + SwitchSpecUtility(super.builder); static final self = SwitchSpecUtility((v) => v); @@ -193,11 +206,13 @@ class SwitchSpecUtility BoxSpecAttribute? container, BoxSpecAttribute? indicator, AnimatedDataDto? animated, + WidgetModifiersDataDto? modifiers, }) { return builder(SwitchSpecAttribute( container: container, indicator: indicator, animated: animated, + modifiers: modifiers, )); } } diff --git a/packages/remix/lib/modifiers/flutter_animate.dart b/packages/remix/lib/modifiers/flutter_animate.dart new file mode 100644 index 000000000..dee694c45 --- /dev/null +++ b/packages/remix/lib/modifiers/flutter_animate.dart @@ -0,0 +1,84 @@ +import 'package:flutter/widgets.dart'; +import 'package:flutter_animate/flutter_animate.dart'; +import 'package:mix/mix.dart'; +import 'package:mix_annotations/mix_annotations.dart'; + +part 'flutter_animate.g.dart'; + +@MixableSpec(prefix: '_FlutterAnimate') +class FlutterAnimateModifierSpec + extends WidgetModifierSpec + with _$FlutterAnimateModifierSpec { + const FlutterAnimateModifierSpec({ + this.effects, + this.autoPlay, + this.delay, + this.value, + this.target, + }); + + final List>? effects; + final bool? autoPlay; + final Duration? delay; + final double? value; + final double? target; + + @override + Widget build(Widget child) { + return child.animate(effects: effects, autoPlay: autoPlay, delay: delay); + } +} + +class FlutterAnimateAttribute extends _FlutterAnimateAttribute + implements AnimateManager { + @override + FlutterAnimateAttribute addEffect(Effect effect) { + return addEffects([effect]); + } + + @override + FlutterAnimateAttribute addEffects(List effects) { + return FlutterAnimateAttribute( + effects: [...(this.effects ?? []), ...effects], + autoPlay: autoPlay, + delay: delay, + value: value, + target: target, + ); + } + + const FlutterAnimateAttribute({ + super.autoPlay, + super.delay, + super.effects, + super.value, + super.target, + }); +} + +class FlutterAnimateUtility + extends MixUtility with AnimateManager { + @override + T addEffect(Effect effect) => call(effects: [effect]); + + static final self = FlutterAnimateUtility((v) => v); + + /// Returns a new [FlutterAnimateModifierSpecAttribute] with the specified properties. + T call({ + List>? effects, + bool? autoPlay, + Duration? delay, + double? value, + double? target, + }) { + return builder(FlutterAnimateAttribute( + effects: effects, + autoPlay: autoPlay, + delay: delay, + value: value, + target: target, + )); + } + + const FlutterAnimateUtility(super.builder); +} diff --git a/packages/remix/lib/modifiers/flutter_animate.g.dart b/packages/remix/lib/modifiers/flutter_animate.g.dart new file mode 100644 index 000000000..1d293eeea --- /dev/null +++ b/packages/remix/lib/modifiers/flutter_animate.g.dart @@ -0,0 +1,222 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'flutter_animate.dart'; + +// ************************************************************************** +// MixableSpecGenerator +// ************************************************************************** + +mixin _$FlutterAnimateModifierSpec + on WidgetModifierSpec { + /// Creates a copy of this [FlutterAnimateModifierSpec] but with the given fields + /// replaced with the new values. + @override + FlutterAnimateModifierSpec copyWith({ + List>? effects, + bool? autoPlay, + Duration? delay, + double? value, + double? target, + }) { + return FlutterAnimateModifierSpec( + effects: effects ?? _$this.effects, + autoPlay: autoPlay ?? _$this.autoPlay, + delay: delay ?? _$this.delay, + value: value ?? _$this.value, + target: target ?? _$this.target, + ); + } + + /// Linearly interpolates between this [FlutterAnimateModifierSpec] and another [FlutterAnimateModifierSpec] based on the given parameter [t]. + /// + /// The parameter [t] represents the interpolation factor, typically ranging from 0.0 to 1.0. + /// When [t] is 0.0, the current [FlutterAnimateModifierSpec] is returned. When [t] is 1.0, the [other] [FlutterAnimateModifierSpec] is returned. + /// For values of [t] between 0.0 and 1.0, an interpolated [FlutterAnimateModifierSpec] is returned. + /// + /// If [other] is null, this method returns the current [FlutterAnimateModifierSpec] instance. + /// + /// The interpolation is performed on each property of the [FlutterAnimateModifierSpec] using the appropriate + /// interpolation method: + /// + /// - [MixHelpers.lerpDouble] for [value] and [target]. + + /// For [effects] and [autoPlay] and [delay], the interpolation is performed using a step function. + /// If [t] is less than 0.5, the value from the current [FlutterAnimateModifierSpec] is used. Otherwise, the value + /// from the [other] [FlutterAnimateModifierSpec] is used. + /// + /// This method is typically used in animations to smoothly transition between + /// different [FlutterAnimateModifierSpec] configurations. + @override + FlutterAnimateModifierSpec lerp(FlutterAnimateModifierSpec? other, double t) { + if (other == null) return _$this; + + return FlutterAnimateModifierSpec( + effects: t < 0.5 ? _$this.effects : other.effects, + autoPlay: t < 0.5 ? _$this.autoPlay : other.autoPlay, + delay: t < 0.5 ? _$this.delay : other.delay, + value: MixHelpers.lerpDouble(_$this.value, other.value, t), + target: MixHelpers.lerpDouble(_$this.target, other.target, t), + ); + } + + /// The list of properties that constitute the state of this [FlutterAnimateModifierSpec]. + /// + /// This property is used by the [==] operator and the [hashCode] getter to + /// compare two [FlutterAnimateModifierSpec] instances for equality. + @override + List get props => [ + _$this.effects, + _$this.autoPlay, + _$this.delay, + _$this.value, + _$this.target, + ]; + + FlutterAnimateModifierSpec get _$this => this as FlutterAnimateModifierSpec; +} + +/// Represents the attributes of a [FlutterAnimateModifierSpec]. +/// +/// This class encapsulates properties defining the layout and +/// appearance of a [FlutterAnimateModifierSpec]. +/// +/// Use this class to configure the attributes of a [FlutterAnimateModifierSpec] and pass it to +/// the [FlutterAnimateModifierSpec] constructor. +class _FlutterAnimateAttribute + extends WidgetModifierSpecAttribute { + final List>? effects; + final bool? autoPlay; + final Duration? delay; + final double? value; + final double? target; + + const _FlutterAnimateAttribute({ + this.effects, + this.autoPlay, + this.delay, + this.value, + this.target, + }); + + /// Resolves to [FlutterAnimateModifierSpec] using the provided [MixData]. + /// + /// If a property is null in the [MixData], it falls back to the + /// default value defined in the `defaultValue` for that property. + /// + /// ```dart + /// final flutterAnimateModifierSpec = _FlutterAnimateAttribute(...).resolve(mix); + /// ``` + @override + FlutterAnimateModifierSpec resolve(MixData mix) { + return FlutterAnimateModifierSpec( + effects: effects, + autoPlay: autoPlay, + delay: delay, + value: value, + target: target, + ); + } + + /// Merges the properties of this [_FlutterAnimateAttribute] with the properties of [other]. + /// + /// If [other] is null, returns this instance unchanged. Otherwise, returns a new + /// [_FlutterAnimateAttribute] with the properties of [other] taking precedence over + /// the corresponding properties of this instance. + /// + /// Properties from [other] that are null will fall back + /// to the values from this instance. + @override + _FlutterAnimateAttribute merge(covariant _FlutterAnimateAttribute? other) { + if (other == null) return this; + + return _FlutterAnimateAttribute( + effects: MixHelpers.mergeList(effects, other.effects), + autoPlay: other.autoPlay ?? autoPlay, + delay: other.delay ?? delay, + value: other.value ?? value, + target: other.target ?? target, + ); + } + + /// The list of properties that constitute the state of this [_FlutterAnimateAttribute]. + /// + /// This property is used by the [==] operator and the [hashCode] getter to + /// compare two [_FlutterAnimateAttribute] instances for equality. + @override + List get props => [ + effects, + autoPlay, + delay, + value, + target, + ]; +} + +/// Utility class for configuring [_FlutterAnimateAttribute] properties. +/// +/// This class provides methods to set individual properties of a [_FlutterAnimateAttribute]. +/// Use the methods of this class to configure specific properties of a [_FlutterAnimateAttribute]. +class _FlutterAnimateUtility + extends SpecUtility { + /// Utility for defining [_FlutterAnimateAttribute.effects] + late final effects = ListUtility>((v) => only(effects: v)); + + /// Utility for defining [_FlutterAnimateAttribute.autoPlay] + late final autoPlay = BoolUtility((v) => only(autoPlay: v)); + + /// Utility for defining [_FlutterAnimateAttribute.delay] + late final delay = DurationUtility((v) => only(delay: v)); + + /// Utility for defining [_FlutterAnimateAttribute.value] + late final value = DoubleUtility((v) => only(value: v)); + + /// Utility for defining [_FlutterAnimateAttribute.target] + late final target = DoubleUtility((v) => only(target: v)); + + _FlutterAnimateUtility(super.builder); + + static final self = _FlutterAnimateUtility((v) => v); + + /// Returns a new [_FlutterAnimateAttribute] with the specified properties. + @override + T only({ + List>? effects, + bool? autoPlay, + Duration? delay, + double? value, + double? target, + }) { + return builder(_FlutterAnimateAttribute( + effects: effects, + autoPlay: autoPlay, + delay: delay, + value: value, + target: target, + )); + } +} + +/// A tween that interpolates between two [FlutterAnimateModifierSpec] instances. +/// +/// This class can be used in animations to smoothly transition between +/// different [FlutterAnimateModifierSpec] specifications. +class FlutterAnimateModifierSpecTween + extends Tween { + FlutterAnimateModifierSpecTween({ + super.begin, + super.end, + }); + + @override + FlutterAnimateModifierSpec lerp(double t) { + if (begin == null && end == null) { + return const FlutterAnimateModifierSpec(); + } + + if (begin == null) { + return end!; + } + + return begin!.lerp(end!, t); + } +} diff --git a/packages/remix/pubspec.yaml b/packages/remix/pubspec.yaml index d198dc789..061539f6f 100644 --- a/packages/remix/pubspec.yaml +++ b/packages/remix/pubspec.yaml @@ -9,6 +9,7 @@ environment: dependencies: flutter: sdk: flutter + flutter_animate: ^4.5.0 mix: ^1.1.2 mix_annotations: ^0.1.0 @@ -16,9 +17,11 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^4.0.0 mix_generator: ^0.1.2 build_runner: ^2.4.9 + dart_code_metrics_presets: ^2.14.0 + flutter: uses-material-design: true diff --git a/packages/remix/scripts/markdown.dart b/packages/remix/scripts/markdown.dart old mode 100644 new mode 100755 index 50503287f..060eedb37 --- a/packages/remix/scripts/markdown.dart +++ b/packages/remix/scripts/markdown.dart @@ -1,3 +1,5 @@ +#!/usr/bin/env dart + import 'dart:developer'; import 'dart:io'; @@ -5,11 +7,18 @@ void main() { final rootDirectory = Directory.current; final contextFile = File('context.md'); + contextFile.exists().then((exists) { + if (exists) { + contextFile.deleteSync(); + } + }); + void processDirectory(Directory directory) { for (var fileOrDir in directory.listSync()) { if (fileOrDir is File && fileOrDir.path.endsWith('.dart') && - !fileOrDir.path.endsWith('.g.dart')) { + !fileOrDir.path.endsWith('.g.dart') && + fileOrDir.path.contains('components')) { final fileName = fileOrDir.path.split('/').last; final fileContent = fileOrDir.readAsStringSync(); diff --git a/schemas/melos.yaml.schema.json b/schemas/melos.yaml.schema.json new file mode 100644 index 000000000..f0f9cda49 --- /dev/null +++ b/schemas/melos.yaml.schema.json @@ -0,0 +1,435 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema", + "title": "melos.yaml", + "description": "The workspace configuration file for Melos", + "type": "object", + "required": ["name", "packages"], + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "description": "The name of the Melos workspace - used by IDE documentation." + }, + "repository": { + "anyOf": [ + { + "type": "string", + "description": "The hosted git repository which contains the workspace." + }, + { + "type": "object", + "description": "The self-hosted git repository which contains the workspace.", + "additionalProperties": false, + "required": ["type", "origin", "owner", "name"], + "properties": { + "type": { + "type": "string", + "description": "The type of repository", + "enum": ["github", "gitlab"] + }, + "origin": { + "type": "string", + "description": "The origin of the repository, e.g. https://git.example.dev/gitlab" + }, + "owner": { + "type": "string", + "description": "The owner of the repository" + }, + "name": { + "type": "string", + "description": "The name of the repository" + } + } + } + ] + }, + "packages": { + "type": "array", + "description": "Patterns for packages that are included in the melos workspace.", + "items": { "type": "string" } + }, + "ignore": { + "type": "array", + "description": "Patterns for packages to exclude from the melos workspace.", + "items": { "type": "string" } + }, + "sdkPath": { + "type": "string", + "description": "Path to the Dart/Flutter SDK that should be used." + }, + "categories": { + "type": "object", + "description": "Categorize packages in the workspace.", + "additionalProperties": { + "type": "array", + "items": { "type": "string" } + } + }, + "ide": { + "type": "object", + "description": "IDE-specific configurations.\n\nThis allows connecting the different scripts to the IDE or tells melos to generate the necessary files for mono-repositories to work in the IDE.", + "additionalProperties": false, + "properties": { + "intellij": { + "description": "IntelliJ-specific configurations.", + "anyOf": [ + { + "type": "boolean", + "description": "Whether IntelliJ support is enabled." + }, + { + "type": "object", + "additionalProperties": false, + "properties": { + "enabled": { + "type": "boolean", + "description": "Whether IntelliJ support is enabled." + }, + "moduleNamePrefix": { + "type": "string", + "description": "Used when generating IntelliJ project modules files, this value specifies a string to prepend to a package's IntelliJ module name.\n\nThe default is 'melos_'." + } + } + } + ] + } + } + }, + "command": { + "type": "object", + "description": "Command-specific configurations.\n\nThis allows customizing the default behavior of melos commands.", + "additionalProperties": false, + "properties": { + "bootstrap": { + "type": "object", + "description": "The bootstrap command configuration.", + "additionalProperties": false, + "properties": { + "runPubGetInParallel": { + "type": "boolean", + "description": "Whether to run `pub get` in parallel during bootstrapping." + }, + "runPubGetOffline": { + "type": "boolean", + "description": "Whether to attempt to run `pub get` in offline mode during bootstrapping." + }, + "enforceLockfile": { + "type": "boolean", + "description": "Whether `pubspec.lock` is enforced when running `pub get` or not.\nUseful when you want to ensure the same versions of dependencies are used across different environments/machines.\n\nDefaults to false." + }, + "hooks": { + "description": "Hooks to run at certain points of the command lifecycle.", + "allOf": [{ "$ref": "#/$defs/commonHooks" }] + }, + "dependencyOverridePaths": { + "type": "array", + "description": "A list of paths to local packages relative to the workspace directory that should be added to each workspace package's dependency overrides. Each entry can be a specific path or a glob pattern.", + "items": { + "type": "string" + } + }, + "dependencyOverrides": { + "type": "object", + "description": "Dependencies that should be added to each workspace package's dependency overrides." + }, + "environment": { + "type": "object", + "description": "Environment configuration to be synced between all packages." + }, + "dependencies": { + "type": "object", + "description": "Dependencies to be synced between all packages." + }, + "dev_dependencies": { + "type": "object", + "description": "Dev dependencies to be synced between all packages." + } + } + }, + "publish": { + "type": "object", + "description": "The publish command configuration.", + "additionalProperties": false, + "properties": { + "hooks": { + "type": "object", + "description": "Hooks to run at certain points of the command lifecycle.", + "properties": { + "pre": { + "type": "string", + "description": "Hook to run before publishing." + }, + "post": { + "type": "string", + "description": "Hook to run after publishing." + } + } + } + } + }, + "version": { + "type": "object", + "description": "The version command configuration.", + "additionalProperties": false, + "properties": { + "message": { + "type": "string", + "description": "A custom header for the generated CHANGELOG.md." + }, + "includeScopes": { + "type": "string", + "description": "Whether to include conventional commit scopes in the generated CHANGELOG.md." + }, + "linkToCommits": { + "type": "boolean", + "description": "Whether to add links to commits in the generated CHANGELOG.md.\n\nDisabled by default." + }, + "workspaceChangelog": { + "type": "boolean", + "description": "Whether to additionally generate a summary CHANGELOG.md at the root of the workspace." + }, + "branch": { + "type": "string", + "description": "If specified, prevents `melos version` from being used inside branches other than the one specified." + }, + "updateGitTagRefs": { + "type": "boolean", + "description": "Whether to also update pubspec with git referenced packages." + }, + "releaseUrl": { + "type": "boolean", + "description": "Whether to generate and print a link to the prefilled release creation page for each package after versioning.\n\nDisabled by default." + }, + "fetchTags": { + "type": "boolean", + "description": "Whether to fetch tags from the origin remote before versioning.\n\nDefaults to true." + }, + "hooks": { + "description": "Hooks to run at certain points of the command lifecycle.", + "allOf": [ + { "$id": "#/$defs/commonHooks" }, + { + "type": "object", + "properties": { + "preCommit": { "$ref": "#/$defs/script" } + } + } + ] + } + } + }, + "clean": { + "type": "object", + "description": "The clean command configuration.", + "additionalProperties": false, + "properties": { + "hooks": { + "description": "Hooks to run at certain points of the command lifecycle.", + "allOf": [{ "$ref": "#/$defs/commonHooks" }] + } + } + } + } + }, + "scripts": { + "type": "object", + "description": "A list of scripts that can be executed with `melos run` or will be executed before/after some specific melos commands.", + "additionalProperties": { "$ref": "#/$defs/script" } + } + }, + "$defs": { + "script": { + "anyOf": [ + { "type": "string", "description": "The command to execute." }, + { + "allOf": [ + { + "anyOf": [ + { + "type": "object", + "required": ["run"], + "properties": { "run": { "type": "string" } } + }, + { + "type": "object", + "required": ["exec"], + "properties": { "exec": { "type": "string" } } + }, + { + "type": "object", + "required": ["exec", "run"], + "properties": { "exec": { "type": "object" } } + } + ] + }, + { + "type": "object", + "description": "The script definition.", + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "description": "A unique identifier for the script." + }, + "description": { + "type": "string", + "description": "A short description, shown when using `melos run` with no argument." + }, + "run": { + "type": "string", + "description": "The command to execute." + }, + "exec": { + "anyOf": [ + { + "type": "string", + "description": "The command to execute in multiple packages." + }, + { + "type": "object", + "description": "The options to pass to `exec`.", + "properties": { + "concurrency": { + "type": "number", + "description": "The number of packages to execute the command in concurrently." + }, + "failFast": { + "type": "boolean", + "description": "Whether exec should fail fast and not execute the script in further packages if the script fails in a individual package." + } + } + } + ] + }, + "env": { + "type": "object", + "description": "Environment variables that will be passed to the command to execute.", + "additionalProperties": { + "anyOf": [ + { "type": "string" }, + { "type": "number" }, + { "type": "integer" }, + { "type": "boolean" }, + { "type": "null" } + ], + "description": "The value of the environment variable." + } + }, + "packageFilters": { + "type": "object", + "description": "If the command to execute is a melos command, allows filtering packages that will execute the command.", + "additionalProperties": false, + "properties": { + "scope": { + "description": "Patterns for including packages by name.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { "type": "string" } + } + ] + }, + "ignore": { + "description": "Patterns for excluding packages by name.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { "type": "string" } + } + ] + }, + "dirExists": { + "description": "Include a package only if a given directory exists.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { "type": "string" } + } + ] + }, + "fileExists": { + "description": "Include a package only if a given file exists.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { "type": "string" } + } + ] + }, + "dependsOn": { + "description": "Include only packages that depend on a specific package.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { "type": "string" } + } + ] + }, + "noDependsOn": { + "description": "Include only packages that do not depend on a specific package.", + "anyOf": [ + { + "type": "string" + }, + { + "type": "array", + "items": { "type": "string" } + } + ] + }, + "diff": { + "type": "string", + "description": "Filter packages based on whether there were changes between a commit and the current HEAD or within a range of commits. A range of commits can be specified using the git short hand syntax `..` and `...." + }, + "private": { + "type": "boolean", + "description": "Include packages with `publish_to: none`." + }, + "noPrivate": { + "type": "boolean", + "description": "Exclude packages with `publish_to: none`." + }, + "published": { + "type": "boolean", + "description": "Include/Exclude packages that are up-to-date on pub.dev." + }, + "nullSafety": { + "type": "boolean", + "description": "Include/Exclude packages that are null-safe." + }, + "flutter": { + "type": "boolean", + "description": "Include/Exclude packages that are Flutter packages." + } + } + } + } + } + ] + } + ] + }, + "commonHooks": { + "type": "object", + "properties": { + "pre": { "$ref": "#/$defs/script" }, + "post": { "$ref": "#/$defs/script" } + } + } + } +} From fbda4dbb3ff139ab319eb97528efbbe12b2b748d Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Fri, 26 Jul 2024 13:34:55 -0400 Subject: [PATCH 4/7] Removed base keyword --- packages/mix/lib/src/core/attribute.dart | 4 ++-- packages/mix/lib/src/core/deprecation_notices.dart | 2 +- packages/mix/lib/src/core/modifier.dart | 6 +++--- packages/mix/lib/src/core/spec.dart | 2 +- packages/mix/lib/src/variants/variant_attribute.dart | 2 +- packages/mix/test/helpers/testing_utils.dart | 4 ++-- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/mix/lib/src/core/attribute.dart b/packages/mix/lib/src/core/attribute.dart index f299637b9..ad971731e 100644 --- a/packages/mix/lib/src/core/attribute.dart +++ b/packages/mix/lib/src/core/attribute.dart @@ -4,7 +4,7 @@ import '../internal/compare_mixin.dart'; import 'dto.dart'; @immutable -abstract base class Attribute with MergeableMixin, EqualityMixin { +abstract class Attribute with MergeableMixin, EqualityMixin { const Attribute(); // Used as the key to determine how @@ -27,7 +27,7 @@ mixin MergeableMixin { } @immutable -abstract base class StyledAttribute extends Attribute { +abstract class StyledAttribute extends Attribute { const StyledAttribute(); @override diff --git a/packages/mix/lib/src/core/deprecation_notices.dart b/packages/mix/lib/src/core/deprecation_notices.dart index 952d8e762..d5730e2df 100644 --- a/packages/mix/lib/src/core/deprecation_notices.dart +++ b/packages/mix/lib/src/core/deprecation_notices.dart @@ -46,7 +46,7 @@ class OnEnabledVariant extends OnDisabledVariant { typedef WidgetModifier> = WidgetModifierSpec; @Deprecated('Use `WidgetModifierSpecAttribute` instead.') -abstract base class WidgetModifierAttribute< +abstract class WidgetModifierAttribute< Self extends WidgetModifierSpecAttribute, Value extends WidgetModifierSpec> extends WidgetModifierSpecAttribute { diff --git a/packages/mix/lib/src/core/modifier.dart b/packages/mix/lib/src/core/modifier.dart index 6113ba138..de2e1a40b 100644 --- a/packages/mix/lib/src/core/modifier.dart +++ b/packages/mix/lib/src/core/modifier.dart @@ -8,7 +8,7 @@ import 'utility.dart'; abstract class WidgetModifierSpec> extends Spec { - const WidgetModifierSpec({super.animated}); + const WidgetModifierSpec({super.animated}) : super(modifiers: null); static WidgetModifierSpec? lerpValue( WidgetModifierSpec? begin, @@ -30,7 +30,7 @@ abstract class WidgetModifierSpec> Widget build(Widget child); } -abstract base class WidgetModifierSpecAttribute< +abstract class WidgetModifierSpecAttribute< Value extends WidgetModifierSpec> extends SpecAttribute with Diagnosticable { const WidgetModifierSpecAttribute(); @@ -39,7 +39,7 @@ abstract base class WidgetModifierSpecAttribute< Value resolve(MixData mix); } -abstract base class WidgetModifierUtility< +abstract class WidgetModifierUtility< T extends Attribute, D extends WidgetModifierSpecAttribute, Value extends WidgetModifierSpec> extends MixUtility { diff --git a/packages/mix/lib/src/core/spec.dart b/packages/mix/lib/src/core/spec.dart index fcd3e1937..eb05046cd 100644 --- a/packages/mix/lib/src/core/spec.dart +++ b/packages/mix/lib/src/core/spec.dart @@ -35,7 +35,7 @@ abstract class Spec> with EqualityMixin { /// /// This class extends the [StyledAttribute] class and provides a generic type [Self] and [Value]. /// The [Self] type represents the concrete implementation of the attribute, while the [Value] type represents the resolvable value. -abstract base class SpecAttribute extends StyledAttribute { +abstract class SpecAttribute extends StyledAttribute { final AnimatedDataDto? animated; final WidgetModifiersDataDto? modifiers; diff --git a/packages/mix/lib/src/variants/variant_attribute.dart b/packages/mix/lib/src/variants/variant_attribute.dart index 86286d60f..5863d5ec9 100644 --- a/packages/mix/lib/src/variants/variant_attribute.dart +++ b/packages/mix/lib/src/variants/variant_attribute.dart @@ -5,7 +5,7 @@ import '../core/factory/style_mix.dart'; import '../core/variant.dart'; @immutable -base class VariantAttribute extends Attribute { +class VariantAttribute extends Attribute { final V variant; final Style _style; const VariantAttribute(this.variant, Style style) : _style = style; diff --git a/packages/mix/test/helpers/testing_utils.dart b/packages/mix/test/helpers/testing_utils.dart index a5b2b53ad..84dcdcc6c 100644 --- a/packages/mix/test/helpers/testing_utils.dart +++ b/packages/mix/test/helpers/testing_utils.dart @@ -228,7 +228,7 @@ final class MockBooleanScalarAttribute const MockBooleanScalarAttribute(super.value); } -abstract base class _MockSpecAttribute extends SpecAttribute { +abstract class _MockSpecAttribute extends SpecAttribute { final T _value; const _MockSpecAttribute(this._value); @@ -379,7 +379,7 @@ class WidgetWithTestableBuild extends StyledWidget { } } -abstract base class TestScalarAttribute< +abstract class TestScalarAttribute< Self extends TestScalarAttribute, Value> extends StyledAttribute { final Value value; From edf6d861d6171abd5a5135fbf7cef4bec8181c0c Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Fri, 26 Jul 2024 14:30:11 -0400 Subject: [PATCH 5/7] Remix improvements --- examples/themed_button/pubspec.yaml | 4 +- examples/todo_list/pubspec.yaml | 2 +- mix.code-workspace | 7 ++- packages/mix/pubspec.yaml | 2 - .../remix/demo/lib/main.directories.g.dart | 2 +- .../remix/lib/components/button/button.g.dart | 52 +++++++++++++++++-- .../remix/lib/components/card/card.g.dart | 43 +++++++++++++-- .../lib/components/checkbox/checkbox.g.dart | 44 ++++++++++++++-- .../lib/components/progress/progress.g.dart | 46 ++++++++++++++-- .../remix/lib/components/radio/radio.g.dart | 44 ++++++++++++++-- .../lib/components/spinner/spinner.g.dart | 40 +++++++++----- .../remix/lib/components/switch/switch.g.dart | 44 ++++++++++++++-- .../remix/lib/modifiers/flutter_animate.dart | 15 +++--- .../lib/modifiers/flutter_animate.g.dart | 47 +++++++++-------- packages/remix/pubspec.yaml | 3 +- 15 files changed, 326 insertions(+), 69 deletions(-) diff --git a/examples/themed_button/pubspec.yaml b/examples/themed_button/pubspec.yaml index 4a0b5e3c2..ac33877bf 100644 --- a/examples/themed_button/pubspec.yaml +++ b/examples/themed_button/pubspec.yaml @@ -25,11 +25,11 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^3.0.0 + flutter_lints: ^4.0.0 mix_lint: path: ../../packages/mix_lint widgetbook_generator: ^3.7.0 - build_runner: ^2.4.0 + build_runner: ^2.4.9 flutter: uses-material-design: true diff --git a/examples/todo_list/pubspec.yaml b/examples/todo_list/pubspec.yaml index 3030db5d1..22f3a13ef 100644 --- a/examples/todo_list/pubspec.yaml +++ b/examples/todo_list/pubspec.yaml @@ -25,7 +25,7 @@ dev_dependencies: mix_lint: path: ../../packages/mix_lint - flutter_lints: ^3.0.0 + flutter_lints: ^4.0.0 flutter: uses-material-design: true diff --git a/mix.code-workspace b/mix.code-workspace index c437408c0..66084edce 100644 --- a/mix.code-workspace +++ b/mix.code-workspace @@ -19,6 +19,10 @@ { "name": "remix", "path": "packages/remix" + }, + { + "name": "mix_animate", + "path": "packages/mix_animate" } ], "settings": { @@ -33,5 +37,6 @@ "files.exclude": { ".fvm/**": true, "website":true, - },} + }, +} } diff --git a/packages/mix/pubspec.yaml b/packages/mix/pubspec.yaml index a109f670e..05100eb95 100644 --- a/packages/mix/pubspec.yaml +++ b/packages/mix/pubspec.yaml @@ -18,8 +18,6 @@ dev_dependencies: build_runner: ^2.4.9 flutter_test: sdk: flutter - dart_code_metrics_presets: ^2.13.0 - build_runner: ^2.4.9 mix_generator: ^0.2.2 # flutter: diff --git a/packages/remix/demo/lib/main.directories.g.dart b/packages/remix/demo/lib/main.directories.g.dart index 679c83de3..c2a5e7634 100644 --- a/packages/remix/demo/lib/main.directories.g.dart +++ b/packages/remix/demo/lib/main.directories.g.dart @@ -39,7 +39,7 @@ final directories = <_i1.WidgetbookNode>[ name: 'button', children: [ _i1.WidgetbookLeafComponent( - name: 'CustomButton', + name: 'RxButton', useCase: _i1.WidgetbookUseCase( name: 'Button Component', builder: _i3.buildButtonUseCase, diff --git a/packages/remix/lib/components/button/button.g.dart b/packages/remix/lib/components/button/button.g.dart index 6f1270132..3740e8228 100644 --- a/packages/remix/lib/components/button/button.g.dart +++ b/packages/remix/lib/components/button/button.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'button_spec.dart'; +part of 'button.dart'; // ************************************************************************** // MixableSpecGenerator @@ -37,6 +37,7 @@ mixin _$ButtonSpec on Spec { FlexSpec? flex, IconSpec? icon, TextSpec? label, + WidgetModifiersData? modifiers, SpinnerSpec? spinner, AnimatedData? animated, }) { @@ -45,6 +46,7 @@ mixin _$ButtonSpec on Spec { flex: flex ?? _$this.flex, icon: icon ?? _$this.icon, label: label ?? _$this.label, + modifiers: modifiers ?? _$this.modifiers, spinner: spinner ?? _$this.spinner, animated: animated ?? _$this.animated, ); @@ -66,7 +68,7 @@ mixin _$ButtonSpec on Spec { /// - [IconSpec.lerp] for [icon]. /// - [TextSpec.lerp] for [label]. - /// For [spinner] and [animated], the interpolation is performed using a step function. + /// For [modifiers] and [spinner] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [ButtonSpec] is used. Otherwise, the value /// from the [other] [ButtonSpec] is used. /// @@ -81,6 +83,7 @@ mixin _$ButtonSpec on Spec { flex: _$this.flex.lerp(other.flex, t), icon: _$this.icon.lerp(other.icon, t), label: _$this.label.lerp(other.label, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, spinner: _$this.spinner.lerp(other.spinner, t), animated: t < 0.5 ? _$this.animated : other.animated, ); @@ -96,11 +99,29 @@ mixin _$ButtonSpec on Spec { _$this.flex, _$this.icon, _$this.label, + _$this.modifiers, _$this.spinner, _$this.animated, ]; ButtonSpec get _$this => this as ButtonSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add( + DiagnosticsProperty('container', _$this.container, defaultValue: null)); + properties + .add(DiagnosticsProperty('flex', _$this.flex, defaultValue: null)); + properties + .add(DiagnosticsProperty('icon', _$this.icon, defaultValue: null)); + properties + .add(DiagnosticsProperty('label', _$this.label, defaultValue: null)); + properties.add( + DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); + properties.add( + DiagnosticsProperty('spinner', _$this.spinner, defaultValue: null)); + properties.add( + DiagnosticsProperty('animated', _$this.animated, defaultValue: null)); + } } /// Represents the attributes of a [ButtonSpec]. @@ -110,7 +131,8 @@ mixin _$ButtonSpec on Spec { /// /// Use this class to configure the attributes of a [ButtonSpec] and pass it to /// the [ButtonSpec] constructor. -base class ButtonSpecAttribute extends SpecAttribute { +class ButtonSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; final IconSpecAttribute? icon; @@ -122,6 +144,7 @@ base class ButtonSpecAttribute extends SpecAttribute { this.flex, this.icon, this.label, + super.modifiers, this.spinner, super.animated, }); @@ -141,6 +164,7 @@ base class ButtonSpecAttribute extends SpecAttribute { flex: flex?.resolve(mix), icon: icon?.resolve(mix), label: label?.resolve(mix), + modifiers: modifiers?.resolve(mix), spinner: spinner?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); @@ -163,6 +187,7 @@ base class ButtonSpecAttribute extends SpecAttribute { flex: flex?.merge(other.flex) ?? other.flex, icon: icon?.merge(other.icon) ?? other.icon, label: label?.merge(other.label) ?? other.label, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, spinner: spinner?.merge(other.spinner) ?? other.spinner, animated: animated?.merge(other.animated) ?? other.animated, ); @@ -178,9 +203,25 @@ base class ButtonSpecAttribute extends SpecAttribute { flex, icon, label, + modifiers, spinner, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty('container', container, defaultValue: null)); + properties.add(DiagnosticsProperty('flex', flex, defaultValue: null)); + properties.add(DiagnosticsProperty('icon', icon, defaultValue: null)); + properties.add(DiagnosticsProperty('label', label, defaultValue: null)); + properties + .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); + properties.add(DiagnosticsProperty('spinner', spinner, defaultValue: null)); + properties + .add(DiagnosticsProperty('animated', animated, defaultValue: null)); + } } /// Utility class for configuring [ButtonSpecAttribute] properties. @@ -201,6 +242,9 @@ class ButtonSpecUtility /// Utility for defining [ButtonSpecAttribute.label] late final label = TextSpecUtility((v) => only(label: v)); + /// Utility for defining [ButtonSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [ButtonSpecAttribute.spinner] late final spinner = SpinnerSpecUtility((v) => only(spinner: v)); @@ -218,6 +262,7 @@ class ButtonSpecUtility FlexSpecAttribute? flex, IconSpecAttribute? icon, TextSpecAttribute? label, + WidgetModifiersDataDto? modifiers, SpinnerSpecAttribute? spinner, AnimatedDataDto? animated, }) { @@ -226,6 +271,7 @@ class ButtonSpecUtility flex: flex, icon: icon, label: label, + modifiers: modifiers, spinner: spinner, animated: animated, )); diff --git a/packages/remix/lib/components/card/card.g.dart b/packages/remix/lib/components/card/card.g.dart index 39783ea6e..f237cee7c 100644 --- a/packages/remix/lib/components/card/card.g.dart +++ b/packages/remix/lib/components/card/card.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'card_spec.dart'; +part of 'card.dart'; // ************************************************************************** // MixableSpecGenerator @@ -35,11 +35,13 @@ mixin _$CardSpec on Spec { 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 +60,7 @@ mixin _$CardSpec on Spec { /// - [BoxSpec.lerp] for [container]. /// - [FlexSpec.lerp] for [flex]. - /// For [animated], the interpolation is performed using a step function. + /// 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 /// from the [other] [CardSpec] is used. /// @@ -71,6 +73,7 @@ mixin _$CardSpec on Spec { return CardSpec( container: _$this.container.lerp(other.container, t), flex: _$this.flex.lerp(other.flex, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -83,10 +86,22 @@ mixin _$CardSpec on Spec { List get props => [ _$this.container, _$this.flex, + _$this.modifiers, _$this.animated, ]; CardSpec get _$this => this as CardSpec; + + 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( + DiagnosticsProperty('animated', _$this.animated, defaultValue: null)); + } } /// Represents the attributes of a [CardSpec]. @@ -96,13 +111,15 @@ mixin _$CardSpec on Spec { /// /// Use this class to configure the attributes of a [CardSpec] and pass it to /// the [CardSpec] constructor. -base class CardSpecAttribute extends SpecAttribute { +base class CardSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final FlexSpecAttribute? flex; const CardSpecAttribute({ this.container, this.flex, + super.modifiers, super.animated, }); @@ -119,6 +136,7 @@ base class CardSpecAttribute extends SpecAttribute { return CardSpec( container: container?.resolve(mix), flex: flex?.resolve(mix), + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -138,6 +156,7 @@ 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, ); } @@ -150,8 +169,21 @@ base class CardSpecAttribute extends SpecAttribute { List get props => [ container, flex, + modifiers, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + 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 + .add(DiagnosticsProperty('animated', animated, defaultValue: null)); + } } /// Utility class for configuring [CardSpecAttribute] properties. @@ -166,6 +198,9 @@ class CardSpecUtility /// 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)); + /// Utility for defining [CardSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -178,11 +213,13 @@ class CardSpecUtility 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/components/checkbox/checkbox.g.dart b/packages/remix/lib/components/checkbox/checkbox.g.dart index 1ca2f2bdc..64715fa7d 100644 --- a/packages/remix/lib/components/checkbox/checkbox.g.dart +++ b/packages/remix/lib/components/checkbox/checkbox.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'checkbox_spec.dart'; +part of 'checkbox.dart'; // ************************************************************************** // MixableSpecGenerator @@ -35,11 +35,13 @@ mixin _$CheckboxSpec on Spec { CheckboxSpec copyWith({ BoxSpec? container, IconSpec? indicator, + WidgetModifiersData? modifiers, AnimatedData? animated, }) { return CheckboxSpec( container: container ?? _$this.container, indicator: indicator ?? _$this.indicator, + modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); } @@ -58,7 +60,7 @@ mixin _$CheckboxSpec on Spec { /// - [BoxSpec.lerp] for [container]. /// - [IconSpec.lerp] for [indicator]. - /// For [animated], the interpolation is performed using a step function. + /// For [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [CheckboxSpec] is used. Otherwise, the value /// from the [other] [CheckboxSpec] is used. /// @@ -71,6 +73,7 @@ mixin _$CheckboxSpec on Spec { return CheckboxSpec( container: _$this.container.lerp(other.container, t), indicator: _$this.indicator.lerp(other.indicator, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -83,10 +86,22 @@ mixin _$CheckboxSpec on Spec { List get props => [ _$this.container, _$this.indicator, + _$this.modifiers, _$this.animated, ]; CheckboxSpec get _$this => this as CheckboxSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add( + DiagnosticsProperty('container', _$this.container, defaultValue: null)); + properties.add( + DiagnosticsProperty('indicator', _$this.indicator, defaultValue: null)); + properties.add( + DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); + properties.add( + DiagnosticsProperty('animated', _$this.animated, defaultValue: null)); + } } /// Represents the attributes of a [CheckboxSpec]. @@ -96,13 +111,15 @@ mixin _$CheckboxSpec on Spec { /// /// Use this class to configure the attributes of a [CheckboxSpec] and pass it to /// the [CheckboxSpec] constructor. -base class CheckboxSpecAttribute extends SpecAttribute { +base class CheckboxSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final IconSpecAttribute? indicator; const CheckboxSpecAttribute({ this.container, this.indicator, + super.modifiers, super.animated, }); @@ -119,6 +136,7 @@ base class CheckboxSpecAttribute extends SpecAttribute { return CheckboxSpec( container: container?.resolve(mix), indicator: indicator?.resolve(mix), + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -138,6 +156,7 @@ base class CheckboxSpecAttribute extends SpecAttribute { return CheckboxSpecAttribute( container: container?.merge(other.container) ?? other.container, indicator: indicator?.merge(other.indicator) ?? other.indicator, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); } @@ -150,8 +169,22 @@ base class CheckboxSpecAttribute extends SpecAttribute { List get props => [ container, indicator, + modifiers, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty('container', container, defaultValue: null)); + properties + .add(DiagnosticsProperty('indicator', indicator, defaultValue: null)); + properties + .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); + properties + .add(DiagnosticsProperty('animated', animated, defaultValue: null)); + } } /// Utility class for configuring [CheckboxSpecAttribute] properties. @@ -166,6 +199,9 @@ class CheckboxSpecUtility /// Utility for defining [CheckboxSpecAttribute.indicator] late final indicator = IconSpecUtility((v) => only(indicator: v)); + /// Utility for defining [CheckboxSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [CheckboxSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -178,11 +214,13 @@ class CheckboxSpecUtility T only({ BoxSpecAttribute? container, IconSpecAttribute? indicator, + WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(CheckboxSpecAttribute( container: container, indicator: indicator, + modifiers: modifiers, animated: animated, )); } diff --git a/packages/remix/lib/components/progress/progress.g.dart b/packages/remix/lib/components/progress/progress.g.dart index f6db8a029..491e92aca 100644 --- a/packages/remix/lib/components/progress/progress.g.dart +++ b/packages/remix/lib/components/progress/progress.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'progress_spec.dart'; +part of 'progress.dart'; // ************************************************************************** // MixableSpecGenerator @@ -37,12 +37,14 @@ mixin _$ProgressSpec on Spec { BoxSpec? track, BoxSpec? fill, AnimatedData? animated, + WidgetModifiersData? modifiers, }) { return ProgressSpec( container: container ?? _$this.container, track: track ?? _$this.track, fill: fill ?? _$this.fill, animated: animated ?? _$this.animated, + modifiers: modifiers ?? _$this.modifiers, ); } @@ -59,7 +61,7 @@ mixin _$ProgressSpec on Spec { /// /// - [BoxSpec.lerp] for [container] and [track] and [fill]. - /// For [animated], the interpolation is performed using a step function. + /// For [animated] and [modifiers], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [ProgressSpec] is used. Otherwise, the value /// from the [other] [ProgressSpec] is used. /// @@ -74,6 +76,7 @@ mixin _$ProgressSpec on Spec { track: _$this.track.lerp(other.track, t), fill: _$this.fill.lerp(other.fill, t), animated: t < 0.5 ? _$this.animated : other.animated, + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, ); } @@ -87,9 +90,23 @@ mixin _$ProgressSpec on Spec { _$this.track, _$this.fill, _$this.animated, + _$this.modifiers, ]; ProgressSpec get _$this => this as ProgressSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add( + DiagnosticsProperty('container', _$this.container, defaultValue: null)); + properties + .add(DiagnosticsProperty('track', _$this.track, defaultValue: null)); + properties + .add(DiagnosticsProperty('fill', _$this.fill, defaultValue: null)); + properties.add( + DiagnosticsProperty('animated', _$this.animated, defaultValue: null)); + properties.add( + DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); + } } /// Represents the attributes of a [ProgressSpec]. @@ -99,7 +116,8 @@ mixin _$ProgressSpec on Spec { /// /// Use this class to configure the attributes of a [ProgressSpec] and pass it to /// the [ProgressSpec] constructor. -base class ProgressSpecAttribute extends SpecAttribute { +base class ProgressSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final BoxSpecAttribute? track; final BoxSpecAttribute? fill; @@ -109,6 +127,7 @@ base class ProgressSpecAttribute extends SpecAttribute { this.track, this.fill, super.animated, + super.modifiers, }); /// Resolves to [ProgressSpec] using the provided [MixData]. @@ -126,6 +145,7 @@ base class ProgressSpecAttribute extends SpecAttribute { track: track?.resolve(mix), fill: fill?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, + modifiers: modifiers?.resolve(mix), ); } @@ -146,6 +166,7 @@ base class ProgressSpecAttribute extends SpecAttribute { track: track?.merge(other.track) ?? other.track, fill: fill?.merge(other.fill) ?? other.fill, animated: animated?.merge(other.animated) ?? other.animated, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, ); } @@ -159,7 +180,21 @@ base class ProgressSpecAttribute extends SpecAttribute { track, fill, animated, + modifiers, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty('container', container, defaultValue: null)); + properties.add(DiagnosticsProperty('track', track, defaultValue: null)); + properties.add(DiagnosticsProperty('fill', fill, defaultValue: null)); + properties + .add(DiagnosticsProperty('animated', animated, defaultValue: null)); + properties + .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); + } } /// Utility class for configuring [ProgressSpecAttribute] properties. @@ -180,6 +215,9 @@ class ProgressSpecUtility /// Utility for defining [ProgressSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); + /// Utility for defining [ProgressSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + ProgressSpecUtility(super.builder); static final self = ProgressSpecUtility((v) => v); @@ -191,12 +229,14 @@ class ProgressSpecUtility BoxSpecAttribute? track, BoxSpecAttribute? fill, AnimatedDataDto? animated, + WidgetModifiersDataDto? modifiers, }) { return builder(ProgressSpecAttribute( container: container, track: track, fill: fill, animated: animated, + modifiers: modifiers, )); } } diff --git a/packages/remix/lib/components/radio/radio.g.dart b/packages/remix/lib/components/radio/radio.g.dart index 3e4ee8d01..9c9c4227a 100644 --- a/packages/remix/lib/components/radio/radio.g.dart +++ b/packages/remix/lib/components/radio/radio.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'radio_spec.dart'; +part of 'radio.dart'; // ************************************************************************** // MixableSpecGenerator @@ -35,11 +35,13 @@ mixin _$RadioSpec on Spec { RadioSpec copyWith({ BoxSpec? container, BoxSpec? indicator, + WidgetModifiersData? modifiers, AnimatedData? animated, }) { return RadioSpec( container: container ?? _$this.container, indicator: indicator ?? _$this.indicator, + modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); } @@ -57,7 +59,7 @@ mixin _$RadioSpec on Spec { /// /// - [BoxSpec.lerp] for [container] and [indicator]. - /// For [animated], the interpolation is performed using a step function. + /// For [modifiers] and [animated], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [RadioSpec] is used. Otherwise, the value /// from the [other] [RadioSpec] is used. /// @@ -70,6 +72,7 @@ mixin _$RadioSpec on Spec { return RadioSpec( container: _$this.container.lerp(other.container, t), indicator: _$this.indicator.lerp(other.indicator, t), + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); } @@ -82,10 +85,22 @@ mixin _$RadioSpec on Spec { List get props => [ _$this.container, _$this.indicator, + _$this.modifiers, _$this.animated, ]; RadioSpec get _$this => this as RadioSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add( + DiagnosticsProperty('container', _$this.container, defaultValue: null)); + properties.add( + DiagnosticsProperty('indicator', _$this.indicator, defaultValue: null)); + properties.add( + DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); + properties.add( + DiagnosticsProperty('animated', _$this.animated, defaultValue: null)); + } } /// Represents the attributes of a [RadioSpec]. @@ -95,13 +110,15 @@ mixin _$RadioSpec on Spec { /// /// Use this class to configure the attributes of a [RadioSpec] and pass it to /// the [RadioSpec] constructor. -base class RadioSpecAttribute extends SpecAttribute { +base class RadioSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final BoxSpecAttribute? indicator; const RadioSpecAttribute({ this.container, this.indicator, + super.modifiers, super.animated, }); @@ -118,6 +135,7 @@ base class RadioSpecAttribute extends SpecAttribute { return RadioSpec( container: container?.resolve(mix), indicator: indicator?.resolve(mix), + modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); } @@ -137,6 +155,7 @@ base class RadioSpecAttribute extends SpecAttribute { return RadioSpecAttribute( container: container?.merge(other.container) ?? other.container, indicator: indicator?.merge(other.indicator) ?? other.indicator, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); } @@ -149,8 +168,22 @@ base class RadioSpecAttribute extends SpecAttribute { List get props => [ container, indicator, + modifiers, animated, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty('container', container, defaultValue: null)); + properties + .add(DiagnosticsProperty('indicator', indicator, defaultValue: null)); + properties + .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); + properties + .add(DiagnosticsProperty('animated', animated, defaultValue: null)); + } } /// Utility class for configuring [RadioSpecAttribute] properties. @@ -165,6 +198,9 @@ class RadioSpecUtility /// Utility for defining [RadioSpecAttribute.indicator] late final indicator = BoxSpecUtility((v) => only(indicator: v)); + /// Utility for defining [RadioSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + /// Utility for defining [RadioSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); @@ -177,11 +213,13 @@ class RadioSpecUtility T only({ BoxSpecAttribute? container, BoxSpecAttribute? indicator, + WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(RadioSpecAttribute( container: container, indicator: indicator, + modifiers: modifiers, animated: animated, )); } diff --git a/packages/remix/lib/components/spinner/spinner.g.dart b/packages/remix/lib/components/spinner/spinner.g.dart index 1a30c9447..0a5a08b45 100644 --- a/packages/remix/lib/components/spinner/spinner.g.dart +++ b/packages/remix/lib/components/spinner/spinner.g.dart @@ -106,13 +106,20 @@ mixin _$SpinnerSpec on Spec { SpinnerSpec get _$this => this as SpinnerSpec; void _debugFillProperties(DiagnosticPropertiesBuilder properties) { - properties.add(DiagnosticsProperty('size', _$this.size)); - properties.add(DiagnosticsProperty('strokeWidth', _$this.strokeWidth)); - properties.add(DiagnosticsProperty('color', _$this.color)); - properties.add(DiagnosticsProperty('duration', _$this.duration)); - properties.add(DiagnosticsProperty('style', _$this.style)); - properties.add(DiagnosticsProperty('modifiers', _$this.modifiers)); - properties.add(DiagnosticsProperty('animated', _$this.animated)); + properties + .add(DiagnosticsProperty('size', _$this.size, defaultValue: null)); + properties.add(DiagnosticsProperty('strokeWidth', _$this.strokeWidth, + defaultValue: null)); + properties + .add(DiagnosticsProperty('color', _$this.color, defaultValue: null)); + properties.add( + DiagnosticsProperty('duration', _$this.duration, defaultValue: null)); + properties + .add(DiagnosticsProperty('style', _$this.style, defaultValue: null)); + properties.add( + DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); + properties.add( + DiagnosticsProperty('animated', _$this.animated, defaultValue: null)); } } @@ -203,13 +210,18 @@ final class SpinnerSpecAttribute extends SpecAttribute @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(DiagnosticsProperty('size', size)); - properties.add(DiagnosticsProperty('strokeWidth', strokeWidth)); - properties.add(DiagnosticsProperty('color', color)); - properties.add(DiagnosticsProperty('duration', duration)); - properties.add(DiagnosticsProperty('style', style, expandableValue: true)); - properties.add(DiagnosticsProperty('modifiers', modifiers)); - properties.add(DiagnosticsProperty('animated', animated)); + properties.add(DiagnosticsProperty('size', size, defaultValue: null)); + properties.add( + DiagnosticsProperty('strokeWidth', strokeWidth, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties + .add(DiagnosticsProperty('duration', duration, defaultValue: null)); + properties.add(DiagnosticsProperty('style', style, + expandableValue: true, defaultValue: null)); + properties + .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); + properties + .add(DiagnosticsProperty('animated', animated, defaultValue: null)); } } diff --git a/packages/remix/lib/components/switch/switch.g.dart b/packages/remix/lib/components/switch/switch.g.dart index 6c8102dc7..275e0873d 100644 --- a/packages/remix/lib/components/switch/switch.g.dart +++ b/packages/remix/lib/components/switch/switch.g.dart @@ -1,6 +1,6 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'switch_spec.dart'; +part of 'switch.dart'; // ************************************************************************** // MixableSpecGenerator @@ -36,11 +36,13 @@ mixin _$SwitchSpec on Spec { BoxSpec? container, BoxSpec? indicator, AnimatedData? animated, + WidgetModifiersData? modifiers, }) { return SwitchSpec( container: container ?? _$this.container, indicator: indicator ?? _$this.indicator, animated: animated ?? _$this.animated, + modifiers: modifiers ?? _$this.modifiers, ); } @@ -57,7 +59,7 @@ mixin _$SwitchSpec on Spec { /// /// - [BoxSpec.lerp] for [container] and [indicator]. - /// For [animated], the interpolation is performed using a step function. + /// For [animated] and [modifiers], the interpolation is performed using a step function. /// If [t] is less than 0.5, the value from the current [SwitchSpec] is used. Otherwise, the value /// from the [other] [SwitchSpec] is used. /// @@ -71,6 +73,7 @@ mixin _$SwitchSpec on Spec { container: _$this.container.lerp(other.container, t), indicator: _$this.indicator.lerp(other.indicator, t), animated: t < 0.5 ? _$this.animated : other.animated, + modifiers: t < 0.5 ? _$this.modifiers : other.modifiers, ); } @@ -83,9 +86,21 @@ mixin _$SwitchSpec on Spec { _$this.container, _$this.indicator, _$this.animated, + _$this.modifiers, ]; SwitchSpec get _$this => this as SwitchSpec; + + void _debugFillProperties(DiagnosticPropertiesBuilder properties) { + properties.add( + DiagnosticsProperty('container', _$this.container, defaultValue: null)); + properties.add( + DiagnosticsProperty('indicator', _$this.indicator, defaultValue: null)); + properties.add( + DiagnosticsProperty('animated', _$this.animated, defaultValue: null)); + properties.add( + DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); + } } /// Represents the attributes of a [SwitchSpec]. @@ -95,7 +110,8 @@ mixin _$SwitchSpec on Spec { /// /// Use this class to configure the attributes of a [SwitchSpec] and pass it to /// the [SwitchSpec] constructor. -base class SwitchSpecAttribute extends SpecAttribute { +base class SwitchSpecAttribute extends SpecAttribute + with Diagnosticable { final BoxSpecAttribute? container; final BoxSpecAttribute? indicator; @@ -103,6 +119,7 @@ base class SwitchSpecAttribute extends SpecAttribute { this.container, this.indicator, super.animated, + super.modifiers, }); /// Resolves to [SwitchSpec] using the provided [MixData]. @@ -119,6 +136,7 @@ base class SwitchSpecAttribute extends SpecAttribute { container: container?.resolve(mix), indicator: indicator?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, + modifiers: modifiers?.resolve(mix), ); } @@ -138,6 +156,7 @@ base class SwitchSpecAttribute extends SpecAttribute { container: container?.merge(other.container) ?? other.container, indicator: indicator?.merge(other.indicator) ?? other.indicator, animated: animated?.merge(other.animated) ?? other.animated, + modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, ); } @@ -150,7 +169,21 @@ base class SwitchSpecAttribute extends SpecAttribute { container, indicator, animated, + modifiers, ]; + + @override + void debugFillProperties(DiagnosticPropertiesBuilder properties) { + super.debugFillProperties(properties); + properties + .add(DiagnosticsProperty('container', container, defaultValue: null)); + properties + .add(DiagnosticsProperty('indicator', indicator, defaultValue: null)); + properties + .add(DiagnosticsProperty('animated', animated, defaultValue: null)); + properties + .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); + } } /// Utility class for configuring [SwitchSpecAttribute] properties. @@ -168,6 +201,9 @@ class SwitchSpecUtility /// Utility for defining [SwitchSpecAttribute.animated] late final animated = AnimatedUtility((v) => only(animated: v)); + /// Utility for defining [SwitchSpecAttribute.modifiers] + late final wrap = SpecModifierUtility((v) => only(modifiers: v)); + SwitchSpecUtility(super.builder); static final self = SwitchSpecUtility((v) => v); @@ -178,11 +214,13 @@ class SwitchSpecUtility BoxSpecAttribute? container, BoxSpecAttribute? indicator, AnimatedDataDto? animated, + WidgetModifiersDataDto? modifiers, }) { return builder(SwitchSpecAttribute( container: container, indicator: indicator, animated: animated, + modifiers: modifiers, )); } } diff --git a/packages/remix/lib/modifiers/flutter_animate.dart b/packages/remix/lib/modifiers/flutter_animate.dart index dee694c45..7e17e38ce 100644 --- a/packages/remix/lib/modifiers/flutter_animate.dart +++ b/packages/remix/lib/modifiers/flutter_animate.dart @@ -5,7 +5,7 @@ import 'package:mix_annotations/mix_annotations.dart'; part 'flutter_animate.g.dart'; -@MixableSpec(prefix: '_FlutterAnimate') +@MixableSpec(prefix: '_FlutterAnimateModifierSpec') class FlutterAnimateModifierSpec extends WidgetModifierSpec with _$FlutterAnimateModifierSpec { @@ -29,13 +29,10 @@ class FlutterAnimateModifierSpec } } -class FlutterAnimateAttribute extends _FlutterAnimateAttribute +class FlutterAnimateAttribute extends _FlutterAnimateModifierSpecAttribute implements AnimateManager { @override - FlutterAnimateAttribute addEffect(Effect effect) { - return addEffects([effect]); - } - + FlutterAnimateAttribute addEffect(Effect effect) => addEffects([effect]); @override FlutterAnimateAttribute addEffects(List effects) { return FlutterAnimateAttribute( @@ -82,3 +79,9 @@ class FlutterAnimateUtility const FlutterAnimateUtility(super.builder); } + +extension TextSpecUtilityX on TextSpecUtility { + FlutterAnimateUtility get animate => FlutterAnimateUtility((v) { + return only(modifiers: WidgetModifiersDataDto([v])); + }); +} diff --git a/packages/remix/lib/modifiers/flutter_animate.g.dart b/packages/remix/lib/modifiers/flutter_animate.g.dart index 1d293eeea..06bf3ef18 100644 --- a/packages/remix/lib/modifiers/flutter_animate.g.dart +++ b/packages/remix/lib/modifiers/flutter_animate.g.dart @@ -82,7 +82,7 @@ mixin _$FlutterAnimateModifierSpec /// /// Use this class to configure the attributes of a [FlutterAnimateModifierSpec] and pass it to /// the [FlutterAnimateModifierSpec] constructor. -class _FlutterAnimateAttribute +class _FlutterAnimateModifierSpecAttribute extends WidgetModifierSpecAttribute { final List>? effects; final bool? autoPlay; @@ -90,7 +90,7 @@ class _FlutterAnimateAttribute final double? value; final double? target; - const _FlutterAnimateAttribute({ + const _FlutterAnimateModifierSpecAttribute({ this.effects, this.autoPlay, this.delay, @@ -104,7 +104,7 @@ class _FlutterAnimateAttribute /// default value defined in the `defaultValue` for that property. /// /// ```dart - /// final flutterAnimateModifierSpec = _FlutterAnimateAttribute(...).resolve(mix); + /// final flutterAnimateModifierSpec = _FlutterAnimateModifierSpecAttribute(...).resolve(mix); /// ``` @override FlutterAnimateModifierSpec resolve(MixData mix) { @@ -117,19 +117,20 @@ class _FlutterAnimateAttribute ); } - /// Merges the properties of this [_FlutterAnimateAttribute] with the properties of [other]. + /// Merges the properties of this [_FlutterAnimateModifierSpecAttribute] with the properties of [other]. /// /// If [other] is null, returns this instance unchanged. Otherwise, returns a new - /// [_FlutterAnimateAttribute] with the properties of [other] taking precedence over + /// [_FlutterAnimateModifierSpecAttribute] with the properties of [other] taking precedence over /// the corresponding properties of this instance. /// /// Properties from [other] that are null will fall back /// to the values from this instance. @override - _FlutterAnimateAttribute merge(covariant _FlutterAnimateAttribute? other) { + _FlutterAnimateModifierSpecAttribute merge( + covariant _FlutterAnimateModifierSpecAttribute? other) { if (other == null) return this; - return _FlutterAnimateAttribute( + return _FlutterAnimateModifierSpecAttribute( effects: MixHelpers.mergeList(effects, other.effects), autoPlay: other.autoPlay ?? autoPlay, delay: other.delay ?? delay, @@ -138,10 +139,10 @@ class _FlutterAnimateAttribute ); } - /// The list of properties that constitute the state of this [_FlutterAnimateAttribute]. + /// The list of properties that constitute the state of this [_FlutterAnimateModifierSpecAttribute]. /// /// This property is used by the [==] operator and the [hashCode] getter to - /// compare two [_FlutterAnimateAttribute] instances for equality. + /// compare two [_FlutterAnimateModifierSpecAttribute] instances for equality. @override List get props => [ effects, @@ -152,32 +153,32 @@ class _FlutterAnimateAttribute ]; } -/// Utility class for configuring [_FlutterAnimateAttribute] properties. +/// Utility class for configuring [_FlutterAnimateModifierSpecAttribute] properties. /// -/// This class provides methods to set individual properties of a [_FlutterAnimateAttribute]. -/// Use the methods of this class to configure specific properties of a [_FlutterAnimateAttribute]. -class _FlutterAnimateUtility - extends SpecUtility { - /// Utility for defining [_FlutterAnimateAttribute.effects] +/// This class provides methods to set individual properties of a [_FlutterAnimateModifierSpecAttribute]. +/// Use the methods of this class to configure specific properties of a [_FlutterAnimateModifierSpecAttribute]. +class _FlutterAnimateModifierSpecUtility + extends SpecUtility { + /// Utility for defining [_FlutterAnimateModifierSpecAttribute.effects] late final effects = ListUtility>((v) => only(effects: v)); - /// Utility for defining [_FlutterAnimateAttribute.autoPlay] + /// Utility for defining [_FlutterAnimateModifierSpecAttribute.autoPlay] late final autoPlay = BoolUtility((v) => only(autoPlay: v)); - /// Utility for defining [_FlutterAnimateAttribute.delay] + /// Utility for defining [_FlutterAnimateModifierSpecAttribute.delay] late final delay = DurationUtility((v) => only(delay: v)); - /// Utility for defining [_FlutterAnimateAttribute.value] + /// Utility for defining [_FlutterAnimateModifierSpecAttribute.value] late final value = DoubleUtility((v) => only(value: v)); - /// Utility for defining [_FlutterAnimateAttribute.target] + /// Utility for defining [_FlutterAnimateModifierSpecAttribute.target] late final target = DoubleUtility((v) => only(target: v)); - _FlutterAnimateUtility(super.builder); + _FlutterAnimateModifierSpecUtility(super.builder); - static final self = _FlutterAnimateUtility((v) => v); + static final self = _FlutterAnimateModifierSpecUtility((v) => v); - /// Returns a new [_FlutterAnimateAttribute] with the specified properties. + /// Returns a new [_FlutterAnimateModifierSpecAttribute] with the specified properties. @override T only({ List>? effects, @@ -186,7 +187,7 @@ class _FlutterAnimateUtility double? value, double? target, }) { - return builder(_FlutterAnimateAttribute( + return builder(_FlutterAnimateModifierSpecAttribute( effects: effects, autoPlay: autoPlay, delay: delay, diff --git a/packages/remix/pubspec.yaml b/packages/remix/pubspec.yaml index 1c9d88246..05aa2533c 100644 --- a/packages/remix/pubspec.yaml +++ b/packages/remix/pubspec.yaml @@ -9,6 +9,7 @@ environment: dependencies: flutter: sdk: flutter + flutter_animate: ^4.5.0 mix: ^1.4.0 mix_annotations: ^0.2.1 @@ -16,7 +17,7 @@ dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^4.0.0 mix_generator: ^0.2.2 build_runner: ^2.4.9 dart_code_metrics_presets: ^2.14.0 From fbb2aa7a80dd7cf12ebf62117d6d3299239c0067 Mon Sep 17 00:00:00 2001 From: Leo Farias Date: Mon, 29 Jul 2024 13:39:16 -0400 Subject: [PATCH 6/7] Removed animate --- .../remix/lib/components/button/button.dart | 3 +- .../lib/components/button/button_style.dart | 8 - .../remix/lib/modifiers/flutter_animate.dart | 87 ------- .../lib/modifiers/flutter_animate.g.dart | 223 ------------------ packages/remix/pubspec.yaml | 1 - 5 files changed, 1 insertion(+), 321 deletions(-) delete mode 100644 packages/remix/lib/modifiers/flutter_animate.dart delete mode 100644 packages/remix/lib/modifiers/flutter_animate.g.dart diff --git a/packages/remix/lib/components/button/button.dart b/packages/remix/lib/components/button/button.dart index 61cfcbdf6..0edca97ce 100644 --- a/packages/remix/lib/components/button/button.dart +++ b/packages/remix/lib/components/button/button.dart @@ -1,10 +1,9 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; -import 'package:flutter_animate/flutter_animate.dart'; + import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; import 'package:remix/components/spinner/spinner.dart'; -import 'package:remix/modifiers/flutter_animate.dart'; import '../../helpers/variant.dart'; import '../../tokens/remix_tokens.dart'; diff --git a/packages/remix/lib/components/button/button_style.dart b/packages/remix/lib/components/button/button_style.dart index 7b7b9bd90..7a4b878d2 100644 --- a/packages/remix/lib/components/button/button_style.dart +++ b/packages/remix/lib/components/button/button_style.dart @@ -5,20 +5,12 @@ final _label = _util.label; final _spinner = _util.spinner; final _container = _util.container; final _flex = _util.flex; -final $animate = FlutterAnimateUtility.self; /// This applies to the icon, label, and spinner final _items = _util.items; Style get _baseStyle { return Style( - $animate() - .fadeIn(duration: 600.ms) - .then( - delay: 200.ms, - ) - .slide(), - $on.press($animate().scale()), _flex.mainAxisAlignment.center(), _flex.crossAxisAlignment.center(), _flex.mainAxisSize.min(), diff --git a/packages/remix/lib/modifiers/flutter_animate.dart b/packages/remix/lib/modifiers/flutter_animate.dart deleted file mode 100644 index 7e17e38ce..000000000 --- a/packages/remix/lib/modifiers/flutter_animate.dart +++ /dev/null @@ -1,87 +0,0 @@ -import 'package:flutter/widgets.dart'; -import 'package:flutter_animate/flutter_animate.dart'; -import 'package:mix/mix.dart'; -import 'package:mix_annotations/mix_annotations.dart'; - -part 'flutter_animate.g.dart'; - -@MixableSpec(prefix: '_FlutterAnimateModifierSpec') -class FlutterAnimateModifierSpec - extends WidgetModifierSpec - with _$FlutterAnimateModifierSpec { - const FlutterAnimateModifierSpec({ - this.effects, - this.autoPlay, - this.delay, - this.value, - this.target, - }); - - final List>? effects; - final bool? autoPlay; - final Duration? delay; - final double? value; - final double? target; - - @override - Widget build(Widget child) { - return child.animate(effects: effects, autoPlay: autoPlay, delay: delay); - } -} - -class FlutterAnimateAttribute extends _FlutterAnimateModifierSpecAttribute - implements AnimateManager { - @override - FlutterAnimateAttribute addEffect(Effect effect) => addEffects([effect]); - @override - FlutterAnimateAttribute addEffects(List effects) { - return FlutterAnimateAttribute( - effects: [...(this.effects ?? []), ...effects], - autoPlay: autoPlay, - delay: delay, - value: value, - target: target, - ); - } - - const FlutterAnimateAttribute({ - super.autoPlay, - super.delay, - super.effects, - super.value, - super.target, - }); -} - -class FlutterAnimateUtility - extends MixUtility with AnimateManager { - @override - T addEffect(Effect effect) => call(effects: [effect]); - - static final self = FlutterAnimateUtility((v) => v); - - /// Returns a new [FlutterAnimateModifierSpecAttribute] with the specified properties. - T call({ - List>? effects, - bool? autoPlay, - Duration? delay, - double? value, - double? target, - }) { - return builder(FlutterAnimateAttribute( - effects: effects, - autoPlay: autoPlay, - delay: delay, - value: value, - target: target, - )); - } - - const FlutterAnimateUtility(super.builder); -} - -extension TextSpecUtilityX on TextSpecUtility { - FlutterAnimateUtility get animate => FlutterAnimateUtility((v) { - return only(modifiers: WidgetModifiersDataDto([v])); - }); -} diff --git a/packages/remix/lib/modifiers/flutter_animate.g.dart b/packages/remix/lib/modifiers/flutter_animate.g.dart deleted file mode 100644 index 06bf3ef18..000000000 --- a/packages/remix/lib/modifiers/flutter_animate.g.dart +++ /dev/null @@ -1,223 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'flutter_animate.dart'; - -// ************************************************************************** -// MixableSpecGenerator -// ************************************************************************** - -mixin _$FlutterAnimateModifierSpec - on WidgetModifierSpec { - /// Creates a copy of this [FlutterAnimateModifierSpec] but with the given fields - /// replaced with the new values. - @override - FlutterAnimateModifierSpec copyWith({ - List>? effects, - bool? autoPlay, - Duration? delay, - double? value, - double? target, - }) { - return FlutterAnimateModifierSpec( - effects: effects ?? _$this.effects, - autoPlay: autoPlay ?? _$this.autoPlay, - delay: delay ?? _$this.delay, - value: value ?? _$this.value, - target: target ?? _$this.target, - ); - } - - /// Linearly interpolates between this [FlutterAnimateModifierSpec] and another [FlutterAnimateModifierSpec] based on the given parameter [t]. - /// - /// The parameter [t] represents the interpolation factor, typically ranging from 0.0 to 1.0. - /// When [t] is 0.0, the current [FlutterAnimateModifierSpec] is returned. When [t] is 1.0, the [other] [FlutterAnimateModifierSpec] is returned. - /// For values of [t] between 0.0 and 1.0, an interpolated [FlutterAnimateModifierSpec] is returned. - /// - /// If [other] is null, this method returns the current [FlutterAnimateModifierSpec] instance. - /// - /// The interpolation is performed on each property of the [FlutterAnimateModifierSpec] using the appropriate - /// interpolation method: - /// - /// - [MixHelpers.lerpDouble] for [value] and [target]. - - /// For [effects] and [autoPlay] and [delay], the interpolation is performed using a step function. - /// If [t] is less than 0.5, the value from the current [FlutterAnimateModifierSpec] is used. Otherwise, the value - /// from the [other] [FlutterAnimateModifierSpec] is used. - /// - /// This method is typically used in animations to smoothly transition between - /// different [FlutterAnimateModifierSpec] configurations. - @override - FlutterAnimateModifierSpec lerp(FlutterAnimateModifierSpec? other, double t) { - if (other == null) return _$this; - - return FlutterAnimateModifierSpec( - effects: t < 0.5 ? _$this.effects : other.effects, - autoPlay: t < 0.5 ? _$this.autoPlay : other.autoPlay, - delay: t < 0.5 ? _$this.delay : other.delay, - value: MixHelpers.lerpDouble(_$this.value, other.value, t), - target: MixHelpers.lerpDouble(_$this.target, other.target, t), - ); - } - - /// The list of properties that constitute the state of this [FlutterAnimateModifierSpec]. - /// - /// This property is used by the [==] operator and the [hashCode] getter to - /// compare two [FlutterAnimateModifierSpec] instances for equality. - @override - List get props => [ - _$this.effects, - _$this.autoPlay, - _$this.delay, - _$this.value, - _$this.target, - ]; - - FlutterAnimateModifierSpec get _$this => this as FlutterAnimateModifierSpec; -} - -/// Represents the attributes of a [FlutterAnimateModifierSpec]. -/// -/// This class encapsulates properties defining the layout and -/// appearance of a [FlutterAnimateModifierSpec]. -/// -/// Use this class to configure the attributes of a [FlutterAnimateModifierSpec] and pass it to -/// the [FlutterAnimateModifierSpec] constructor. -class _FlutterAnimateModifierSpecAttribute - extends WidgetModifierSpecAttribute { - final List>? effects; - final bool? autoPlay; - final Duration? delay; - final double? value; - final double? target; - - const _FlutterAnimateModifierSpecAttribute({ - this.effects, - this.autoPlay, - this.delay, - this.value, - this.target, - }); - - /// Resolves to [FlutterAnimateModifierSpec] using the provided [MixData]. - /// - /// If a property is null in the [MixData], it falls back to the - /// default value defined in the `defaultValue` for that property. - /// - /// ```dart - /// final flutterAnimateModifierSpec = _FlutterAnimateModifierSpecAttribute(...).resolve(mix); - /// ``` - @override - FlutterAnimateModifierSpec resolve(MixData mix) { - return FlutterAnimateModifierSpec( - effects: effects, - autoPlay: autoPlay, - delay: delay, - value: value, - target: target, - ); - } - - /// Merges the properties of this [_FlutterAnimateModifierSpecAttribute] with the properties of [other]. - /// - /// If [other] is null, returns this instance unchanged. Otherwise, returns a new - /// [_FlutterAnimateModifierSpecAttribute] with the properties of [other] taking precedence over - /// the corresponding properties of this instance. - /// - /// Properties from [other] that are null will fall back - /// to the values from this instance. - @override - _FlutterAnimateModifierSpecAttribute merge( - covariant _FlutterAnimateModifierSpecAttribute? other) { - if (other == null) return this; - - return _FlutterAnimateModifierSpecAttribute( - effects: MixHelpers.mergeList(effects, other.effects), - autoPlay: other.autoPlay ?? autoPlay, - delay: other.delay ?? delay, - value: other.value ?? value, - target: other.target ?? target, - ); - } - - /// The list of properties that constitute the state of this [_FlutterAnimateModifierSpecAttribute]. - /// - /// This property is used by the [==] operator and the [hashCode] getter to - /// compare two [_FlutterAnimateModifierSpecAttribute] instances for equality. - @override - List get props => [ - effects, - autoPlay, - delay, - value, - target, - ]; -} - -/// Utility class for configuring [_FlutterAnimateModifierSpecAttribute] properties. -/// -/// This class provides methods to set individual properties of a [_FlutterAnimateModifierSpecAttribute]. -/// Use the methods of this class to configure specific properties of a [_FlutterAnimateModifierSpecAttribute]. -class _FlutterAnimateModifierSpecUtility - extends SpecUtility { - /// Utility for defining [_FlutterAnimateModifierSpecAttribute.effects] - late final effects = ListUtility>((v) => only(effects: v)); - - /// Utility for defining [_FlutterAnimateModifierSpecAttribute.autoPlay] - late final autoPlay = BoolUtility((v) => only(autoPlay: v)); - - /// Utility for defining [_FlutterAnimateModifierSpecAttribute.delay] - late final delay = DurationUtility((v) => only(delay: v)); - - /// Utility for defining [_FlutterAnimateModifierSpecAttribute.value] - late final value = DoubleUtility((v) => only(value: v)); - - /// Utility for defining [_FlutterAnimateModifierSpecAttribute.target] - late final target = DoubleUtility((v) => only(target: v)); - - _FlutterAnimateModifierSpecUtility(super.builder); - - static final self = _FlutterAnimateModifierSpecUtility((v) => v); - - /// Returns a new [_FlutterAnimateModifierSpecAttribute] with the specified properties. - @override - T only({ - List>? effects, - bool? autoPlay, - Duration? delay, - double? value, - double? target, - }) { - return builder(_FlutterAnimateModifierSpecAttribute( - effects: effects, - autoPlay: autoPlay, - delay: delay, - value: value, - target: target, - )); - } -} - -/// A tween that interpolates between two [FlutterAnimateModifierSpec] instances. -/// -/// This class can be used in animations to smoothly transition between -/// different [FlutterAnimateModifierSpec] specifications. -class FlutterAnimateModifierSpecTween - extends Tween { - FlutterAnimateModifierSpecTween({ - super.begin, - super.end, - }); - - @override - FlutterAnimateModifierSpec lerp(double t) { - if (begin == null && end == null) { - return const FlutterAnimateModifierSpec(); - } - - if (begin == null) { - return end!; - } - - return begin!.lerp(end!, t); - } -} diff --git a/packages/remix/pubspec.yaml b/packages/remix/pubspec.yaml index 05aa2533c..c66c65f88 100644 --- a/packages/remix/pubspec.yaml +++ b/packages/remix/pubspec.yaml @@ -9,7 +9,6 @@ environment: dependencies: flutter: sdk: flutter - flutter_animate: ^4.5.0 mix: ^1.4.0 mix_annotations: ^0.2.1 From 17986682bd2d4a6ace08923b421d341c4ecb75cf Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Wed, 31 Jul 2024 22:04:37 -0300 Subject: [PATCH 7/7] add LiveCode --- .../demo/lib/components/avatar_use_case.dart | 61 +++++++++---------- packages/remix/demo/lib/main.dart | 44 ++++++++++++- .../demo/lib/utils/components/code_view.dart | 39 ++++++++++++ packages/remix/demo/pubspec.yaml | 4 +- .../components/avatar/avatar_variants.dart | 24 +++++++- .../lib/components/avatar/avatar_widget.dart | 12 ++++ packages/remix/pubspec.yaml | 2 + 7 files changed, 149 insertions(+), 37 deletions(-) create mode 100644 packages/remix/demo/lib/utils/components/code_view.dart diff --git a/packages/remix/demo/lib/components/avatar_use_case.dart b/packages/remix/demo/lib/components/avatar_use_case.dart index 3955d684e..1572248b7 100644 --- a/packages/remix/demo/lib/components/avatar_use_case.dart +++ b/packages/remix/demo/lib/components/avatar_use_case.dart @@ -1,9 +1,11 @@ +import 'package:demo/main.dart'; import 'package:flutter/material.dart'; import 'package:remix/components/avatar/avatar.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; final _key = GlobalKey(); +final _avatarKey = GlobalKey(); @widgetbook.UseCase( name: 'Avatar Component', @@ -15,41 +17,38 @@ Widget buildAvatarUseCase(BuildContext context) { initialValue: 'https://i.pravatar.cc/150?img=48', ); - Widget buildAvatar(AvatarVariant variant) { - return Column( - children: [ - Text(variant.name.split('.').last), - const SizedBox(height: 10), - RxAvatar( - image: NetworkImage(imageUrl), - fallback: context.knobs.string( - label: 'Fallback', - initialValue: 'AB', - ), - variant: variant, - size: context.knobs.list( - label: 'Size', - options: AvatarSize.values, - initialOption: AvatarSize.size4, - labelBuilder: (value) => value.name.split('.').last, - ), - radius: context.knobs.list( - label: 'Radius', - options: AvatarRadius.values, - initialOption: AvatarRadius.full, - labelBuilder: (value) => value.name.split('.').last, - ), - ), - ], - ); + final avatar = _avatarKey.currentWidget; + if (avatar is RxAvatar) { + $code.value = avatar.toStringComponent(); } return KeyedSubtree( key: _key, - child: Wrap( - spacing: 12, - runSpacing: 12, - children: AvatarVariant.values.map(buildAvatar).toList(), + child: RxAvatar( + key: _avatarKey, + image: NetworkImage(imageUrl), + fallback: context.knobs.string( + label: 'Fallback', + initialValue: 'AB', + ), + variant: context.knobs.list( + label: 'Variant', + initialOption: AvatarVariant.soft, + options: AvatarVariant.values, + labelBuilder: (value) => value.name.split('.').last, + ), + size: context.knobs.list( + label: 'Size', + options: AvatarSize.values, + initialOption: AvatarSize.size4, + labelBuilder: (value) => value.name.split('.').last, + ), + radius: context.knobs.list( + label: 'Radius', + options: AvatarRadius.values, + initialOption: AvatarRadius.full, + labelBuilder: (value) => value.name.split('.').last, + ), ), ); } diff --git a/packages/remix/demo/lib/main.dart b/packages/remix/demo/lib/main.dart index 6db213484..71f06f6e2 100644 --- a/packages/remix/demo/lib/main.dart +++ b/packages/remix/demo/lib/main.dart @@ -1,12 +1,34 @@ +import 'package:demo/utils/components/code_view.dart'; import 'package:flutter/material.dart'; import 'package:remix/remix.dart'; +import 'package:syntax_highlight/syntax_highlight.dart'; import 'package:widgetbook/widgetbook.dart'; import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; import 'main.directories.g.dart'; +late final Highlighter dartLightHighlighter; + +class LiveCode extends ValueNotifier { + LiveCode() : super(''); +} + +final $code = LiveCode(); + @widgetbook.App() -void main() { +void main() async { + WidgetsFlutterBinding.ensureInitialized(); + + await Highlighter.initialize([ + 'dart', + ]); + + var lightTheme = await HighlighterTheme.loadDarkTheme(); + + dartLightHighlighter = Highlighter( + language: 'dart', + theme: lightTheme, + ); runApp(const HotReload()); } @@ -50,7 +72,25 @@ class HotReload extends StatelessWidget { ], appBuilder: (context, child) => MaterialApp( debugShowCheckedModeBanner: false, - home: Scaffold(body: Center(child: child)), + home: RemixTokens( + data: RemixTokens.light, + child: Scaffold( + body: Center(child: child), + floatingActionButtonLocation: + FloatingActionButtonLocation.centerFloat, + floatingActionButton: $code.value == '' + ? const RxButton( + label: '', + onPressed: null, + disabled: true, + iconLeft: Icons.code_rounded, + size: ButtonSize.large, + ) + : CodeView( + code: $code.value, + ), + ), + ), ), directories: directories, ); diff --git a/packages/remix/demo/lib/utils/components/code_view.dart b/packages/remix/demo/lib/utils/components/code_view.dart new file mode 100644 index 000000000..2e4e61947 --- /dev/null +++ b/packages/remix/demo/lib/utils/components/code_view.dart @@ -0,0 +1,39 @@ +import 'package:demo/main.dart'; +import 'package:flutter/material.dart'; +import 'package:google_fonts/google_fonts.dart'; +import 'package:mix/mix.dart'; + +class CodeView extends StatelessWidget { + const CodeView({ + super.key, + required this.code, + }); + + final String code; + + @override + Widget build(BuildContext context) { + return Box( + style: Style( + $with.padding.horizontal(24), + $box.padding(16), + $box.color(const Color(0xFF141726)), + $box.borderRadius(15), + ), + child: SizedBox( + child: SingleChildScrollView( + physics: const ClampingScrollPhysics(), + scrollDirection: Axis.horizontal, + child: SelectableText.rich( + dartLightHighlighter.highlight(code), + style: GoogleFonts.firaCode( + fontSize: 13, + height: 1.3, + fontWeight: FontWeight.w300, + ), + ), + ), + ), + ); + } +} diff --git a/packages/remix/demo/pubspec.yaml b/packages/remix/demo/pubspec.yaml index 71e01d1e3..e18e27a52 100644 --- a/packages/remix/demo/pubspec.yaml +++ b/packages/remix/demo/pubspec.yaml @@ -19,6 +19,8 @@ dependencies: path: ../ mix: ^1.4.0 + syntax_highlight: ^0.4.0 + google_fonts: ^6.2.0 dev_dependencies: flutter_test: @@ -29,4 +31,4 @@ dev_dependencies: build_runner: ^2.4.9 flutter: - uses-material-design: true + uses-material-design: true \ No newline at end of file diff --git a/packages/remix/lib/components/avatar/avatar_variants.dart b/packages/remix/lib/components/avatar/avatar_variants.dart index e7f07bbc1..093b8552a 100644 --- a/packages/remix/lib/components/avatar/avatar_variants.dart +++ b/packages/remix/lib/components/avatar/avatar_variants.dart @@ -5,16 +5,23 @@ abstract interface class IAvatarVariant extends RemixVariant { } class AvatarVariant extends IAvatarVariant { - const AvatarVariant(String name) : super('variant.$name'); + const AvatarVariant(this._name) : super('variant.$_name'); + final String _name; static const solid = AvatarVariant('solid'); static const soft = AvatarVariant('soft'); static List get values => [solid, soft]; + + @override + String toString() { + return 'AvatarVariant(\'$_name\')'; + } } class AvatarSize extends IAvatarVariant { - const AvatarSize(String name) : super('size.$name'); + const AvatarSize(this._name) : super('size.$_name'); + final String _name; static const size1 = AvatarSize('size1'); static const size2 = AvatarSize('size2'); @@ -35,10 +42,16 @@ class AvatarSize extends IAvatarVariant { size7, size8, ]; + + @override + String toString() { + return 'AvatarSize(\'$_name\')'; + } } class AvatarRadius extends IAvatarVariant { - const AvatarRadius(String name) : super('radius.$name'); + const AvatarRadius(this._name) : super('radius.$_name'); + final String _name; static const none = AvatarRadius('none'); static const small = AvatarRadius('small'); @@ -47,4 +60,9 @@ class AvatarRadius extends IAvatarVariant { static const full = AvatarRadius('full'); static List get values => [none, small, medium, large, full]; + + @override + String toString() { + return 'AvatarRadius(\'$_name\')'; + } } diff --git a/packages/remix/lib/components/avatar/avatar_widget.dart b/packages/remix/lib/components/avatar/avatar_widget.dart index b948d3656..574eacfbb 100644 --- a/packages/remix/lib/components/avatar/avatar_widget.dart +++ b/packages/remix/lib/components/avatar/avatar_widget.dart @@ -42,4 +42,16 @@ class RxAvatar extends StatelessWidget { }, ); } + + String toStringComponent() { + return ''' +RxAvatar( + image: $image, + fallback: '$fallback', + size: $size, + variant: $variant, + radius: $radius, +) +'''; + } } diff --git a/packages/remix/pubspec.yaml b/packages/remix/pubspec.yaml index c66c65f88..7b096bac2 100644 --- a/packages/remix/pubspec.yaml +++ b/packages/remix/pubspec.yaml @@ -7,8 +7,10 @@ environment: sdk: ">=3.3.0 <4.0.0" dependencies: + code_viewer: ^0.0.2 flutter: sdk: flutter + flutter_syntax_view: ^4.0.0 mix: ^1.4.0 mix_annotations: ^0.2.1