Commit c44f0a57 authored by Adam Barth's avatar Adam Barth

Merge pull request #1114 from abarth/rm_block_direction

Remove BlockDirection in favor of ScrollDirection
parents 95092bb4 76dd6228
......@@ -13,14 +13,6 @@ import 'viewport.dart';
/// Parent data for use with [RenderBlockBase].
class BlockParentData extends ContainerBoxParentDataMixin<RenderBox> { }
/// The direction in which the block should lay out.
enum BlockDirection {
/// Children are arranged horizontally, from left to right.
horizontal,
/// Children are arranged vertically, from top to bottom.
vertical
}
typedef double _ChildSizingFunction(RenderBox child, BoxConstraints constraints);
typedef double _Constrainer(double value);
......@@ -40,7 +32,7 @@ abstract class RenderBlockBase extends RenderBox
RenderBlockBase({
List<RenderBox> children,
BlockDirection direction: BlockDirection.vertical,
ScrollDirection direction: ScrollDirection.vertical,
double itemExtent,
double minExtent: 0.0
}) : _direction = direction, _itemExtent = itemExtent, _minExtent = minExtent {
......@@ -53,9 +45,9 @@ abstract class RenderBlockBase extends RenderBox
}
/// The direction to use as the main axis.
BlockDirection get direction => _direction;
BlockDirection _direction;
void set direction (BlockDirection value) {
ScrollDirection get direction => _direction;
ScrollDirection _direction;
void set direction (ScrollDirection value) {
if (_direction != value) {
_direction = value;
markNeedsLayout();
......@@ -83,10 +75,9 @@ abstract class RenderBlockBase extends RenderBox
}
/// Whether the main axis is vertical.
bool get isVertical => _direction == BlockDirection.vertical;
bool get isVertical => _direction == ScrollDirection.vertical;
// TODO(abarth): Remove BlockDirection in favor of ScrollDirection.
ScrollDirection get scrollDirection => isVertical ? ScrollDirection.vertical : ScrollDirection.horizontal;
ScrollDirection get scrollDirection => _direction;
BoxConstraints _getInnerConstraints(BoxConstraints constraints) {
if (isVertical)
......@@ -135,7 +126,7 @@ class RenderBlock extends RenderBlockBase {
RenderBlock({
List<RenderBox> children,
BlockDirection direction: BlockDirection.vertical,
ScrollDirection direction: ScrollDirection.vertical,
double itemExtent,
double minExtent: 0.0
}) : super(children: children, direction: direction, itemExtent: itemExtent, minExtent: minExtent);
......@@ -251,7 +242,7 @@ class RenderBlockViewport extends RenderBlockBase {
ExtentCallback maxCrossAxisDimensionCallback,
ExtentCallback minCrossAxisDimensionCallback,
Painter overlayPainter,
BlockDirection direction: BlockDirection.vertical,
ScrollDirection direction: ScrollDirection.vertical,
double itemExtent,
double minExtent: 0.0,
double startOffset: 0.0,
......
......@@ -11,7 +11,6 @@ import 'framework.dart';
export 'package:flutter/rendering.dart' show
BackgroundImage,
BlockDirection,
Border,
BorderSide,
BoxConstraints,
......@@ -948,13 +947,13 @@ class Container extends StatelessComponent {
class BlockBody extends MultiChildRenderObjectWidget {
BlockBody(List<Widget> children, {
Key key,
this.direction: BlockDirection.vertical
this.direction: ScrollDirection.vertical
}) : super(key: key, children: children) {
assert(direction != null);
}
/// The direction to use as the main axis.
final BlockDirection direction;
final ScrollDirection direction;
RenderBlock createRenderObject() => new RenderBlock(direction: direction);
......
......@@ -207,7 +207,7 @@ class _HomogeneousViewportElement extends _ViewportBaseElement<HomogeneousViewpo
_layoutItemCount = math.max(0, _layoutItemCount);
_updateChildren();
// Update the renderObject configuration
renderObject.direction = widget.direction == ScrollDirection.vertical ? BlockDirection.vertical : BlockDirection.horizontal;
renderObject.direction = widget.direction;
renderObject.itemExtent = widget.itemExtent;
renderObject.minExtent = getTotalExtent(null);
renderObject.startOffset = offset;
......
......@@ -509,14 +509,7 @@ class _MixedViewportElement extends RenderObjectElement<MixedViewport> {
int index = startIndex;
if (haveChildren) {
// Update the renderObject configuration
switch (widget.direction) {
case ScrollDirection.vertical:
renderObject.direction = BlockDirection.vertical;
break;
case ScrollDirection.horizontal:
renderObject.direction = BlockDirection.horizontal;
break;
}
renderObject.direction = renderObject.direction;
renderObject.startOffset = _childOffsets[index] - widget.startOffset;
// Build all the widgets we still need.
while (_childOffsets[index] < endOffset) {
......
......@@ -424,14 +424,8 @@ class Block extends StatelessComponent {
final ScrollDirection scrollDirection;
final ScrollListener onScroll;
BlockDirection get _direction {
if (scrollDirection == ScrollDirection.vertical)
return BlockDirection.vertical;
return BlockDirection.horizontal;
}
Widget build(BuildContext context) {
Widget contents = new BlockBody(children, direction: _direction);
Widget contents = new BlockBody(children, direction: scrollDirection);
if (padding != null)
contents = new Padding(padding: padding, child: contents);
return new ScrollableViewport(
......
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