Skip to content

Commit

Permalink
Use rememberSaveable with screen state
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmed3elshaer committed Sep 28, 2023
1 parent 89750b1 commit 95553c9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions test-app/presenter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -43,8 +43,9 @@ class TestContext(

@Composable
fun TestApp(context: TestContext) {
val screenKeyState = remember { mutableStateOf<String?>(null) }
val screenKeyState = rememberSaveable { mutableStateOf<String?>(null) }
val screenKey = screenKeyState.value
println("screenKey: $screenKey")
if (screenKey == null) {
ScreenList(screenKeyState)
} else {
Expand Down

0 comments on commit 95553c9

Please sign in to comment.