From 5039245587df85da21c7454132d41bf19e0678be Mon Sep 17 00:00:00 2001 From: Hans Muller Date: Wed, 4 Nov 2015 08:54:25 -0800 Subject: [PATCH] Widen the dropdown menu item InkWells --- sky/packages/sky/lib/src/material/dropdown.dart | 13 ++++++++----- sky/packages/sky/lib/src/painting/box_painter.dart | 4 ++++ 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/sky/packages/sky/lib/src/material/dropdown.dart b/sky/packages/sky/lib/src/material/dropdown.dart index d40698022e7..66a152d0dfb 100644 --- a/sky/packages/sky/lib/src/material/dropdown.dart +++ b/sky/packages/sky/lib/src/material/dropdown.dart @@ -17,7 +17,7 @@ import 'theme.dart'; const Duration _kMenuDuration = const Duration(milliseconds: 300); const double _kMenuItemHeight = 48.0; -const double _kMenuHorizontalPadding = 36.0; +const EdgeDims _kMenuHorizontalPadding = const EdgeDims.only(left: 36.0, right: 36.0); const double _kBaselineOffsetFromBottom = 20.0; const Border _kDropdownUnderline = const Border(bottom: const BorderSide(color: const Color(0xFFBDBDBD), width: 2.0)); @@ -54,7 +54,10 @@ class _DropdownMenu extends StatusTransitionComponent { performance: route.performance, opacity: opacity, child: new InkWell( - child: route.items[itemIndex], + child: new Container( + padding: _kMenuHorizontalPadding, + child: route.items[itemIndex] + ), onTap: () { Navigator.of(context).pop(route.items[itemIndex].value); } @@ -91,8 +94,8 @@ class _DropdownMenu extends StatusTransitionComponent { return new Positioned( top: menuRect.top - (route.selectedIndex * route.rect.height), - right: menuRect.right - _kMenuHorizontalPadding, - left: menuRect.left - _kMenuHorizontalPadding, + right: menuRect.right, + left: menuRect.left, child: new Focus( key: new GlobalObjectKey(route), child: new FadeTransition( @@ -196,7 +199,7 @@ class DropdownButton extends StatelessComponent { completer: completer, items: items, selectedIndex: selectedIndex, - rect: rect, + rect: _kMenuHorizontalPadding.inflateRect(rect), level: level )); completer.future.then((T newValue) { diff --git a/sky/packages/sky/lib/src/painting/box_painter.dart b/sky/packages/sky/lib/src/painting/box_painter.dart index c27e41015bf..ccf1f0bc013 100644 --- a/sky/packages/sky/lib/src/painting/box_painter.dart +++ b/sky/packages/sky/lib/src/painting/box_painter.dart @@ -51,6 +51,10 @@ class EdgeDims { /// The size that this edge dims would occupy with an empty interior. Size get collapsedSize => new Size(left + right, top + bottom); + Rect inflateRect(Rect rect) { + return new Rect.fromLTRB(rect.left - left, rect.top - top, rect.right + right, rect.bottom + bottom); + } + EdgeDims operator -(EdgeDims other) { return new EdgeDims.TRBL( top - other.top,