From 95553c94ecb9431583c7affad8804083a47f9d73 Mon Sep 17 00:00:00 2001 From: BraveTroubleshooter Date: Fri, 29 Sep 2023 01:56:10 +0300 Subject: [PATCH] Use rememberSaveable with screen state --- test-app/presenter/build.gradle | 1 + .../kotlin/com/example/redwood/testing/presenter/TestApp.kt | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/test-app/presenter/build.gradle b/test-app/presenter/build.gradle index 6e9e0c90b6..34f67c42c6 100644 --- a/test-app/presenter/build.gradle +++ b/test-app/presenter/build.gradle @@ -19,6 +19,7 @@ kotlin { implementation projects.testApp.schema.compose implementation projects.redwoodLazylayoutCompose implementation projects.redwoodProtocolCompose + implementation libs.jetbrains.compose.runtime.saveable implementation libs.paging.compose.common implementation libs.kotlinx.coroutines.core } diff --git a/test-app/presenter/src/commonMain/kotlin/com/example/redwood/testing/presenter/TestApp.kt b/test-app/presenter/src/commonMain/kotlin/com/example/redwood/testing/presenter/TestApp.kt index 652d7d4073..073a71a387 100644 --- a/test-app/presenter/src/commonMain/kotlin/com/example/redwood/testing/presenter/TestApp.kt +++ b/test-app/presenter/src/commonMain/kotlin/com/example/redwood/testing/presenter/TestApp.kt @@ -19,7 +19,7 @@ import androidx.compose.runtime.Composable import androidx.compose.runtime.MutableState import androidx.compose.runtime.Stable import androidx.compose.runtime.mutableStateOf -import androidx.compose.runtime.remember +import androidx.compose.runtime.saveable.rememberSaveable import app.cash.redwood.Modifier import app.cash.redwood.compose.BackHandler import app.cash.redwood.layout.api.Constraint.Companion.Fill @@ -43,8 +43,9 @@ class TestContext( @Composable fun TestApp(context: TestContext) { - val screenKeyState = remember { mutableStateOf(null) } + val screenKeyState = rememberSaveable { mutableStateOf(null) } val screenKey = screenKeyState.value + println("screenKey: $screenKey") if (screenKey == null) { ScreenList(screenKeyState) } else {