Skip to content

Instantly share code, notes, and snippets.

@riggaroo
Created June 28, 2022 09:14
Show Gist options
  • Save riggaroo/a20bf326c323ce8888c2be0e0bcee612 to your computer and use it in GitHub Desktop.
Save riggaroo/a20bf326c323ce8888c2be0e0bcee612 to your computer and use it in GitHub Desktop.
[AnimatedContent] JetSurvey initial wrap
/* Copyright 2022 Google LLC.
SPDX-License-Identifier: Apache-2.0 */
val state = viewModel.uiState.observeAsState().value ?: return@JetsurveyTheme
AnimatedContent(targetState = state) { targetState ->
// It's important to use targetState and not state, as its critical to ensure
// a successful lookup of all the incoming and outgoing content during
// content transform.
when (targetState) {
is SurveyState.Questions -> SurveyQuestionsScreen(
questions = targetState, /* other parameters */)
is SurveyState.Result -> SurveyResultScreen(
result = targetState, /* other parameters */)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment