-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Android notoriously give us no control over the z order of Dialog windows other than taking care to `show()` them in the right order, so keeping a pile of windows in sync with a list of `Overlay` rendering models is hard. We've already solved that for individual instances of `LayeredDialogSessions` (the delegate that does all of the work for `BodyAndOverlaysContainer`), but it was still a problem when you nested them, e.g. in the style of the recently introduced Nested Overlays sample. Also, the solution was kind of nasty because we would replace any out of order Dialogs with brand new ones, rather than preserving them by calling `dismiss()` and `show()`. To fix all that we introduce `internal class DialogCollator`. On each view update pass, a new `DialogCollator` instance is created by the outermost `LayeredDialogSessions` and made available to any nested instances via the `ViewEnvironment`. The shared collator collects a list of all existing `DialogSession` instances, and a set of `DialogSessionUpdate` functions to be asynchronously used to update existing instances or create new ones. Because a `DialogCollator` has complete knowledge of all the windows managed by the set of nested `LayerDialogSessions` instances it supports, it is able to ensure that inserts are supported by calling `dismiss()` / `show()` on existing windows in the sequence needed to reorder them. One important change to note: our `SavedStateRegistry` code requires that each window in a set has a unique name, which we derive by applying `Compatible.keyFor` to its defining `Overlay`. We used to append to that key an `Overlay`'s position in its `LayeredDialogSessions` list, as a poorly considered hack to simplify showing several of the same type at once. That approach conflicts with reordering. With this commit we no longer include the index value in `SavedStateRegistry` keys, meaning that each `Overlay` shown by a `LayeredDialogSession` must have a unique key -- `BackStackScreen` has long had a similar requirement. `NamedScreen` exists to simplify that kind of thing, and in particular can be used to wrap `ScreenOverlay.content` to meet the new requirement. Fixes #966
- Loading branch information
Showing
18 changed files
with
626 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<resources> | ||
<item name="button_bar_text" type="id"/> | ||
</resources> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
<resources> | ||
<string name="body">body</string> | ||
<string name="bottom">bottom</string> | ||
<string name="close">❌</string> | ||
<string name="cover_all">Cover Everything</string> | ||
<string name="cover_body">Cover Body</string> | ||
<string name="hide_bottom">Hide Bottom</string> | ||
<string name="hide_top">Hide Top</string> | ||
<string name="nuke">💣</string> | ||
<string name="reset">Reset</string> | ||
<string name="reveal_body">Reveal Body</string> | ||
<string name="show_bottom">Show Bottom Bar</string> | ||
<string name="show_top">Show Top Bar</string> | ||
<string name="app_name">Nested Overlays</string> | ||
<string name="BODY">body</string> | ||
<string name="COVER_BODY">Cover Body</string> | ||
<string name="BOTTOM">bottom</string> | ||
<string name="HIDE_BOTTOM">Hide Bottom Bar</string> | ||
<string name="SHOW_BOTTOM">Show Bottom Bar</string> | ||
<string name="HIDE_TOP">Hide Top Bar</string> | ||
<string name="SHOW_TOP">Show Top Bar</string> | ||
<string name="REVEAL_BODY">Reveal Body</string> | ||
<string name="COVER_ALL">Cover Everything</string> | ||
<string name="CLOSE">Close</string> | ||
</resources> |
Oops, something went wrong.