Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Last active June 13, 2021 05:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hongbeomi/cbb3af270597ad2dfd30234cf914aa1a to your computer and use it in GitHub Desktop.
Save hongbeomi/cbb3af270597ad2dfd30234cf914aa1a to your computer and use it in GitHub Desktop.
@ExperimentalAnimationApi
@ExperimentalFoundationApi
@Composable
fun DetailScreen(
houseType: HouseType,
viewModel: DetailViewModel = viewModel()
) {
val isLoadingState by getLifecycleAwareState(
flow = viewModel.isLoadingFlow,
initialValue = false,
)
val selectedCharacter by getLifecycleAwareState(
flow = viewModel.selectedCharacter,
initialValue = null
)
... // parent compose
if (isLoadingState) {
Box(
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
LoopLottieAnimation(rawId = R.raw.wingardium_leviosa)
}
} else {
CharacterList(
characterFlow = viewModel.characterListFlow,
modifier = Modifier.fillMaxSize(),
onClickItem = { viewModel.showCharacterDialogEvent(it) }
)
}
...
selectedCharacter?.let {
CharacterDialog(
character = it,
houseType = houseType
) {
viewModel.hideCharacterDialogEvent()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment