Last active
June 13, 2021 05:04
-
-
Save hongbeomi/cbb3af270597ad2dfd30234cf914aa1a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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