You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Copy file name to clipboardExpand all lines: samples/tutorial/README.md
+2-22Lines changed: 2 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,29 +1,9 @@
1
1
# Tutorial
2
2
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
-
23
3
## Overview
24
4
25
5
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.
27
7
28
8
## Layout
29
9
@@ -33,7 +13,7 @@ To help with the setup, we have created a few helper modules:
33
13
34
14
-`tutorial-views`: A set of 3 views for the 3 screens we will be building, `Welcome`, `TodoList`,
35
15
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.
37
17
-`tutorial-final`: This is an example of the completed tutorial - could be used as a reference if
0 commit comments