Skip to content

Commit

Permalink
Merge pull request #171 from conceptadev/doc/update-migration
Browse files Browse the repository at this point in the history
Update migration.md
  • Loading branch information
leoafarias authored Jan 26, 2024
2 parents 1d2b9c3 + 4bf6a64 commit edf3537
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 74 deletions.
44 changes: 44 additions & 0 deletions website/pages/docs/overview/migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,47 @@ 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).

### 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

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),
),
)
)
```
14 changes: 1 addition & 13 deletions website/pages/docs/widgets/flex.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
```
```
2 changes: 1 addition & 1 deletion website/pages/docs/widgets/icon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 12 additions & 2 deletions website/pages/docs/widgets/image.mdx
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## Image
---
title: Image
---

Coming soon.
import { Callout } from "nextra-theme-docs";

# StyleImage

<Callout type="info">
The StyledImage is in progress, if you would like to keep up to date with the progress.
</Callout>

please follow the <a href="https://github.com/conceptadev/mix/issues/166"> StyledImage issue</a>.
6 changes: 3 additions & 3 deletions website/pages/docs/widgets/pressable-box.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
111 changes: 56 additions & 55 deletions website/pages/docs/widgets/text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

1 comment on commit edf3537

@vercel
Copy link

@vercel vercel bot commented on edf3537 Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.