Skip to content

Commit 471d1d7

Browse files
committed
Modernize tutorials
At long last, the Tutorial catches up with the current release. - Big picture discussion of our navigation story (see the end of Tutorial2.md) - Use `AndroidScreen` and drop `ViewRegistry` - Better, more consistent use of `BackStackScreen` - Use `View.setBackHandler` - Use `TextController` - Use `RequestContext.eventHandler` - Delete a lot of `// Exactly what the function name and the code say` comments - Hint at the existance of `ComposeWorkflow` and `Overlay` without turning this into a complete rewrite - More consistent naming, code style for actions and event handlers in `Screen` renderings - Event handler fields are named `onVerbPhrase`, like `onBackPressed` - Action names are verb phrases describing the action that is being taken, not the event that is being handled - Output names are generally in terms of the semantic event being reported to the parent, rather than describing what the parent will do Thus: ```kotlin return TodoListScreen( onRowPressed = { context.actionSink.send(reportSelection(it)) } ``` ```kotlin private fun reportSelection(index: Int) = action { // Tell our parent that a todo item was selected. setOutput(TodoSelected(index)) } ``` (Although most of these are inlined as `eventHandler("…") {}` calls.) I've mainly focussed on updating what exists, not extending its coverage further. Once this is merged I'd like to follow up and do more: - Introduce `Overlay` properly - How about move `TodoEditScreen` to a `BottomSheetDialog`? - Could be too noisy, `BottomSheetDialog` is a bastard. - If that's the case create a separate sample for it. - Introduce `Compose`. - I think the way to go is add a sixth step that updates `TodoListScreen`, talk about getting rid of that `RecyclerView`. - Could point out that the existing workflows and tests are unchangedn
1 parent 8ebab92 commit 471d1d7

File tree

91 files changed

+3026
-3250
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+3026
-3250
lines changed

samples/tutorial/README.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,9 @@
11
# Tutorial
22

3-
## Stale Docs Warning
4-
5-
**This tutorial is tied to an older version of Workflow, and relies on API that has been deprecated or deleted.**
6-
The general concepts are the same, and refactoring to the current API is straightforward,
7-
so it is still worthwhile to work through the tutorial in its current state until we find time to update it.
8-
(Track that work [here](https://github.com/square/workflow-kotlin/issues/905)
9-
and [here](https://github.com/square/workflow-kotlin/issues/884).)
10-
11-
Here's a summary of what has changed, and what replaces what:
12-
13-
- Use of `ViewRegistry` is now optional, and rare.
14-
Have your renderings implement `AndroidScreen` or `ComposeScreen` to avoid it.
15-
- The API for binding a rendering to UI code has changed as follows, and can all
16-
be avoided if you use `ComposeScreen`:
17-
- `ViewFactory<in RenderingT : Any>` is replaced by `ScreenViewFactory<in ScreenT : Screen>`.
18-
-`LayoutRunner<RenderingT : Any>` is replaced by `ScreenViewRunner<in ScreenT : Screen>`.
19-
- `LayoutRunner.bind` is replaced by `ScreenViewFactory.fromViewBinding`.
20-
- `BackStackScreen` has been moved to package `com.squareup.workflow1.ui.navigation`.
21-
- `EditText.updateText` and `EditText.setTextChangedListener` are replaced by `TextController`
22-
233
## Overview
244

255
Oh hi! Looks like you want build some software with Workflows! It's a bit different from traditional
26-
Android development, so let's go through building a simple little TODO app to get the basics down.
6+
Android development, so let's go through building a simple little To-Do app to get the basics down.
277

288
## Layout
299

@@ -33,7 +13,7 @@ To help with the setup, we have created a few helper modules:
3313

3414
- `tutorial-views`: A set of 3 views for the 3 screens we will be building, `Welcome`, `TodoList`,
3515
and `TodoEdit`.
36-
- `tutorial-base`: This is the starting point to build out the tutorial. It contains layouts that host the views from `TutorialViews` to see how they display.
16+
- `tutorial-base`: This is the starting point to build out the tutorial.
3717
- `tutorial-final`: This is an example of the completed tutorial - could be used as a reference if
3818
you get stuck.
3919

samples/tutorial/Tutorial1.md

Lines changed: 310 additions & 154 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)