mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-04 05:40:17 +00:00
slightly improve weird behavior
This commit is contained in:
parent
9bb087b422
commit
cb08d32d14
2 changed files with 5 additions and 2 deletions
|
@ -113,6 +113,7 @@ fun <T: Any> SearchScreen(
|
||||||
) {
|
) {
|
||||||
var searchText by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue()) }
|
var searchText by rememberSaveable(stateSaver = TextFieldValue.Saver) { mutableStateOf(TextFieldValue()) }
|
||||||
Column(Modifier.fillMaxSize()) {
|
Column(Modifier.fillMaxSize()) {
|
||||||
|
// todo: saving is good on orientation change, but bad on pressing back...
|
||||||
var showSearch by rememberSaveable { mutableStateOf(false) }
|
var showSearch by rememberSaveable { mutableStateOf(false) }
|
||||||
|
|
||||||
fun setShowSearch(value: Boolean) {
|
fun setShowSearch(value: Boolean) {
|
||||||
|
@ -120,7 +121,7 @@ fun <T: Any> SearchScreen(
|
||||||
if (!value) searchText = TextFieldValue()
|
if (!value) searchText = TextFieldValue()
|
||||||
}
|
}
|
||||||
BackHandler {
|
BackHandler {
|
||||||
if (showSearch) setShowSearch(false)
|
if (showSearch || searchText.text.isNotEmpty()) setShowSearch(false)
|
||||||
else onClickBack()
|
else onClickBack()
|
||||||
}
|
}
|
||||||
Surface(
|
Surface(
|
||||||
|
|
|
@ -7,6 +7,7 @@ import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
import androidx.compose.ui.platform.LocalLayoutDirection
|
import androidx.compose.ui.platform.LocalLayoutDirection
|
||||||
import androidx.compose.ui.unit.LayoutDirection
|
import androidx.compose.ui.unit.LayoutDirection
|
||||||
|
import androidx.navigation.NavOptions
|
||||||
import androidx.navigation.compose.NavHost
|
import androidx.navigation.compose.NavHost
|
||||||
import androidx.navigation.compose.composable
|
import androidx.navigation.compose.composable
|
||||||
import androidx.navigation.compose.rememberNavController
|
import androidx.navigation.compose.rememberNavController
|
||||||
|
@ -100,7 +101,7 @@ fun SettingsNavHost(
|
||||||
ColorsScreen(isNight = true, onClickBack = ::goBack)
|
ColorsScreen(isNight = true, onClickBack = ::goBack)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (target.value != SettingsDestination.Settings)
|
if (target.value != SettingsDestination.Settings/* && target.value != navController.currentBackStackEntry?.destination?.route*/)
|
||||||
navController.navigate(route = target.value)
|
navController.navigate(route = target.value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,5 +129,6 @@ object SettingsDestination {
|
||||||
navScope.launch { delay(10); navTarget.value = target }
|
navScope.launch { delay(10); navTarget.value = target }
|
||||||
} else
|
} else
|
||||||
navTarget.value = target
|
navTarget.value = target
|
||||||
|
navScope.launch { delay(50); navTarget.value = Settings }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue