Skip to content

Commit 8a04e34

Browse files
committed
wip: Modernize tutorial final code
Long lived branch (which I will totally rebase like mad) accumulating incremental tutorial updates. - `README.md` done - `tutorial-base` done - `Tutorial1.md` done - `tutorial-1-complete` done - `Tutorial2.md` done - `tutorial-2-complete` done - `tutorial-final` is updated (especially `WelcomeWorkflow`) and its tests pass It's time to get the Tutorial caught up with undeprecated API: - Explicit discussion of out big picture navigation story (so far 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` 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` (though it's mentioned). - 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 656491b commit 8a04e34

File tree

81 files changed

+1596
-1732
lines changed

Some content is hidden

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

81 files changed

+1596
-1732
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: 296 additions & 157 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)