Skip to content

Commit aa4d9b0

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
📝 Update docs.
1 parent 3b719dd commit aa4d9b0

File tree

7 files changed

+22
-49
lines changed

7 files changed

+22
-49
lines changed

docs/flutter_controller.mdx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ title: Using a controller
88
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`, and `handleTapSize` since these are accessibility and
12-
rendering features.
11+
in the constructor excluding `contentBuilder`, `handleBuilder`, `handleTapSize`, `allowFlippingWhileResizing`,
12+
`movable`, `resizable`, `handleAlignment`, `hideHandlesWhenNotResizable`, and `allowContentFlipping` since these are
13+
accessibility and rendering features that are controlled at the Widget level.
1314

1415
<Warning>When using a controller, you should move these parameters from your `TransformableBox` to the constructor of
1516
the `TransformableBoxController`: **_box_**, **_flip_**, **_clampingBox_**, **_constraints_**, and
16-
**_resolveResizeModeCallback_**. These are all intrinsically managed by the controller.
17+
**_resizeModeResolver_**. These are all intrinsically managed by the controller.
1718

1819
There must always be only one source of truth, either the `TransformableBox` or the `TransformableBoxController`, not both.</Warning>
1920

@@ -100,9 +101,6 @@ controller.setConstraints(constraints);
100101
// Change clamping rect
101102
controller.setClampingRect(clampingRect);
102103
103-
// Disable content/child flipping
104-
controller.setFlipChild(false);
105-
106104
// Disable flipping the rect while resizing
107-
controller.setFlipRectWhileResizing(false);
105+
controller.setAllowFlippingWhileResizing(false);
108106
```

docs/flutter_resizing.mdx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ Resizing is freeform by default, meaning that the user can resize the box in any
4242

4343
## Controlling Resize Modes
4444

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

49-
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 `defaultResizeModeResolver` function is used by
5050
default when resizing, and it's job is to listen to keyboard meta keys to change the `ResizeMode`.
5151

5252
### Default Resize Mode:
@@ -58,14 +58,14 @@ default when resizing, and it's job is to listen to keyboard meta keys to change
5858

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

61-
Override this default behavior by providing `resolveResizeModeCallback` in `TransformableBox` constructor to customize
61+
Override this default behavior by providing `resizeModeResolver` in `TransformableBox` constructor to customize
6262
resizing to your liking. This can also be used to allow only certain resize modes.
6363

6464
```dart title="Resizing with preseving aspect ratio"
6565
TransformableBox(
6666
rect: rect,
6767
flip: flip,
68-
resolveResizeModeCallback: () => ResizeMode.scale,
68+
resizeModeResolver: () => ResizeMode.scale,
6969
onChanged: (event) {...},
7070
contentBuilder: (context, rect, flip) {...},
7171
);

docs/handles.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ You can customize the default handles or build your own handles using the `corne
2626
properties in the `TransformableBox` constructor. They both provide access to the `BuildContext` and `HandlePosition`
2727
of the appropriate handle.
2828

29-
You can use `handleAlign` on `TransformableBox` to change the position of the handle's interactive area. By default,
29+
You can use `HandleAlignment` on `TransformableBox` to change the position of the handle's interactive area. By default,
3030
the interactive area is aligned to the center of box corner/side.
3131

3232
```dart title="Putting handle completely inside the box area"
3333
TransformableBox(
3434
rect: rect,
3535
flip: flip,
36-
handleAlign: HandleAlign.inside,
36+
handleAlignment: HandleAlignment.inside,
3737
onChanged: (event) {...},
3838
contentBuilder: (context, rect, flip) {...},
3939
);
@@ -121,7 +121,7 @@ You can use `AngularHandle` to build angular handles that look like corner brack
121121
TransformableBox(
122122
rect: rect,
123123
flip: flip,
124-
handleAlign: HandleAlign.inside,
124+
handleAlignment: HandleAlignment.inside,
125125
cornerHandleBuilder: (context, handle) {
126126
return AngularCornerHandle(
127127
handle: handle,
@@ -131,14 +131,14 @@ You can use `AngularHandle` to build angular handles that look like corner brack
131131
sideHandleBuilder: (context, handle) {
132132
return AngularSideHandle(
133133
handle: handle,
134-
handleAlign: HandleAlign.inside,
134+
handleAlignment: HandleAlignment.inside,
135135
);
136136
},
137137
onChanged: (event) {...},
138138
contentBuilder: (context, rect, flip) {...},
139139
);
140140
```
141141

142-
Use `handleAlign` to align `AngularHandle` to the inside, outside or in the center of the box.
142+
Use `handleAlignment` to align `AngularHandle` to the inside, outside or in the center of the box.
143143

144144
<Image alt="Angular Handle Alignements" src="assets/angular_handle_alignments.png"/>

