Skip to content

Eliminates WorkflowUiExperimentalApi #1290

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ Workflow is:
* A corresponding testing framework that facilitates simple-to-write unit
tests for all application business logic and helps ensure correctness.

_**1.0.0-rc is ready and the core is stable. There are still experimental /**
**under construction areas of the API for UI integration however.**
These classes and functions are marked with `@WorkflowUIExperimentalApi`.
They are suitable for production use (we've been shipping them for months
at the very heart of our flagship app), but may require signature tweaks as
we iterate a bit more on Dialog management, and configuring transition effects.
If they do change, we will take care to minimize the impact via deprecation, etc._

## Using Workflows in your project

### Maven Artifacts
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import com.squareup.workflow1.StatefulWorkflow
import com.squareup.workflow1.Workflow
import com.squareup.workflow1.action
import com.squareup.workflow1.runningWorker
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import kotlinx.coroutines.flow.Flow

typealias IsLoading = Boolean

@OptIn(WorkflowUiExperimentalApi::class)
class MaybeLoadingGatekeeperWorkflow<T : Any>(
private val childWithLoading: Workflow<T, Any, OverviewDetailScreen<*>>,
private val childProps: T,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import com.squareup.workflow1.WorkflowAction
import com.squareup.workflow1.WorkflowAction.Companion.noAction
import com.squareup.workflow1.action
import com.squareup.workflow1.runningWorker
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.navigation.BackStackScreen
import com.squareup.workflow1.ui.navigation.toBackStackScreen
import kotlinx.coroutines.delay
Expand Down Expand Up @@ -94,7 +93,6 @@ class PerformancePoemWorkflow(
}
}

@OptIn(WorkflowUiExperimentalApi::class)
override fun render(
renderProps: Poem,
renderState: State,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import com.squareup.workflow1.StatefulWorkflow
import com.squareup.workflow1.WorkflowAction.Companion.noAction
import com.squareup.workflow1.action
import com.squareup.workflow1.runningWorker
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.navigation.BackStackScreen
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow
Expand Down Expand Up @@ -84,7 +83,6 @@ class PerformancePoemsBrowserWorkflow(
}
}

@OptIn(WorkflowUiExperimentalApi::class)
override fun render(
renderProps: ConfigAndPoems,
renderState: State,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ import com.squareup.sample.container.SampleContainers
import com.squareup.sample.poetry.model.Poem
import com.squareup.workflow1.RuntimeConfig
import com.squareup.workflow1.RuntimeConfigOptions.Companion.RENDER_PER_ACTION
import com.squareup.workflow1.WorkflowExperimentalRuntime
import com.squareup.workflow1.WorkflowInterceptor
import com.squareup.workflow1.ui.Screen
import com.squareup.workflow1.ui.ViewEnvironment.Companion.EMPTY
import com.squareup.workflow1.ui.ViewRegistry
import com.squareup.workflow1.ui.WorkflowLayout
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.renderWorkflowIn
import com.squareup.workflow1.ui.withEnvironment
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import timber.log.Timber

@OptIn(WorkflowUiExperimentalApi::class)
private val viewEnvironment = EMPTY + (ViewRegistry to SampleContainers)

class PerformancePoetryActivity : AppCompatActivity() {
Expand All @@ -53,7 +50,6 @@ class PerformancePoetryActivity : AppCompatActivity() {
private var selectTimeoutCount = 0
private var selectTimeoutMainThreadMessageLatch = 0

@OptIn(WorkflowUiExperimentalApi::class, WorkflowExperimentalRuntime::class)
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

Expand Down Expand Up @@ -164,7 +160,6 @@ class PerformancePoetryActivity : AppCompatActivity() {
}
}

@OptIn(WorkflowUiExperimentalApi::class)
private fun traceRenderingLatency(screen: Screen) {
// Start the trace sections for new rendering produced -> shown.
val navigationHolder = navigationInFlight
Expand Down Expand Up @@ -269,7 +264,6 @@ class PoetryModel(
interceptor: WorkflowInterceptor?,
runtimeConfig: RuntimeConfig
) : ViewModel() {
@OptIn(WorkflowUiExperimentalApi::class)
val renderings: StateFlow<Screen> by lazy {
renderWorkflowIn(
workflow = workflow,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import android.widget.FrameLayout
import com.squareup.workflow1.ui.AndroidScreen
import com.squareup.workflow1.ui.ScreenViewFactory
import com.squareup.workflow1.ui.ScreenViewHolder
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi

@OptIn(WorkflowUiExperimentalApi::class)
object BlankScreen : AndroidScreen<BlankScreen> {
override val viewFactory: ScreenViewFactory<BlankScreen>
get() = ScreenViewFactory.fromCode<BlankScreen> { _, initialEnvironment, context, container ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import com.squareup.benchmarks.performance.complex.poetry.R
import com.squareup.workflow1.ui.AndroidScreen
import com.squareup.workflow1.ui.ScreenViewFactory
import com.squareup.workflow1.ui.ScreenViewHolder
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi

@OptIn(WorkflowUiExperimentalApi::class)
object LoaderSpinner : AndroidScreen<LoaderSpinner> {
override val viewFactory =
ScreenViewFactory.fromCode<LoaderSpinner> { _, initialEnvironment, context, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,12 @@ package com.squareup.benchmarks.performance.complex.poetry.views

import com.squareup.sample.container.overviewdetail.OverviewDetailScreen
import com.squareup.sample.container.panel.ScrimScreen
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.navigation.BodyAndOverlaysScreen
import com.squareup.workflow1.ui.navigation.FullScreenModal

@OptIn(WorkflowUiExperimentalApi::class)
typealias MayBeLoadingScreen =
BodyAndOverlaysScreen<ScrimScreen<OverviewDetailScreen<*>>, FullScreenModal<LoaderSpinner>>

@OptIn(WorkflowUiExperimentalApi::class)
fun MayBeLoadingScreen(
baseScreen: OverviewDetailScreen<*>,
loaders: List<LoaderSpinner> = emptyList()
Expand Down
27 changes: 0 additions & 27 deletions fileTemplates/Layout Runner (ViewBinding).kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import com.squareup.workflow1.ui.internal.test.compose.settleForNextRendering
Expand All @@ -18,7 +17,6 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class HelloComposeTest {

private val composeRule = createAndroidComposeRule<HelloComposeActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import leakcanary.DetectLeaksAfterTestSuccess
Expand All @@ -15,7 +14,6 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class HelloBindingTest {

private val composeRule = createAndroidComposeRule<HelloBindingActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import leakcanary.DetectLeaksAfterTestSuccess
Expand All @@ -15,7 +14,6 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class HelloComposeWorkflowTest {

private val composeRule = createAndroidComposeRule<HelloComposeWorkflowActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import androidx.compose.ui.test.hasClickAction
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import com.squareup.workflow1.ui.internal.test.compose.settleForNextRendering
Expand All @@ -19,7 +18,6 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class InlineRenderingTest {

private val composeRule = createAndroidComposeRule<InlineRenderingActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import androidx.test.espresso.Espresso.pressBack
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import com.squareup.sample.compose.R
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import leakcanary.DetectLeaksAfterTestSuccess
Expand All @@ -20,7 +19,6 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class SampleLauncherTest {

private val composeRule = createAndroidComposeRule<SampleLauncherActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import leakcanary.DetectLeaksAfterTestSuccess
Expand All @@ -21,7 +20,6 @@ import org.junit.runner.RunWith
private const val ADD_BUTTON_TEXT = "Add Child"

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class NestedRenderingsTest {

private val composeRule = createAndroidComposeRule<NestedRenderingsActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import androidx.compose.ui.test.assertTextContains
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.onNodeWithText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import leakcanary.DetectLeaksAfterTestSuccess
Expand All @@ -15,7 +14,6 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class PreviewTest {

private val composeRule = createAndroidComposeRule<PreviewActivity>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTextInput
import androidx.compose.ui.test.performTextReplacement
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.internal.test.IdleAfterTestRule
import com.squareup.workflow1.ui.internal.test.IdlingDispatcherRule
import com.squareup.workflow1.ui.internal.test.compose.settleForNextRendering
Expand All @@ -22,7 +21,6 @@ import org.junit.rules.RuleChain
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
@OptIn(WorkflowUiExperimentalApi::class)
class TextInputTest {

private val composeRule = createAndroidComposeRule<TextInputActivity>()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@file:OptIn(WorkflowUiExperimentalApi::class, WorkflowExperimentalRuntime::class)
@file:OptIn(WorkflowExperimentalRuntime::class)

package com.squareup.sample.compose.hellocompose

Expand All @@ -13,21 +13,24 @@ import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import com.squareup.workflow1.WorkflowExperimentalRuntime
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
import com.squareup.workflow1.mapRendering
import com.squareup.workflow1.ui.ViewEnvironment
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.compose.WorkflowRendering
import com.squareup.workflow1.ui.compose.renderAsState
import com.squareup.workflow1.ui.compose.withComposeInteropSupport
import com.squareup.workflow1.ui.withEnvironment

private val viewEnvironment = ViewEnvironment.EMPTY.withComposeInteropSupport()

@Composable fun App() {
MaterialTheme {
val rendering by HelloComposeWorkflow.renderAsState(
props = Unit,
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig(),
onOutput = {}
)
val rendering by HelloComposeWorkflow
.mapRendering { it.withEnvironment(viewEnvironment) }
.renderAsState(
props = Unit,
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig(),
onOutput = {}
)
WorkflowRendering(
rendering,
Modifier.border(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.compose.ComposeScreen
import com.squareup.workflow1.ui.compose.tooling.Preview

@OptIn(WorkflowUiExperimentalApi::class)
data class HelloComposeScreen(
val message: String,
val onClick: () -> Unit
Expand All @@ -28,7 +26,6 @@ data class HelloComposeScreen(
}
}

@OptIn(WorkflowUiExperimentalApi::class)
@Preview(heightDp = 150, showBackground = true)
@Composable
private fun HelloPreview() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.squareup.sample.compose.hellocomposebinding.HelloWorkflow.Rendering
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.compose.ScreenComposableFactory
import com.squareup.workflow1.ui.compose.tooling.Preview

@OptIn(WorkflowUiExperimentalApi::class)
val HelloBinding = ScreenComposableFactory<Rendering> { rendering ->
Text(
rendering.message,
Expand All @@ -23,7 +21,6 @@ val HelloBinding = ScreenComposableFactory<Rendering> { rendering ->
)
}

@OptIn(WorkflowUiExperimentalApi::class)
@Preview(heightDp = 150, showBackground = true)
@Composable
fun DrawHelloRenderingPreview() {
Expand Down
Loading
Loading