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

Container and Wrapper interfaces, improved forWrapper() #920

Merged
merged 8 commits into from
Mar 16, 2023
Merged

Conversation

rjrjr
Copy link
Contributor

@rjrjr rjrjr commented Feb 8, 2023

Introduces the Container and Wrapper types, giving Workflow UI its first general notion of structure. Their integration with Compatibile reduces the likelihood of making the most common mistake with wrapper types (namely, forgetting to do that). And they standardize the map() function that gets implemented by wrappers more often than not.

Also updates forWrapper and toUnwrappingViewFactory to be defined in terms of Wrapper, allowing us to simplify their APIs by relying on Wrapper.content in default lambda implementations.

And while we're in the neighborhood, adds long needed prepEnvironment and prepContext function arguments that simplify transforming a ScreenViewFactory to pre-process its ViewEnvironment and Context. We use this new capability to simplify the default ScreenViewFactory implementation for EnvironmentScreen.

Closes #916

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.

😵 . I hope I managed to understand things.

@rjrjr
Copy link
Contributor Author

rjrjr commented Feb 28, 2023

Update:

  • rebases to keep up with main
  • fixes stale name in AsScreen deprecation
  • adds missing deprecation conveniences to NamedScreen, EnvironmentScreen, BackButtonScreen
  • Fixes PanelOvelay sample (it was missing its map implementation).
  • Improves kdoc in Container.kt

@rjrjr rjrjr marked this pull request as ready for review February 28, 2023 00:26
@rjrjr rjrjr requested review from a team and zach-klippenstein as code owners February 28, 2023 00:26
@rjrjr rjrjr marked this pull request as draft February 28, 2023 00:40
@rjrjr
Copy link
Contributor Author

rjrjr commented Feb 28, 2023

Update:

  • Rebases to main again
  • Fixes Tic Tac Toe sample
  • Fixes NamedScreen

God bless CI and unit tests.

@rjrjr rjrjr force-pushed the ray/container branch 2 times, most recently from db1005c to 5f65bec Compare February 28, 2023 19:44
@rjrjr rjrjr marked this pull request as ready for review February 28, 2023 20:23
@rjrjr rjrjr requested a review from a team as a code owner February 28, 2023 20:23
}

/**
* A singleton [Container] -- that is, a rendering which wraps a single rendering of type
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: "singleton" Container still throws me off as I think, oh - it makes it so that this Rendering is a Singleton; which, i get, is absurd but I need the explanation sentence anyway so why not change what we are summarizing this as?

"A frame [Container]"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

 * A [Container] rendering that wraps exactly one other rendering, its [content]. These are
 * typically used to "add value" to the [content], e.g. an
 * [EnvironmentScreen][com.squareup.workflow1.ui.container.EnvironmentScreen] that allows
 * changes to be made to the the [ViewEnvironment].

Copy link
Contributor Author

Choose a reason for hiding this comment

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

"the the" :/

@rjrjr rjrjr force-pushed the ray/container branch 2 times, most recently from ece4923 to 7cd607f Compare March 1, 2023 00:34
@rjrjr
Copy link
Contributor Author

rjrjr commented Mar 1, 2023

Addressed the last couple of issues that @steve-the-edwards raised, thanks Steve. Holding off on merging this until #944 has been vetted, maybe until it's published.

rjrjr added 2 commits March 1, 2023 09:31
Introduces the `Container` and `Wrapper` types, giving Workflow UI its first
general notion of structure. Their integration with `Compatibile` reduces the
likelihood of making the most common mistake with wrapper types (namely,
forgetting to do that). And they standardize the `map()` function that
gets implemented by wrappers more often than not.

Also updates `forWrapper` and `toUnwrappingViewFactory` to be defined in terms
of `Wrapper`, allowing us to simplify their APIs by relying on
`Wrapper.content` in default lambda implementations.

And while we're in the neighborhood, adds long needed `prepEnvironment` and
`prepContext` function arguments that simplify transforming a
`ScreenViewFactory` to pre-process its `ViewEnvironment` and `Context`. We
use this new capability to simplify the default `ScreenViewFactory`
implementation for `EnvironmentScreen`.

Closes #916
rjrjr and others added 6 commits March 10, 2023 16:09
And can demonstrate the bug where dialogs are shown out of order:

- Click _Cover Everything_
- Click _Cover Body_

The red inner dialog is shown over the outer green dialog,
but the green one should always be on top. (#966)

Also introduces `name` parameter for `BodyAndOverlaysScreen`, because they're
a nightmare to nest without it. See the kdoc for details.
- Replaces `View.getGlobalVisibleRect` calls with new, more robust `View.getScreenRect` extension

- `Dialog.setBounds` sets `FLAG_LAYOUT_IN_SCREEN` to ensure `Dialog` is really placed where we want it.
  Otherwise it may be offset by the height of the toolbar. I think we've missed this up until
  now because our other samples and prod use all have richer themes than the default codepaths
  set up.

- Default `ScreenOverlayDialogFactory` implementation disables dimming, for least confusing
  out of box behavior.

Note that these tweaks do not address #966, that's a bigger effort.
Trying to reduce Espresso flakes by being more careful and conventional about `RootMatcher` use; about targetting back button presses; and by using `recreate()` for configuration changes.
Nested overlays sample, small bug fixes
@rjrjr rjrjr enabled auto-merge March 16, 2023 17:40
@rjrjr
Copy link
Contributor Author

rjrjr commented Mar 16, 2023

I've merged #967 down into this branch, merged master into it, and have set this for auto-merge.

@rjrjr rjrjr merged commit b0a2c7c into main Mar 16, 2023
@rjrjr rjrjr deleted the ray/container branch March 16, 2023 18: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.

Yet another stab at a general wrapper / container interface
2 participants