Abhimanyu
10/04/2023, 2:55 PMAbhimanyu
10/04/2023, 2:56 PM@Immutable
data class HomeScreenUIData(
val isXVisible: Boolean = false,
// ...
)
@Immutable
internal data class HomeScreenUIEvents(
val navigateToSettingsScreen: () -> Unit,
// ...
)
fun HomeScreenUI(
events: HomeScreenUIEvents,
uiState: HomeScreenUIState,
state: CommonScreenUIState,
) {
// ...
}
The problem with this data class approach is the screen composable recomposes for any changes.Abhimanyu
10/04/2023, 2:57 PMNow In Android
and they pass all the data and events into the compostables directly.
This may be too large to maintain.Joel Denke
10/04/2023, 4:44 PMcomposable(
"profile?userId={userId}",
arguments = listOf(navArgument("userId") { defaultValue = "user1234" })
) { backStackEntry ->
Profile(navController, backStackEntry.arguments?.getString("userId"))
}
See https://developer.android.com/jetpack/compose/navigation#nav-with-args
In viewmodel getting data through SavedStateHandle.
Can also combine navgraphs per compose screen.Joel Denke
10/04/2023, 4:46 PMAbhimanyu
10/04/2023, 5:00 PMJoel Denke
10/04/2023, 6:11 PMJoel Denke
10/04/2023, 6:25 PM