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

Tutorial uses LayoutRunner instead of ScreenViewFactory #905

Open
tom-pratt opened this issue Dec 21, 2022 · 2 comments
Open

Tutorial uses LayoutRunner instead of ScreenViewFactory #905

tom-pratt opened this issue Dec 21, 2022 · 2 comments
Labels
documentation Improvements or additions to documentation tutorial Related to tutorial

Comments

@tom-pratt
Copy link
Contributor

It seems that ScreenViewFactory is preferred over LayoutRunner these days. It would also be nice if the tutorial mentioned AndroidScreen as an alternative. This would align the tutorials with info here https://square.github.io/workflow/userguide/ui-in-code/#building-views-from-screens.

@steve-the-edwards steve-the-edwards added the documentation Improvements or additions to documentation label Dec 21, 2022
@rjrjr
Copy link
Contributor

rjrjr commented Dec 21, 2022

The tutorials are indeed out of date, but ScreenViewFactory and LayoutRunner aren't analogs.

Before Screen and Overlay were introduced:

  • A ViewFactory would create a View to be driven by a LayoutRunner function to show renderings of a particular type.
  • These ViewFactory bindings had to be gathered at runtime in ViewRegistry collections.
  • AndroidViewRendering was introduced to allow a rendering to provide its ViewFactory directly, avoiding the ViewRegistry boilerplate and runtime errors.

This year, the Screen and Overlay marker types were created, along with replacements for most of the above. This was done mainly to simplify Android Dialog management. Today:

  • A ScreenViewFactory creates a View to be driven by a ScreenViewRunner function to show a particular type of Screen.
  • An OverlayDialogFactory creates a Dialog to show a particular type of Overlay. There is no Dialog analog to ScreenViewRunner.
  • AndroidScreen replaces AndroidViewRendering, and an analagous AndroidOverlay has been introduced.

Both before and after, ViewRegistry is still available to allow runtime bindings between rendering types and the view system where needed. These runtime bindings can also be used to override those implemented via AndroidScreen and the like.

There are still shortcomings with the updated Workflow UI -- redundancy and assymetry between View and Dialog support, and some inefficieny in Compose support (#546). In 2023, I'm hoping to roll out VisualFactory as a simpler, more flexible replacement for most of the above (#874).

@rjrjr
Copy link
Contributor

rjrjr commented Dec 21, 2022

tl;dr: we should indeed update the tutorials to use non-deprecated interfaces, and also to encourage the use of AndroidScreen.

@steve-the-edwards steve-the-edwards added the tutorial Related to tutorial label Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation tutorial Related to tutorial
Projects
None yet
Development

No branches or pull requests

3 participants