Added boundary feature to ReorderableList.#146182
Added boundary feature to ReorderableList.#146182auto-submit[bot] merged 3 commits intoflutter:masterfrom
Conversation
| /// When this widget wraps a [ReorderableList], the drag boundary of the [ReorderableList] is confined within this widget. | ||
| /// If the [dragBoundingRect] property is provided, the drag boundary is limited to the rectangle returned by [dragBoundingRect]. | ||
| /// The boundary is specified in global coordinates. | ||
| class ReorderableDragBoundary extends InheritedWidget { |
There was a problem hiding this comment.
This is a really neat concept! I just came across #146749 and wondered if this might be beneficial as a generic drag gesture bounding widget, not just for ReorderableList. WDYT?
| }); | ||
|
|
||
| /// Return the drag boundary of [ReorderableList]. | ||
| final Rect Function(SliverReorderableListState reorderableListCurrentState)? dragBoundingRect; |
There was a problem hiding this comment.
This could benefit from typedef-ing the function signature.
| /// The [dragBoundingRect] needs to return a rectangle in global coordinates. | ||
| const ReorderableDragBoundary({ | ||
| required super.child, | ||
| this.dragBoundingRect, |
There was a problem hiding this comment.
This feels a bit difficult for users to define. Say the user wants to stick within the bounds of the Viewport, since a Viewport will expand to fill all of the available space, how does the user know what that rect is?
|
I implemented a generic drag gesture boundary here: #147521. This PR needs to be reimplemented after it. |
|
(triage): We are still waiting on #147521 before we can make progress here. |
|
(triage) converting to draft for now until the other pr is merged. Feel free to convert back once this is ready for review |
|
(triage) still waiting for the other pr to merge |
Inspired by the review on #146182. This PR adds boundary feature to the drag gestures, including `MultiDragGestureRecognizer` and `DragGestureRecognizer`. The `GestureDetector` widget will also benefit from this.
22bfa28 to
ce14b02
Compare
ce14b02 to
1ee40b3
Compare
| dragOffset = itemRenderBox.globalToLocal(initialPosition); | ||
| itemSize = item.context.size!; | ||
| _rawDragPosition = initialPosition; | ||
| boundary = listState.widget.dragBoundaryProvider?.call(listState.context); |
There was a problem hiding this comment.
Have you considered having ReorderableList inherit the drag boundary through forRectMaybeOf by default instead of passing it down as a parameter? Or maybe it should do both, inherit by default, and have a parameter that overrides the default inherited provider.
There was a problem hiding this comment.
I'm also curious if there is any native behavior we have to compare to on other platforms (if a similar component exists).
There was a problem hiding this comment.
Modified to default to using DragBoundary.forRectMaybeOf.
Renzo-Olivares
left a comment
There was a problem hiding this comment.
LGTM, thank you for the contribution!
Fixes: #146112
Code sample
DragBoundaryDragBoundaryPre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.