Commit 6d7bf20f authored by Adam Barth's avatar Adam Barth

Merge pull request #1243 from abarth/edge_trigger

Stocks has both tabs reified in the wiget tree
parents 675f4c4d b5ed355b
......@@ -225,10 +225,10 @@ class _PageViewportElement extends VirtualViewportElement<PageViewport> {
return -(widget.startOffset - startOffsetBase) * _containerExtent;
}
void updateRenderObject() {
void updateRenderObject(PageViewport oldWidget) {
renderObject.scrollDirection = widget.scrollDirection;
renderObject.overlayPainter = widget.overlayPainter;
super.updateRenderObject();
super.updateRenderObject(oldWidget);
}
double _containerExtent;
......
......@@ -122,9 +122,9 @@ class _GridViewportElement extends VirtualViewportElement<GridViewport> {
double get startOffsetLimit =>_startOffsetLimit;
double _startOffsetLimit;
void updateRenderObject() {
void updateRenderObject(GridViewport oldWidget) {
renderObject.delegate = widget.delegate;
super.updateRenderObject();
super.updateRenderObject(oldWidget);
}
double _contentExtent;
......
......@@ -135,12 +135,12 @@ class _ListViewportElement extends VirtualViewportElement<ListViewport> {
double get startOffsetLimit =>_startOffsetLimit;
double _startOffsetLimit;
void updateRenderObject() {
void updateRenderObject(ListViewport oldWidget) {
renderObject.scrollDirection = widget.scrollDirection;
renderObject.itemExtent = widget.itemExtent;
renderObject.padding = widget.padding;
renderObject.overlayPainter = widget.overlayPainter;
super.updateRenderObject();
super.updateRenderObject(oldWidget);
}
double _contentExtent;
......
......@@ -43,7 +43,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
_iterator = null;
_widgets = <Widget>[];
renderObject.callback = layout;
updateRenderObject();
updateRenderObject(null);
}
void unmount() {
......@@ -56,8 +56,9 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
_iterator = null;
_widgets = <Widget>[];
}
T oldWidget = widget;
super.update(newWidget);
updateRenderObject();
updateRenderObject(oldWidget);
if (!renderObject.needsLayout)
_materializeChildren();
}
......@@ -73,7 +74,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
}
}
void updateRenderObject() {
void updateRenderObject(T oldWidget) {
renderObject.virtualChildCount = widget.children.length;
if (startOffsetBase != null) {
......@@ -82,9 +83,22 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
// If we don't already need layout, we need to request a layout if the
// viewport has shifted to expose new children.
if (!renderObject.needsLayout) {
if (startOffsetBase != null && widget.startOffset < startOffsetBase)
renderObject.markNeedsLayout();
else if (startOffsetLimit != null && widget.startOffset > startOffsetLimit)
bool shouldLayout = false;
if (startOffsetBase != null) {
if (widget.startOffset < startOffsetBase)
shouldLayout = true;
else if (widget.startOffset == startOffsetBase && oldWidget?.startOffset != startOffsetBase)
shouldLayout = true;
}
if (startOffsetLimit != null) {
if (widget.startOffset > startOffsetLimit)
shouldLayout = true;
else if (widget.startOffset == startOffsetLimit && oldWidget?.startOffset != startOffsetLimit)
shouldLayout = true;
}
if (shouldLayout)
renderObject.markNeedsLayout();
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment