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

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

Issue 1237213003: Wire up popup menus to back button (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 5 years, 5 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
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_menu.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 7b4641c19044bc77cef3d4f2c52035e0cf59f2cb..2d8a0dd50e75c9ed660a4363b44c3d2e6811cd94 100644
--- a/sky/sdk/lib/widgets/popup_menu.dart
+++ b/sky/sdk/lib/widgets/popup_menu.dart
@@ -11,6 +11,7 @@ import 'package:sky/theme/colors.dart';
import 'package:sky/theme/shadows.dart';
import 'package:sky/widgets/animated_component.dart';
import 'package:sky/widgets/basic.dart';
+import 'package:sky/widgets/navigator.dart';
import 'package:sky/widgets/popup_menu_item.dart';
import 'package:sky/widgets/scrollable_viewport.dart';
@@ -37,13 +38,15 @@ class PopupMenu extends AnimatedComponent {
this.showing,
this.onStatusChanged,
this.items,
- this.level
+ this.level,
+ this.navigator
}) : super(key: key);
bool showing;
PopupMenuStatusChangedCallback onStatusChanged;
List<PopupMenuItem> items;
int level;
+ Navigator navigator;
AnimatedType<double> _opacity;
AnimatedType<double> _width;
@@ -79,6 +82,7 @@ class PopupMenu extends AnimatedComponent {
if (items.length != source.items.length)
_updateAnimationVariables();
items = source.items;
+ navigator = source.navigator;
super.syncFields(source);
}
@@ -115,14 +119,23 @@ class PopupMenu extends AnimatedComponent {
PopupMenuStatus _lastStatus;
void _checkForStateChanged() {
PopupMenuStatus status = _status;
- if (_lastStatus != null && status != _lastStatus && onStatusChanged != null)
- onStatusChanged(status);
+ if (_lastStatus != null && status != _lastStatus) {
+ if (status == PopupMenuStatus.inactive &&
+ navigator != null &&
+ navigator.currentRoute.key == this)
+ navigator.pop();
+ if (onStatusChanged != null)
+ onStatusChanged(status);
+ }
_lastStatus = status;
}
+
void _open() {
_animationList.interval = null;
_performance.play();
+ if (navigator != null)
+ navigator.pushState(this, (_) => _close());
}
void _close() {
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_menu.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698