https://kotlinlang.org logo
#compose-wear
Title
# compose-wear
y

Yingding Wang

12/30/2021, 9:43 PM
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

Chris Sinco [G]

12/31/2021, 2:08 AM
Not sure (on my phone) but I'd check the Compose Wear advanced sample on GitHub that has this exact feature
j

John Nichol

12/31/2021, 11:10 AM
@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

Yingding Wang

12/31/2021, 11:41 AM
@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.
5 Views