I want to make the time text in scaffold disappear...
# compose-wear
y
I want to make the time text in scaffold disappear, when the ScalingLazyColumn scrolled up. Is there a better approach as check the first element in
layoutInfo.visibleItemsInfo
and its
offset
?
Copy code
...
        val listState = rememberScalingLazyListState()        
        Scaffold(
            timeText = {
                val itemInfoList = listState.layoutInfo.visibleItemsInfo
                // the first element is scrolled up more than 15dp, deactivate the Time Text
                if (itemInfoList.isNotEmpty()
                    && itemInfoList[0].index == 0 // the first visible index is the first element
                    && itemInfoList[0].offset >= -15 // the first element is scrolled up less than 15dp
                ) {
                    // show time text
                    TimeText()
                }
            },
c
Not sure (on my phone) but I'd check the Compose Wear advanced sample on GitHub that has this exact feature
j
@Yingding Wang The index/offset approach is the right one. From the next alpha release you will be able to use the centralItemIndex and centralItemScrollOffset directly from the state. You will also be able to set the initial central item index and offset. See https://android-review.googlesource.com/c/platform/frameworks/support/+/1907934 for details
y
@John Nichol thanks for implementing the centralItemScrollOffset feature, I am looking forward to the next alpha release with the animatedScrollTo methods 🙂 @Chris Sinco [G] @yschimke Also thanks for your reply. I wish you all a happy new year in advance.