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