Skip to content
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

BREAKING: Renames BackStackConfig.Other to CanGoBack #1214

Merged
merged 1 commit into from
Aug 1, 2024
Merged
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
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
Loading