Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Unified Diff: sky/sdk/lib/widgets/popup_menu.dart

Issue 1215613005: Improve the padding and sizing of popup menus. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/sdk/lib/widgets/popup_menu.dart
diff --git a/sky/sdk/lib/widgets/popup_menu.dart b/sky/sdk/lib/widgets/popup_menu.dart
index 336b90280b74f956fde61e2b8a5a9fe81e5f9be2..6fdf366dc30b714aa751a5e1cb46622032552b89 100644
--- a/sky/sdk/lib/widgets/popup_menu.dart
+++ b/sky/sdk/lib/widgets/popup_menu.dart
@@ -17,6 +17,10 @@ import 'popup_menu_item.dart';
const double _kMenuOpenDuration = 300.0;
const double _kMenuCloseDuration = 200.0;
const double _kMenuCloseDelay = 100.0;
+const double _kMenuWidthStep = 56.0;
+const double _kMenuMinWidth = 1.5 * _kMenuWidthStep;
+const double _kMenuHorizontalPadding = 16.0;
+const double _kMenuVerticalPadding = 8.0;
enum MenuState { hidden, opening, open, closing }
@@ -64,7 +68,7 @@ class PopupMenu extends AnimatedComponent {
}
PopupMenuController controller;
- List<Widget> items;
+ List<PopupMenuItem> items;
int level;
void syncFields(PopupMenu source) {
@@ -95,16 +99,25 @@ class PopupMenu extends AnimatedComponent {
return new Opacity(
opacity: math.min(1.0, controller.position.value * 3.0),
- child: new ShrinkWrapWidth(
- child: new CustomPaint(
- callback: (sky.Canvas canvas, Size size) {
- double width = math.min(size.width, size.width * (0.5 + controller.position.value * 2.0));
- double height = math.min(size.height, size.height * controller.position.value * 1.5);
- _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, width, height));
- },
- child: new Container(
- padding: const EdgeDims.all(8.0),
- child: new Block(children)
+ child: new CustomPaint(
+ callback: (sky.Canvas canvas, Size size) {
+ double width = math.min(size.width, size.width * (0.5 + controller.position.value * 2.0));
+ double height = math.min(size.height, size.height * controller.position.value * 1.5);
+ _painter.paint(canvas, new Rect.fromLTRB(size.width - width, 0.0, width, height));
+ },
+ child: new ConstrainedBox(
+ constraints: new BoxConstraints(
+ minWidth: _kMenuMinWidth
+ ),
+ child: new ShrinkWrapWidth(
+ stepWidth: _kMenuWidthStep,
+ child: new Container(
+ padding: const EdgeDims.symmetric(
+ horizontal: _kMenuHorizontalPadding,
+ vertical: _kMenuVerticalPadding
+ ),
+ child: new Block(children)
+ )
)
)
)

Powered by Google App Engine
This is Rietveld 408576698