diff --git a/app-launcher/common/src/commonMain/kotlin/io/ashdavies/playground/LauncherPresenter.kt b/app-launcher/common/src/commonMain/kotlin/io/ashdavies/playground/LauncherPresenter.kt index a333a515b..819b8d97e 100644 --- a/app-launcher/common/src/commonMain/kotlin/io/ashdavies/playground/LauncherPresenter.kt +++ b/app-launcher/common/src/commonMain/kotlin/io/ashdavies/playground/LauncherPresenter.kt @@ -38,14 +38,14 @@ internal fun LauncherPresenter(navigator: Navigator): LauncherScreen.State { } @Composable -public fun rememberSaveableBackStack(initialScreenName: String? = null): SaveableBackStack = rememberSaveableBackStack { - when (val initialScreen = initialScreenOrNull(initialScreenName)) { - is Screen -> listOf(LauncherScreen, initialScreen) - else -> listOf(LauncherScreen) - }.forEach(::push) +public fun rememberSaveableBackStack(nextScreenName: String? = null): SaveableBackStack { + return rememberSaveableBackStack(LauncherScreen) { + val nextScreen = screenOrNull(nextScreenName) + if (nextScreen != null) push(nextScreen) + } } -private fun initialScreenOrNull(name: String? = null): Screen? = name?.let { +private fun screenOrNull(name: String? = null): Screen? = name?.let { return enumValues() .firstOrNull { it.name.lowercase() == name.lowercase() } ?.screen diff --git a/app-launcher/common/src/jvmTest/kotlin/io/ashdavies/playground/LauncherPresenterTest.kt b/app-launcher/common/src/jvmTest/kotlin/io/ashdavies/playground/LauncherPresenterTest.kt index 35cd24ab8..2593df2e3 100644 --- a/app-launcher/common/src/jvmTest/kotlin/io/ashdavies/playground/LauncherPresenterTest.kt +++ b/app-launcher/common/src/jvmTest/kotlin/io/ashdavies/playground/LauncherPresenterTest.kt @@ -10,7 +10,7 @@ import kotlin.test.assertEquals internal class LauncherPresenterTest { - private val navigator = FakeNavigator() + private val navigator = FakeNavigator(LauncherScreen) @Test fun `should navigate to after party screen`() = runTest { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 0abc0e344..172eb6473 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,7 +19,7 @@ kotlinx-serialization = "1.6.2" ktor = "2.3.8" paging-compose = "3.2.0-alpha05-0.2.3" pinterest-ktlint = "0.50.0" -slack-circuit = "0.19.0" +slack-circuit = "0.19.1" [libraries] androidx-activity-compose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activity" }