-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Our templates were out of date, and our `install.sh` script doesn't work any more. Replaces it with an IDE-produced zip file that the IDE is willing to import. Replaces `Layout Runner (ViewBinding)` with `Android Screen (ViewBinding)`: ```kotlin package ${PACKAGE_NAME} import com.squareup.workflow1.ui.AndroidScreen import com.squareup.workflow1.ui.ScreenViewFactory import com.squareup.workflow1.ui.ScreenViewFactory.Companion.fromViewBinding import com.squareup.workflow1.ui.ScreenViewRunner import com.squareup.workflow1.ui.ViewEnvironment import com.squareup.workflow1.ui.WorkflowUiExperimentalApi @OptIn(WorkflowUiExperimentalApi::class) data class $Name( // TODO: add properties needed to update $VIEW_BINDING_TYPE ) : AndroidScreen<$Name> { override val viewFactory: ScreenViewFactory<$Name> = fromViewBinding($VIEW_BINDING_TYPE::inflate, ::${Name}Runner) } @OptIn(WorkflowUiExperimentalApi::class) private class ${Name}Runner( private val viewBinding: $VIEW_BINDING_TYPE ) : ScreenViewRunner<$Name> { override fun showRendering( rendering: $Name, environment: ViewEnvironment ) { TODO("Update viewBinding from rendering") } } ```
- Loading branch information
Showing
14 changed files
with
127 additions
and
294 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# File Templates | ||
|
||
`workflow-file-templates.zip` can be imported into Android Studio / IntelliJ IDEA to add a few Workflow-specific file templates, via _File > Manage IDE Settings > Import Settings…_. | ||
|
||
To update the templates: | ||
|
||
* edit them in the IDE (_Settings > Editor > File and Code Templates_) | ||
* export them (_File > Manage IDE Settings > Import Settings…_), taking care to clear every checkbox except that for File Templates. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
samples/tutorial/tutorial-1-complete/src/main/java/workflow/tutorial/WelcomeScreenRunner.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package workflow.tutorial | ||
|
||
import com.squareup.workflow1.ui.LayoutRunner | ||
import com.squareup.workflow1.ui.LayoutRunner.Companion.bind | ||
import com.squareup.workflow1.ui.ViewEnvironment | ||
import com.squareup.workflow1.ui.ViewFactory | ||
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi | ||
import com.squareup.workflow1.ui.setTextChangedListener | ||
import com.squareup.workflow1.ui.updateText | ||
import workflow.tutorial.views.databinding.WelcomeViewBinding | ||
|
||
@OptIn(WorkflowUiExperimentalApi::class) | ||
class WelcomeScreenRunner( | ||
private val welcomeBinding: WelcomeViewBinding | ||
) : LayoutRunner<WelcomeScreen> { | ||
|
||
override fun showRendering( | ||
rendering: WelcomeScreen, | ||
viewEnvironment: ViewEnvironment | ||
) { | ||
// updateText and setTextChangedListener are helpers provided by the workflow library that take | ||
// care of the complexity of correctly interacting with EditTexts in a declarative manner. | ||
welcomeBinding.username.updateText(rendering.username) | ||
welcomeBinding.username.setTextChangedListener { | ||
rendering.onUsernameChanged(it.toString()) | ||
} | ||
welcomeBinding.login.setOnClickListener { rendering.onLoginTapped() } | ||
} | ||
|
||
/** | ||
* Define a [ViewFactory] that will inflate an instance of [WelcomeViewBinding] and an instance | ||
* of [WelcomeScreenRunner] when asked, then wire them up so that [showRendering] will be called | ||
* whenever the workflow emits a new [WelcomeScreen]. | ||
*/ | ||
companion object : ViewFactory<WelcomeScreen> by bind( | ||
WelcomeViewBinding::inflate, ::WelcomeScreenRunner | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 0 additions & 24 deletions
24
samples/tutorial/tutorial-final/src/main/java/workflow/tutorial/TodoEditScreenRunner.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.