Skip to content

Commit

Permalink
Removed ContainerRegistrationStrategy from the "core" `rememberNavi…
Browse files Browse the repository at this point in the history
…gationContainer` methods, to stop the requirement to opt-in for `AdvancedEnroApi` when using the standard `rememberNavigationContainer` APIs. This was introduced accidentally with 2.4.0.
  • Loading branch information
isaac-udy committed May 7, 2024
1 parent 95b13bd commit 43bf3b1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 18 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Changelog

## Unreleased
## 2.4.1
* Added `EnroBackConfiguration`, which can be set when creating a `NavigationController`. This controls how Enro handles back presses.
* EnroBackConfiguration.Default will use the behavior that has been standard in Enro until this point
* EnroBackConfiguration.Manual disables all back handling via Enro, and allows developers to set their own back pressed handling for individual destinations
* EnroBackConfiguration.Predictive is experimental, but adds support for predictive back gestures and animations. This is not yet fully implemented, and is not recommended for production use. Once this is stabilised, EnroBackNavigation.Default will be renamed to EnroBackNavigation.Legacy, and EnroBackNavigation.Predictive will become the default.
* Removed `ContainerRegistrationStrategy` from the "core" `rememberNavigationContainer` methods, to stop the requirement to opt-in for `AdvancedEnroApi` when using the standard `rememberNavigationContainer` APIs. This was introduced accidentally with 2.4.0.

## 2.4.0
* Updated dependency versions
Expand Down
7 changes: 6 additions & 1 deletion buildSrc/src/main/kotlin/configureAndroid.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.the
import org.gradle.kotlin.dsl.withType
import org.jetbrains.kotlin.gradle.model.KotlinAndroidExtension
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.FileInputStream
import java.util.Properties
Expand Down Expand Up @@ -76,6 +75,12 @@ private fun Project.commonAndroidConfig(
kotlinOptions {
jvmTarget = JavaVersion.VERSION_17.toString()

// We want to disable the automatic inclusion of the `dev.enro.annotations.AdvancedEnroApi` and `dev.enro.annotations.ExperimentalEnroApi`
// opt-ins when we're compiling the test application, so that we're not accidentally making changes that might break the public API by
// requiring the opt-ins.
if (path.startsWith(":tests:application")) {
return@kotlinOptions
}
freeCompilerArgs += "-Xopt-in=dev.enro.annotations.AdvancedEnroApi"
freeCompilerArgs += "-Xopt-in=dev.enro.annotations.ExperimentalEnroApi"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,6 @@ public fun rememberNavigationContainer(
interceptor: NavigationInterceptorBuilder.() -> Unit = {},
animations: NavigationAnimationOverrideBuilder.() -> Unit = {},
filter: NavigationInstructionFilter = acceptAll(),
registrationStrategy: ContainerRegistrationStrategy = remember(key) {
when(key) {
is NavigationContainerKey.Dynamic -> ContainerRegistrationStrategy.DisposeWithComposition
else -> ContainerRegistrationStrategy.DisposeWithLifecycle
}
}
): ComposableNavigationContainer {
return rememberNavigationContainer(
key = key,
Expand All @@ -46,37 +40,29 @@ public fun rememberNavigationContainer(
interceptor = interceptor,
animations = animations,
filter = filter,
registrationStrategy = registrationStrategy,
)
}

@Composable
public fun rememberNavigationContainer(
key: NavigationContainerKey = rememberSaveable { NavigationContainerKey.Dynamic() },
initialState: List<NavigationKey.SupportsPush> = emptyList(),
initialBackstack: List<NavigationKey.SupportsPush> = emptyList(),
emptyBehavior: EmptyBehavior,
interceptor: NavigationInterceptorBuilder.() -> Unit = {},
animations: NavigationAnimationOverrideBuilder.() -> Unit = {},
filter: NavigationInstructionFilter = acceptAll(),
registrationStrategy: ContainerRegistrationStrategy = remember(key) {
when(key) {
is NavigationContainerKey.Dynamic -> ContainerRegistrationStrategy.DisposeWithComposition
else -> ContainerRegistrationStrategy.DisposeWithLifecycle
}
}
): ComposableNavigationContainer {
return rememberNavigationContainer(
key = key,
initialBackstack = rememberSaveable {
initialState.map {
initialBackstack.map {
NavigationInstruction.Push(it)
}.toBackstack()
},
emptyBehavior = emptyBehavior,
interceptor = interceptor,
animations = animations,
filter = filter,
registrationStrategy = registrationStrategy,
)
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(AdvancedEnroApi::class, ExperimentalEnroApi::class)

package dev.enro.tests.application.compose.results

import androidx.compose.animation.fadeIn
Expand All @@ -22,6 +24,8 @@ import androidx.compose.ui.window.Dialog
import androidx.lifecycle.SavedStateHandle
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewmodel.compose.viewModel
import dev.enro.annotations.AdvancedEnroApi
import dev.enro.annotations.ExperimentalEnroApi
import dev.enro.annotations.NavigationDestination
import dev.enro.core.NavigationKey
import dev.enro.core.close
Expand Down

0 comments on commit 43bf3b1

Please sign in to comment.