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

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

Issue 1231753008: Support for anonymous state routes (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: re-upload 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_home.dart ('k') | sky/sdk/lib/widgets/navigator.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/drawer.dart
diff --git a/sky/sdk/lib/widgets/drawer.dart b/sky/sdk/lib/widgets/drawer.dart
index 44f78014cf4d38501284e39136fda329c3636d25..ccab36d4ca7d62bc6b662859df6f3bdf8e07ffa9 100644
--- a/sky/sdk/lib/widgets/drawer.dart
+++ b/sky/sdk/lib/widgets/drawer.dart
@@ -72,26 +72,24 @@ class Drawer extends AnimatedComponent {
..addListener(_checkForStateChanged);
watch(_performance);
if (showing)
- _performance.play();
+ _show();
+ }
+
+ void _show() {
+ if (navigator != null)
+ navigator.pushState(this, (_) => _performance.reverse());
+ _performance.play();
}
void syncFields(Drawer source) {
- const String kDrawerRouteName = "[open drawer]";
children = source.children;
level = source.level;
navigator = source.navigator;
if (showing != source.showing) {
showing = source.showing;
if (showing) {
- if (navigator != null) {
- navigator.pushState(kDrawerRouteName, (_) {
- onStatusChanged(DrawerStatus.inactive);
- });
- }
- _performance.play();
+ _show();
} else {
- if (navigator != null && navigator.currentRoute.name == kDrawerRouteName)
- navigator.pop();
_performance.reverse();
}
}
@@ -136,8 +134,14 @@ class Drawer extends AnimatedComponent {
DrawerStatus _lastStatus;
void _checkForStateChanged() {
DrawerStatus status = _status;
- if (_lastStatus != null && status != _lastStatus && onStatusChanged != null)
- onStatusChanged(status);
+ if (_lastStatus != null && status != _lastStatus) {
+ if (status == DrawerStatus.inactive &&
+ navigator != null &&
+ navigator.currentRoute.key == this)
+ navigator.pop();
+ if (onStatusChanged != null)
+ onStatusChanged(status);
+ }
_lastStatus = status;
}
« no previous file with comments | « sky/sdk/example/stocks/lib/stock_home.dart ('k') | sky/sdk/lib/widgets/navigator.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698