Last Wear M3 broke the placeholders. No time for a...
# compose-wear
t
Last Wear M3 broke the placeholders. No time for a repro this week but if you take the placeholder sample and do not call the
animatePlaceholder
then there's no recomposition on isContent ready change. (Also if you remove the
placeholderShimmer
so not tied to shimmer.
😦 1
s
Thanks - we'll take a look
Hi - we have looked at the samples, but haven't been able to establish a change in behavior between the current Material3 and the Material 2.5 placeholders. The changes in the recent release only concerned naming (at least, that's the intention). If you could record a video of before and after to show the change, or provide a simple repro, we'll take another look.
t
The change is between alpha 27 and 28, I've done the renaming.
Copy code
ScreenScaffold(scrollState = scalingLazyColumnState) {
        ScalingLazyColumn2(scalingLazyColumnState) {
            item {
                val placeholderState = rememberPlaceholderState {
                    viewModel.items != null
                }
                ResponsiveListHeader(contentPadding = firstItemPadding()) {
                    Column(horizontalAlignment = Alignment.CenterHorizontally) {
                        Text(
                            viewModel.wearMediaCollection.title,
                            color = MaterialTheme.colorScheme.onSurface,
                            fontWeight = FontWeight.Bold,
                            style = MaterialTheme.typography.titleMedium,
                            maxLines = 2,
                            overflow = TextOverflow.Ellipsis,
                            textAlign = TextAlign.Center,
                            modifier = Modifier.fillParentMaxWidth(),
                        )
                        if (viewModel.items == null || viewModel.description.isNotEmpty()) {
                            Text(
                                viewModel.description,
                                style = MaterialTheme.typography.labelSmall,
                                textAlign = TextAlign.Center,
                                color = MaterialTheme.colorScheme.onSurfaceVariant,
                                modifier = Modifier
                                    .fillMaxWidth()
                                    .padding(top = 8.dp)
                                    //.placeholderShimmer(placeholderState)
                                    .placeholder(placeholderState),
                            )
                        }
                    }
                    if (!placeholderState.isHidden) {
                        //LaunchedEffect(placeholderState) { placeholderState.animatePlaceholder() }
                    }
                }
            }
Notice the removal of the
animatePlaceholder
in that case the placeholder does not update when the viewModel.item is no more null.
Adding back the
LaunchedEffect(placeholderState) { placeholderState.animatePlaceholder() }
does work. I did not have that call in some screen as no shimmer and it worked before.
s
I'm not very familiar with the Placeholders myself - but all of our samples have the code for to call animatePlaceholder when not hidden - so I would infer that call is needed and wouldn't expect the animations to occur if that code is commented out.
Copy code
if (!placeholderState.isHidden) {
                        LaunchedEffect(placeholderState) { placeholderState.animatePlaceholder() }
                    }
t
What is the purpose of the first lambda then ? Id we need to manually show / hide the placeholder on state change we can directly launch on that.