Skip to content

Instantly share code, notes, and snippets.

@hongbeomi
Last active Jun 13, 2021
Embed
What would you like to do?
@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