From bdd830def122ceef54881ebfadf29757c1aa6dc6 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:30:45 -0300 Subject: [PATCH] Rewrite radio in the new architecture --- .../demo/lib/components/radio_use_case.dart | 56 ++----- packages/remix/demo/lib/helpers/string.dart | 5 + .../ephemeral/FlutterInputs.xcfilelist | 149 +---------------- .../remix/lib/components/radio/radio.dart | 13 +- .../remix/lib/components/radio/radio.g.dart | 36 +++++ .../lib/components/radio/radio_blank.dart | 75 --------- .../lib/components/radio/radio_style.dart | 153 ++++++++---------- .../lib/components/radio/radio_variants.dart | 32 ---- .../lib/components/radio/radio_widget.dart | 99 ++++++++++-- .../components/radio/radio_widget_test.dart | 75 +++------ 10 files changed, 237 insertions(+), 456 deletions(-) create mode 100644 packages/remix/demo/lib/helpers/string.dart delete mode 100644 packages/remix/lib/components/radio/radio_blank.dart delete mode 100644 packages/remix/lib/components/radio/radio_variants.dart diff --git a/packages/remix/demo/lib/components/radio_use_case.dart b/packages/remix/demo/lib/components/radio_use_case.dart index 29fd126bb..d8dd1722b 100644 --- a/packages/remix/demo/lib/components/radio_use_case.dart +++ b/packages/remix/demo/lib/components/radio_use_case.dart @@ -1,3 +1,4 @@ +import 'package:demo/helpers/string.dart'; import 'package:flutter/material.dart'; import 'package:remix/components/radio/radio.dart'; import 'package:widgetbook/widgetbook.dart'; @@ -5,29 +6,15 @@ import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook; final _key = GlobalKey(); -enum RadioType { - solid, - outline, - soft, - surface; - - RadioVariant get variant { - switch (this) { - case RadioType.solid: - return RadioVariant.solid; - case RadioType.outline: - return RadioVariant.outline; - case RadioType.soft: - return RadioVariant.soft; - case RadioType.surface: - return RadioVariant.surface; - } - } +enum Theme { + dark, + light, + system, } @widgetbook.UseCase( name: 'Radio Component', - type: RxRadio, + type: XRadio, ) Widget buildRadioUseCase(BuildContext context) { return const RadioExample(); @@ -41,7 +28,7 @@ class RadioExample extends StatefulWidget { } class _RadioExampleState extends State { - RadioType? _type = RadioType.outline; + Theme _theme = Theme.dark; @override Widget build(BuildContext context) { @@ -51,38 +38,27 @@ class _RadioExampleState extends State { mainAxisSize: MainAxisSize.min, key: _key, children: [ - for (var type in RadioType.values) + for (var theme in Theme.values) ...[ Row( children: [ - RxRadio( - value: type, - groupValue: _type, - variant: type.variant, - onChanged: (RadioType? value) { + XRadio( + value: theme, + groupValue: _theme, + onChanged: (Theme? value) { setState(() { - _type = value; + _theme = value!; }); }, - size: context.knobs.list( - label: 'Size', - options: RadioSize.values, - initialOption: RadioSize.medium, - labelBuilder: (value) => value.label, - ), disabled: context.knobs.boolean( label: 'Disabled', initialValue: false, ), - ), - const SizedBox(width: 16, height: 30), - Text( - type.name, - style: const TextStyle( - fontSize: 16, - ), + text: theme.name.capitalize(), ), ], ), + const SizedBox(height: 8), + ] ], ), ); diff --git a/packages/remix/demo/lib/helpers/string.dart b/packages/remix/demo/lib/helpers/string.dart new file mode 100644 index 000000000..5d9294894 --- /dev/null +++ b/packages/remix/demo/lib/helpers/string.dart @@ -0,0 +1,5 @@ +extension StringExtension on String { + String capitalize() { + return "${this[0].toUpperCase()}${substring(1).toLowerCase()}"; + } +} diff --git a/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist b/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist index 4e8aeb92e..d429072b7 100644 --- a/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist +++ b/packages/remix/demo/macos/Flutter/ephemeral/FlutterInputs.xcfilelist @@ -854,152 +854,6 @@ /Users/lucasoliveira/.pub-cache/hosted/pub.dev/widgetbook_annotation-3.1.0/lib/widgetbook_annotation.dart /Users/lucasoliveira/.pub-cache/hosted/pub.dev/widgetbook_generator-3.8.0/LICENSE /Users/lucasoliveira/.pub-cache/hosted/pub.dev/yaml-3.1.2/LICENSE -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/LICENSE -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/mix.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/animated/animated_data.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/animated/animated_data_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/animated/animated_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/border_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/border_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/border_radius_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/border_radius_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/border_radius_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/border_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/shape_border_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/border/shape_border_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/color/color_directives.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/color/color_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/color/color_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/color/material_colors_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/constraints/constraints_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/constraints/constraints_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/decoration/decoration_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/decoration/decoration_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/decoration/image/decoration_image_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/decoration/image/decoration_image_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/enum/enum_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/enum/enum_util.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/gap/gap_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/gap/spacing_side_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/gradient/gradient_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/gradient/gradient_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/modifiers/widget_modifiers_data.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/modifiers/widget_modifiers_data_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/modifiers/widget_modifiers_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/nested_style/nested_style_attribute.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/nested_style/nested_style_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/scalars/scalar_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/scalars/scalar_util.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/shadow/shadow_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/shadow/shadow_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/shadow/shadow_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/spacing/edge_insets_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/spacing/edge_insets_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/spacing/spacing_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/strut_style/strut_style_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/strut_style/strut_style_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/text_style/text_style_dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/text_style/text_style_dto.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/attributes/text_style/text_style_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/attribute.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/attributes_map.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/deprecation_notices.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/directive.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/dto.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/factory/mix_data.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/factory/mix_provider.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/factory/style_mix.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/factory/style_widgets_ext.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/helpers.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/spec.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/styled_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/utility.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/variant.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/widget_state/internal/gesture_mix_state.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/widget_state/internal/interactive_mix_state.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/widget_state/internal/mix_widget_state_builder.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/widget_state/internal/mouse_region_mix_state.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/core/widget_state/widget_state_controller.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/build_context_ext.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/compare_mixin.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/constants.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/deep_collection_equality.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/diagnostic_properties_builder_ext.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/helper_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/iterable_ext.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/internal/string_ext.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/align_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/align_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/aspect_ratio_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/aspect_ratio_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/clip_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/clip_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/flexible_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/flexible_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/fractionally_sized_box_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/fractionally_sized_box_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/internal/render_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/intrinsic_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/intrinsic_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/opacity_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/opacity_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/padding_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/padding_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/rotated_box_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/rotated_box_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/sized_box_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/sized_box_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/transform_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/transform_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/visibility_widget_modifier.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/visibility_widget_modifier.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/modifiers/widget_modifiers_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/box/box_spec.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/box/box_spec.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/box/box_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/flex/flex_spec.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/flex/flex_spec.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/flex/flex_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/icon/icon_spec.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/icon/icon_spec.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/icon/icon_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/image/image_spec.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/image/image_spec.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/image/image_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/spec_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/stack/stack_spec.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/stack/stack_spec.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/stack/stack_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/text/text_directives_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/text/text_spec.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/text/text_spec.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/specs/text/text_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/material/material_theme.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/material/material_tokens.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/mix/mix_theme.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/breakpoints_token.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/color_token.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/mix_token.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/radius_token.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/space_token.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/text_style_token.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/token_resolver.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/theme/tokens/token_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant_util/on_breakpoint_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant_util/on_brightness_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant_util/on_directionality_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant_util/on_not_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant_util/on_orientation_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant_util/on_platform_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/context_variant_util/on_util.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/variant_attribute.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/variants/widget_state_variant.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix/lib/src/widgets/pressable_widget.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix_annotations/LICENSE -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix_annotations/lib/mix_annotations.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/mix_annotations/lib/src/annotations.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/LICENSE /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/addons/icon_data_knob.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/components/avatar_use_case.dart @@ -1013,6 +867,7 @@ /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/components/spinner_use_case.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/components/switch_use_case.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/helpers/label_variant_builder.dart +/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/helpers/string.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/helpers/use_case_state.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/main.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/demo/lib/main.directories.g.dart @@ -1059,9 +914,7 @@ /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/progress/progress_widget.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/radio/radio.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/radio/radio.g.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/radio/radio_blank.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/radio/radio_style.dart -/Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/radio/radio_variants.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/radio/radio_widget.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/spinner/spinner.dart /Users/lucasoliveira/Developer/Concepta/open_source/mix_ecosystem/mix/packages/remix/lib/components/spinner/spinner.g.dart diff --git a/packages/remix/lib/components/radio/radio.dart b/packages/remix/lib/components/radio/radio.dart index c691983e8..00b657c04 100644 --- a/packages/remix/lib/components/radio/radio.dart +++ b/packages/remix/lib/components/radio/radio.dart @@ -5,19 +5,16 @@ import 'package:mix/mix.dart'; import 'package:mix_annotations/mix_annotations.dart'; import '../../helpers/utility_extension.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'; -part 'radio_blank.dart'; @MixableSpec() base class RadioSpec extends Spec with _$RadioSpec, Diagnosticable { final BoxSpec container; final BoxSpec indicator; + final FlexSpec flex; + final TextSpec text; /// {@macro radio_spec_of} static const of = _$RadioSpec.of; @@ -27,10 +24,14 @@ base class RadioSpec extends Spec with _$RadioSpec, Diagnosticable { const RadioSpec({ BoxSpec? container, BoxSpec? indicator, + FlexSpec? flex, + TextSpec? text, super.modifiers, super.animated, }) : container = container ?? const BoxSpec(), - indicator = indicator ?? const BoxSpec(); + indicator = indicator ?? const BoxSpec(), + text = text ?? const TextSpec(), + flex = flex ?? const FlexSpec(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { diff --git a/packages/remix/lib/components/radio/radio.g.dart b/packages/remix/lib/components/radio/radio.g.dart index 9335c0de0..b49e1cfb9 100644 --- a/packages/remix/lib/components/radio/radio.g.dart +++ b/packages/remix/lib/components/radio/radio.g.dart @@ -35,12 +35,16 @@ mixin _$RadioSpec on Spec { RadioSpec copyWith({ BoxSpec? container, BoxSpec? indicator, + FlexSpec? flex, + TextSpec? text, WidgetModifiersData? modifiers, AnimatedData? animated, }) { return RadioSpec( container: container ?? _$this.container, indicator: indicator ?? _$this.indicator, + flex: flex ?? _$this.flex, + text: text ?? _$this.text, modifiers: modifiers ?? _$this.modifiers, animated: animated ?? _$this.animated, ); @@ -58,6 +62,8 @@ mixin _$RadioSpec on Spec { /// interpolation method: /// /// - [BoxSpec.lerp] for [container] and [indicator]. + /// - [FlexSpec.lerp] for [flex]. + /// - [TextSpec.lerp] for [text]. /// 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 @@ -72,6 +78,8 @@ mixin _$RadioSpec on Spec { return RadioSpec( container: _$this.container.lerp(other.container, t), indicator: _$this.indicator.lerp(other.indicator, t), + flex: _$this.flex.lerp(other.flex, t), + text: _$this.text.lerp(other.text, t), modifiers: other.modifiers, animated: t < 0.5 ? _$this.animated : other.animated, ); @@ -85,6 +93,8 @@ mixin _$RadioSpec on Spec { List get props => [ _$this.container, _$this.indicator, + _$this.flex, + _$this.text, _$this.modifiers, _$this.animated, ]; @@ -96,6 +106,10 @@ mixin _$RadioSpec on Spec { DiagnosticsProperty('container', _$this.container, defaultValue: null)); properties.add( DiagnosticsProperty('indicator', _$this.indicator, defaultValue: null)); + properties + .add(DiagnosticsProperty('flex', _$this.flex, defaultValue: null)); + properties + .add(DiagnosticsProperty('text', _$this.text, defaultValue: null)); properties.add( DiagnosticsProperty('modifiers', _$this.modifiers, defaultValue: null)); properties.add( @@ -114,10 +128,14 @@ base class RadioSpecAttribute extends SpecAttribute with Diagnosticable { final BoxSpecAttribute? container; final BoxSpecAttribute? indicator; + final FlexSpecAttribute? flex; + final TextSpecAttribute? text; const RadioSpecAttribute({ this.container, this.indicator, + this.flex, + this.text, super.modifiers, super.animated, }); @@ -135,6 +153,8 @@ base class RadioSpecAttribute extends SpecAttribute return RadioSpec( container: container?.resolve(mix), indicator: indicator?.resolve(mix), + flex: flex?.resolve(mix), + text: text?.resolve(mix), modifiers: modifiers?.resolve(mix), animated: animated?.resolve(mix) ?? mix.animation, ); @@ -155,6 +175,8 @@ base class RadioSpecAttribute extends SpecAttribute return RadioSpecAttribute( container: container?.merge(other.container) ?? other.container, indicator: indicator?.merge(other.indicator) ?? other.indicator, + flex: flex?.merge(other.flex) ?? other.flex, + text: text?.merge(other.text) ?? other.text, modifiers: modifiers?.merge(other.modifiers) ?? other.modifiers, animated: animated?.merge(other.animated) ?? other.animated, ); @@ -168,6 +190,8 @@ base class RadioSpecAttribute extends SpecAttribute List get props => [ container, indicator, + flex, + text, modifiers, animated, ]; @@ -179,6 +203,8 @@ base class RadioSpecAttribute extends SpecAttribute .add(DiagnosticsProperty('container', container, defaultValue: null)); properties .add(DiagnosticsProperty('indicator', indicator, defaultValue: null)); + properties.add(DiagnosticsProperty('flex', flex, defaultValue: null)); + properties.add(DiagnosticsProperty('text', text, defaultValue: null)); properties .add(DiagnosticsProperty('modifiers', modifiers, defaultValue: null)); properties @@ -198,6 +224,12 @@ class RadioSpecUtility /// Utility for defining [RadioSpecAttribute.indicator] late final indicator = BoxSpecUtility((v) => only(indicator: v)); + /// Utility for defining [RadioSpecAttribute.flex] + late final flex = FlexSpecUtility((v) => only(flex: v)); + + /// Utility for defining [RadioSpecAttribute.text] + late final text = TextSpecUtility((v) => only(text: v)); + /// Utility for defining [RadioSpecAttribute.modifiers] late final wrap = SpecModifierUtility((v) => only(modifiers: v)); @@ -213,12 +245,16 @@ class RadioSpecUtility T only({ BoxSpecAttribute? container, BoxSpecAttribute? indicator, + FlexSpecAttribute? flex, + TextSpecAttribute? text, WidgetModifiersDataDto? modifiers, AnimatedDataDto? animated, }) { return builder(RadioSpecAttribute( container: container, indicator: indicator, + flex: flex, + text: text, modifiers: modifiers, animated: animated, )); diff --git a/packages/remix/lib/components/radio/radio_blank.dart b/packages/remix/lib/components/radio/radio_blank.dart deleted file mode 100644 index 25c06213f..000000000 --- a/packages/remix/lib/components/radio/radio_blank.dart +++ /dev/null @@ -1,75 +0,0 @@ -part of 'radio.dart'; - -class RxBlankRadio extends StatefulWidget { - const RxBlankRadio({ - super.key, - this.disabled = false, - required this.style, - required this.value, - required this.onChanged, - required this.groupValue, - }); - - final T value; - final ValueChanged onChanged; - final T? groupValue; - final Style style; - final bool disabled; - - bool get _selected => value == groupValue; - - @override - State> createState() => _RxBlankRadioState(); -} - -class _RxBlankRadioState extends State> { - late final MixWidgetStateController _controller; - @override - void initState() { - super.initState(); - _controller = MixWidgetStateController() - ..selected = widget._selected - ..disabled = widget.disabled; - } - - void _handleOnPress() => widget.onChanged(!widget.value); - - @override - void didUpdateWidget(RxBlankRadio oldWidget) { - super.didUpdateWidget(oldWidget); - - if (oldWidget._selected != widget._selected) { - _controller.selected = widget._selected; - } - - if (oldWidget.disabled != widget.disabled) { - _controller.disabled = widget.disabled; - } - } - - @override - void dispose() { - _controller.dispose(); - super.dispose(); - } - - @override - Widget build(BuildContext context) { - return Pressable( - enabled: !widget.disabled, - onPress: widget.disabled ? null : _handleOnPress, - controller: _controller, - child: SpecBuilder( - builder: (context) { - final spec = RadioSpec.of(context); - - final ContainerWidget = spec.container; - final IndicatorWidget = spec.indicator; - - return ContainerWidget(child: IndicatorWidget()); - }, - style: widget.style, - ), - ); - } -} diff --git a/packages/remix/lib/components/radio/radio_style.dart b/packages/remix/lib/components/radio/radio_style.dart index 22cb748c0..99fa2ea19 100644 --- a/packages/remix/lib/components/radio/radio_style.dart +++ b/packages/remix/lib/components/radio/radio_style.dart @@ -3,99 +3,74 @@ part of 'radio.dart'; final _radio = RadioSpecUtility.self; final _container = _radio.container; final _indicator = _radio.indicator; +final _flex = _radio.flex; +final _text = _radio.text; -Style get _baseStyle { - return Style( - _container.borderRadius(99), - _container.alignment.center(), - _indicator.borderRadius(99), - _indicator.wrap.opacity(0), - _indicator.wrap.scale(0.5), - $on.selected(_indicator.wrap.opacity(1), _indicator.wrap.scale(1)), - ); -} - -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(3)), - ); -} - -Style get _smallVariant { - return Style(_container.size(16), _indicator.size(8)); -} - -Style get _mediumVariant { - return Style(_container.size(20), _indicator.size(10)); -} - -Style get _largeVariant { - return Style(_container.size(24), _indicator.size(12)); -} - -Style get _disabledVariant { - return Style( - _container.color.$neutralAlpha(3), - _container.border.color.$neutralAlpha(5), - _indicator.color.$neutralAlpha(7), - ); -} +class XRadioStyle { + static Style get container => Style( + _container.borderRadius(99), + _container.alignment.center(), + _container.size(14), + _container.border.all.width(1), + _container.border.all.color.black(), + $on.disabled( + _container.border.color.black.brighten(80), + ), + $on.dark( + _container.border.all.color.white(), + $on.disabled( + _container.border.color.black.darken(30), + ), + ), + ); + static Style get indicator => Style( + _indicator.borderRadius(99), + _indicator.color.black(), + _indicator.wrap.padding.all(2), + _indicator.wrap.opacity(0), + _indicator.wrap.scale(0.5), + $on.selected( + _indicator.wrap.opacity(1), + _indicator.wrap.scale(1), + ), + $on.disabled( + _indicator.color.black.brighten(70), + ), + $on.dark( + _indicator.color.white(), + $on.disabled( + _indicator.color.black.darken(50), + ), + ), + ); -Style _buildDefaultRadioStyle(Style? style, List variants) { - return Style( - _baseStyle(), + static Style get text => Style( + _text.style.fontSize(14), + _text.style.height(1), + _text.style.fontWeight.w500(), + _text.textHeightBehavior(TextHeightBehavior( + applyHeightToFirstAscent: false, + applyHeightToLastDescent: false, + )), + $on.disabled( + _indicator.color.black.brighten(70), + ), + ); - /// Size Variants - RadioSize.small(_smallVariant()), - RadioSize.medium(_mediumVariant()), - RadioSize.large(_largeVariant()), + static Style get flex => Style( + _flex.row(), + _flex.mainAxisAlignment.start(), + _flex.crossAxisAlignment.center(), + _flex.gap(8), + ); - // State variants - RadioVariant.solid(_solidVariant()), - RadioVariant.soft(_softVariant()), - RadioVariant.outline(_outlineVariant()), - RadioVariant.surface(_surfaceVariant()), - $on.disabled(_disabledVariant()), - ).merge(style).applyVariants(variants).animate( - duration: Duration(milliseconds: 150), + static Style get base => Style( + container(), + indicator(), + text(), + flex(), + ).animate( + duration: Duration(milliseconds: 100), curve: Curves.easeInOutQuad, ); } diff --git a/packages/remix/lib/components/radio/radio_variants.dart b/packages/remix/lib/components/radio/radio_variants.dart deleted file mode 100644 index adc3e970d..000000000 --- a/packages/remix/lib/components/radio/radio_variants.dart +++ /dev/null @@ -1,32 +0,0 @@ -part of 'radio.dart'; - -abstract interface class IRadioVariant extends RemixVariant { - const IRadioVariant(String name) : super('radio.$name'); -} - -class RadioStatus extends IRadioVariant { - static const checked = RadioStatus('checked'); - static const unchecked = RadioStatus('unchecked'); - const RadioStatus(String name) : super('status.$name'); -} - -class RadioVariant extends IRadioVariant { - static const solid = RadioVariant('solid'); - static const soft = RadioVariant('soft'); - static const surface = RadioVariant('surface'); - static const outline = RadioVariant('outline'); - - const RadioVariant(String name) : super('variant.$name'); - - static List get values => [solid, soft, surface, outline]; -} - -class RadioSize extends IRadioVariant { - static const small = RadioSize('small'); - static const medium = RadioSize('medium'); - static const large = RadioSize('large'); - - const RadioSize(String name) : super('size.$name'); - - static List get values => [small, medium, large]; -} diff --git a/packages/remix/lib/components/radio/radio_widget.dart b/packages/remix/lib/components/radio/radio_widget.dart index aea8ad276..048a66c53 100644 --- a/packages/remix/lib/components/radio/radio_widget.dart +++ b/packages/remix/lib/components/radio/radio_widget.dart @@ -1,33 +1,102 @@ part of 'radio.dart'; -class RxRadio extends StatelessWidget { - const RxRadio({ +class XRadio extends StatefulWidget { + const XRadio({ super.key, required this.value, required this.onChanged, required this.groupValue, - this.variant = RadioVariant.solid, - this.size = RadioSize.medium, this.disabled = false, - this.style, - }); + this.style = const Style.empty(), + required this.text, + }) : _blank = false; + + const XRadio.blank({ + super.key, + required this.value, + required this.onChanged, + required this.groupValue, + this.disabled = false, + required this.style, + required this.text, + }) : _blank = true; final T value; final ValueChanged onChanged; final T? groupValue; + final String text; final bool disabled; - final RadioVariant variant; - final RadioSize size; - final Style? style; + final Style style; + + final bool _blank; + + bool get _selected => value == groupValue; + + @override + State> createState() => _XRadioState(); +} + +class _XRadioState extends State> { + late final MixWidgetStateController _controller; + void _handleOnPress() { + widget.onChanged(widget.value); + } + + @override + void initState() { + super.initState(); + _controller = MixWidgetStateController() + ..selected = widget._selected + ..disabled = widget.disabled; + } + + @override + void didUpdateWidget(XRadio oldWidget) { + super.didUpdateWidget(oldWidget); + + if (oldWidget._selected != widget._selected) { + _controller.selected = widget._selected; + } + + if (oldWidget.disabled != widget.disabled) { + _controller.disabled = widget.disabled; + } + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } @override Widget build(BuildContext context) { - return RxBlankRadio( - value: value, - groupValue: groupValue, - onChanged: onChanged, - disabled: disabled, - style: _buildDefaultRadioStyle(style, [size, variant]), + return Pressable( + onPress: widget.disabled ? null : _handleOnPress, + enabled: !widget.disabled, + controller: _controller, + child: SpecBuilder( + style: + widget._blank ? widget.style : XRadioStyle.base.merge(widget.style), + builder: (context) { + final spec = RadioSpec.of(context); + + final ContainerWidget = spec.container; + final IndicatorWidget = spec.indicator; + final FlexWidget = spec.flex; + final TextWidget = spec.text; + + return FlexWidget( + direction: Axis.horizontal, + children: [ + ContainerWidget( + child: IndicatorWidget(), + ), + TextWidget(widget.text), + ], + ); + }, + ), ); } } diff --git a/packages/remix/test/components/radio/radio_widget_test.dart b/packages/remix/test/components/radio/radio_widget_test.dart index f8d8b4341..a08ada4fe 100644 --- a/packages/remix/test/components/radio/radio_widget_test.dart +++ b/packages/remix/test/components/radio/radio_widget_test.dart @@ -6,30 +6,29 @@ import 'package:remix/components/radio/radio.dart'; import '../../utils/extensions/widget_tester.dart'; void main() { - group('RxRadio', () { + group('xRadio', () { testWidgets('renders RxBlankRadio with correct properties', (WidgetTester tester) async { bool value = true; bool? changedValue; await tester.pumpRxComponent( - RxRadio( + XRadio( value: value, onChanged: (v) => changedValue = v, groupValue: true, - variant: RadioVariant.outline, - size: RadioSize.small, disabled: true, + text: '', ), ); final rxBlankRadio = - tester.widget>(find.byType(RxBlankRadio)); + tester.widget>(find.byType(XRadio)); expect(rxBlankRadio.value, equals(true)); expect(rxBlankRadio.groupValue, equals(true)); expect(rxBlankRadio.disabled, equals(true)); - await tester.tap(find.byType(RxBlankRadio)); + await tester.tap(find.byType(XRadio)); expect(changedValue, isNull); }); @@ -37,23 +36,21 @@ void main() { final $radio = RadioSpecUtility.self; await tester.pumpRxComponent( - RxRadio( + XRadio( value: false, groupValue: true, disabled: false, onChanged: (_) {}, style: Style( - RadioVariant.solid( - $radio.container.color.red(), - ), + $radio.container.color.red(), ), + text: '', ), ); - final rxBlankRadio = - tester.firstWidget(find.byType(Container)); + final container = tester.firstWidget(find.byType(Container)); expect( - (rxBlankRadio.decoration as BoxDecoration).color, + (container.decoration as BoxDecoration).color, equals(Colors.red), ); }); @@ -63,55 +60,31 @@ void main() { bool? changedValue; await tester.pumpRxComponent( - RxRadio( + XRadio( value: value, groupValue: true, onChanged: (v) => changedValue = v, + text: '', ), ); - await tester.tap(find.byType(RxBlankRadio)); + await tester.tap(find.byType(XRadio)); expect(changedValue, isFalse); }); - testWidgets('applies different variants', (WidgetTester tester) async { - for (final variant in RadioVariant.values) { - await tester.pumpRxComponent( - RxRadio( - value: true, - groupValue: false, - onChanged: (_) {}, - variant: variant, - ), - ); - - final radio = - tester.widget>(find.byType(RxBlankRadio)); - final appliedVariantStillInStyle = - radio.style.variants.values.any((e) => e.variant == variant); - - expect(appliedVariantStillInStyle, false); - } - }); - - testWidgets('applies different sizes', (WidgetTester tester) async { - for (final size in RadioSize.values) { - await tester.pumpRxComponent( - RxRadio( - value: true, - groupValue: false, - onChanged: (_) {}, - size: size, - ), - ); + testWidgets('displays correct text', (WidgetTester tester) async { + const testText = 'Test Radio'; - final radio = - tester.widget>(find.byType(RxBlankRadio)); - final appliedVariantStillInStyle = - radio.style.variants.values.any((e) => e.variant == size); + await tester.pumpRxComponent( + XRadio( + value: false, + groupValue: true, + onChanged: (_) {}, + text: testText, + ), + ); - expect(appliedVariantStillInStyle, false); - } + expect(find.text(testText), findsOneWidget); }); }); }