Skip to content

Instantly share code, notes, and snippets.

@motorro
Created August 14, 2022 14:28
Show Gist options
  • Save motorro/e65022b6323c894dea9ca43ae3481028 to your computer and use it in GitHub Desktop.
Save motorro/e65022b6323c894dea9ca43ae3481028 to your computer and use it in GitHub Desktop.
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