Akram Bensalem
09/06/2022, 3:11 PMStylianos Gakis
09/06/2022, 3:33 PMAppState
itself change, or some internal state of AppState
?
If it’s internal state, is that defined as a MutableState
or a simple var
?
A peek inside your AppState
would make it easier to debug.Akram Bensalem
09/06/2022, 3:38 PMStylianos Gakis
09/06/2022, 3:43 PMbottombarVisibility
and drawerVisibility
should not be `var`s, since they themselves should not be changing, but their internal state.
But there doesn’t seem to be anything wrong with the isLandscape
part. It relies on windowSizeClass
which is a val
and should only be updated when you construct a whole new AppState
object.
Can I see where you’re constructing and remembering your AppState
object as well?Rick Regan
09/06/2022, 3:57 PMAkram Bensalem
09/06/2022, 4:03 PMRick Regan
09/06/2022, 4:12 PM@Composable
fun AppNavGraph(
...
settings: Settings
) {
val settingsAsState = rememberUpdatedState(settings)
NavHost(...) {
settingsNavGraph(
...
settings = { settingsAsState.value }
)
}
...
}
fun NavGraphBuilder.settingsNavGraph(
...
settings: () -> Settings
) {
navigation(...) {
composable(
route = ...,
) {
SettingsScreen(
...
settings = settings()
)
}
...
}
}
Rick Regan
09/06/2022, 4:15 PMappState
, not settings
.Akram Bensalem
09/06/2022, 4:50 PM