Skip to content

Commit a778895

Browse files
authored
Merge branch 'main' into wenli/workflow-viewer
2 parents e36ca77 + 9c6504f commit a778895

File tree

79 files changed

+236
-300
lines changed

Some content is hidden

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

79 files changed

+236
-300
lines changed

RELEASING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
1. `git merge --no-ff origin/yourname/kotlin-v0.1.0`
9494
1. `git push origin gh-pages`
9595

96-
1. _Don't do this until the tutorial gets updated._ Once Maven artifacts are synced, update the workflow version used by the tutorial in
96+
1. Once Maven artifacts are synced, update the workflow version used by the tutorial in
9797
`samples/tutorial/build.gradle`.
9898

9999
### Validating Markdown

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/MaybeLoadingGatekeeperWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class MaybeLoadingGatekeeperWorkflow<T : Any>(
2727
override fun render(
2828
renderProps: Unit,
2929
renderState: IsLoading,
30-
context: RenderContext
30+
context: RenderContext<Unit, IsLoading, Unit>
3131
): MayBeLoadingScreen {
3232
context.runningWorker(isLoading.asTraceableWorker("GatekeeperLoading")) {
3333
action("GatekeeperLoading") {

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/PerformancePoemWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class PerformancePoemWorkflow(
9696
override fun render(
9797
renderProps: Poem,
9898
renderState: State,
99-
context: RenderContext
99+
context: RenderContext<Poem, State, ClosePoem>
100100
): OverviewDetailScreen<*> {
101101
if (simulatedPerfConfig.simultaneousActions > 0) {
102102
repeat(simulatedPerfConfig.simultaneousActions) { index ->

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/PerformancePoemsBrowserWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class PerformancePoemsBrowserWorkflow(
8686
override fun render(
8787
renderProps: ConfigAndPoems,
8888
renderState: State,
89-
context: RenderContext
89+
context: RenderContext<ConfigAndPoems, State, Unit>
9090
): OverviewDetailScreen<*> {
9191
when (renderState) {
9292
is Recurse -> {

benchmarks/performance-poetry/complex-poetry/src/main/java/com/squareup/benchmarks/performance/complex/poetry/PerformancePoetryActivity.kt

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.squareup.benchmarks.performance.complex.poetry
22

33
import android.content.pm.ApplicationInfo
4-
import android.os.Build
54
import android.os.Bundle
65
import android.os.Handler
76
import android.os.Looper
@@ -26,9 +25,9 @@ import com.squareup.workflow1.WorkflowInterceptor
2625
import com.squareup.workflow1.ui.Screen
2726
import com.squareup.workflow1.ui.ViewEnvironment.Companion.EMPTY
2827
import com.squareup.workflow1.ui.ViewRegistry
29-
import com.squareup.workflow1.ui.WorkflowLayout
3028
import com.squareup.workflow1.ui.renderWorkflowIn
3129
import com.squareup.workflow1.ui.withEnvironment
30+
import com.squareup.workflow1.ui.workflowContentView
3231
import kotlinx.coroutines.flow.StateFlow
3332
import kotlinx.coroutines.flow.map
3433
import kotlinx.coroutines.flow.onEach
@@ -97,13 +96,9 @@ class PerformancePoetryActivity : AppCompatActivity() {
9796
model.renderings
9897
}
9998

100-
setContentView(
101-
WorkflowLayout(this).apply {
102-
take(
103-
lifecycle,
104-
instrumentedRenderings.map { it.withEnvironment(viewEnvironment) }
105-
)
106-
}
99+
workflowContentView.take(
100+
lifecycle,
101+
instrumentedRenderings.map { it.withEnvironment(viewEnvironment) }
107102
)
108103

109104
// We can report this here as the first rendering from the Workflow is rendered synchronously.
@@ -125,7 +120,7 @@ class PerformancePoetryActivity : AppCompatActivity() {
125120
val traceMain = intent.getBooleanExtra(EXTRA_TRACE_ALL_MAIN_THREAD_MESSAGES, false)
126121
val traceSelectOnTimeout = intent.getBooleanExtra(EXTRA_TRACE_SELECT_TIMEOUTS, false)
127122
val areTracingViaMainLooperCurrently = traceMain || traceSelectOnTimeout
128-
val ableToTrace = Build.VERSION.SDK_INT != 28 && (debuggable || profileable)
123+
val ableToTrace = debuggable || profileable
129124

130125
if (areTracingViaMainLooperCurrently && ableToTrace) {
131126
// Add main message tracing to see everything happening in Perfetto.

design-docs/compose-based-workflows-design.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ A more interesting, comprehensive example that ties this in with the First Primi
282282
```kotlin
283283
class IdentityWorkflow(
284284
private val child: Workflow<Props, Output, Rendering>
285-
) : StatelessWorkflow<Props, Output, Rendering {
285+
) : StatelessWorkflow<Props, Output, Rendering> {
286286
override fun render(props: Props, context: RenderContext): Rendering {
287287
return context.renderComposable {
288288
renderWorkflow(child, props, onOutput = { output ->
@@ -379,8 +379,7 @@ public abstract class ComposeWorkflow<
379379
To implement the `Workflow` interface, we need to have a function that returns a `StatefulWorkflow` with the actual implementation. That's trivial: we just return a really simple workflow that does nothing but call `renderComposable` from above in its render method:
380380

381381
```kotlin
382-
private inner class ComposeWorkflowWrapper :
383-
StatefulWorkflow<PropsT, Unit, OutputT, RenderingT>() {
382+
inner class ComposeWorkflowWrapper : StatefulWorkflow<PropsT, Unit, OutputT, RenderingT>() {
384383

385384
override fun initialState(
386385
props: PropsT,
@@ -392,7 +391,7 @@ To implement the `Workflow` interface, we need to have a function that returns a
392391
override fun render(
393392
renderProps: PropsT,
394393
renderState: Unit,
395-
context: RenderContext
394+
context: StatefulWorkflow.RenderContext<PropsT,Unit,OutputT>
396395
): RenderingT = context.renderComposable {
397396
// Explicitly remember the output function since we know that actionSink
398397
// is stable even though Compose might not know that.

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocompose/HelloComposeWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object HelloComposeWorkflow : StatefulWorkflow<Unit, State, Nothing, HelloCompos
3232
override fun render(
3333
renderProps: Unit,
3434
renderState: State,
35-
context: RenderContext
35+
context: RenderContext<Unit, State, Nothing>
3636
): HelloComposeScreen = HelloComposeScreen(
3737
message = renderState.name,
3838
onClick = { context.actionSink.send(helloAction) }

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocomposebinding/HelloBindingActivity.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ import com.squareup.workflow1.mapRendering
1515
import com.squareup.workflow1.ui.Screen
1616
import com.squareup.workflow1.ui.ViewEnvironment
1717
import com.squareup.workflow1.ui.ViewRegistry
18-
import com.squareup.workflow1.ui.WorkflowLayout
1918
import com.squareup.workflow1.ui.compose.withComposeInteropSupport
2019
import com.squareup.workflow1.ui.plus
2120
import com.squareup.workflow1.ui.renderWorkflowIn
2221
import com.squareup.workflow1.ui.withEnvironment
22+
import com.squareup.workflow1.ui.workflowContentView
2323
import kotlinx.coroutines.flow.StateFlow
2424

2525
private val viewEnvironment =
@@ -37,13 +37,9 @@ class HelloBindingActivity : AppCompatActivity() {
3737
super.onCreate(savedInstanceState)
3838

3939
val model: HelloBindingModel by viewModels()
40-
setContentView(
41-
WorkflowLayout(this).apply {
42-
take(
43-
lifecycle = lifecycle,
44-
renderings = model.renderings,
45-
)
46-
}
40+
workflowContentView.take(
41+
lifecycle = lifecycle,
42+
renderings = model.renderings,
4743
)
4844
}
4945

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocomposebinding/HelloWorkflow.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ object HelloWorkflow : StatefulWorkflow<Unit, State, Nothing, Rendering>() {
3939
override fun render(
4040
renderProps: Unit,
4141
renderState: State,
42-
context: RenderContext
42+
context: RenderContext<Unit, State, Nothing>
4343
): Rendering {
4444
return Rendering(
4545
message = renderState.name,

samples/compose-samples/src/main/java/com/squareup/sample/compose/hellocomposeworkflow/ComposeWorkflowImpl.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ internal class ComposeWorkflowImpl<PropsT, OutputT : Any>(
5959
override fun render(
6060
renderProps: PropsT,
6161
renderState: State<PropsT, OutputT>,
62-
context: RenderContext
62+
context: RenderContext<PropsT, State<PropsT, OutputT>, OutputT>
6363
): ComposeScreen {
6464
// The first render pass needs to cache the sink. The sink is reusable, so we can just pass the
6565
// same one every time.

0 commit comments

Comments
 (0)