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> { ...@@ -225,10 +225,10 @@ class _PageViewportElement extends VirtualViewportElement<PageViewport> {
return -(widget.startOffset - startOffsetBase) * _containerExtent; return -(widget.startOffset - startOffsetBase) * _containerExtent;
} }
void updateRenderObject() { void updateRenderObject(PageViewport oldWidget) {
renderObject.scrollDirection = widget.scrollDirection; renderObject.scrollDirection = widget.scrollDirection;
renderObject.overlayPainter = widget.overlayPainter; renderObject.overlayPainter = widget.overlayPainter;
super.updateRenderObject(); super.updateRenderObject(oldWidget);
} }
double _containerExtent; double _containerExtent;
......
...@@ -122,9 +122,9 @@ class _GridViewportElement extends VirtualViewportElement<GridViewport> { ...@@ -122,9 +122,9 @@ class _GridViewportElement extends VirtualViewportElement<GridViewport> {
double get startOffsetLimit =>_startOffsetLimit; double get startOffsetLimit =>_startOffsetLimit;
double _startOffsetLimit; double _startOffsetLimit;
void updateRenderObject() { void updateRenderObject(GridViewport oldWidget) {
renderObject.delegate = widget.delegate; renderObject.delegate = widget.delegate;
super.updateRenderObject(); super.updateRenderObject(oldWidget);
} }
double _contentExtent; double _contentExtent;
......
...@@ -135,12 +135,12 @@ class _ListViewportElement extends VirtualViewportElement<ListViewport> { ...@@ -135,12 +135,12 @@ class _ListViewportElement extends VirtualViewportElement<ListViewport> {
double get startOffsetLimit =>_startOffsetLimit; double get startOffsetLimit =>_startOffsetLimit;
double _startOffsetLimit; double _startOffsetLimit;
void updateRenderObject() { void updateRenderObject(ListViewport oldWidget) {
renderObject.scrollDirection = widget.scrollDirection; renderObject.scrollDirection = widget.scrollDirection;
renderObject.itemExtent = widget.itemExtent; renderObject.itemExtent = widget.itemExtent;
renderObject.padding = widget.padding; renderObject.padding = widget.padding;
renderObject.overlayPainter = widget.overlayPainter; renderObject.overlayPainter = widget.overlayPainter;
super.updateRenderObject(); super.updateRenderObject(oldWidget);
} }
double _contentExtent; double _contentExtent;
......
...@@ -43,7 +43,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO ...@@ -43,7 +43,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
_iterator = null; _iterator = null;
_widgets = <Widget>[]; _widgets = <Widget>[];
renderObject.callback = layout; renderObject.callback = layout;
updateRenderObject(); updateRenderObject(null);
} }
void unmount() { void unmount() {
...@@ -56,8 +56,9 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO ...@@ -56,8 +56,9 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
_iterator = null; _iterator = null;
_widgets = <Widget>[]; _widgets = <Widget>[];
} }
T oldWidget = widget;
super.update(newWidget); super.update(newWidget);
updateRenderObject(); updateRenderObject(oldWidget);
if (!renderObject.needsLayout) if (!renderObject.needsLayout)
_materializeChildren(); _materializeChildren();
} }
...@@ -73,7 +74,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO ...@@ -73,7 +74,7 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO
} }
} }
void updateRenderObject() { void updateRenderObject(T oldWidget) {
renderObject.virtualChildCount = widget.children.length; renderObject.virtualChildCount = widget.children.length;
if (startOffsetBase != null) { if (startOffsetBase != null) {
...@@ -82,9 +83,22 @@ abstract class VirtualViewportElement<T extends VirtualViewport> extends RenderO ...@@ -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 // If we don't already need layout, we need to request a layout if the
// viewport has shifted to expose new children. // viewport has shifted to expose new children.
if (!renderObject.needsLayout) { if (!renderObject.needsLayout) {
if (startOffsetBase != null && widget.startOffset < startOffsetBase) bool shouldLayout = false;
renderObject.markNeedsLayout(); if (startOffsetBase != null) {
else if (startOffsetLimit != null && widget.startOffset > startOffsetLimit) 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(); 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