https://kotlinlang.org logo
#compose
Title
# compose
d

dimsuz

10/19/2021, 11:26 AM
I need to inform the grand-grand-[grand]-parent of LazyRow that scroll is in progress. What is the most idiomatic way to do this? Code in thread.
Copy code
Box {
  var showButton = remember { mutableStateOf(false) }
  ComposableWithRow(
    onScrollStateChange = { isScrolling -> showButton = isScrolling }
  )
  if (showButton) Button()
}

fun ComposableWithRow(
  onScrollStateChange: (isScrolling: Boolean) -> Unit
) {
  Box {
    Box {
        val listState = rememberLazyListState()
        listState.isScrollInProgress // HOW TO USE?

        LazyRow(state = listState)
    }
  }
}
How should I call
onScrollStateChange
? Or should I instead pass
State<Boolean>
as an argument to
ComposableWithRow
?
a

Albert Chang

10/19/2021, 11:30 AM
You should hoist
LazyListState
.
d

dimsuz

10/19/2021, 12:06 PM
got it, thanks
👍 1
3 Views