nuhkoca
04/03/2022, 6:34 AMLoadingView
that should be centered on the screen but BoxScope
is not working if I use CrossFade
animation. It always appears on the left hand corner by default. However, if I do not wrap `Composable`s into CrossFade
, it is working as expected. Somehow LoadingView
is losing BoxScope
. What should I do?
Box(
modifier = Modifier
.fillMaxSize()
.padding(it)
.verticalScroll(scrollState)
) {
Crossfade(targetState = collectionState) { state ->
when (state) {
CollectionState.Loading -> LoadingView()
...
}
}
}
@Composable
private fun BoxScope.LoadingView() {
Box(modifier = Modifier.align(Alignment.Center)) {
TRCircularProgressIndicator()
}
}
Albert Chang
04/03/2022, 9:27 AMModifier.align()
only works on direct children of a Box
so you should apply the modifier on Crossfade
.nuhkoca
04/03/2022, 1:47 PMalign
on Crossfade
? I don't want other `Composables`(Error
and Success
views) to be centered but only Loading
.Albert Chang
04/03/2022, 2:42 PMBox
in Crossfade
.Modifier.fillMaxSize().wrapContentSize(align = Alignment.Center)
on LoadingView
.nuhkoca
04/03/2022, 2:55 PM