We have two screens:
- The first screen contains a list of focusable items that are also clickable.
- The second screen is a detail screen.
When the user selects an item from the first screen, the detail screen is shown. Pressing the back button returns to the first screen, but the focus is reset. I want to keep the focus in place when returning to the first screen. What could be wrong? Is there a clean and easy way to achieve this?
val mainNavController = rememberNavController()
NavHost(
navController = mainNavController,
startDestination = MainDestinations.MainScreen
) {
composable(MainDestinations.MainScreen) {
MainScreen(
mainScreenViewModel = mainScreenViewModel,
homeScreenViewModel = homeScreenViewModel,
liveTvScreenViewModel = liveTvViewModel,
settingsScreenViewModel = settingsScreenViewModel,
mainNavController = mainNavController
)
}
composable(MainDestinations.AccessibilityScreen) {
AccessibilityScreen(
accessibilityScreenViewModel = accessibilityScreenViewModel,
mainNavController = mainNavController
)
}
}
private fun handleClick() {
mainNavController.navigate(MainDestinations.AccessibilityScreen)
}
Thank you!
1