Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SystemUiController] Add Dialog and custom Window support #1114

Merged
merged 1 commit into from
Apr 3, 2022

Conversation

alexvanyo
Copy link
Collaborator

@alexvanyo alexvanyo commented Apr 1, 2022

This PR adds an optional, nullable Window parameter to rememberSystemUiController.

The default value of this parameter is a multi-step fallback:

  • First, the Window will be pulled from the DialogWindowProvider (if available), which will return the Window corresponding to a Dialog managed by Compose.
  • Second, the Window will be attempted to be retrieved from the Activity (which matches current behavior).
  • Third, return null.

If both methods fail, then no Window will be available, and systemUiController will degrade in behavior (which is useful for @Preview usage).

Additionally, a specific Window can be passed directly as an argument, which is useful in cases where the default behavior will fail (for example, if a ComposeView is being used inside of a Dialog or a DialogFragment)

I added a new Dialog sample to showcase the new behavior, and the remainder of this PR's content is tests.

This fixes #1110

@alexvanyo alexvanyo marked this pull request as ready for review April 1, 2022 21:43
Copy link
Collaborator

@bentrengrove bentrengrove left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Nice work

@bentrengrove bentrengrove merged commit debccee into main Apr 3, 2022
@bentrengrove bentrengrove deleted the av/dialog-systemuicontroller branch April 3, 2022 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[System UI Controller] Support using Window from Dialog
2 participants