Skip to content

Commit

Permalink
BREAKING: Renames BackStackConfig.Other to CanGoBack
Browse files Browse the repository at this point in the history
Just trying to make it easier to understand.
  • Loading branch information
rjrjr committed Aug 1, 2024
1 parent c4f52b1 commit 55d3d3f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import com.squareup.workflow1.ui.ScreenViewRunner
import com.squareup.workflow1.ui.ViewEnvironment
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.navigation.BackStackConfig
import com.squareup.workflow1.ui.navigation.BackStackConfig.Other
import com.squareup.workflow1.ui.navigation.BackStackConfig.CanGoBack
import com.squareup.workflow1.ui.navigation.setBackHandler

@OptIn(WorkflowUiExperimentalApi::class)
Expand Down Expand Up @@ -53,7 +53,7 @@ private class StanzaListLayoutRunner(view: View) : ScreenViewRunner<StanzaListSc
toolbar.title = rendering.title
toolbar.subtitle = rendering.subtitle

if (environment[BackStackConfig] == Other) {
if (environment[BackStackConfig] == CanGoBack) {
toolbar.setNavigationOnClickListener { rendering.onExit() }
toolbar.setBackHandler(rendering.onExit)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.squareup.workflow1.ui.ViewEnvironment
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.control
import com.squareup.workflow1.ui.navigation.BackStackConfig
import com.squareup.workflow1.ui.navigation.BackStackConfig.Other
import com.squareup.workflow1.ui.navigation.BackStackConfig.CanGoBack
import com.squareup.workflow1.ui.navigation.setBackHandler

@OptIn(WorkflowUiExperimentalApi::class)
Expand Down Expand Up @@ -60,7 +60,7 @@ private class Runner(
rendering.session.title.control(todoTitle)
itemListView.setRows(rendering.session.rows)

if (environment[BackStackConfig] == Other) {
if (environment[BackStackConfig] == CanGoBack) {
todoEditorToolbar.setNavigationOnClickListener { rendering.onGoBackClicked() }
root.setBackHandler(rendering.onGoBackClicked)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import com.squareup.workflow1.ui.androidx.WorkflowAndroidXSupport.stateRegistryO
import com.squareup.workflow1.ui.androidx.WorkflowLifecycleOwner
import com.squareup.workflow1.ui.canShow
import com.squareup.workflow1.ui.compatible
import com.squareup.workflow1.ui.navigation.BackStackConfig.CanGoBack
import com.squareup.workflow1.ui.navigation.BackStackConfig.First
import com.squareup.workflow1.ui.navigation.BackStackConfig.Other
import com.squareup.workflow1.ui.screen
import com.squareup.workflow1.ui.show
import com.squareup.workflow1.ui.startShowing
Expand Down Expand Up @@ -71,7 +71,7 @@ public open class BackStackContainer @JvmOverloads constructor(
) {
savedStateParentKey = keyFor(screen)

val config = if (newRendering.backStack.isEmpty()) First else Other
val config = if (newRendering.backStack.isEmpty()) First else CanGoBack
val environment = newViewEnvironment + config

val named: BackStackScreen<NamedScreen<*>> = newRendering
Expand Down
2 changes: 1 addition & 1 deletion workflow-ui/core-common/api/core-common.api
Original file line number Diff line number Diff line change
Expand Up @@ -191,10 +191,10 @@ public final class com/squareup/workflow1/ui/navigation/AlertOverlay$Event$Cance
}

public final class com/squareup/workflow1/ui/navigation/BackStackConfig : java/lang/Enum {
public static final field CanGoBack Lcom/squareup/workflow1/ui/navigation/BackStackConfig;
public static final field Companion Lcom/squareup/workflow1/ui/navigation/BackStackConfig$Companion;
public static final field First Lcom/squareup/workflow1/ui/navigation/BackStackConfig;
public static final field None Lcom/squareup/workflow1/ui/navigation/BackStackConfig;
public static final field Other Lcom/squareup/workflow1/ui/navigation/BackStackConfig;
public static fun getEntries ()Lkotlin/enums/EnumEntries;
public static fun valueOf (Ljava/lang/String;)Lcom/squareup/workflow1/ui/navigation/BackStackConfig;
public static fun values ()[Lcom/squareup/workflow1/ui/navigation/BackStackConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package com.squareup.workflow1.ui.navigation
import com.squareup.workflow1.ui.ViewEnvironment
import com.squareup.workflow1.ui.ViewEnvironmentKey
import com.squareup.workflow1.ui.WorkflowUiExperimentalApi
import com.squareup.workflow1.ui.navigation.BackStackConfig.First
import com.squareup.workflow1.ui.navigation.BackStackConfig.Other

/**
* Informs views whether they're children of a [BackStackScreen],
* and if so whether they're the [first frame][First] or [not][Other].
* and if so whether they're the
* [first frame][com.squareup.workflow1.ui.navigation.BackStackConfig.First]
* or [not][com.squareup.workflow1.ui.navigation.BackStackConfig.CanGoBack].
*/
@WorkflowUiExperimentalApi
public enum class BackStackConfig {
Expand All @@ -27,7 +27,7 @@ public enum class BackStackConfig {
* This rendering is in a [BackStackScreen] but is not the first frame.
* Useful as a hint to enable "go back" behavior.
*/
Other;
CanGoBack;

public companion object : ViewEnvironmentKey<BackStackConfig>() {
override val default: BackStackConfig = None
Expand Down

0 comments on commit 55d3d3f

Please sign in to comment.