Commit 377c74f7 authored by Ian Hickson's avatar Ian Hickson

Merge pull request #538 from Hixie/overlay-route-insert-all

Provide a way to insert multiple overlays at once.
parents 2f83da25 aef60030
...@@ -66,6 +66,18 @@ class OverlayState extends State<Overlay> { ...@@ -66,6 +66,18 @@ class OverlayState extends State<Overlay> {
}); });
} }
void insertAll(Iterable<OverlayEntry> entries, { OverlayEntry above }) {
assert(above == null || (above._state == this && _entries.contains(above)));
for (OverlayEntry entry in entries) {
assert(entry._state == null);
entry._state = this;
}
setState(() {
int index = above == null ? _entries.length : _entries.indexOf(above) + 1;
_entries.insertAll(index, entries);
});
}
void _remove(OverlayEntry entry) { void _remove(OverlayEntry entry) {
setState(() { setState(() {
_entries.remove(entry); _entries.remove(entry);
......
...@@ -41,11 +41,9 @@ abstract class OverlayRoute<T> extends Route<T> { ...@@ -41,11 +41,9 @@ abstract class OverlayRoute<T> extends Route<T> {
final List<OverlayEntry> _overlayEntries = <OverlayEntry>[]; final List<OverlayEntry> _overlayEntries = <OverlayEntry>[];
void didPush(OverlayState overlay, OverlayEntry insertionPoint) { void didPush(OverlayState overlay, OverlayEntry insertionPoint) {
for (WidgetBuilder builder in builders) { for (WidgetBuilder builder in builders)
_overlayEntries.add(new OverlayEntry(builder: builder)); _overlayEntries.add(new OverlayEntry(builder: builder));
overlay?.insert(_overlayEntries.last, above: insertionPoint); overlay?.insertAll(_overlayEntries, above: insertionPoint);
insertionPoint = _overlayEntries.last;
}
} }
// Subclasses shouldn't call this if they want to delay the finished() call. // Subclasses shouldn't call this if they want to delay the finished() call.
......
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