Skip to content

Commit f40d751

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
📝 Update all docs.
* Update Dart/Flutter versions. * Rename flipRect to allowBoxFlipping.
1 parent 8c137df commit f40d751

35 files changed

+1013
-982
lines changed

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,26 @@
55
[![melos](https://img.shields.io/badge/maintained%20with-melos-f700ff.svg?style=flat-square)](https://github.com/invertase/melos) [![Codemagic build status](https://api.codemagic.io/apps/63dd4d4ae6be1d561b8f45d2/63dd4d4ae6be1d561b8f45d1/status_badge.svg)](https://codemagic.io/apps/63dd4d4ae6be1d561b8f45d2/63dd4d4ae6be1d561b8f45d1/latest_build) [![Tests](https://github.com/hyper-designed/box_transform/workflows/Tests/badge.svg?branch=main)](https://github.com/hyper-designed/box_transform/actions) [![codecov](https://codecov.io/gh/BirjuVachhani/box_transform/branch/main/graph/badge.svg?token=SX5FXDUD7A)](https://codecov.io/gh/BirjuVachhani/box_transform)
66

77
[Box Transform][github] provides packages that allows you to programmatically handle box resizing and dragging.
8-
It provides highly flexible, programmatically resizable and draggable boxes that can be used in any Dart or Flutter
9-
project. A library for advanced resizing of rect in UI.
8+
It provides a highly flexible, programmatically resizable and draggable boxes that can be used in any Dart or Flutter
9+
project.
1010

1111
## Packages
1212

13-
| Package | Pub | Description |
14-
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------|
15-
| box_transform | [![Pub Version](https://img.shields.io/pub/v/box_transform?label=Pub)](https://pub.dev/packages/box_transform) | A pure Dart implementation of transformation operations that doesn't rely on Flutter. |
16-
| flutter_box_transform | [![Pub Version](https://img.shields.io/pub/v/flutter_box_transform?label=Pub)](https://pub.dev/packages/flutter_box_transform) | A Flutter implementation of Box Transform that provides flexible, customization and easy to use interface tailored for Flutter projects. |
13+
| Package | Pub | Description |
14+
|-----------------------|--------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------|
15+
| box_transform | [![Pub Version](https://img.shields.io/pub/v/box_transform?label=Pub)](https://pub.dev/packages/box_transform) | A pure Dart implementation for box transformation operations that does not rely on Flutter. |
16+
| flutter_box_transform | [![Pub Version](https://img.shields.io/pub/v/flutter_box_transform?label=Pub)](https://pub.dev/packages/flutter_box_transform) | A Flutter implementation that provides a flexible, customizable and easy to use interface tailored for Flutter projects. |
1717

1818

1919
## Features
2020

2121
* 📏 **Dimension Constraining:** Set maximum and minimum constraints to keep boxes within specific boundaries while resizing.
2222
* 🔁 **Flipping Mechanics:** Advanced positional-flipping when resizing hits extreme values with hard constraints.
23-
* 🔒 **Drag Clamping:** Clamp boxes inside a parent box to contain them within a specific area.
23+
* 🔒 **Drag Clamping:** Specify clamping boxes to keep your transformable boxes within a specific region.
2424
* 🎨 **Flexible Resizing Modes:** Choose from four different resizing modes for more flexibility in how boxes are resized.
2525
* 📍 **Customizable Anchor Points:** Define resizing corner-handles to anchor different parts of the box when resizing.
2626
* 🎨 **Customizable Handles:** Use default resizing handles or define your own custom handles.
27-
* 🚀 **Easy Integration:** Integrate Box Transform into your dart or flutter project with ease.
27+
* 🚀 **Easy Integration:** Integrate Box Transform into your Dart or Flutter project with ease.
2828

2929
## Getting Started
3030

@@ -52,6 +52,8 @@ See [DEVELOPMENT.md][development] for development setup.
5252
</tr>
5353
</table>
5454

55+
Feel free to join our Discord server for any inquiries or support: https://discord.gg/yrahEhCqTJ
56+
5557
## License
5658

5759
```

docs/flutter_controller.mdx

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ title: Using a controller
44

55
## Using a controller
66

7-
`TransformableBox` can use a controller if provided. This is the most flexible method and allows you to
8-
control the transformable box externally with proper state management.
7+
`TransformableBox` uses a controller pattern. This is the most flexible pattern and allows you to control the
8+
transformable box externally with proper state management.
99

1010
To create a controller, you can use the `TransformableBoxController` class. It mirrors a lot of the observed parameters
11-
in the constructor excluding `contentBuilder`, `handleBuilder`, `handleGestureResponseDiameter` and
12-
`handleRenderedDiameter` since these are accessibility and rendering specific features.
11+
in the constructor excluding `contentBuilder`, `handleBuilder`, and `handleTapSize` since these are accessibility and
12+
rendering features.
1313

14-
<Warning>When using a controller, you should not use the following parameters: **_box_**, **_flip_**, **_clampingBox_**, **_constraints_**,
15-
and **_resolveResizeModeCallback_**. These are all intrinsically managed by the controller.</Warning>
14+
<Warning>When using a controller, you should move these parameters from your `TransformableBox` to the constructor of
15+
the `TransformableBoxController`: **_box_**, **_flip_**, **_clampingBox_**, **_constraints_**, and
16+
**_resolveResizeModeCallback_**. These are all intrinsically managed by the controller.
1617

17-
Initialize a controller and provide.
18+
There must always be only one source of truth, either the `TransformableBox` or the `TransformableBoxController`, not both.</Warning>
19+
20+
Initialize a controller like so:
1821

1922
```dart title="Initializing a controller"
2023
late final TransformableBoxController controller;
@@ -57,7 +60,7 @@ Remove the listener when no longer needed.
5760

5861
```dart title="Removing a listener"
5962
controller.removeListener(onControllerChanged);
60-
```
63+
```
6164
### Setting constraints
6265

6366
You can set constraints on the controller using the `setConstraints` method.
@@ -81,8 +84,8 @@ You can limit the movements of the controller using the `setClampingBox` method.
8184

8285
### Other things you can do with a controller
8386

84-
Controller almost mirrors the constructor parameters. You can do things like setting rect, flip, constraints,
85-
clampingRect, disabling resizing or moving, etc.
87+
The `TransformableBoxController` almost mirrors the constructor parameters of the `TransformableBox`. You can do things
88+
like setting a rect, flip, constraints, clampingRect, disabling resizing or moving, etc...
8689

8790
```dart title="Things controller can do"
8891
// Change current rect
@@ -102,4 +105,4 @@ controller.setFlipChild(false);
102105
103106
// Disable flipping the rect while resizing
104107
controller.setFlipRectWhileResizing(false);
105-
```
108+
```

docs/flutter_get_started.mdx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Getting Started
66

77
## Installation
88

9-
Add this package as dependency in your `pubspec.yaml` file:
9+
Add this package to your dependencies in your `pubspec.yaml` file:
1010

1111
```dart
1212
dependencies:
@@ -19,12 +19,12 @@ or run following command in your project directory:
1919
```
2020

2121
## Usage
22-
Wrap the widget you want to resize/move with `TransformableBox`.
22+
Wrap the widget you want to resize or move with `TransformableBox`.
2323

24-
<Warning>**_TransformableBox_** internally uses **_Positioned_** to place child at given position with given size.
25-
So, **_TransformableBox_** must be a child of **_Stack_** widget.</Warning>
24+
<Warning>**_TransformableBox_** internally uses **_Positioned_** to place its content at a given position with a given
25+
size. So, **_TransformableBox_** must be a child of a **_Stack_** widget.</Warning>
2626

27-
```dart title="Using as a widget"
27+
```dart title="Using TransformableBox inside a Stack"
2828
Stack(
2929
children: [
3030
TransformableBox(
@@ -51,9 +51,9 @@ So, **_TransformableBox_** must be a child of **_Stack_** widget.</Warning>
5151
);
5252
```
5353

54-
`onChanged` callback is called when user resizes/moves the box. You can use this callback to update the box by calling
54+
`onChanged` callback is called when user resizes or moves the box. You can use this callback to update the box by calling
5555
`setState` method explicitly.
5656

57-
<Info>**_TransformableBox_** follows flutter widget pattern and does not store any state. So, you must store the box and
58-
flip state in your widget state and pass it to **_TransformableBox_** as parameters. Don't forget to call **_setState_**
59-
method to update the state.</Info>
57+
<Info>**_TransformableBox_** follows flutter's widget patterns by not storing any state. You must store the box and
58+
flip state by yourself in your widget's state class and pass it to **_TransformableBox_** as constructor parameters.
59+
Be sure to call **_setState_** to refresh the UI when changes occur.</Info>

docs/flutter_moving.mdx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Moving
44

55
# Moving/Dragging
66

7-
`TransformableBox` can be used to move/drag a widget by default.
7+
`TransformableBox` allows moving/dragging/translating a widget by default.
88

99
```dart title="Moving a widget"
1010
Stack(
@@ -19,13 +19,14 @@ title: Moving
1919
],
2020
);
2121
```
22-
`onChanged` callback is called when user moves the box. You can use this callback to update the box by calling
23-
`setState` method explicitly. You can also use `TransformableBox.onMoved` callback to
22+
`onMoved` callback is called when the user drags the box. You can use this callback to update the box by calling
23+
the `setState` method explicitly. You can also use `TransformableBox.onChanged` callback for a combined event that
24+
includes resizing in addition to moving/dragging.
2425

2526
## Limiting movements
2627

27-
You can limit the movements by setting `TransformableBox.clampingBox` property. `clampingBox` takes a `Rect` that
28-
defines the boundary for the box to move within.
28+
You can limit the allowed space the box can be moved within by setting `TransformableBox.clampingBox` property.
29+
`clampingBox` takes a `Rect` that defines a legal boundary that the box must stay inside.
2930

3031
```dart title="Limiting movements"
3132
TransformableBox(
@@ -38,12 +39,12 @@ defines the boundary for the box to move within.
3839
);
3940
```
4041

41-
This will limit the movements to a box of size `1000x1000` and centered at origin. If your `Stack` has a size, provide
42-
that size to `clampingBox` to allow movements only within the `Stack` boundary.
42+
This will limit the space the box can be move in to be inside an area of size `1000x1000` and centered at the origin.
43+
If your `Stack` has a size, provide that size to `clampingBox` to allow movements only within the `Stack` boundary.
4344

4445
## Disable movements
4546

46-
Setting `TransformableBox.movable` to `false` will disable movements.
47+
Setting `TransformableBox.movable` to `false` will completely disable moving/dragging behavior.
4748

4849
```dart title="Disable moving"
4950
TransformableBox(

docs/flutter_resizing.mdx

Lines changed: 37 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: Resizing
44

55
# Resizing
66

7-
`TransformableBox` can be used to resize a widget by default. [Transformable Box][transformableBox] utilizes
7+
`TransformableBox` is used to resize its content by default. [Transformable Box][transformableBox] utilizes
88
[Box Transform][boxTransform] to create a fully-featured Flutter implementation of the [Box Transform][boxTransform] API.
99

1010
```dart title="Resizable widget"
@@ -30,29 +30,31 @@ title: Resizing
3030
);
3131
```
3232

33-
<Info>**_onChanged_** callback is a general callback that is called whenever a change is made to the box. To listen to specific
34-
changes, you can use **_onResized_** and **_onMoved_** callbacks for resizing and moving respectively.</Info>
33+
<Info>The **_onChanged_** callback is a general callback that is called whenever a change is made to the box. To listen
34+
to specific changes, you can use **_onResized_** and **_onMoved_** callbacks for resizing and moving respectively.
3535

36-
By default, resizing allows flipping the rect horizontally and vertically. Flipping is done by using the
36+
There are also more granular callbacks if desired.</Info>
37+
38+
By default, resizing allows flipping the rect horizontally and vertically. Flipping is done by using the
3739
`Transform.scale` widget with negative scale values.
3840

3941
Resizing is freeform by default, meaning that the user can resize the box in any direction and in any size.
4042

4143
## Controlling Resize Modes
4244

4345
The `resolveResizeModeCallback` is a callback that is called whenever a resize operation is about to be performed on a
44-
given [Transformable Box][transformableBox]. This allows you to define the resize behavior at the time of the resize
46+
given [Transformable Box][transformableBox]. This allows you to define the resize behavior at the time of the resize
4547
operation. This is useful when you want to change the resize behavior based on the state of the application.
4648

47-
The most common use case for this is **keyboard shortcuts**. A `defaultResolveResizeModeCallback` function is used by
49+
The most common use case for this is **keyboard shortcuts**. A `defaultResolveResizeModeCallback` function is used by
4850
default when resizing, and it's job is to listen to keyboard meta keys to change the `ResizeMode`.
4951

5052
### Default Resize Mode:
5153

5254
1. ResizeMode.freeform: **Default** mode. When no keys are pressed.
5355
2. ResizeMode.scale: When `Shift` key is pressed.
54-
3. ResizeMode.symmetric: When `Alt` key is pressed.
55-
4. ResizeMode.symmetricScale: When both `Shift` and `Alt` keys are pressed.
56+
3. ResizeMode.symmetric: When `Alt` or `Option` key is pressed.
57+
4. ResizeMode.symmetricScale: When both `Shift` and `Alt`/`Option` keys are pressed.
5658

5759
See [ResizeModes](/resize_modes) page for more information on the different resize modes.
5860

@@ -68,17 +70,17 @@ resizing to your liking. This can also be used to allow only certain resize mode
6870
contentBuilder: (context, rect, flip) {...},
6971
);
7072
```
71-
This will resize the box such that the **aspect ratio** is preserved.
73+
This will resize the box such that the **aspect ratio** is preserved at all times.
7274

7375
## Flipping
7476

7577
By default, resizing allows flipping the rect horizontally and vertically. Flipping is done by using the
7678
`Transform.scale` widget with negative scale values internally. There are two kinds of flipping involved in resizing:
7779

7880
### Flipping the rect while resizing
79-
While resizing, the rect can be flipped horizontally and vertically whenever the
80-
user drags a handle beyond the opposite side of the rect. This allows more flexibility in resizing the box. However,
81-
this is not responsible for flipping the content of the box.
81+
While resizing, the rect can be flipped horizontally and vertically whenever the user drags a handle beyond the opposite
82+
side of the rect. This allows more freedom when resizing a box. However, this is not responsible for flipping the
83+
content of the box.
8284

8385
This behavior can be disabled by setting `flipRectWhileResizing` to `false`.
8486

@@ -93,26 +95,28 @@ This behavior can be disabled by setting `flipRectWhileResizing` to `false`.
9395
```
9496

9597
### Flipping the content of the box
96-
This is done by using the `Transform.scale` widget with negative scale values. This
97-
is done to allow the content to be flipped horizontally and vertically.
98+
This is done by using the `Transform.scale` widget with negative scale values. This is done to allow the content to be
99+
flipped horizontally and vertically.
98100

99-
This behavior can be disabled by setting `flipChild` to `false`.
101+
This behavior can be disabled by setting `allowContentFlipping` to `false`.
100102

101103
```dart title="Disable flipping the child/content of the box"
102104
TransformableBox(
103105
rect: rect,
104106
flip: flip,
105-
flipChild: false,
107+
allowContentFlipping: false,
106108
onChanged: (event) {...},
107109
contentBuilder: (context, rect, flip) {...},
108110
);
109111
```
110112

111-
You can set both `flipRectWhileResizing` and `flipChild` to `false` to disable flipping completely.
113+
You can set both `flipRectWhileResizing` and `allowContentFlipping` to `false` to disable flipping completely.
114+
The result will be a box that stops shrinking once it reaches a size of zero, as if it hit a wall.
112115

113116
## Constraints
114117

115-
Resizing can be constrained by providing `minSize` and `maxSize` using `constraints` property.
118+
Resizing can be constrained by providing any desirable combination of `minHeight`, `minWidth`, `maxHeight` and
119+
`maxWidth` using the `constraints` property.
116120

117121
```dart title="Resizable widget with constrained resizing"
118122
TransformableBox(
@@ -128,19 +132,25 @@ Resizing can be constrained by providing `minSize` and `maxSize` using `constrai
128132
contentBuilder: (context, rect, flip) {...},
129133
);
130134
```
131-
This will allow resizing the box between 100x100 and 500x500 pixels.
135+
This will disallow the box from growing or shrinking beyond 100x100 and 500x500 pixels.
132136

133137
### Constraint callbacks
134138

135-
You can register callbacks to listen to when the box reaches the minimum or maximum size. This is useful when you want
139+
You can listen to callbacks to listen to when the box reaches the minimum or maximum size. This is useful when you want
136140
to react to these events to show some UI indication like showing a message or changing border color.
137141

138-
You can register `onTerminalSizeReached` callback to listen to when the box reaches the terminal size. This is useful
139-
when you want to show a message to the user that the box has reached the maximum size.
142+
You can listen to the `onTerminalSizeReached` callback to listen to when the box reaches some terminal size, vertically
143+
or horizontally to a minimum or maximum size. This is useful when you want to show a message to the user that the box
144+
has reached some resizing limit.
140145

141-
<Info>A **terminal size** is a size that is either the **minimum** or **maximum** size of the box on either axis.
142-
This can happen when the user tries to resize the box beyond the given **constraints** or the size reaches the
143-
`clampingRect` size.</Info>
146+
<Info>A **terminal size** is a size that is either the **minimum** or **maximum** size of the box on either axis.
147+
This can happen when the user tries to resize the box beyond the given **constraints** or the size reaches the
148+
`clampingRect` size.</Info>
149+
150+
There are more granular terminal callback functions if desired. You can use `onMinWidthReached`, `onMaxWidthReached`,
151+
`onMinHeightReached` and `onMaxHeightReached` callbacks to listen to the individual terminal size events.
152+
You can also use `onTerminalWidthReached` and `onTerminalHeightReached` to listen to combined terminal width and height
153+
events respectively.
144154

145155
```dart title="onTerminalSizeReached callback"
146156
TransformableBox(
@@ -165,13 +175,9 @@ This can happen when the user tries to resize the box beyond the given **constra
165175
);
166176
```
167177

168-
You can also use `onMinWidthReached`, `onMaxWidthReached`, `onMinHeightReached` and `onMaxHeightReached` callbacks to
169-
listen to the individual terminal size events. You can also use `onTerminalWidthReached` and `onTerminalHeightReached` to listen
170-
to combined terminal width and height events respectively.
171-
172178
## Disable Resizing
173179

174-
Resizing can be disabled by setting the `resizable` property to `false`.
180+
Resizing can be disabled completely by setting the `resizable` property to `false`.
175181

176182
```dart title="Resizable widget without resizing"
177183
TransformableBox(
@@ -184,4 +190,4 @@ Resizing can be disabled by setting the `resizable` property to `false`.
184190
```
185191

186192
[boxTransform]: https://github.com/hyper-designed/box_transform/tree/main/packages/box_transform
187-
[transformableBox]: https://github.com/hyper-designed/box_transform/blob/main/packages/flutter_box_transform/lib/src/transformable_box.dart
193+
[transformableBox]: https://github.com/hyper-designed/box_transform/blob/main/packages/flutter_box_transform/lib/src/transformable_box.dart

0 commit comments

Comments
 (0)