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

4/4 asDialogHolderWithContent, ScreenViewHolder.startShowing #1031

Conversation

rjrjr
Copy link
Contributor

@rjrjr rjrjr commented Jun 15, 2023

Hide whitespace while reviewing this, especially in ScreenViewFactory.kt.

  1. setContent as a method name gave no clue that we were returning a new manager object, so now it's called asDialogHolderWithContent

  2. Hard coding the call to Dialog.setContent interferes with code that needs to make that call itself. We now accept a setContent: (ScreenViewHolder<C>) -> Unit lambda to do that work, which defaults to the current behavior.

  3. Decouple building and starting views. This allows us to ensure that a Dialog's content view is attached to its window before its first rendering -- before the first call to ScreenViewHolder.show. Necessary to ensure that the strictly view-tree-based AndroidX findViewTreeOnBackPressedDispatcherOwner() call works immediately. This was always the original intention, but never actually found a use case until now.

  4. Moves most of that default behavior to a public Dialog.fixBackgroundAndDimming extension function to keep it available and more self documenting (hard learned lessons in there). Pretty similar to how ScreenOverlayDialogFactory acts.

  5. Big kdoc update

@rjrjr rjrjr changed the title setContent to asDialogHolderWithContent, turnOffChrome 4/4 setContent to asDialogHolderWithContent, turnOffChrome Jun 15, 2023
@rjrjr rjrjr marked this pull request as ready for review June 15, 2023 23:26
@rjrjr rjrjr requested review from a team and zach-klippenstein as code owners June 15, 2023 23:26
@rjrjr rjrjr force-pushed the ray/4-better-method-name-and-optional-chrome-wrangling branch from 3b0b714 to ccc0bb0 Compare June 16, 2023 15:01
@steve-the-edwards
Copy link
Contributor

Btw - I don't remember seeing naming update in the deprecation warning strings. Need to add that.

@rjrjr rjrjr force-pushed the ray/3-new-back-handler branch from bb48afd to af3caaf Compare June 21, 2023 20:30
@rjrjr rjrjr force-pushed the ray/4-better-method-name-and-optional-chrome-wrangling branch from c8d713d to 10b1c37 Compare June 21, 2023 20:30
@rjrjr rjrjr changed the title 4/4 setContent to asDialogHolderWithContent, turnOffChrome 4/4 asDialogHolderWithContent, ScreenViewHolder.startShowing Jun 21, 2023
@rjrjr rjrjr force-pushed the ray/4-better-method-name-and-optional-chrome-wrangling branch 2 times, most recently from 6568f63 to eebc089 Compare June 22, 2023 00:59
@rjrjr
Copy link
Contributor Author

rjrjr commented Jun 22, 2023

@steve-the-edwards Good morning! I've smoked and canaried the heck out of this, and it's ready to go. The three upstream PRs haven't changed since you reviewed them, but this one could definitely use a new review.

Be sure to check ignore whitespace!

@rjrjr rjrjr requested a review from steve-the-edwards June 22, 2023 01:23
@rjrjr rjrjr force-pushed the ray/3-new-back-handler branch from af3caaf to eb3de9c Compare June 24, 2023 00:51
@rjrjr rjrjr force-pushed the ray/4-better-method-name-and-optional-chrome-wrangling branch from eebc089 to f686c15 Compare June 24, 2023 00:51
Copy link
Contributor

@steve-the-edwards steve-the-edwards left a comment

Choose a reason for hiding this comment

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

LGTM! 2 nits/typos.

Comment on lines +31 to +37
* +----+=============+------+
* | My| | |
* | | MyEditModal | |
* | | | |
* +----+=============+------+
* | MyTutorialScreen |
* +-------------------------+
Copy link
Contributor

Choose a reason for hiding this comment

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

😮 . ASCII diagram skills. 🔥

Comment on lines +64 to +69
* Whatever structure you settle on for your root rendering, it is important
* to render the same structure every time. If your app will ever want to show
* an [Overlay], it should always render [BodyAndOverlaysScreen], even when
* there is no [Overlay] to show. Otherwise your entire view tree will be rebuilt,
* since the view built for a `MyBodyAndBottomBarScreen` cannot be updated to show
* a [BodyAndOverlaysScreen] rendering.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice recent addition :)

1. `setContent` as a method name gave no clue that we were returning a new manager object, so now it's called `asDialogHolderWithContent`

2. Hard coding the call to `Dialog.setContent` interferes with code that needs to make that call itself. We now accept a `setContent: (ScreenViewHolder<C>) -> Unit` lambda to do that work, which defaults to the current behavior.

3. Decouple building and starting views. This allows us to ensure that a Dialog's content view is attached to its window before its first rendering -- before the first call to `ScreenViewHolder.show`. Necessary to ensure that the strictly view-tree-based AndroidX `findViewTreeOnBackPressedDispatcherOwner()` call works immediately. This was always the original intention, but never actually found a use case until now.

4. Moves most of that default behavior to a public `Dialog.fixBackgroundAndDimming` extension function to keep it available and more self documenting (hard learned lessons in there). Pretty similar to how `ScreenOverlayDialogFactory` acts.

5. Big kdoc update
@rjrjr rjrjr force-pushed the ray/4-better-method-name-and-optional-chrome-wrangling branch from f686c15 to 834da85 Compare June 26, 2023 21:40
Base automatically changed from ray/3-new-back-handler to ray/1-component-set-dialog June 26, 2023 21:41
@rjrjr rjrjr merged commit 408fafd into ray/1-component-set-dialog Jun 26, 2023
@rjrjr rjrjr deleted the ray/4-better-method-name-and-optional-chrome-wrangling branch June 26, 2023 21:41
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.

2 participants