K Merle
08/01/2021, 6:45 PMOutlinedTextField
and
var email by rememberSaveable { mutableStateOf("") }
inside single compose function. Upon rotating screen, email state value resets to ""
. Shouldn't rememberSaveable
actually keep value of an email and not reset it?Colton Idle
08/01/2021, 6:53 PMColton Idle
08/01/2021, 6:54 PMclass MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
AppTheme {
Surface(modifier = Modifier.fillMaxSize()) {
var email by rememberSaveable { mutableStateOf("") }
OutlinedTextField(value = email, onValueChange = { email = it })
}
}
}
}
}
K Merle
08/01/2021, 7:00 PMrememberSaveable
should still work, right?K Merle
08/01/2021, 7:18 PMprivate fun NavGraphBuilder.addAuthenticationScreenModule() {
navigation(
route = AuthenticationNavigation.route,
startDestination = AuthenticationNavigation.SignInNavigation.route
) {
addSignInScreen()
}
}
private fun NavGraphBuilder.addSignInScreen() {
composable(
route = AuthenticationNavigation.SignInNavigation.route,
) {
SignInScreen()
}
}
I just tested and it works all until inside SignInScreen composable.Colton Idle
08/01/2021, 7:54 PMK Merle
08/01/2021, 8:16 PMK Merle
08/02/2021, 8:41 AMNavHost
definately for some reason breaks it, not sure if it's my fault, but this does not save `rememberSaveable`:
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
OperationCenterTheme {
NavHost(navController = rememberNavController(), startDestination = SplashNavigation.route) {
composable(route = SplashNavigation.route) {
TestComposable()
}
}
}
}
}
}
and this works
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
OperationCenterTheme {
TestComposable()
}
}
}
}
K Merle
08/02/2021, 8:52 AMrememberSaveable
got broken with androidx.navigation:navigation-compose:2.4.0-alpha05
, works in 2.4.0-alpha04
Colton Idle
08/05/2021, 5:11 AMK Merle
08/05/2021, 6:18 AMStepan Furman
08/12/2021, 6:41 AMColton Idle
08/12/2021, 6:42 AM