Merge pull request #1983 from Hixie/block-padding
Teach Block about padding.
This commit is contained in:
@@ -107,7 +107,7 @@ class _DropdownMenu extends StatusTransitionComponent {
|
||||
builder: (BuildContext context) {
|
||||
RenderBox renderBox = context.findRenderObject();
|
||||
return new CustomPaint(
|
||||
child: new ScrollableViewport(child: new Container(child: new Column(children))),
|
||||
child: new Block(children),
|
||||
onPaint: (ui.Canvas canvas, Size size) {
|
||||
double top = renderBox.globalToLocal(new Point(0.0, menuTop.value)).y;
|
||||
double bottom = renderBox.globalToLocal(new Point(0.0, menuBottom.value)).y;
|
||||
|
||||
@@ -76,14 +76,11 @@ class _PopupMenu extends StatelessComponent {
|
||||
),
|
||||
child: new IntrinsicWidth(
|
||||
stepWidth: _kMenuWidthStep,
|
||||
child: new ScrollableViewport(
|
||||
child: new Container(
|
||||
// TODO(abarth): Teach Block about padding.
|
||||
padding: const EdgeDims.symmetric(
|
||||
horizontal: _kMenuHorizontalPadding,
|
||||
vertical: _kMenuVerticalPadding
|
||||
),
|
||||
child: new BlockBody(children)
|
||||
child: new Block(
|
||||
children,
|
||||
padding: const EdgeDims.symmetric(
|
||||
horizontal: _kMenuHorizontalPadding,
|
||||
vertical: _kMenuVerticalPadding
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -382,6 +382,7 @@ class ScrollableViewportState extends ScrollableState<ScrollableViewport> {
|
||||
class Block extends StatelessComponent {
|
||||
Block(this.children, {
|
||||
Key key,
|
||||
this.padding,
|
||||
this.initialScrollOffset,
|
||||
this.scrollDirection: ScrollDirection.vertical,
|
||||
this.onScroll
|
||||
@@ -390,6 +391,7 @@ class Block extends StatelessComponent {
|
||||
}
|
||||
|
||||
final List<Widget> children;
|
||||
final EdgeDims padding;
|
||||
final double initialScrollOffset;
|
||||
final ScrollDirection scrollDirection;
|
||||
final ScrollListener onScroll;
|
||||
@@ -401,11 +403,14 @@ class Block extends StatelessComponent {
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
Widget contents = new BlockBody(children, direction: _direction);
|
||||
if (padding != null)
|
||||
contents = new Padding(padding: padding, child: contents);
|
||||
return new ScrollableViewport(
|
||||
initialScrollOffset: initialScrollOffset,
|
||||
scrollDirection: scrollDirection,
|
||||
onScroll: onScroll,
|
||||
child: new BlockBody(children, direction: _direction)
|
||||
child: contents
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user