packages/flutter_box_transform/lib/src/handle.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ class AngularHandle extends StatelessWidget {
165165
/// The thickness of the handle.
166166
final double thickness;
167167

168-
//// Whether the handle has a shadow.
168+
/// Whether the handle has a shadow.
169169
final bool hasShadow;
170170

171171
/// The alignment of the handle.
172-
final HandleAlignment handleAlign;
172+
final HandleAlignment handleAlignment;
173173

174174
/// Creates a new angular corner handle.
175175
const AngularHandle({
@@ -179,7 +179,7 @@ class AngularHandle extends StatelessWidget {
179179
this.thickness = 5,
180180
this.color,
181181
this.hasShadow = true,
182-
this.handleAlign = HandleAlignment.inside,
182+
this.handleAlignment = HandleAlignment.inside,
183183
});
184184

185185
@override
@@ -197,7 +197,7 @@ class AngularHandle extends StatelessWidget {
197197
thickness: thickness,
198198
handle: handle,
199199
hasShadow: hasShadow,
200-
handleAlign: handleAlign,
200+
handleAlign: handleAlignment,
201201
length: min(
202202
length,
203203
handle.isHorizontal

packages/flutter_box_transform/lib/src/transformable_box.dart

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -439,14 +439,6 @@ class _TransformableBoxState extends State<TransformableBox> {
439439
controller.setResizable(widget.resizable, notify: false);
440440
}
441441

442-
if (oldWidget.hideHandlesWhenNotResizable !=
443-
widget.hideHandlesWhenNotResizable) {
444-
controller.setHideHandlesWhenNotResizable(
445-
widget.hideHandlesWhenNotResizable,
446-
notify: false,
447-
);
448-
}
449-
450442
if (oldWidget.movable != widget.movable) {
451443
controller.setMovable(widget.movable, notify: false);
452444
}
@@ -592,7 +584,7 @@ class _TransformableBoxState extends State<TransformableBox> {
592584
height: box.height,
593585
child: content,
594586
),
595-
if (controller.resizable || !controller.hideHandlesWhenNotResizable)
587+
if (controller.resizable || !widget.hideHandlesWhenNotResizable)
596588
for (final handle in HandlePosition.corners)
597589
_CornerHandleWidget(
598590
key: ValueKey(handle),
@@ -606,7 +598,7 @@ class _TransformableBoxState extends State<TransformableBox> {
606598
onPointerCancel: (event) => onHandlePointerDone(event, handle),
607599
builder: widget.cornerHandleBuilder,
608600
),
609-
if (controller.resizable || !controller.hideHandlesWhenNotResizable)
601+
if (controller.resizable || !widget.hideHandlesWhenNotResizable)
610602
for (final handle in HandlePosition.sides)
611603
_SideHandleWidget(
612604
key: ValueKey(handle),

packages/flutter_box_transform/lib/src/transformable_box_controller.dart

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,6 @@ class TransformableBoxController extends ChangeNotifier {
117117
/// all resizing operations.
118118
bool get resizable => _resizable;
119119

120-
/// Whether the box should hide the corner/side resize controls when [resizable] is
121-
/// false.
122-
bool _hideHandlesWhenNotResizable = true;
123-
124-
/// Whether the box should hide the corner/side resize controls when [resizable] is
125-
/// false.
126-
bool get hideHandlesWhenNotResizable => _hideHandlesWhenNotResizable;
127-
128120
/// Whether to allow flipping of the box while resizing. If this is set to
129121
/// true, the box will flip when the user drags the handles to opposite
130122
/// corners of the rect.
@@ -217,15 +209,6 @@ class TransformableBoxController extends ChangeNotifier {
217209
if (notify) notifyListeners();
218210
}
219211

220-
/// Whether the box should hide the corner/side resize controls when [resizable] is
221-
/// false.
222-
void setHideHandlesWhenNotResizable(bool hideHandlesWhenNotResizable,
223-
{bool notify = true}) {
224-
_hideHandlesWhenNotResizable = hideHandlesWhenNotResizable;
225-
226-
if (notify) notifyListeners();
227-
}
228-
229212
/// Whether to allow flipping of the box while resizing. If this is set to
230213
/// true, the box will flip when the user drags the handles to opposite
231214
/// corners of the rect.

packages/flutter_box_transform/playground/lib/main.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,13 +764,13 @@ class _ClampingRectState extends State<ClampingRect> {
764764
handle: handle,
765765
color: mainColor,
766766
hasShadow: false,
767-
handleAlign: HandleAlignment.inside,
767+
handleAlignment: HandleAlignment.inside,
768768
),
769769
sideHandleBuilder: (context, handle) => AngularHandle(
770770
handle: handle,
771771
color: mainColor,
772772
hasShadow: false,
773-
handleAlign: HandleAlignment.inside,
773+
handleAlignment: HandleAlignment.inside,
774774
),
775775
contentBuilder: (context, _, flip) => Container(
776776
width: model.clampingRect.width,

0 commit comments

Comments
 (0)