Commit 1c3247f
committed
wip: Modernize tutorial final code
Long lived branch (which I will totally rebase like mad) accumulating incremental tutorial updates.
- `tutorial-final` is updated (especially `WelcomeWorkflow`) and its tests pass
- `tutorial-base` done
- `README.md` done
- `Tutorial1.md` done
- `tutorial-1-complete` done
It's time to get the Tutorial caught up with undeprecated API:
- 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` 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 will be inlined as `eventHandler {}` calls.)
When the rest of the `tutorial-N` modules have been updated I'll put this up for review.
I've mainly focussed on updating what exists, not extending its coverage further. Once this is merged I'd like to follow and do more:
- Introduce `Overlay`.
- 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 fifth step that updates `TodoListScreen`, talk about getting rid of that `RecyclerView`.
- Should also mention at the top that people can use `ComposeScreen` instead of `AndroidScreen`;
and on the `TextController` page call out `asMutableState()`1 parent 4216d38 commit 1c3247f
File tree
68 files changed
+1032
-1134
lines changed- samples/tutorial
- images
- tutorial-1-complete
- src/main
- java/workflow/tutorial
- tutorial-2-complete
- src/main/java/workflow/tutorial
- tutorial-3-complete
- src/main/java/workflow/tutorial
- tutorial-4-complete
- src/main/java/workflow/tutorial
- tutorial-base
- src/main
- tutorial-final
- src
- main
- java/workflow/tutorial
- test/java/workflow/tutorial
- tutorial-views
- src/main/res
- layout
- values
- workflow-ui/core-common/src/main/java/com/squareup/workflow1/ui
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
68 files changed
+1032
-1134
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 3 | | |
24 | 4 | | |
25 | 5 | | |
26 | | - | |
| 6 | + | |
27 | 7 | | |
28 | 8 | | |
29 | 9 | | |
| |||
33 | 13 | | |
34 | 14 | | |
35 | 15 | | |
36 | | - | |
| 16 | + | |
37 | 17 | | |
38 | 18 | | |
39 | 19 | | |
| |||
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 5 | | |
26 | 6 | | |
27 | 7 | | |
| |||
539 | 519 | | |
540 | 520 | | |
541 | 521 | | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
547 | | - | |
548 | | - | |
549 | | - | |
550 | | - | |
551 | | - | |
552 | 522 | | |
553 | 523 | | |
554 | 524 | | |
555 | | - | |
| 525 | + | |
556 | 526 | | |
557 | 527 | | |
558 | 528 | | |
559 | | - | |
560 | | - | |
| 529 | + | |
561 | 530 | | |
562 | 531 | | |
563 | 532 | | |
564 | | - | |
| 533 | + | |
565 | 534 | | |
566 | 535 | | |
567 | 536 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
| 3 | + | |
22 | 4 | | |
23 | 5 | | |
24 | 6 | | |
| |||
284 | 266 | | |
285 | 267 | | |
286 | 268 | | |
287 | | - | |
| 269 | + | |
288 | 270 | | |
289 | 271 | | |
290 | 272 | | |
291 | 273 | | |
292 | 274 | | |
293 | 275 | | |
294 | 276 | | |
295 | | - | |
| 277 | + | |
296 | 278 | | |
297 | 279 | | |
298 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 5 | | |
26 | 6 | | |
27 | 7 | | |
| |||
284 | 264 | | |
285 | 265 | | |
286 | 266 | | |
287 | | - | |
| 267 | + | |
288 | 268 | | |
289 | 269 | | |
290 | 270 | | |
291 | 271 | | |
292 | 272 | | |
293 | 273 | | |
294 | 274 | | |
295 | | - | |
| 275 | + | |
296 | 276 | | |
297 | 277 | | |
298 | 278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | 5 | | |
26 | 6 | | |
27 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | | - | |
| 27 | + | |
| 28 | + | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
| |||
Binary file not shown.
Loading
Loading
0 commit comments