make searchText non-saveable and add a comment

This commit is contained in:
Helium314 2025-03-31 20:12:52 +02:00
parent 452770566c
commit 7a57f5a24f

View file

@ -33,7 +33,6 @@ import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.rotate
@ -107,9 +106,12 @@ fun <T: Any?> SearchScreen(
menu: List<Pair<String, () -> Unit>>? = null,
content: @Composable (ColumnScope.() -> Unit)? = null,
) {
var searchText by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue()) }
Column(Modifier.fillMaxSize()) {
// searchText and showSearch should have the same remember or rememberSaveable
// saveable survives orientation changes and switching between screens, but shows the
// keyboard in unexpected situations such as going back from another screen, which is rather annoying
var searchText by remember { mutableStateOf(TextFieldValue()) }
var showSearch by remember { mutableStateOf(false) }
Column(Modifier.fillMaxSize()) {
fun setShowSearch(value: Boolean) {
showSearch = value