Entirely out of my depth so any help most welcome! 🙂
y
yschimke
11/09/2021, 8:00 AM
I like this, the screen implicitly knows that it shouldn't be open as soon as there is a connection by any means.
s
Steve Bower [G]
11/09/2021, 9:22 AM
Looks good to me. I can see that the app now has just one Scaffold and is passing UIState into the screens, including the navHostController - and the check for whether the screen is in the background or foreground is working too. The LaunchedEffect code above looks like the right approach - you might need to key it on both screenStarted and connectionStatus so that it reacts when either of them changes.
g
Garan Jenkin
11/09/2021, 9:27 AM
Thanks! I'll take another look. And I've realised I'm setting the visibility of timetext directly in the compostable. Is this wrong? Does this constitute a side effect so I should be doing in the LaunchedEffect?
s
Steve Bower [G]
11/09/2021, 11:39 AM
Yes, state changes should be made in one of the SideEffect APIs, so LaunchedEffect, DisposableEffect or SideEffect.