From e7c05e5781c2f98a7c9692537f7ebeccf55c36a2 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Sat, 5 Dec 2015 01:21:07 -0800 Subject: [PATCH] Popup menu splash doesn't go to edge Now the splash goes to the edge. Also, fold popup_menu_item.dart into popup_menu.dart for simplicity. Fixes #266 --- packages/flutter/lib/material.dart | 1 - .../flutter/lib/src/material/popup_menu.dart | 36 ++++++++++++++++--- .../lib/src/material/popup_menu_item.dart | 34 ------------------ 3 files changed, 31 insertions(+), 40 deletions(-) delete mode 100644 packages/flutter/lib/src/material/popup_menu_item.dart diff --git a/packages/flutter/lib/material.dart b/packages/flutter/lib/material.dart index 4300bdc8ca..fcbd9ab568 100644 --- a/packages/flutter/lib/material.dart +++ b/packages/flutter/lib/material.dart @@ -37,7 +37,6 @@ export 'src/material/material_button.dart'; export 'src/material/material_list.dart'; export 'src/material/page.dart'; export 'src/material/popup_menu.dart'; -export 'src/material/popup_menu_item.dart'; export 'src/material/progress_indicator.dart'; export 'src/material/radio.dart'; export 'src/material/raised_button.dart'; diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index 7909dc716a..ca9189550d 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -9,15 +9,42 @@ import 'package:flutter/widgets.dart'; import 'ink_well.dart'; import 'material.dart'; -import 'popup_menu_item.dart'; +import 'theme.dart'; const Duration _kMenuDuration = const Duration(milliseconds: 300); +const double _kBaselineOffsetFromBottom = 20.0; const double _kMenuCloseIntervalEnd = 2.0 / 3.0; -const double _kMenuWidthStep = 56.0; -const double _kMenuMinWidth = 2.0 * _kMenuWidthStep; -const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep; const double _kMenuHorizontalPadding = 16.0; +const double _kMenuItemHeight = 48.0; +const double _kMenuMaxWidth = 5.0 * _kMenuWidthStep; +const double _kMenuMinWidth = 2.0 * _kMenuWidthStep; const double _kMenuVerticalPadding = 8.0; +const double _kMenuWidthStep = 56.0; + +class PopupMenuItem extends StatelessComponent { + PopupMenuItem({ + Key key, + this.value, + this.child + }) : super(key: key); + + final Widget child; + final T value; + + Widget build(BuildContext context) { + return new Container( + height: _kMenuItemHeight, + padding: const EdgeDims.symmetric(horizontal: _kMenuHorizontalPadding), + child: new DefaultTextStyle( + style: Theme.of(context).text.subhead, + child: new Baseline( + baseline: _kMenuItemHeight - _kBaselineOffsetFromBottom, + child: child + ) + ) + ); + } +} class _PopupMenu extends StatelessComponent { _PopupMenu({ @@ -71,7 +98,6 @@ class _PopupMenu extends StatelessComponent { child: new Block( children, padding: const EdgeDims.symmetric( - horizontal: _kMenuHorizontalPadding, vertical: _kMenuVerticalPadding ) ) diff --git a/packages/flutter/lib/src/material/popup_menu_item.dart b/packages/flutter/lib/src/material/popup_menu_item.dart deleted file mode 100644 index 017b86f6cf..0000000000 --- a/packages/flutter/lib/src/material/popup_menu_item.dart +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'package:flutter/widgets.dart'; - -import 'theme.dart'; - -const double _kMenuItemHeight = 48.0; -const double _kBaselineOffsetFromBottom = 20.0; - -class PopupMenuItem extends StatelessComponent { - PopupMenuItem({ - Key key, - this.value, - this.child - }) : super(key: key); - - final Widget child; - final T value; - - Widget build(BuildContext context) { - return new Container( - height: _kMenuItemHeight, - child: new DefaultTextStyle( - style: Theme.of(context).text.subhead, - child: new Baseline( - baseline: _kMenuItemHeight - _kBaselineOffsetFromBottom, - child: child - ) - ) - ); - } -}