From 0cd7280a1647b33c09034bdedcc7b761a5f56810 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Thu, 25 Jan 2024 18:44:00 -0300 Subject: [PATCH 1/4] Update migration.md --- website/pages/docs/overview/migration.md | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/website/pages/docs/overview/migration.md b/website/pages/docs/overview/migration.md index 36e304a05..399a26686 100644 --- a/website/pages/docs/overview/migration.md +++ b/website/pages/docs/overview/migration.md @@ -23,3 +23,40 @@ To enhance readability, short aliases and shorthand property/method names are re #### Decorators Decorators' order was previously determined by their addition sequence. Now, we enforce specific ordering but also allow customizable orders. This might cause behavior changes in rare cases. For details, refer to the [decorators guide](https://fluttermix.com/docs/guides/decorators). + +### Behavior changes + +#### Decorators + +Decorators cannot be inherited by any children. The reason is that abstract class `Attribute` has gained a new property, `isInheritable`, witch can be set to false if you want your custom attributes to be non-inheritable, such as Decorators. + +#### Operators `and` (`&`) and `or` (`|`) + +The operators have been redesigned to allow for concatenation and grouping, enabling the creation of conditions like, `(primary | secondary) & onHover`. For details, refer to the [variants guide](https://www.fluttermix.com/docs/guides/variants#combining-operators) + +#### StyledWidgets and Decorators + +A bunch of `StyledWidgets` are now allow to receive decorators' attributes, including `StyledIcon`, `StyledFlex` and `StyledIcon`. Additionally, when a decorator is not applied to a Style, a `RenderWidgetDecorators` will not be present in the widget tree. This simplification makes the widget easier to debug. + +#### Theming + +The `MixTheme` feature has been improved and now offer better API. It can applied to main attributes using the method `.of`, as shown in the following code: +```dart +const primaryColor = ColorToken('primary'); +final theme = MixThemeData( + colors: { + primaryColor: Colors.blue, + }, +); + +// ... body method ... +MixTheme( + data: theme, + Box( + key: key, + style: Style( + box.color.of(primaryColor), + ), + ) +) +``` \ No newline at end of file From 575b7188609206659257e74c89b898af5cb4fa94 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Thu, 25 Jan 2024 20:29:58 -0300 Subject: [PATCH 2/4] Update docs Update flex.mdx Update image.mdx Update icon.mdx Update image.mdx Update text.mdx Update migration.md Update pressable-box.mdx --- website/pages/docs/overview/migration.md | 7 ++ website/pages/docs/widgets/flex.mdx | 14 +-- website/pages/docs/widgets/icon.mdx | 2 +- website/pages/docs/widgets/image.mdx | 4 +- website/pages/docs/widgets/pressable-box.mdx | 6 +- website/pages/docs/widgets/text.mdx | 111 ++++++++++--------- 6 files changed, 71 insertions(+), 73 deletions(-) diff --git a/website/pages/docs/overview/migration.md b/website/pages/docs/overview/migration.md index 399a26686..c02be4a98 100644 --- a/website/pages/docs/overview/migration.md +++ b/website/pages/docs/overview/migration.md @@ -24,6 +24,13 @@ To enhance readability, short aliases and shorthand property/method names are re Decorators' order was previously determined by their addition sequence. Now, we enforce specific ordering but also allow customizable orders. This might cause behavior changes in rare cases. For details, refer to the [decorators guide](https://fluttermix.com/docs/guides/decorators). +### StyledWidgets updates + +#### The new PressableBox + +To provide a more consistent way to use the gesture APIs, we developed a new widget that merges the functionalities of Box and `Pressable`. Thus, the new `PressableBox` can receive a style like a Box and also accept interactions and its variants, similar to a `Pressable`. For more information, see the [PressableBox guide](https://www.fluttermix.com/docs/widgets/pressable-box). +Keep in mind that the ideia is to reserve the old `Pressable` to more advanced cases. + ### Behavior changes #### Decorators diff --git a/website/pages/docs/widgets/flex.mdx b/website/pages/docs/widgets/flex.mdx index d1aa2ea43..c99db2601 100644 --- a/website/pages/docs/widgets/flex.mdx +++ b/website/pages/docs/widgets/flex.mdx @@ -164,16 +164,4 @@ Set the space (gap) between each child in the flex container. ```dart // Set a gap of 8 logical pixels between children. flex.gap(8); -``` - -### **Aliases** - -Shortcuts for creating `FlexSpecAttribute`s with `Row` or `Column` configurations. - -```dart -// Shortcut for setting up a Row attribute. -var myRow = flex.row(); - -// Shortcut for setting up a Column attribute. -var myColumn = flex.column(); -``` +``` \ No newline at end of file diff --git a/website/pages/docs/widgets/icon.mdx b/website/pages/docs/widgets/icon.mdx index 634820baa..5646800b0 100644 --- a/website/pages/docs/widgets/icon.mdx +++ b/website/pages/docs/widgets/icon.mdx @@ -30,7 +30,7 @@ Box( ); ``` -In the above example, the `StyledIcon` widget will inherit the icon size and color style from the `Box` widget. +In the above example, the `StyledIcon` widget will inherit the icon size and color style from the `Box` widget. However, remember that decorators attributes cannot be inherited. ## AnimatedStyledIcon diff --git a/website/pages/docs/widgets/image.mdx b/website/pages/docs/widgets/image.mdx index 531c57caa..5428a1504 100644 --- a/website/pages/docs/widgets/image.mdx +++ b/website/pages/docs/widgets/image.mdx @@ -1,3 +1,5 @@ ## Image -Coming soon. + + The StyledImage is in progress, if you would like to keep up to date with the progress, please follow the StyledImage issue. + diff --git a/website/pages/docs/widgets/pressable-box.mdx b/website/pages/docs/widgets/pressable-box.mdx index 83f2d8559..e697ba6bd 100644 --- a/website/pages/docs/widgets/pressable-box.mdx +++ b/website/pages/docs/widgets/pressable-box.mdx @@ -36,9 +36,9 @@ In the example above, the `PressableBox` will apply a blue background color to t `PressableBox` integrates with various context variant utilities that apply styles based on different widget states and gestures. Here are a few of the interaction states and their corresponding styling hooks: -- `onPress`: Styles applied when the widget is being pressed. -- `onLongPress`: Styles applied when the widget is being long-pressed. +- `onPressed`: Styles applied when the widget is being pressed. +- `onLongPressed`: Styles applied when the widget is being long-pressed. - `onDisabled`: Styles applied when the widget is disabled and therefore non-interactive. - `onEnabled`: Styles applied when the widget is enabled and interactive. -- `onFocus`: Styles applied when the widget gains focus. +- `onFocused`: Styles applied when the widget gains focus. - `onHover`: Styles applied when a pointer has hovered over a widget. diff --git a/website/pages/docs/widgets/text.mdx b/website/pages/docs/widgets/text.mdx index 849531851..5c8414491 100644 --- a/website/pages/docs/widgets/text.mdx +++ b/website/pages/docs/widgets/text.mdx @@ -16,7 +16,7 @@ StyledText( ## Inheritance -The **StyledText** widget has the **inherit** flag true by default. That means that the style attributes will be inherited from the parent widget. +The **StyledText** widget has the **inherit** flag true by default. That means that the style attributes will be inherited from the parent widget. However, remember that decorators attributes cannot be inherited. ```dart Box( @@ -78,6 +78,61 @@ Limit the number of lines for the text block: text.maxLines(2); ``` + +#### **textWidthBasis** + +Determine how text width is measured: + +```dart +// Measure text width based on the longest line +text.textWidthBasis.longestLine(); + +// Measure text width based on the parent container +text.textWidthBasis.parent(); +``` + +#### **textHeightBehavior** + +Define how text height adjustments are made: + +```dart +// Set a specified text height behavior +text.textHeightBehavior(...); // TextHeightBehavior instance +``` + +#### **textDirection** + +Set the reading directionality of the text: + +```dart +// Left-to-right text direction +text.textDirection.ltr(); + +// Right-to-left text direction +text.textDirection.rtl(); +``` + +#### **softWrap** + +Choose whether the text should soft-wrap: + +```dart +// Enable soft wrapping +text.softWrap(true); + +// Disable soft wrapping +text.softWrap(false); +``` + +#### **textScaleFactor** + +Adjust the text scale factor for sizing: + +```dart +// Increase text size by a factor of 1.5 +text.textScaleFactor(1.5); +``` + #### **`style`** Allows to style `TextStyle` attributes efficiently, creating a cohesive and maintainable text styling semantics. @@ -211,60 +266,6 @@ Set the locale for the text, affecting how it's displayed: text.style.locale(Locale('en')); // English locale ``` -#### **textWidthBasis** - -Determine how text width is measured: - -```dart -// Measure text width based on the longest line -text.textWidthBasis.longestLine(); - -// Measure text width based on the parent container -text.textWidthBasis.parent(); -``` - -#### **textHeightBehavior** - -Define how text height adjustments are made: - -```dart -// Set a specified text height behavior -text.textHeightBehavior(...); // TextHeightBehavior instance -``` - -#### **textDirection** - -Set the reading directionality of the text: - -```dart -// Left-to-right text direction -text.textDirection.ltr(); - -// Right-to-left text direction -text.textDirection.rtl(); -``` - -#### **softWrap** - -Choose whether the text should soft-wrap: - -```dart -// Enable soft wrapping -text.softWrap(true); - -// Disable soft wrapping -text.softWrap(false); -``` - -#### **textScaleFactor** - -Adjust the text scale factor for sizing: - -```dart -// Increase text size by a factor of 1.5 -text.textScaleFactor(1.5); -``` - ### **Directives** Transform text data through various case operations: From f3d5a73c90833541b0c5626049e739a604b97064 Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Thu, 25 Jan 2024 21:19:37 -0300 Subject: [PATCH 3/4] Update image.mdx --- website/pages/docs/widgets/image.mdx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/website/pages/docs/widgets/image.mdx b/website/pages/docs/widgets/image.mdx index 5428a1504..9200c6d89 100644 --- a/website/pages/docs/widgets/image.mdx +++ b/website/pages/docs/widgets/image.mdx @@ -1,4 +1,9 @@ -## Image +--- +id: Image +title: "Image" +--- + +import { Callout } from "nextra-theme-docs"; The StyledImage is in progress, if you would like to keep up to date with the progress, please follow the StyledImage issue. From 4bf6a642b4077e8449abd8fc7d9e2bd5bc79968b Mon Sep 17 00:00:00 2001 From: Lucas Oliveira <62367544+tilucasoli@users.noreply.github.com> Date: Thu, 25 Jan 2024 21:23:43 -0300 Subject: [PATCH 4/4] Update image.mdx --- website/pages/docs/widgets/image.mdx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/website/pages/docs/widgets/image.mdx b/website/pages/docs/widgets/image.mdx index 9200c6d89..c52d49cfa 100644 --- a/website/pages/docs/widgets/image.mdx +++ b/website/pages/docs/widgets/image.mdx @@ -1,10 +1,13 @@ --- -id: Image -title: "Image" +title: Image --- import { Callout } from "nextra-theme-docs"; +# StyleImage + - The StyledImage is in progress, if you would like to keep up to date with the progress, please follow the StyledImage issue. + The StyledImage is in progress, if you would like to keep up to date with the progress. + +please follow the StyledImage issue. \ No newline at end of file