|
|
|
|
|
|
|
|
|
|
public class ReorderableListView : StatefulWidget { |
|
|
|
public ReorderableListView( |
|
|
|
Key key = null, |
|
|
|
ScrollController scrollController = null, |
|
|
|
) { |
|
|
|
) : base(key: key) { |
|
|
|
D.assert(onReorder != null); |
|
|
|
D.assert(children != null); |
|
|
|
D.assert( |
|
|
|
|
|
|
this.header = header; |
|
|
|
this.children = children; |
|
|
|
this.scrollController = scrollController; |
|
|
|
this.scrollDirection = scrollDirection; |
|
|
|
this.padding = padding; |
|
|
|
this.onReorder = onReorder; |
|
|
|
|
|
|
public readonly List<Widget> children; |
|
|
|
|
|
|
|
public readonly Axis scrollDirection; |
|
|
|
|
|
|
|
public readonly ScrollController scrollController; |
|
|
|
|
|
|
|
public readonly EdgeInsets padding; |
|
|
|
|
|
|
|
|
|
|
return new _ReorderableListContent( |
|
|
|
header: widget.header, |
|
|
|
children: widget.children, |
|
|
|
scrollController: widget.scrollController, |
|
|
|
scrollDirection: widget.scrollDirection, |
|
|
|
onReorder: widget.onReorder, |
|
|
|
padding: widget.padding, |
|
|
|
|
|
|
public _ReorderableListContent( |
|
|
|
Widget header, |
|
|
|
List<Widget> children, |
|
|
|
ScrollController scrollController, |
|
|
|
Axis scrollDirection, |
|
|
|
EdgeInsets padding, |
|
|
|
ReorderCallback onReorder, |
|
|
|
|
|
|
this.children = children; |
|
|
|
this.scrollController = scrollController; |
|
|
|
this.scrollDirection = scrollDirection; |
|
|
|
this.padding = padding; |
|
|
|
this.onReorder = onReorder; |
|
|
|
|
|
|
public readonly Widget header; |
|
|
|
public readonly List<Widget> children; |
|
|
|
public readonly ScrollController scrollController; |
|
|
|
public readonly Axis scrollDirection; |
|
|
|
public readonly EdgeInsets padding; |
|
|
|
public readonly ReorderCallback onReorder; |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
public override void didChangeDependencies() { |
|
|
|
_scrollController = PrimaryScrollController.of(context) ?? new ScrollController(); |
|
|
|
_scrollController = widget.scrollController ?? PrimaryScrollController.of(context) ?? new ScrollController(); |
|
|
|
base.didChangeDependencies(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
D.assert(material_.debugCheckHasMaterialLocalizations(context)); |
|
|
|
return new LayoutBuilder(builder: (BuildContext _, BoxConstraints constraints) => { |
|
|
|
List<Widget> wrappedChildren = new List<Widget> { }; |
|
|
|
if (widget.header != null) { |
|
|
|
wrappedChildren.Add(widget.header); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < widget.children.Count; i += 1) { |
|
|
|
wrappedChildren.Add(_wrap(widget.children[i], i, constraints)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Key endWidgetKey = Key.key("DraggableList - End Widget"); |
|
|
|
Widget finalDropArea; |
|
|
|
switch (widget.scrollDirection) { |
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (widget.reverse == true) { |
|
|
|
wrappedChildren.Insert(0, _wrap( |
|
|
|
wrappedChildren.Add(_wrap( |
|
|
|
else { |
|
|
|
if (widget.header != null) { |
|
|
|
wrappedChildren.Add(widget.header); |
|
|
|
} |
|
|
|
for (int i = 0; i < widget.children.Count; i += 1) { |
|
|
|
wrappedChildren.Add(_wrap(widget.children[i], i, constraints)); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (widget.reverse != true) { |
|
|
|
wrappedChildren.Add(_wrap( |
|
|
|
finalDropArea, widget.children.Count, |
|
|
|
constraints) |
|
|
|