parent
19f615fc2f
commit
e9b8f4450b
@ -784,7 +784,7 @@ class _TabBarState<T> extends ScrollableState<TabBar<T>> implements TabBarSelect
|
|||||||
|
|
||||||
if (config.isScrollable) {
|
if (config.isScrollable) {
|
||||||
return new Viewport(
|
return new Viewport(
|
||||||
scrollDirection: Axis.horizontal,
|
mainAxis: Axis.horizontal,
|
||||||
paintOffset: scrollOffsetToPixelDelta(scrollOffset),
|
paintOffset: scrollOffsetToPixelDelta(scrollOffset),
|
||||||
onPaintOffsetUpdateNeeded: _handlePaintOffsetUpdateNeeded,
|
onPaintOffsetUpdateNeeded: _handlePaintOffsetUpdateNeeded,
|
||||||
child: contents
|
child: contents
|
||||||
@ -961,7 +961,7 @@ class _TabBarViewState<T> extends PageableListState<TabBarView<T>> implements Ta
|
|||||||
_initSelection(newSelection);
|
_initSelection(newSelection);
|
||||||
return new PageViewport(
|
return new PageViewport(
|
||||||
itemsWrap: config.itemsWrap,
|
itemsWrap: config.itemsWrap,
|
||||||
scrollDirection: config.scrollDirection,
|
mainAxis: config.scrollDirection,
|
||||||
startOffset: scrollOffset,
|
startOffset: scrollOffset,
|
||||||
overlayPainter: config.scrollableListPainter,
|
overlayPainter: config.scrollableListPainter,
|
||||||
children: _items
|
children: _items
|
||||||
|
@ -28,14 +28,14 @@ typedef double _Constrainer(double value);
|
|||||||
abstract class RenderBlockBase extends RenderBox
|
abstract class RenderBlockBase extends RenderBox
|
||||||
with ContainerRenderObjectMixin<RenderBox, BlockParentData>,
|
with ContainerRenderObjectMixin<RenderBox, BlockParentData>,
|
||||||
RenderBoxContainerDefaultsMixin<RenderBox, BlockParentData>
|
RenderBoxContainerDefaultsMixin<RenderBox, BlockParentData>
|
||||||
implements HasScrollDirection {
|
implements HasMainAxis {
|
||||||
|
|
||||||
RenderBlockBase({
|
RenderBlockBase({
|
||||||
List<RenderBox> children,
|
List<RenderBox> children,
|
||||||
Axis direction: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
double itemExtent,
|
double itemExtent,
|
||||||
double minExtent: 0.0
|
double minExtent: 0.0
|
||||||
}) : _direction = direction, _itemExtent = itemExtent, _minExtent = minExtent {
|
}) : _mainAxis = mainAxis, _itemExtent = itemExtent, _minExtent = minExtent {
|
||||||
addAll(children);
|
addAll(children);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,11 +45,11 @@ abstract class RenderBlockBase extends RenderBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// The direction to use as the main axis.
|
/// The direction to use as the main axis.
|
||||||
Axis get direction => _direction;
|
Axis get mainAxis => _mainAxis;
|
||||||
Axis _direction;
|
Axis _mainAxis;
|
||||||
void set direction (Axis value) {
|
void set mainAxis (Axis value) {
|
||||||
if (_direction != value) {
|
if (_mainAxis != value) {
|
||||||
_direction = value;
|
_mainAxis = value;
|
||||||
markNeedsLayout();
|
markNeedsLayout();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -75,9 +75,7 @@ abstract class RenderBlockBase extends RenderBox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the main axis is vertical.
|
/// Whether the main axis is vertical.
|
||||||
bool get isVertical => _direction == Axis.vertical;
|
bool get isVertical => _mainAxis == Axis.vertical;
|
||||||
|
|
||||||
Axis get scrollDirection => _direction;
|
|
||||||
|
|
||||||
BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
|
BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
|
||||||
if (isVertical)
|
if (isVertical)
|
||||||
@ -117,7 +115,7 @@ abstract class RenderBlockBase extends RenderBox
|
|||||||
|
|
||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
super.debugFillDescription(description);
|
super.debugFillDescription(description);
|
||||||
description.add('direction: $direction');
|
description.add('mainAxis: $mainAxis');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -126,10 +124,10 @@ class RenderBlock extends RenderBlockBase {
|
|||||||
|
|
||||||
RenderBlock({
|
RenderBlock({
|
||||||
List<RenderBox> children,
|
List<RenderBox> children,
|
||||||
Axis direction: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
double itemExtent,
|
double itemExtent,
|
||||||
double minExtent: 0.0
|
double minExtent: 0.0
|
||||||
}) : super(children: children, direction: direction, itemExtent: itemExtent, minExtent: minExtent);
|
}) : super(children: children, mainAxis: mainAxis, itemExtent: itemExtent, minExtent: minExtent);
|
||||||
|
|
||||||
double _getIntrinsicCrossAxis(BoxConstraints constraints, _ChildSizingFunction childSize, _Constrainer constrainer) {
|
double _getIntrinsicCrossAxis(BoxConstraints constraints, _ChildSizingFunction childSize, _Constrainer constrainer) {
|
||||||
double extent = 0.0;
|
double extent = 0.0;
|
||||||
@ -242,7 +240,7 @@ class RenderBlockViewport extends RenderBlockBase {
|
|||||||
ExtentCallback maxCrossAxisDimensionCallback,
|
ExtentCallback maxCrossAxisDimensionCallback,
|
||||||
ExtentCallback minCrossAxisDimensionCallback,
|
ExtentCallback minCrossAxisDimensionCallback,
|
||||||
Painter overlayPainter,
|
Painter overlayPainter,
|
||||||
Axis direction: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
double itemExtent,
|
double itemExtent,
|
||||||
double minExtent: 0.0,
|
double minExtent: 0.0,
|
||||||
double startOffset: 0.0,
|
double startOffset: 0.0,
|
||||||
@ -253,7 +251,7 @@ class RenderBlockViewport extends RenderBlockBase {
|
|||||||
_minCrossAxisExtentCallback = minCrossAxisDimensionCallback,
|
_minCrossAxisExtentCallback = minCrossAxisDimensionCallback,
|
||||||
_overlayPainter = overlayPainter,
|
_overlayPainter = overlayPainter,
|
||||||
_startOffset = startOffset,
|
_startOffset = startOffset,
|
||||||
super(children: children, direction: direction, itemExtent: itemExtent, minExtent: minExtent);
|
super(children: children, mainAxis: mainAxis, itemExtent: itemExtent, minExtent: minExtent);
|
||||||
|
|
||||||
bool _inCallback = false;
|
bool _inCallback = false;
|
||||||
bool get isRepaintBoundary => true;
|
bool get isRepaintBoundary => true;
|
||||||
|
@ -384,13 +384,13 @@ class RenderGrid extends RenderVirtualViewport<GridParentData> {
|
|||||||
_delegate = newDelegate;
|
_delegate = newDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set scrollDirection(Axis value) {
|
void set mainAxis(Axis value) {
|
||||||
assert(() {
|
assert(() {
|
||||||
if (value != Axis.vertical)
|
if (value != Axis.vertical)
|
||||||
throw new RenderingError('RenderGrid doesn\'t yet support horizontal scrolling.');
|
throw new RenderingError('RenderGrid doesn\'t yet support horizontal scrolling.');
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
super.scrollDirection = value;
|
super.mainAxis = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
int get virtualChildCount => super.virtualChildCount ?? childCount;
|
int get virtualChildCount => super.virtualChildCount ?? childCount;
|
||||||
|
@ -18,7 +18,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
|
|||||||
EdgeDims padding,
|
EdgeDims padding,
|
||||||
int virtualChildCount,
|
int virtualChildCount,
|
||||||
Offset paintOffset: Offset.zero,
|
Offset paintOffset: Offset.zero,
|
||||||
Axis scrollDirection: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
Painter overlayPainter,
|
Painter overlayPainter,
|
||||||
LayoutCallback callback
|
LayoutCallback callback
|
||||||
}) : _itemExtent = itemExtent,
|
}) : _itemExtent = itemExtent,
|
||||||
@ -26,7 +26,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
|
|||||||
super(
|
super(
|
||||||
virtualChildCount: virtualChildCount,
|
virtualChildCount: virtualChildCount,
|
||||||
paintOffset: paintOffset,
|
paintOffset: paintOffset,
|
||||||
scrollDirection: scrollDirection,
|
mainAxis: mainAxis,
|
||||||
overlayPainter: overlayPainter,
|
overlayPainter: overlayPainter,
|
||||||
callback: callback
|
callback: callback
|
||||||
) {
|
) {
|
||||||
@ -58,7 +58,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
double get _scrollAxisPadding {
|
double get _scrollAxisPadding {
|
||||||
switch (scrollDirection) {
|
switch (mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
return padding.vertical;
|
return padding.vertical;
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
@ -80,7 +80,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
|
|||||||
|
|
||||||
double _getIntrinsicWidth(BoxConstraints constraints) {
|
double _getIntrinsicWidth(BoxConstraints constraints) {
|
||||||
assert(constraints.debugAssertIsNormalized);
|
assert(constraints.debugAssertIsNormalized);
|
||||||
switch (scrollDirection) {
|
switch (mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
return constraints.constrainWidth(0.0);
|
return constraints.constrainWidth(0.0);
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
@ -98,7 +98,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
|
|||||||
|
|
||||||
double _getIntrinsicHeight(BoxConstraints constraints) {
|
double _getIntrinsicHeight(BoxConstraints constraints) {
|
||||||
assert(constraints.debugAssertIsNormalized);
|
assert(constraints.debugAssertIsNormalized);
|
||||||
switch (scrollDirection) {
|
switch (mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
return constraints.constrainHeight(_preferredExtent);
|
return constraints.constrainHeight(_preferredExtent);
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
@ -115,7 +115,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void performLayout() {
|
void performLayout() {
|
||||||
switch (scrollDirection) {
|
switch (mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
size = new Size(constraints.maxWidth,
|
size = new Size(constraints.maxWidth,
|
||||||
constraints.constrainHeight(_preferredExtent));
|
constraints.constrainHeight(_preferredExtent));
|
||||||
@ -138,7 +138,7 @@ class RenderList extends RenderVirtualViewport<ListParentData> {
|
|||||||
double y = 0.0;
|
double y = 0.0;
|
||||||
double dy = 0.0;
|
double dy = 0.0;
|
||||||
|
|
||||||
switch (scrollDirection) {
|
switch (mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
itemWidth = math.max(0.0, size.width - (padding == null ? 0.0 : padding.horizontal));
|
itemWidth = math.max(0.0, size.width - (padding == null ? 0.0 : padding.horizontal));
|
||||||
itemHeight = itemExtent ?? size.height;
|
itemHeight = itemExtent ?? size.height;
|
||||||
|
@ -71,9 +71,9 @@ class ViewportDimensions {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// An interface that indicates that an object has a scroll direction.
|
/// An interface that indicates that an object has a scroll direction.
|
||||||
abstract class HasScrollDirection {
|
abstract class HasMainAxis {
|
||||||
/// Whether this object scrolls horizontally or vertically.
|
/// Whether this object scrolls horizontally or vertically.
|
||||||
Axis get scrollDirection;
|
Axis get mainAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A base class for render objects that are bigger on the inside.
|
/// A base class for render objects that are bigger on the inside.
|
||||||
@ -81,19 +81,19 @@ abstract class HasScrollDirection {
|
|||||||
/// This class holds the common fields for viewport render objects but does not
|
/// This class holds the common fields for viewport render objects but does not
|
||||||
/// have a child model. See [RenderViewport] for a viewport with a single child
|
/// have a child model. See [RenderViewport] for a viewport with a single child
|
||||||
/// and [RenderVirtualViewport] for a viewport with multiple children.
|
/// and [RenderVirtualViewport] for a viewport with multiple children.
|
||||||
class RenderViewportBase extends RenderBox implements HasScrollDirection {
|
class RenderViewportBase extends RenderBox implements HasMainAxis {
|
||||||
RenderViewportBase(
|
RenderViewportBase(
|
||||||
Offset paintOffset,
|
Offset paintOffset,
|
||||||
Axis scrollDirection,
|
Axis mainAxis,
|
||||||
ViewportAnchor scrollAnchor,
|
ViewportAnchor scrollAnchor,
|
||||||
Painter overlayPainter
|
Painter overlayPainter
|
||||||
) : _paintOffset = paintOffset,
|
) : _paintOffset = paintOffset,
|
||||||
_scrollDirection = scrollDirection,
|
_mainAxis = mainAxis,
|
||||||
_scrollAnchor = scrollAnchor,
|
_scrollAnchor = scrollAnchor,
|
||||||
_overlayPainter = overlayPainter {
|
_overlayPainter = overlayPainter {
|
||||||
assert(paintOffset != null);
|
assert(paintOffset != null);
|
||||||
assert(scrollDirection != null);
|
assert(mainAxis != null);
|
||||||
assert(_offsetIsSane(_paintOffset, scrollDirection));
|
assert(_offsetIsSane(_paintOffset, mainAxis));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _offsetIsSane(Offset offset, Axis direction) {
|
bool _offsetIsSane(Offset offset, Axis direction) {
|
||||||
@ -107,14 +107,14 @@ class RenderViewportBase extends RenderBox implements HasScrollDirection {
|
|||||||
|
|
||||||
/// The offset at which to paint the child.
|
/// The offset at which to paint the child.
|
||||||
///
|
///
|
||||||
/// The offset can be non-zero only in the [scrollDirection].
|
/// The offset can be non-zero only in the [mainAxis].
|
||||||
Offset get paintOffset => _paintOffset;
|
Offset get paintOffset => _paintOffset;
|
||||||
Offset _paintOffset;
|
Offset _paintOffset;
|
||||||
void set paintOffset(Offset value) {
|
void set paintOffset(Offset value) {
|
||||||
assert(value != null);
|
assert(value != null);
|
||||||
if (value == _paintOffset)
|
if (value == _paintOffset)
|
||||||
return;
|
return;
|
||||||
assert(_offsetIsSane(value, scrollDirection));
|
assert(_offsetIsSane(value, mainAxis));
|
||||||
_paintOffset = value;
|
_paintOffset = value;
|
||||||
markNeedsPaint();
|
markNeedsPaint();
|
||||||
markNeedsSemanticsUpdate();
|
markNeedsSemanticsUpdate();
|
||||||
@ -125,14 +125,14 @@ class RenderViewportBase extends RenderBox implements HasScrollDirection {
|
|||||||
/// If the viewport is scrollable in a particular direction (e.g., vertically),
|
/// If the viewport is scrollable in a particular direction (e.g., vertically),
|
||||||
/// the child is given layout constraints that are fully unconstrainted in
|
/// the child is given layout constraints that are fully unconstrainted in
|
||||||
/// that direction (e.g., the child can be as tall as it wants).
|
/// that direction (e.g., the child can be as tall as it wants).
|
||||||
Axis get scrollDirection => _scrollDirection;
|
Axis get mainAxis => _mainAxis;
|
||||||
Axis _scrollDirection;
|
Axis _mainAxis;
|
||||||
void set scrollDirection(Axis value) {
|
void set mainAxis(Axis value) {
|
||||||
assert(value != null);
|
assert(value != null);
|
||||||
if (value == _scrollDirection)
|
if (value == _mainAxis)
|
||||||
return;
|
return;
|
||||||
assert(_offsetIsSane(_paintOffset, value));
|
assert(_offsetIsSane(_paintOffset, value));
|
||||||
_scrollDirection = value;
|
_mainAxis = value;
|
||||||
markNeedsLayout();
|
markNeedsLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,7 +198,7 @@ class RenderViewportBase extends RenderBox implements HasScrollDirection {
|
|||||||
void debugFillDescription(List<String> description) {
|
void debugFillDescription(List<String> description) {
|
||||||
super.debugFillDescription(description);
|
super.debugFillDescription(description);
|
||||||
description.add('paintOffset: $paintOffset');
|
description.add('paintOffset: $paintOffset');
|
||||||
description.add('scrollDirection: $scrollDirection');
|
description.add('mainAxis: $mainAxis');
|
||||||
description.add('scrollAnchor: $scrollAnchor');
|
description.add('scrollAnchor: $scrollAnchor');
|
||||||
if (overlayPainter != null)
|
if (overlayPainter != null)
|
||||||
description.add('overlay painter: $overlayPainter');
|
description.add('overlay painter: $overlayPainter');
|
||||||
@ -218,11 +218,11 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin<
|
|||||||
RenderViewport({
|
RenderViewport({
|
||||||
RenderBox child,
|
RenderBox child,
|
||||||
Offset paintOffset: Offset.zero,
|
Offset paintOffset: Offset.zero,
|
||||||
Axis scrollDirection: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
||||||
Painter overlayPainter,
|
Painter overlayPainter,
|
||||||
this.onPaintOffsetUpdateNeeded
|
this.onPaintOffsetUpdateNeeded
|
||||||
}) : super(paintOffset, scrollDirection, scrollAnchor, overlayPainter) {
|
}) : super(paintOffset, mainAxis, scrollAnchor, overlayPainter) {
|
||||||
this.child = child;
|
this.child = child;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ class RenderViewport extends RenderViewportBase with RenderObjectWithChildMixin<
|
|||||||
|
|
||||||
BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
|
BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
|
||||||
BoxConstraints innerConstraints;
|
BoxConstraints innerConstraints;
|
||||||
switch (scrollDirection) {
|
switch (mainAxis) {
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
innerConstraints = constraints.heightConstraints();
|
innerConstraints = constraints.heightConstraints();
|
||||||
break;
|
break;
|
||||||
@ -338,12 +338,12 @@ abstract class RenderVirtualViewport<T extends ContainerBoxParentDataMixin<Rende
|
|||||||
int virtualChildCount,
|
int virtualChildCount,
|
||||||
LayoutCallback callback,
|
LayoutCallback callback,
|
||||||
Offset paintOffset: Offset.zero,
|
Offset paintOffset: Offset.zero,
|
||||||
Axis scrollDirection: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
||||||
Painter overlayPainter
|
Painter overlayPainter
|
||||||
}) : _virtualChildCount = virtualChildCount,
|
}) : _virtualChildCount = virtualChildCount,
|
||||||
_callback = callback,
|
_callback = callback,
|
||||||
super(paintOffset, scrollDirection, scrollAnchor, overlayPainter);
|
super(paintOffset, mainAxis, scrollAnchor, overlayPainter);
|
||||||
|
|
||||||
int get virtualChildCount => _virtualChildCount;
|
int get virtualChildCount => _virtualChildCount;
|
||||||
int _virtualChildCount;
|
int _virtualChildCount;
|
||||||
|
@ -832,19 +832,19 @@ class Viewport extends OneChildRenderObjectWidget {
|
|||||||
Viewport({
|
Viewport({
|
||||||
Key key,
|
Key key,
|
||||||
this.paintOffset: Offset.zero,
|
this.paintOffset: Offset.zero,
|
||||||
this.scrollDirection: Axis.vertical,
|
this.mainAxis: Axis.vertical,
|
||||||
this.scrollAnchor: ViewportAnchor.start,
|
this.scrollAnchor: ViewportAnchor.start,
|
||||||
this.overlayPainter,
|
this.overlayPainter,
|
||||||
this.onPaintOffsetUpdateNeeded,
|
this.onPaintOffsetUpdateNeeded,
|
||||||
Widget child
|
Widget child
|
||||||
}) : super(key: key, child: child) {
|
}) : super(key: key, child: child) {
|
||||||
assert(scrollDirection != null);
|
assert(mainAxis != null);
|
||||||
assert(paintOffset != null);
|
assert(paintOffset != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The offset at which to paint the child.
|
/// The offset at which to paint the child.
|
||||||
///
|
///
|
||||||
/// The offset can be non-zero only in the [scrollDirection].
|
/// The offset can be non-zero only in the [mainAxis].
|
||||||
final Offset paintOffset;
|
final Offset paintOffset;
|
||||||
|
|
||||||
/// The direction in which the child is permitted to be larger than the viewport
|
/// The direction in which the child is permitted to be larger than the viewport
|
||||||
@ -852,7 +852,7 @@ class Viewport extends OneChildRenderObjectWidget {
|
|||||||
/// If the viewport is scrollable in a particular direction (e.g., vertically),
|
/// If the viewport is scrollable in a particular direction (e.g., vertically),
|
||||||
/// the child is given layout constraints that are fully unconstrainted in
|
/// the child is given layout constraints that are fully unconstrainted in
|
||||||
/// that direction (e.g., the child can be as tall as it wants).
|
/// that direction (e.g., the child can be as tall as it wants).
|
||||||
final Axis scrollDirection;
|
final Axis mainAxis;
|
||||||
|
|
||||||
final ViewportAnchor scrollAnchor;
|
final ViewportAnchor scrollAnchor;
|
||||||
|
|
||||||
@ -866,7 +866,7 @@ class Viewport extends OneChildRenderObjectWidget {
|
|||||||
RenderViewport createRenderObject(BuildContext context) {
|
RenderViewport createRenderObject(BuildContext context) {
|
||||||
return new RenderViewport(
|
return new RenderViewport(
|
||||||
paintOffset: paintOffset,
|
paintOffset: paintOffset,
|
||||||
scrollDirection: scrollDirection,
|
mainAxis: mainAxis,
|
||||||
scrollAnchor: scrollAnchor,
|
scrollAnchor: scrollAnchor,
|
||||||
onPaintOffsetUpdateNeeded: onPaintOffsetUpdateNeeded,
|
onPaintOffsetUpdateNeeded: onPaintOffsetUpdateNeeded,
|
||||||
overlayPainter: overlayPainter
|
overlayPainter: overlayPainter
|
||||||
@ -874,9 +874,9 @@ class Viewport extends OneChildRenderObjectWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateRenderObject(BuildContext context, RenderViewport renderObject) {
|
void updateRenderObject(BuildContext context, RenderViewport renderObject) {
|
||||||
// Order dependency: RenderViewport validates scrollOffset based on scrollDirection.
|
// Order dependency: RenderViewport validates scrollOffset based on mainAxis.
|
||||||
renderObject
|
renderObject
|
||||||
..scrollDirection = scrollDirection
|
..mainAxis = mainAxis
|
||||||
..scrollAnchor = scrollAnchor
|
..scrollAnchor = scrollAnchor
|
||||||
..paintOffset = paintOffset
|
..paintOffset = paintOffset
|
||||||
..onPaintOffsetUpdateNeeded = onPaintOffsetUpdateNeeded
|
..onPaintOffsetUpdateNeeded = onPaintOffsetUpdateNeeded
|
||||||
@ -1006,18 +1006,18 @@ class BlockBody extends MultiChildRenderObjectWidget {
|
|||||||
BlockBody({
|
BlockBody({
|
||||||
Key key,
|
Key key,
|
||||||
List<Widget> children: _emptyWidgetList,
|
List<Widget> children: _emptyWidgetList,
|
||||||
this.direction: Axis.vertical
|
this.mainAxis: Axis.vertical
|
||||||
}) : super(key: key, children: children) {
|
}) : super(key: key, children: children) {
|
||||||
assert(direction != null);
|
assert(mainAxis != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The direction to use as the main axis.
|
/// The direction to use as the main axis.
|
||||||
final Axis direction;
|
final Axis mainAxis;
|
||||||
|
|
||||||
RenderBlock createRenderObject(BuildContext context) => new RenderBlock(direction: direction);
|
RenderBlock createRenderObject(BuildContext context) => new RenderBlock(mainAxis: mainAxis);
|
||||||
|
|
||||||
void updateRenderObject(BuildContext context, RenderBlock renderObject) {
|
void updateRenderObject(BuildContext context, RenderBlock renderObject) {
|
||||||
renderObject.direction = direction;
|
renderObject.mainAxis = mainAxis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class _MixedViewportElement extends RenderObjectElement {
|
|||||||
void mount(Element parent, dynamic newSlot) {
|
void mount(Element parent, dynamic newSlot) {
|
||||||
super.mount(parent, newSlot);
|
super.mount(parent, newSlot);
|
||||||
renderObject
|
renderObject
|
||||||
..direction = widget.direction
|
..mainAxis = widget.direction
|
||||||
..callback = layout
|
..callback = layout
|
||||||
..postLayoutCallback = postLayout
|
..postLayoutCallback = postLayout
|
||||||
..totalExtentCallback = _noIntrinsicExtent
|
..totalExtentCallback = _noIntrinsicExtent
|
||||||
@ -181,7 +181,7 @@ class _MixedViewportElement extends RenderObjectElement {
|
|||||||
void update(MixedViewport newWidget) {
|
void update(MixedViewport newWidget) {
|
||||||
_ChangeDescription changes = newWidget.evaluateChangesFrom(widget);
|
_ChangeDescription changes = newWidget.evaluateChangesFrom(widget);
|
||||||
super.update(newWidget);
|
super.update(newWidget);
|
||||||
renderObject.direction = widget.direction;
|
renderObject.mainAxis = widget.direction;
|
||||||
_overrideStartOffset = null;
|
_overrideStartOffset = null;
|
||||||
if (changes == _ChangeDescription.resized)
|
if (changes == _ChangeDescription.resized)
|
||||||
_resetCache();
|
_resetCache();
|
||||||
|
@ -165,7 +165,7 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
|
|||||||
Widget buildContent(BuildContext context) {
|
Widget buildContent(BuildContext context) {
|
||||||
return new PageViewport(
|
return new PageViewport(
|
||||||
itemsWrap: config.itemsWrap,
|
itemsWrap: config.itemsWrap,
|
||||||
scrollDirection: config.scrollDirection,
|
mainAxis: config.scrollDirection,
|
||||||
scrollAnchor: config.scrollAnchor,
|
scrollAnchor: config.scrollAnchor,
|
||||||
startOffset: scrollOffset,
|
startOffset: scrollOffset,
|
||||||
overlayPainter: config.scrollableListPainter,
|
overlayPainter: config.scrollableListPainter,
|
||||||
@ -226,17 +226,17 @@ class PageableListState<T extends PageableList> extends ScrollableState<T> {
|
|||||||
class PageViewport extends VirtualViewportFromIterable {
|
class PageViewport extends VirtualViewportFromIterable {
|
||||||
PageViewport({
|
PageViewport({
|
||||||
this.startOffset: 0.0,
|
this.startOffset: 0.0,
|
||||||
this.scrollDirection: Axis.vertical,
|
this.mainAxis: Axis.vertical,
|
||||||
this.scrollAnchor: ViewportAnchor.start,
|
this.scrollAnchor: ViewportAnchor.start,
|
||||||
this.itemsWrap: false,
|
this.itemsWrap: false,
|
||||||
this.overlayPainter,
|
this.overlayPainter,
|
||||||
this.children
|
this.children
|
||||||
}) {
|
}) {
|
||||||
assert(scrollDirection != null);
|
assert(mainAxis != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
final double startOffset;
|
final double startOffset;
|
||||||
final Axis scrollDirection;
|
final Axis mainAxis;
|
||||||
final ViewportAnchor scrollAnchor;
|
final ViewportAnchor scrollAnchor;
|
||||||
final bool itemsWrap;
|
final bool itemsWrap;
|
||||||
final Painter overlayPainter;
|
final Painter overlayPainter;
|
||||||
@ -274,7 +274,7 @@ class _PageViewportElement extends VirtualViewportElement {
|
|||||||
|
|
||||||
void updateRenderObject(PageViewport oldWidget) {
|
void updateRenderObject(PageViewport oldWidget) {
|
||||||
renderObject
|
renderObject
|
||||||
..scrollDirection = widget.scrollDirection
|
..mainAxis = widget.mainAxis
|
||||||
..overlayPainter = widget.overlayPainter;
|
..overlayPainter = widget.overlayPainter;
|
||||||
super.updateRenderObject(oldWidget);
|
super.updateRenderObject(oldWidget);
|
||||||
}
|
}
|
||||||
@ -285,7 +285,7 @@ class _PageViewportElement extends VirtualViewportElement {
|
|||||||
final Size containerSize = renderObject.size;
|
final Size containerSize = renderObject.size;
|
||||||
|
|
||||||
Size materializedContentSize;
|
Size materializedContentSize;
|
||||||
switch (widget.scrollDirection) {
|
switch (widget.mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
materializedContentSize = new Size(containerSize.width, _materializedChildCount * containerSize.height);
|
materializedContentSize = new Size(containerSize.width, _materializedChildCount * containerSize.height);
|
||||||
break;
|
break;
|
||||||
@ -299,7 +299,7 @@ class _PageViewportElement extends VirtualViewportElement {
|
|||||||
void layout(BoxConstraints constraints) {
|
void layout(BoxConstraints constraints) {
|
||||||
final int length = renderObject.virtualChildCount;
|
final int length = renderObject.virtualChildCount;
|
||||||
|
|
||||||
switch (widget.scrollDirection) {
|
switch (widget.mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
_containerExtent = renderObject.size.height;
|
_containerExtent = renderObject.size.height;
|
||||||
break;
|
break;
|
||||||
|
@ -8,7 +8,7 @@ import 'dart:ui' as ui show window;
|
|||||||
|
|
||||||
import 'package:newton/newton.dart';
|
import 'package:newton/newton.dart';
|
||||||
import 'package:flutter/gestures.dart';
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/rendering.dart' show HasScrollDirection;
|
import 'package:flutter/rendering.dart' show HasMainAxis;
|
||||||
|
|
||||||
import 'basic.dart';
|
import 'basic.dart';
|
||||||
import 'framework.dart';
|
import 'framework.dart';
|
||||||
@ -657,7 +657,7 @@ class _ScrollableViewportState extends ScrollableState<ScrollableViewport> {
|
|||||||
Widget buildContent(BuildContext context) {
|
Widget buildContent(BuildContext context) {
|
||||||
return new Viewport(
|
return new Viewport(
|
||||||
paintOffset: scrollOffsetToPixelDelta(scrollOffset),
|
paintOffset: scrollOffsetToPixelDelta(scrollOffset),
|
||||||
scrollDirection: config.scrollDirection,
|
mainAxis: config.scrollDirection,
|
||||||
scrollAnchor: config.scrollAnchor,
|
scrollAnchor: config.scrollAnchor,
|
||||||
onPaintOffsetUpdateNeeded: _handlePaintOffsetUpdateNeeded,
|
onPaintOffsetUpdateNeeded: _handlePaintOffsetUpdateNeeded,
|
||||||
child: config.child
|
child: config.child
|
||||||
@ -692,7 +692,7 @@ class Block extends StatelessComponent {
|
|||||||
final Key scrollableKey;
|
final Key scrollableKey;
|
||||||
|
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
Widget contents = new BlockBody(children: children, direction: scrollDirection);
|
Widget contents = new BlockBody(children: children, mainAxis: scrollDirection);
|
||||||
if (padding != null)
|
if (padding != null)
|
||||||
contents = new Padding(padding: padding, child: contents);
|
contents = new Padding(padding: padding, child: contents);
|
||||||
return new ScrollableViewport(
|
return new ScrollableViewport(
|
||||||
@ -709,15 +709,15 @@ class Block extends StatelessComponent {
|
|||||||
abstract class ScrollableListPainter extends Painter {
|
abstract class ScrollableListPainter extends Painter {
|
||||||
void attach(RenderObject renderObject) {
|
void attach(RenderObject renderObject) {
|
||||||
assert(renderObject is RenderBox);
|
assert(renderObject is RenderBox);
|
||||||
assert(renderObject is HasScrollDirection);
|
assert(renderObject is HasMainAxis);
|
||||||
super.attach(renderObject);
|
super.attach(renderObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderBox get renderObject => super.renderObject;
|
RenderBox get renderObject => super.renderObject;
|
||||||
|
|
||||||
Axis get scrollDirection {
|
Axis get scrollDirection {
|
||||||
HasScrollDirection scrollable = renderObject as dynamic;
|
HasMainAxis scrollable = renderObject as dynamic;
|
||||||
return scrollable?.scrollDirection;
|
return scrollable?.mainAxis;
|
||||||
}
|
}
|
||||||
|
|
||||||
Size get viewportSize => renderObject.size;
|
Size get viewportSize => renderObject.size;
|
||||||
|
@ -77,8 +77,8 @@ class GridViewport extends VirtualViewportFromIterable {
|
|||||||
final ExtentsChangedCallback onExtentsChanged;
|
final ExtentsChangedCallback onExtentsChanged;
|
||||||
final Iterable<Widget> children;
|
final Iterable<Widget> children;
|
||||||
|
|
||||||
// TODO(abarth): Support horizontal scrolling;
|
// TODO(abarth): Support horizontal grids.
|
||||||
Axis get scrollDirection => Axis.vertical;
|
Axis get mainAxis => Axis.vertical;
|
||||||
|
|
||||||
RenderGrid createRenderObject(BuildContext context) => new RenderGrid(delegate: delegate);
|
RenderGrid createRenderObject(BuildContext context) => new RenderGrid(delegate: delegate);
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ class _ScrollableListState extends ScrollableState<ScrollableList> {
|
|||||||
return new ListViewport(
|
return new ListViewport(
|
||||||
onExtentsChanged: _handleExtentsChanged,
|
onExtentsChanged: _handleExtentsChanged,
|
||||||
scrollOffset: scrollOffset,
|
scrollOffset: scrollOffset,
|
||||||
scrollDirection: config.scrollDirection,
|
mainAxis: config.scrollDirection,
|
||||||
scrollAnchor: config.scrollAnchor,
|
scrollAnchor: config.scrollAnchor,
|
||||||
itemExtent: config.itemExtent,
|
itemExtent: config.itemExtent,
|
||||||
itemsWrap: config.itemsWrap,
|
itemsWrap: config.itemsWrap,
|
||||||
@ -93,20 +93,20 @@ class _VirtualListViewport extends VirtualViewport {
|
|||||||
_VirtualListViewport(
|
_VirtualListViewport(
|
||||||
this.onExtentsChanged,
|
this.onExtentsChanged,
|
||||||
this.scrollOffset,
|
this.scrollOffset,
|
||||||
this.scrollDirection,
|
this.mainAxis,
|
||||||
this.scrollAnchor,
|
this.scrollAnchor,
|
||||||
this.itemExtent,
|
this.itemExtent,
|
||||||
this.itemsWrap,
|
this.itemsWrap,
|
||||||
this.padding,
|
this.padding,
|
||||||
this.overlayPainter
|
this.overlayPainter
|
||||||
) {
|
) {
|
||||||
assert(scrollDirection != null);
|
assert(mainAxis != null);
|
||||||
assert(itemExtent != null);
|
assert(itemExtent != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
final ExtentsChangedCallback onExtentsChanged;
|
final ExtentsChangedCallback onExtentsChanged;
|
||||||
final double scrollOffset;
|
final double scrollOffset;
|
||||||
final Axis scrollDirection;
|
final Axis mainAxis;
|
||||||
final ViewportAnchor scrollAnchor;
|
final ViewportAnchor scrollAnchor;
|
||||||
final double itemExtent;
|
final double itemExtent;
|
||||||
final bool itemsWrap;
|
final bool itemsWrap;
|
||||||
@ -114,7 +114,7 @@ class _VirtualListViewport extends VirtualViewport {
|
|||||||
final Painter overlayPainter;
|
final Painter overlayPainter;
|
||||||
|
|
||||||
double get _leadingPadding {
|
double get _leadingPadding {
|
||||||
switch (scrollDirection) {
|
switch (mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
switch (scrollAnchor) {
|
switch (scrollAnchor) {
|
||||||
case ViewportAnchor.start:
|
case ViewportAnchor.start:
|
||||||
@ -166,7 +166,7 @@ class _VirtualListViewportElement extends VirtualViewportElement {
|
|||||||
|
|
||||||
void updateRenderObject(_VirtualListViewport oldWidget) {
|
void updateRenderObject(_VirtualListViewport oldWidget) {
|
||||||
renderObject
|
renderObject
|
||||||
..scrollDirection = widget.scrollDirection
|
..mainAxis = widget.mainAxis
|
||||||
..scrollAnchor = widget.scrollAnchor
|
..scrollAnchor = widget.scrollAnchor
|
||||||
..itemExtent = widget.itemExtent
|
..itemExtent = widget.itemExtent
|
||||||
..padding = widget.padding
|
..padding = widget.padding
|
||||||
@ -186,7 +186,7 @@ class _VirtualListViewportElement extends VirtualViewportElement {
|
|||||||
double containerExtent;
|
double containerExtent;
|
||||||
double contentExtent;
|
double contentExtent;
|
||||||
|
|
||||||
switch (widget.scrollDirection) {
|
switch (widget.mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
containerExtent = containerSize.height;
|
containerExtent = containerSize.height;
|
||||||
contentExtent = length == null ? double.INFINITY : widget.itemExtent * length + padding.vertical;
|
contentExtent = length == null ? double.INFINITY : widget.itemExtent * length + padding.vertical;
|
||||||
@ -222,7 +222,7 @@ class _VirtualListViewportElement extends VirtualViewportElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Size materializedContentSize;
|
Size materializedContentSize;
|
||||||
switch (widget.scrollDirection) {
|
switch (widget.mainAxis) {
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
materializedContentSize = new Size(containerSize.width, _materializedChildCount * itemExtent);
|
materializedContentSize = new Size(containerSize.width, _materializedChildCount * itemExtent);
|
||||||
break;
|
break;
|
||||||
@ -246,7 +246,7 @@ class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable
|
|||||||
ListViewport({
|
ListViewport({
|
||||||
ExtentsChangedCallback onExtentsChanged,
|
ExtentsChangedCallback onExtentsChanged,
|
||||||
double scrollOffset: 0.0,
|
double scrollOffset: 0.0,
|
||||||
Axis scrollDirection: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
||||||
double itemExtent,
|
double itemExtent,
|
||||||
bool itemsWrap: false,
|
bool itemsWrap: false,
|
||||||
@ -256,7 +256,7 @@ class ListViewport extends _VirtualListViewport with VirtualViewportFromIterable
|
|||||||
}) : super(
|
}) : super(
|
||||||
onExtentsChanged,
|
onExtentsChanged,
|
||||||
scrollOffset,
|
scrollOffset,
|
||||||
scrollDirection,
|
mainAxis,
|
||||||
scrollAnchor,
|
scrollAnchor,
|
||||||
itemExtent,
|
itemExtent,
|
||||||
itemsWrap,
|
itemsWrap,
|
||||||
@ -341,7 +341,7 @@ class _ScrollableLazyListState extends ScrollableState<ScrollableLazyList> {
|
|||||||
return new LazyListViewport(
|
return new LazyListViewport(
|
||||||
onExtentsChanged: _handleExtentsChanged,
|
onExtentsChanged: _handleExtentsChanged,
|
||||||
scrollOffset: scrollOffset,
|
scrollOffset: scrollOffset,
|
||||||
scrollDirection: config.scrollDirection,
|
mainAxis: config.scrollDirection,
|
||||||
scrollAnchor: config.scrollAnchor,
|
scrollAnchor: config.scrollAnchor,
|
||||||
itemExtent: config.itemExtent,
|
itemExtent: config.itemExtent,
|
||||||
itemCount: config.itemCount,
|
itemCount: config.itemCount,
|
||||||
@ -356,7 +356,7 @@ class LazyListViewport extends _VirtualListViewport with VirtualViewportFromBuil
|
|||||||
LazyListViewport({
|
LazyListViewport({
|
||||||
ExtentsChangedCallback onExtentsChanged,
|
ExtentsChangedCallback onExtentsChanged,
|
||||||
double scrollOffset: 0.0,
|
double scrollOffset: 0.0,
|
||||||
Axis scrollDirection: Axis.vertical,
|
Axis mainAxis: Axis.vertical,
|
||||||
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
ViewportAnchor scrollAnchor: ViewportAnchor.start,
|
||||||
double itemExtent,
|
double itemExtent,
|
||||||
EdgeDims padding,
|
EdgeDims padding,
|
||||||
@ -366,7 +366,7 @@ class LazyListViewport extends _VirtualListViewport with VirtualViewportFromBuil
|
|||||||
}) : super(
|
}) : super(
|
||||||
onExtentsChanged,
|
onExtentsChanged,
|
||||||
scrollOffset,
|
scrollOffset,
|
||||||
scrollDirection,
|
mainAxis,
|
||||||
scrollAnchor,
|
scrollAnchor,
|
||||||
itemExtent,
|
itemExtent,
|
||||||
false, // Don't support wrapping yet.
|
false, // Don't support wrapping yet.
|
||||||
|
@ -62,7 +62,7 @@ abstract class VirtualViewportElement extends RenderObjectElement {
|
|||||||
/// Returns a two-dimensional representation of the scroll offset, accounting
|
/// Returns a two-dimensional representation of the scroll offset, accounting
|
||||||
/// for the scroll direction and scroll anchor.
|
/// for the scroll direction and scroll anchor.
|
||||||
Offset scrollOffsetToPixelDelta(double scrollOffset) {
|
Offset scrollOffsetToPixelDelta(double scrollOffset) {
|
||||||
switch (renderObject.scrollDirection) {
|
switch (renderObject.mainAxis) {
|
||||||
case Axis.horizontal:
|
case Axis.horizontal:
|
||||||
return new Offset(scrollOffsetToPixelOffset(scrollOffset), 0.0);
|
return new Offset(scrollOffsetToPixelOffset(scrollOffset), 0.0);
|
||||||
case Axis.vertical:
|
case Axis.vertical:
|
||||||
|
@ -40,7 +40,7 @@ void main() {
|
|||||||
tester.pumpWidget(
|
tester.pumpWidget(
|
||||||
new Center(
|
new Center(
|
||||||
child: new Viewport(
|
child: new Viewport(
|
||||||
scrollDirection: Axis.horizontal,
|
mainAxis: Axis.horizontal,
|
||||||
child: new AspectRatio(
|
child: new AspectRatio(
|
||||||
aspectRatio: 2.0,
|
aspectRatio: 2.0,
|
||||||
child: new Container(
|
child: new Container(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user