From e7a5673298640a9734aabd85b37da883fc5841d0 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:40:35 -0300 Subject: [PATCH 1/5] Add deprecated attributes --- lib/src/deprecations.dart | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/lib/src/deprecations.dart b/lib/src/deprecations.dart index 0de62d136..67bbc78b7 100644 --- a/lib/src/deprecations.dart +++ b/lib/src/deprecations.dart @@ -444,8 +444,30 @@ final borderVertical = border.vertical; @Deprecated('use border.all instead') final borderAll = border.all; -@Deprecated('Use StyledText now') -typedef TextMix = StyledText; +@Deprecated('Use StyledText instead') +class TextMix extends StyledText { + const TextMix( + super.text, { + super.semanticsLabel, + Mix? mix, + super.key, + super.inherit = true, + super.locale, + }) : super(style: mix); +} + +@Deprecated('Use StyledIcon instead') +class IconMix extends StyledIcon { + const IconMix( + super.icon, { + super.semanticLabel, + required Mix mix, + super.key, + super.inherit = true, + super.textDirection, + }); +} + @Deprecated('Use text.style instead') final textStyle = text.style; @@ -473,6 +495,15 @@ final mainAxisSize = flex.mainAxisSize; @Deprecated('use text.style.bold() instead') final bold = text.style.bold; +@Deprecated('use flex.gap(value) instead') +final gap = flex.gap; + +@Deprecated('use icon.size instead') +final iconSize = icon.size; + +@Deprecated('use icon.color instead') +final iconColor = icon.color; + // @Deprecated('Use box.maxHeight instead') // final maxHeight = box.maxHeight; From 31bac1bf90d5ce58e21f9900af3e956303690ff0 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Mon, 8 Jan 2024 19:41:20 -0300 Subject: [PATCH 2/5] create a new constructor to VBox and Hbox --- demo/lib/views/button_example.dart | 4 +-- lib/src/factory/style_mix_ext.dart | 8 ++--- lib/src/specs/flex/flex_widget.dart | 39 +++++++++++++++++++----- test/src/factory/style_mix_ext_test.dart | 16 +++++----- 4 files changed, 45 insertions(+), 22 deletions(-) diff --git a/demo/lib/views/button_example.dart b/demo/lib/views/button_example.dart index b94d696f2..ccda05f6b 100644 --- a/demo/lib/views/button_example.dart +++ b/demo/lib/views/button_example.dart @@ -126,8 +126,8 @@ abstract class Button extends StatelessWidget { return Pressable( onPressed: onPressed, onLongPress: onLongPressed, - child: HBox( - style: mergedStyle, + child: HBox.withStyle( + mergedStyle, children: [ _leftContent, _centerContent, diff --git a/lib/src/factory/style_mix_ext.dart b/lib/src/factory/style_mix_ext.dart index da3c43c65..d392f833f 100644 --- a/lib/src/factory/style_mix_ext.dart +++ b/lib/src/factory/style_mix_ext.dart @@ -45,8 +45,8 @@ extension StyleExt on Style { @Deprecated('Use the style parameter instead') Style? mix, Style? style, }) { - return HBox( - style: merge(style ?? mix), + return HBox.withStyle( + merge(style ?? mix), key: key, inherit: inherit, children: children, @@ -92,8 +92,8 @@ extension StyleExt on Style { @Deprecated('Use the style parameter instead') Style? mix, Style? style, }) { - return VBox( - style: merge(style ?? mix), + return VBox.withStyle( + merge(style ?? mix), key: key, inherit: inherit, children: children, diff --git a/lib/src/specs/flex/flex_widget.dart b/lib/src/specs/flex/flex_widget.dart index 812ecd55b..1b809b0ea 100644 --- a/lib/src/specs/flex/flex_widget.dart +++ b/lib/src/specs/flex/flex_widget.dart @@ -3,6 +3,7 @@ import 'package:flutter/widgets.dart'; import '../../core/styled_widget.dart'; import '../../factory/mix_provider.dart'; import '../../factory/mix_provider_data.dart'; +import '../../factory/style_mix.dart'; import '../../widgets/gap_widget.dart'; import '../container/box_widget.dart'; import 'flex_spec.dart'; @@ -184,18 +185,29 @@ class FlexBox extends StyledWidget { /// /// Example Usage: /// ```dart -/// HBox( -/// style: yourStyle, +/// HBox.withStyle( +/// yourStyle, /// children: [Widget1(), Widget2()], /// ); /// ``` class HBox extends FlexBox { + const HBox.withStyle( + Style style, { + super.key, + super.inherit, + super.children = const [], + }) : super(style: style, direction: Axis.horizontal); + + @Deprecated('Use the HBox.withStyle instead') const HBox({ - super.style, + required Mix mix, super.key, super.inherit, super.children = const [], - }) : super(direction: Axis.horizontal); + }) : super( + style: mix, + direction: Axis.horizontal, + ); } /// A vertical flex container that uses `Style` for streamlined styling. @@ -209,18 +221,29 @@ class HBox extends FlexBox { /// /// Example Usage: /// ```dart -/// VBox( -/// style: yourStyle, +/// VBox.withStyle( +/// yourStyle, /// children: [Widget1(), Widget2()], /// ); /// ``` class VBox extends FlexBox { + const VBox.withStyle( + Style style, { + super.key, + super.inherit, + super.children = const [], + }) : super(style: style, direction: Axis.vertical); + + @Deprecated('Use the VBox.withStyle instead') const VBox({ - super.style, + required Mix mix, super.key, super.inherit, super.children = const [], - }) : super(direction: Axis.vertical); + }) : super( + style: mix, + direction: Axis.vertical, + ); } const _defaultFlex = Flex(direction: Axis.horizontal, children: []); diff --git a/test/src/factory/style_mix_ext_test.dart b/test/src/factory/style_mix_ext_test.dart index 7a3679034..06ea83c3a 100644 --- a/test/src/factory/style_mix_ext_test.dart +++ b/test/src/factory/style_mix_ext_test.dart @@ -89,14 +89,14 @@ void main() { home: Column( children: [ style.hbox(children: [const SizedBox()], key: keyOne), - HBox( + HBox.withStyle( + style, key: keyTwo, - style: style, children: const [SizedBox()], ), - HBox( + HBox.withStyle( + const Style.empty(), key: keyThree, - style: const Style.empty(), children: const [SizedBox()], ), ], @@ -189,14 +189,14 @@ void main() { home: Column( children: [ style.vbox(children: [const SizedBox()], key: keyOne), - VBox( + VBox.withStyle( + style, key: keyTwo, - style: style, children: const [SizedBox()], ), - VBox( + VBox.withStyle( + const Style.empty(), key: keyThree, - style: const Style.empty(), children: const [SizedBox()], ), ], From df9b853dc59f36d4d679f60cd228f6dc99e5183e Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Mon, 8 Jan 2024 21:15:42 -0300 Subject: [PATCH 3/5] Change named constructor for deprecated inline --- demo/lib/views/button_example.dart | 4 +-- lib/src/factory/style_mix_ext.dart | 8 +++--- lib/src/specs/flex/flex_widget.dart | 34 +++++++----------------- test/src/factory/style_mix_ext_test.dart | 16 +++++------ 4 files changed, 24 insertions(+), 38 deletions(-) diff --git a/demo/lib/views/button_example.dart b/demo/lib/views/button_example.dart index ccda05f6b..b94d696f2 100644 --- a/demo/lib/views/button_example.dart +++ b/demo/lib/views/button_example.dart @@ -126,8 +126,8 @@ abstract class Button extends StatelessWidget { return Pressable( onPressed: onPressed, onLongPress: onLongPressed, - child: HBox.withStyle( - mergedStyle, + child: HBox( + style: mergedStyle, children: [ _leftContent, _centerContent, diff --git a/lib/src/factory/style_mix_ext.dart b/lib/src/factory/style_mix_ext.dart index d392f833f..da3c43c65 100644 --- a/lib/src/factory/style_mix_ext.dart +++ b/lib/src/factory/style_mix_ext.dart @@ -45,8 +45,8 @@ extension StyleExt on Style { @Deprecated('Use the style parameter instead') Style? mix, Style? style, }) { - return HBox.withStyle( - merge(style ?? mix), + return HBox( + style: merge(style ?? mix), key: key, inherit: inherit, children: children, @@ -92,8 +92,8 @@ extension StyleExt on Style { @Deprecated('Use the style parameter instead') Style? mix, Style? style, }) { - return VBox.withStyle( - merge(style ?? mix), + return VBox( + style: merge(style ?? mix), key: key, inherit: inherit, children: children, diff --git a/lib/src/specs/flex/flex_widget.dart b/lib/src/specs/flex/flex_widget.dart index 1b809b0ea..837738d2e 100644 --- a/lib/src/specs/flex/flex_widget.dart +++ b/lib/src/specs/flex/flex_widget.dart @@ -185,27 +185,20 @@ class FlexBox extends StyledWidget { /// /// Example Usage: /// ```dart -/// HBox.withStyle( -/// yourStyle, +/// HBox( +/// style: yourStyle, /// children: [Widget1(), Widget2()], /// ); /// ``` class HBox extends FlexBox { - const HBox.withStyle( - Style style, { - super.key, - super.inherit, - super.children = const [], - }) : super(style: style, direction: Axis.horizontal); - - @Deprecated('Use the HBox.withStyle instead') const HBox({ - required Mix mix, + Style? style, + @Deprecated('Use the the style parameter instead') Mix? mix, super.key, super.inherit, super.children = const [], }) : super( - style: mix, + style: style ?? mix, direction: Axis.horizontal, ); } @@ -221,27 +214,20 @@ class HBox extends FlexBox { /// /// Example Usage: /// ```dart -/// VBox.withStyle( -/// yourStyle, +/// VBox( +/// style: yourStyle, /// children: [Widget1(), Widget2()], /// ); /// ``` class VBox extends FlexBox { - const VBox.withStyle( - Style style, { - super.key, - super.inherit, - super.children = const [], - }) : super(style: style, direction: Axis.vertical); - - @Deprecated('Use the VBox.withStyle instead') const VBox({ - required Mix mix, + Style? style, + @Deprecated('Use the the style parameter instead') Mix? mix, super.key, super.inherit, super.children = const [], }) : super( - style: mix, + style: style ?? mix, direction: Axis.vertical, ); } diff --git a/test/src/factory/style_mix_ext_test.dart b/test/src/factory/style_mix_ext_test.dart index 06ea83c3a..008613afa 100644 --- a/test/src/factory/style_mix_ext_test.dart +++ b/test/src/factory/style_mix_ext_test.dart @@ -89,13 +89,13 @@ void main() { home: Column( children: [ style.hbox(children: [const SizedBox()], key: keyOne), - HBox.withStyle( - style, + HBox( + style: style, key: keyTwo, children: const [SizedBox()], ), - HBox.withStyle( - const Style.empty(), + HBox( + style: const Style.empty(), key: keyThree, children: const [SizedBox()], ), @@ -189,13 +189,13 @@ void main() { home: Column( children: [ style.vbox(children: [const SizedBox()], key: keyOne), - VBox.withStyle( - style, + VBox( + style: style, key: keyTwo, children: const [SizedBox()], ), - VBox.withStyle( - const Style.empty(), + VBox( + style: const Style.empty(), key: keyThree, children: const [SizedBox()], ), From c87e375f238d3ee6bc60f447f3ef6dbcf512c9fe Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Tue, 9 Jan 2024 18:07:55 -0300 Subject: [PATCH 4/5] add more deprecated symbols --- lib/exports.dart | 1 - lib/src/deprecations.dart | 20 +++++++++++--------- lib/src/factory/style_group.dart | 11 ----------- lib/src/factory/style_mix.dart | 10 ++++------ lib/src/specs/container/box_widget.dart | 15 ++++++++------- lib/src/specs/flex/flex_widget.dart | 1 + 6 files changed, 24 insertions(+), 34 deletions(-) delete mode 100644 lib/src/factory/style_group.dart diff --git a/lib/exports.dart b/lib/exports.dart index cfe703e7b..2290b19c9 100644 --- a/lib/exports.dart +++ b/lib/exports.dart @@ -37,7 +37,6 @@ export 'src/decorators/widget_decorators_util.dart'; export 'src/deprecations.dart'; export 'src/factory/mix_provider.dart'; export 'src/factory/mix_provider_data.dart'; -export 'src/factory/style_group.dart'; export 'src/factory/style_mix.dart'; export 'src/factory/style_mix_ext.dart'; export 'src/specs/container/box_attribute.dart'; diff --git a/lib/src/deprecations.dart b/lib/src/deprecations.dart index 67bbc78b7..8a01852a3 100644 --- a/lib/src/deprecations.dart +++ b/lib/src/deprecations.dart @@ -5,34 +5,37 @@ import '../mix.dart'; const kShortAliasDeprecation = 'Short aliases will be deprecated, you can create your own. Example: final p = padding;'; +@Deprecated('Use Style instead') +typedef Mix = Style; + extension DeprecatedMixExtension on Style { /// Adds an Attribute to a Mix. @Deprecated('Simplifying the mix API to avoid confusion. Use apply instead') SpreadFunctionParams get mix => SpreadFunctionParams(addAttributes); - @Deprecated('Use selectVariants now') + @Deprecated('Use variantList(value:) instead') Style withVariants(List variants) => withManyVariants(variants); + @Deprecated('Use variantList(value:) instead') + Style withManyVariants(Iterable variants) => variantList(variants); + @Deprecated( - 'Use merge() or mergeMany() now. You might have to turn into a Mix first. firstMixFactory.merge(secondMix)', + 'Use merge() or mergeMany() instead. You might have to turn into a Mix first. firstMixFactory.merge(secondMix)', ) Style addAttributes(Iterable attributes) => merge(Style.create(attributes)); - @Deprecated('Use selectVariants now') - Style withManyVariants(Iterable variants) => variantList(variants); - @Deprecated('Use merge() or mergeMany() instead') SpreadFunctionParams get apply => const SpreadFunctionParams(Style.combine); - @Deprecated('Use selectVariant now') + @Deprecated('Use variant(value:) instead') Style withVariant(Variant value) => variant(value); - @Deprecated('Use combine now') + @Deprecated('Use combine instead') Style combineAll(List