From 977ece7e55cca4efef8ea19b26b8191915ededa2 Mon Sep 17 00:00:00 2001 From: Adam Barth Date: Wed, 18 Mar 2015 11:31:07 -0700 Subject: [PATCH] Begin work on the PopupMenu entrance animation This CL also refactors how animations work, particularly for the Drawer. I've renamed DrawerAnimation to DrawerController and switched it from being an Animation to having an Animation. I've also renamed Animation to AnimatedValue to capture the idea that the class actually presents the value being animated. Finally, I've factored AnimatedValueListener out of Drawer so that it can be used by PopupMenuItem as well. Finally, I've added a scheduleBuild convienence function to Component instead of having to call setState(() {}), which has come up a couple times. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1016093002 --- examples/stocks-fn/lib/stock_app.dart | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/examples/stocks-fn/lib/stock_app.dart b/examples/stocks-fn/lib/stock_app.dart index e17c308a55c..14f2e6a741d 100644 --- a/examples/stocks-fn/lib/stock_app.dart +++ b/examples/stocks-fn/lib/stock_app.dart @@ -18,7 +18,7 @@ import 'stock_menu.dart'; class StocksApp extends App { - DrawerAnimation _drawerAnimation = new DrawerAnimation(); + DrawerController _DrawerController = new DrawerController(); static Style _style = new Style(''' display: flex; @@ -68,7 +68,7 @@ class StocksApp extends App { Node build() { var drawer = new Drawer( - animation: _drawerAnimation, + controller: _DrawerController, level: 3, children: [ new DrawerHeader( @@ -112,7 +112,7 @@ class StocksApp extends App { new Icon(key: 'menu', style: _iconStyle, size: 24, type: 'navigation/menu_white') - ..events.listen('gesturetap', _drawerAnimation.toggle), + ..events.listen('gesturetap', _DrawerController.toggle), new Container( style: _titleStyle, children: [title] @@ -143,8 +143,13 @@ class StocksApp extends App { drawer ]; - if (_isShowingMenu) - children.add(new StockMenu()); + if (_isShowingMenu) { + children.add(new StockMenu()..events.listen('gesturetap', (_) { + setState(() { + _isShowingMenu = false; + }); + })); + } return new Container(key: 'StocksApp', children: children); }