From abb5961f5a2ffd0a91c767c8efc4ea1fd6786a10 Mon Sep 17 00:00:00 2001 From: Collin Jackson Date: Mon, 29 Jun 2015 18:02:40 -0700 Subject: [PATCH] Fix padding on Sky home screen scrollable list R=chinmaygarde@google.com, abarth Review URL: https://codereview.chromium.org/1209413006. --- sdk/home.dart | 3 ++- sdk/lib/widgets/card.dart | 2 +- sdk/lib/widgets/fixed_height_scrollable.dart | 14 +++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/sdk/home.dart b/sdk/home.dart index aad73300d9b..5cce0dfb23a 100644 --- a/sdk/home.dart +++ b/sdk/home.dart @@ -106,9 +106,10 @@ List demos = [ ]; const double kCardHeight = 120.0; +const EdgeDims kListPadding = const EdgeDims.all(4.0); class DemoList extends FixedHeightScrollable { - DemoList({ String key }) : super(key: key, itemHeight: kCardHeight) { + DemoList({ String key }) : super(key: key, itemHeight: kCardHeight, padding: kListPadding) { itemCount = demos.length; } diff --git a/sdk/lib/widgets/card.dart b/sdk/lib/widgets/card.dart index 93f67d7bb4e..6c373768631 100644 --- a/sdk/lib/widgets/card.dart +++ b/sdk/lib/widgets/card.dart @@ -27,7 +27,7 @@ class Card extends Component { Widget build() { return new Container( - margin: const EdgeDims(8.0, 8.0, 0.0, 8.0), + margin: const EdgeDims.all(4.0), child: new Material( color: materialColor, edge: MaterialEdge.card, diff --git a/sdk/lib/widgets/fixed_height_scrollable.dart b/sdk/lib/widgets/fixed_height_scrollable.dart index 18a4109540c..01ac4f9ac36 100644 --- a/sdk/lib/widgets/fixed_height_scrollable.dart +++ b/sdk/lib/widgets/fixed_height_scrollable.dart @@ -12,7 +12,9 @@ import 'scrollable.dart'; abstract class FixedHeightScrollable extends Scrollable { - FixedHeightScrollable({ String key, this.itemHeight, Color backgroundColor }) + final EdgeDims padding; + + FixedHeightScrollable({ String key, this.itemHeight, Color backgroundColor, this.padding }) : super(key: key, backgroundColor: backgroundColor) { assert(itemHeight != null); } @@ -32,7 +34,10 @@ abstract class FixedHeightScrollable extends Scrollable { void set itemCount (int value) { if (_itemCount != value) { _itemCount = value; - scrollBehavior.contentsHeight = itemHeight * _itemCount; + double contentsHeight = itemHeight * _itemCount; + if (padding != null) + contentsHeight += padding.top + padding.bottom; + scrollBehavior.contentsHeight = contentsHeight; } } @@ -76,7 +81,10 @@ abstract class FixedHeightScrollable extends Scrollable { child: new ClipRect( child: new Transform( transform: transform, - child: new Block(items) + child: new Container( + padding: padding, + child: new Block(items) + ) ) ) );