Skip to content

Commit ad05052

Browse files
authored
Merge pull request #1118 from square/ray/really-it-is-deprecated-for-real
Forgot to re-deprecate a couple of pre-Overlay things.
2 parents 0a14ba0 + 9b44a6a commit ad05052

File tree

14 files changed

+58
-72
lines changed

14 files changed

+58
-72
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@file:Suppress("DEPRECATION")
21
@file:OptIn(WorkflowExperimentalRuntime::class)
32

43
package com.squareup.sample.compose.hellocomposebinding
@@ -12,12 +11,15 @@ import androidx.lifecycle.ViewModel
1211
import androidx.lifecycle.viewModelScope
1312
import com.squareup.workflow1.WorkflowExperimentalRuntime
1413
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
14+
import com.squareup.workflow1.mapRendering
15+
import com.squareup.workflow1.ui.Screen
1516
import com.squareup.workflow1.ui.ViewEnvironment
1617
import com.squareup.workflow1.ui.ViewRegistry
1718
import com.squareup.workflow1.ui.WorkflowLayout
1819
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
1920
import com.squareup.workflow1.ui.compose.composeViewFactory
2021
import com.squareup.workflow1.ui.compose.withCompositionRoot
22+
import com.squareup.workflow1.ui.container.withEnvironment
2123
import com.squareup.workflow1.ui.plus
2224
import com.squareup.workflow1.ui.renderWorkflowIn
2325
import kotlinx.coroutines.flow.StateFlow
@@ -39,20 +41,19 @@ class HelloBindingActivity : AppCompatActivity() {
3941
val model: HelloBindingModel by viewModels()
4042
setContentView(
4143
WorkflowLayout(this).apply {
42-
start(
44+
take(
4345
lifecycle = lifecycle,
4446
renderings = model.renderings,
45-
environment = viewEnvironment
4647
)
4748
}
4849
)
4950
}
5051

5152
class HelloBindingModel(savedState: SavedStateHandle) : ViewModel() {
5253
@OptIn(WorkflowUiExperimentalApi::class)
53-
val renderings: StateFlow<Any> by lazy {
54+
val renderings: StateFlow<Screen> by lazy {
5455
renderWorkflowIn(
55-
workflow = HelloWorkflow,
56+
workflow = HelloWorkflow.mapRendering { it.withEnvironment(viewEnvironment) },
5657
scope = viewModelScope,
5758
savedStateHandle = savedState,
5859
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig()

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@file:Suppress("DEPRECATION")
21
@file:OptIn(WorkflowExperimentalRuntime::class)
32

43
package com.squareup.sample.compose.hellocomposeworkflow
@@ -11,6 +10,7 @@ import androidx.lifecycle.ViewModel
1110
import androidx.lifecycle.viewModelScope
1211
import com.squareup.workflow1.WorkflowExperimentalRuntime
1312
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
13+
import com.squareup.workflow1.ui.Screen
1414
import com.squareup.workflow1.ui.WorkflowLayout
1515
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
1616
import com.squareup.workflow1.ui.renderWorkflowIn
@@ -22,13 +22,13 @@ class HelloComposeWorkflowActivity : AppCompatActivity() {
2222
super.onCreate(savedInstanceState)
2323
val model: HelloComposeModel by viewModels()
2424
setContentView(
25-
WorkflowLayout(this).apply { start(lifecycle, model.renderings) }
25+
WorkflowLayout(this).apply { take(lifecycle, model.renderings) }
2626
)
2727
}
2828

2929
class HelloComposeModel(savedState: SavedStateHandle) : ViewModel() {
3030
@OptIn(WorkflowUiExperimentalApi::class)
31-
val renderings: StateFlow<Any> by lazy {
31+
val renderings: StateFlow<Screen> by lazy {
3232
renderWorkflowIn(
3333
workflow = HelloWorkflow,
3434
scope = viewModelScope,

samples/compose-samples/src/main/java/com/squareup/sample/compose/inlinerendering/InlineRenderingActivity.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@file:Suppress("DEPRECATION")
21
@file:OptIn(WorkflowExperimentalRuntime::class)
32

43
package com.squareup.sample.compose.inlinerendering
@@ -11,6 +10,7 @@ import androidx.lifecycle.ViewModel
1110
import androidx.lifecycle.viewModelScope
1211
import com.squareup.workflow1.WorkflowExperimentalRuntime
1312
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
13+
import com.squareup.workflow1.ui.Screen
1414
import com.squareup.workflow1.ui.WorkflowLayout
1515
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
1616
import com.squareup.workflow1.ui.renderWorkflowIn
@@ -26,13 +26,13 @@ class InlineRenderingActivity : AppCompatActivity() {
2626

2727
val model: HelloBindingModel by viewModels()
2828
setContentView(
29-
WorkflowLayout(this).apply { start(lifecycle, model.renderings) }
29+
WorkflowLayout(this).apply { take(lifecycle, model.renderings) }
3030
)
3131
}
3232

3333
class HelloBindingModel(savedState: SavedStateHandle) : ViewModel() {
3434
@OptIn(WorkflowUiExperimentalApi::class)
35-
val renderings: StateFlow<Any> by lazy {
35+
val renderings: StateFlow<Screen> by lazy {
3636
renderWorkflowIn(
3737
workflow = InlineRenderingWorkflow,
3838
scope = viewModelScope,

samples/compose-samples/src/main/java/com/squareup/sample/compose/nestedrenderings/LegacyRunner.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("DEPRECATION")
2-
31
package com.squareup.sample.compose.nestedrenderings
42

53
import androidx.compose.foundation.layout.fillMaxSize
@@ -25,7 +23,7 @@ class LegacyRunner(private val binding: LegacyViewBinding) : ScreenViewRunner<Le
2523
rendering: LegacyRendering,
2624
environment: ViewEnvironment
2725
) {
28-
binding.stub.update(rendering.rendering, environment)
26+
binding.stub.show(rendering.rendering, environment)
2927
}
3028

3129
companion object : ScreenViewFactory<LegacyRendering> by fromViewBinding(

samples/compose-samples/src/main/java/com/squareup/sample/compose/nestedrenderings/NestedRenderingsActivity.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@file:Suppress("DEPRECATION")
21
@file:OptIn(WorkflowExperimentalRuntime::class)
32

43
package com.squareup.sample.compose.nestedrenderings
@@ -13,11 +12,14 @@ import androidx.lifecycle.ViewModel
1312
import androidx.lifecycle.viewModelScope
1413
import com.squareup.workflow1.WorkflowExperimentalRuntime
1514
import com.squareup.workflow1.config.AndroidRuntimeConfigTools
15+
import com.squareup.workflow1.mapRendering
16+
import com.squareup.workflow1.ui.Screen
1617
import com.squareup.workflow1.ui.ViewEnvironment
1718
import com.squareup.workflow1.ui.ViewRegistry
1819
import com.squareup.workflow1.ui.WorkflowLayout
1920
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
2021
import com.squareup.workflow1.ui.compose.withCompositionRoot
22+
import com.squareup.workflow1.ui.container.withEnvironment
2123
import com.squareup.workflow1.ui.plus
2224
import com.squareup.workflow1.ui.renderWorkflowIn
2325
import kotlinx.coroutines.flow.StateFlow
@@ -44,20 +46,19 @@ class NestedRenderingsActivity : AppCompatActivity() {
4446
val model: NestedRenderingsModel by viewModels()
4547
setContentView(
4648
WorkflowLayout(this).apply {
47-
start(
49+
take(
4850
lifecycle = lifecycle,
4951
renderings = model.renderings,
50-
environment = viewEnvironment
5152
)
5253
}
5354
)
5455
}
5556

5657
class NestedRenderingsModel(savedState: SavedStateHandle) : ViewModel() {
5758
@OptIn(WorkflowUiExperimentalApi::class)
58-
val renderings: StateFlow<Any> by lazy {
59+
val renderings: StateFlow<Screen> by lazy {
5960
renderWorkflowIn(
60-
workflow = RecursiveWorkflow,
61+
workflow = RecursiveWorkflow.mapRendering { it.withEnvironment(viewEnvironment) },
6162
scope = viewModelScope,
6263
savedStateHandle = savedState,
6364
runtimeConfig = AndroidRuntimeConfigTools.getAppWorkflowRuntimeConfig()

samples/containers/hello-back-button/src/main/java/com/squareup/sample/hellobackbutton/HelloBackButtonActivity.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
@file:Suppress("DEPRECATION")
21
@file:OptIn(WorkflowUiExperimentalApi::class, WorkflowExperimentalRuntime::class)
32

43
package com.squareup.sample.hellobackbutton
@@ -17,15 +16,13 @@ import com.squareup.workflow1.ui.Screen
1716
import com.squareup.workflow1.ui.WorkflowLayout
1817
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
1918
import com.squareup.workflow1.ui.container.withRegistry
20-
import com.squareup.workflow1.ui.modal.AlertContainer
21-
import com.squareup.workflow1.ui.plus
2219
import com.squareup.workflow1.ui.renderWorkflowIn
2320
import kotlinx.coroutines.Job
2421
import kotlinx.coroutines.flow.StateFlow
2522
import kotlinx.coroutines.flow.map
2623
import kotlinx.coroutines.launch
2724

28-
private val viewRegistry = SampleContainers + AlertContainer
25+
private val viewRegistry = SampleContainers
2926

3027
class HelloBackButtonActivity : AppCompatActivity() {
3128
override fun onCreate(savedInstanceState: Bundle?) {

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/Component.kt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("DEPRECATION")
2-
31
package com.squareup.sample.dungeon
42

53
import android.content.Context.VIBRATOR_SERVICE
@@ -10,7 +8,6 @@ import com.squareup.sample.dungeon.GameSessionWorkflow.State.Loading
108
import com.squareup.sample.timemachine.shakeable.ShakeableTimeMachineLayoutRunner
119
import com.squareup.workflow1.ui.ViewRegistry
1210
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
13-
import com.squareup.workflow1.ui.modal.AlertContainer
1411
import kotlinx.coroutines.Dispatchers
1512
import kotlin.random.Random
1613
import kotlin.time.ExperimentalTime
@@ -31,7 +28,6 @@ class Component(context: AppCompatActivity) {
3128
LoadingScreenViewFactory<Loading>(R.string.loading_board),
3229
GameLayoutRunner,
3330
BoardView,
34-
AlertContainer
3531
)
3632

3733
val random = Random(System.currentTimeMillis())

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/DungeonAppWorkflow.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("DEPRECATION")
2-
31
package com.squareup.sample.dungeon
42

53
import com.squareup.sample.dungeon.DungeonAppWorkflow.Props
@@ -15,18 +13,19 @@ import com.squareup.workflow1.renderChild
1513
import com.squareup.workflow1.runningWorker
1614
import com.squareup.workflow1.ui.Screen
1715
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
18-
import com.squareup.workflow1.ui.modal.AlertContainerScreen
16+
import com.squareup.workflow1.ui.container.BodyAndOverlaysScreen
17+
import com.squareup.workflow1.ui.container.Overlay
1918

2019
@OptIn(WorkflowUiExperimentalApi::class)
2120
class DungeonAppWorkflow(
2221
private val gameSessionWorkflow: GameSessionWorkflow,
2322
private val boardLoader: BoardLoader
24-
) : StatefulWorkflow<Props, State, Nothing, AlertContainerScreen<Any>>() {
23+
) : StatefulWorkflow<Props, State, Nothing, BodyAndOverlaysScreen<Screen, Overlay>>() {
2524

2625
data class Props(val paused: Boolean = false)
2726

28-
sealed class State {
29-
object LoadingBoardList : State(), Screen
27+
sealed class State : Screen {
28+
object LoadingBoardList : State()
3029
data class ChoosingBoard(val boards: List<Pair<String, Board>>) : State()
3130
data class PlayingGame(val boardPath: BoardPath) : State()
3231
}
@@ -45,18 +44,18 @@ class DungeonAppWorkflow(
4544
renderProps: Props,
4645
renderState: State,
4746
context: RenderContext
48-
): AlertContainerScreen<Any> = when (renderState) {
47+
): BodyAndOverlaysScreen<Screen, Overlay> = when (renderState) {
4948
LoadingBoardList -> {
5049
context.runningWorker(boardLoader.loadAvailableBoards()) { displayBoards(it) }
51-
AlertContainerScreen(renderState)
50+
BodyAndOverlaysScreen(renderState)
5251
}
5352

5453
is ChoosingBoard -> {
5554
val screen = DisplayBoardsListScreen(
5655
boards = renderState.boards.map { it.second },
5756
onBoardSelected = { index -> context.actionSink.send(selectBoard(index)) }
5857
)
59-
AlertContainerScreen(screen)
58+
BodyAndOverlaysScreen(screen)
6059
}
6160

6261
is PlayingGame -> {

samples/dungeon/app/src/main/java/com/squareup/sample/dungeon/GameSessionWorkflow.kt

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("DEPRECATION")
2-
31
package com.squareup.sample.dungeon
42

53
import android.os.Vibrator
@@ -19,9 +17,10 @@ import com.squareup.workflow1.action
1917
import com.squareup.workflow1.runningWorker
2018
import com.squareup.workflow1.ui.Screen
2119
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
22-
import com.squareup.workflow1.ui.modal.AlertContainerScreen
23-
import com.squareup.workflow1.ui.modal.AlertScreen
24-
import com.squareup.workflow1.ui.modal.AlertScreen.Button.POSITIVE
20+
import com.squareup.workflow1.ui.container.AlertOverlay
21+
import com.squareup.workflow1.ui.container.AlertOverlay.Button.POSITIVE
22+
import com.squareup.workflow1.ui.container.BodyAndOverlaysScreen
23+
import com.squareup.workflow1.ui.container.Overlay
2524

2625
typealias BoardPath = String
2726

@@ -33,7 +32,7 @@ class GameSessionWorkflow(
3332
private val gameWorkflow: GameWorkflow,
3433
private val vibrator: Vibrator,
3534
private val boardLoader: BoardLoader
36-
) : StatefulWorkflow<Props, State, Nothing, AlertContainerScreen<Any>>() {
35+
) : StatefulWorkflow<Props, State, Nothing, BodyAndOverlaysScreen<Screen, Overlay>>() {
3736

3837
data class Props(
3938
val boardPath: BoardPath,
@@ -55,32 +54,32 @@ class GameSessionWorkflow(
5554
renderProps: Props,
5655
renderState: State,
5756
context: RenderContext
58-
): AlertContainerScreen<Any> = when (renderState) {
57+
): BodyAndOverlaysScreen<Screen, Overlay> = when (renderState) {
5958
Loading -> {
6059
context.runningWorker(boardLoader.loadBoard(renderProps.boardPath)) { StartRunning(it) }
61-
AlertContainerScreen(Loading)
60+
BodyAndOverlaysScreen(Loading)
6261
}
6362

6463
is Running -> {
6564
val gameInput = GameWorkflow.Props(renderState.board, paused = renderProps.paused)
6665
val gameScreen = context.renderChild(gameWorkflow, gameInput) {
6766
handleGameOutput(it, renderState.board)
6867
}
69-
AlertContainerScreen(gameScreen)
68+
BodyAndOverlaysScreen(gameScreen)
7069
}
7170

7271
is GameOver -> {
7372
val gameInput = GameWorkflow.Props(renderState.board)
7473
val gameScreen = context.renderChild(gameWorkflow, gameInput) { noAction() }
7574

76-
val gameOverDialog = AlertScreen(
75+
val gameOverDialog = AlertOverlay(
7776
buttons = mapOf(POSITIVE to "Restart"),
7877
message = "You've been eaten, try again.",
7978
cancelable = false,
8079
onEvent = { context.actionSink.send(restartGame()) }
8180
)
8281

83-
AlertContainerScreen(gameScreen, gameOverDialog)
82+
BodyAndOverlaysScreen(gameScreen, listOf(gameOverDialog))
8483
}
8584
}
8685

samples/tictactoe/app/src/main/java/com/squareup/sample/mainactivity/TicTacToeActivity.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
@file:Suppress("DEPRECATION")
2-
31
package com.squareup.sample.mainactivity
42

53
import android.os.Bundle
@@ -13,9 +11,7 @@ import com.squareup.sample.gameworkflow.TicTacToeViewFactories
1311
import com.squareup.workflow1.ui.WorkflowLayout
1412
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
1513
import com.squareup.workflow1.ui.container.withRegistry
16-
import com.squareup.workflow1.ui.modal.AlertContainer
1714
import com.squareup.workflow1.ui.plus
18-
import kotlinx.coroutines.flow.collect
1915
import kotlinx.coroutines.flow.map
2016
import kotlinx.coroutines.launch
2117
import timber.log.Timber
@@ -51,7 +47,6 @@ class TicTacToeActivity : AppCompatActivity() {
5147
private companion object {
5248
val viewRegistry = SampleContainers +
5349
AuthViewFactories +
54-
TicTacToeViewFactories +
55-
AlertContainer
50+
TicTacToeViewFactories
5651
}
5752
}

workflow-ui/container-android/src/androidTest/java/com/squareup/workflow1/ui/modal/test/ModalViewContainerLifecycleActivity.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
@file:Suppress("DEPRECATION")
2+
13
package com.squareup.workflow1.ui.modal.test
24

35
import android.view.View

workflow-ui/container-common/src/main/java/com/squareup/workflow1/ui/modal/AlertContainerScreen.kt

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// @file:Suppress("DEPRECATION")
2-
31
package com.squareup.workflow1.ui.modal
42

53
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
@@ -14,14 +12,15 @@ import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
1412
*
1513
* @param B the type of [beneathModals]
1614
*/
15+
@Suppress("DEPRECATION")
1716
@WorkflowUiExperimentalApi
18-
// @Deprecated(
19-
// "Use BodyAndModalsScreen and AlertOverlay",
20-
// ReplaceWith(
21-
// "BodyAndModalsScreen<B>(beneathModals, modals)",
22-
// "com.squareup.workflow1.ui.container.BodyAndModalsScreen"
23-
// )
24-
// )
17+
@Deprecated(
18+
"Use BodyAndModalsScreen and AlertOverlay",
19+
ReplaceWith(
20+
"BodyAndModalsScreen<B>(beneathModals, modals)",
21+
"com.squareup.workflow1.ui.container.BodyAndModalsScreen"
22+
)
23+
)
2524
public data class AlertContainerScreen<B : Any>(
2625
override val beneathModals: B,
2726
override val modals: List<AlertScreen> = emptyList()

0 commit comments

Comments
 (0)