perf(app): quick slide page transitions, close work after the page leaves, instant star/close/reopen
This commit is contained in:
@@ -54,7 +54,9 @@ class DetailPageHost {
|
||||
Navigator.of(context).push(route).then((_) {
|
||||
if (_route != route) return;
|
||||
_route = null;
|
||||
onClosed();
|
||||
// Rebuild what lies underneath (route, tab bar, list) once the
|
||||
// page has finished sliding away, not during its animation.
|
||||
_afterExit(route, onClosed);
|
||||
});
|
||||
});
|
||||
} else if (!selected && _route != null) {
|
||||
@@ -66,6 +68,21 @@ class DetailPageHost {
|
||||
}
|
||||
}
|
||||
|
||||
static void _afterExit(Route<void> route, VoidCallback onClosed) {
|
||||
final animation = route is ModalRoute<void> ? route.animation : null;
|
||||
if (animation == null || animation.status == AnimationStatus.dismissed) {
|
||||
onClosed();
|
||||
return;
|
||||
}
|
||||
late final AnimationStatusListener listener;
|
||||
listener = (status) {
|
||||
if (status != AnimationStatus.dismissed) return;
|
||||
animation.removeStatusListener(listener);
|
||||
onClosed();
|
||||
};
|
||||
animation.addStatusListener(listener);
|
||||
}
|
||||
|
||||
/// Removes the page with its owner.
|
||||
void dispose() {
|
||||
// The notifier is left to the page: a page still animating out keeps
|
||||
|
||||
Reference in New Issue
Block a user