Skip to content

Instantly share code, notes, and snippets.

@motorro
Created August 14, 2022 14:28
Embed
What would you like to do?
Application master view
fun WelcomeScreen(onTerminate: @Composable () -> Unit) {
val model = hiltViewModel<WelcomeViewModel>()
val state = model.state.collectAsState(WelcomeUiState.Loading)
BackHandler(onBack = { model.process(Back) })
when (val uiState = state.value) {
// Native ui-state rendering...
// Render login screens
is WelcomeUiState.Login -> LoginScreen(
state = uiState.value,
onGesture = { model.process(Login(it)) }
)
// Render registration screens
is WelcomeUiState.Register -> RegistrationScreen(
state = uiState.value,
onGesture = { model.process(Register(it))}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment