Commit f6d53459 authored by Adam Barth's avatar Adam Barth

Improve the openning animation for PopupMenu

We're now doing all of the elements of the popup menu entrance animation from
the material design spec, but our timing and curves might not be exactly right
yet. I haven't started on the exit animation.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1017193004
parent d5a089fd
...@@ -10,6 +10,7 @@ import 'package:sky/framework/components/icon.dart'; ...@@ -10,6 +10,7 @@ import 'package:sky/framework/components/icon.dart';
import 'package:sky/framework/components/input.dart'; import 'package:sky/framework/components/input.dart';
import 'package:sky/framework/components/menu_divider.dart'; import 'package:sky/framework/components/menu_divider.dart';
import 'package:sky/framework/components/menu_item.dart'; import 'package:sky/framework/components/menu_item.dart';
import 'package:sky/framework/components/popup_menu.dart';
import 'package:sky/framework/fn.dart'; import 'package:sky/framework/fn.dart';
import 'package:sky/framework/theme/typography.dart' as typography; import 'package:sky/framework/theme/typography.dart' as typography;
import 'stock_data.dart'; import 'stock_data.dart';
...@@ -18,7 +19,8 @@ import 'stock_menu.dart'; ...@@ -18,7 +19,8 @@ import 'stock_menu.dart';
class StocksApp extends App { class StocksApp extends App {
DrawerController _DrawerController = new DrawerController(); DrawerController _drawerController = new DrawerController();
PopupMenuController _menuController = new PopupMenuController();
static Style _style = new Style(''' static Style _style = new Style('''
display: flex; display: flex;
...@@ -56,7 +58,7 @@ class StocksApp extends App { ...@@ -56,7 +58,7 @@ class StocksApp extends App {
void _handleMenuClick(_) { void _handleMenuClick(_) {
setState(() { setState(() {
_isShowingMenu = !_isShowingMenu; _menuController.open();
}); });
} }
...@@ -68,7 +70,7 @@ class StocksApp extends App { ...@@ -68,7 +70,7 @@ class StocksApp extends App {
Node build() { Node build() {
var drawer = new Drawer( var drawer = new Drawer(
controller: _DrawerController, controller: _drawerController,
level: 3, level: 3,
children: [ children: [
new DrawerHeader( new DrawerHeader(
...@@ -112,7 +114,7 @@ class StocksApp extends App { ...@@ -112,7 +114,7 @@ class StocksApp extends App {
new Icon(key: 'menu', style: _iconStyle, new Icon(key: 'menu', style: _iconStyle,
size: 24, size: 24,
type: 'navigation/menu_white') type: 'navigation/menu_white')
..events.listen('gesturetap', _DrawerController.toggle), ..events.listen('gesturetap', _drawerController.toggle),
new Container( new Container(
style: _titleStyle, style: _titleStyle,
children: [title] children: [title]
...@@ -143,10 +145,13 @@ class StocksApp extends App { ...@@ -143,10 +145,13 @@ class StocksApp extends App {
drawer drawer
]; ];
if (_isShowingMenu) { if (_menuController.isOpen) {
children.add(new StockMenu()..events.listen('gesturetap', (_) { children.add(new StockMenu(controller: _menuController)
..events.listen('gesturetap', (_) {
// TODO(abarth): We should close the menu when you tap away from the
// menu rather than when you tap on the menu.
setState(() { setState(() {
_isShowingMenu = false; _menuController.close();
}); });
})); }));
} }
......
...@@ -5,8 +5,6 @@ ...@@ -5,8 +5,6 @@
import 'package:sky/framework/components/popup_menu.dart'; import 'package:sky/framework/components/popup_menu.dart';
import 'package:sky/framework/fn.dart'; import 'package:sky/framework/fn.dart';
import 'package:sky/framework/theme/view-configuration.dart'; import 'package:sky/framework/theme/view-configuration.dart';
import 'stock_arrow.dart';
import 'stock_data.dart';
class StockMenu extends Component { class StockMenu extends Component {
static final Style _style = new Style(''' static final Style _style = new Style('''
...@@ -14,13 +12,16 @@ class StockMenu extends Component { ...@@ -14,13 +12,16 @@ class StockMenu extends Component {
right: 8px; right: 8px;
top: ${8 + kStatusBarHeight}px;'''); top: ${8 + kStatusBarHeight}px;''');
StockMenu({Object key}) : super(key: key); PopupMenuController controller;
StockMenu({Object key, this.controller}) : super(key: key);
Node build() { Node build() {
return new Container( return new Container(
style: _style, style: _style,
children: [ children: [
new PopupMenu( new PopupMenu(
controller: controller,
items: [ items: [
[new Text('Add stock')], [new Text('Add stock')],
[new Text('Remove stock')], [new Text('Remove stock')],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment