onebone/compose-collapsing-toolbar

Not able Collabs tool bar manully

Opened this issue · 0 comments

I want to scroll my list and collapse my toolbar to show scroll items but when i call collapse() it not working. following is the my compose method.

@Composable
fun Collapsing() {
    val scope = rememberCoroutineScope()
    val rememberLazyListState = rememberLazyListState()
    val scaffoldState = rememberCollapsingToolbarScaffoldState()
    CollapsingToolbarScaffold(
        state = scaffoldState,
        scrollStrategy = ScrollStrategy.EnterAlwaysCollapsed,// provide the state of the scaffold
        toolbar = {
            Text(text = "My Activity", modifier = Modifier
                .fillMaxWidth()
                .height(200.dp)
                .background(color = Color.Red)
                .clickable {
                    scope.launch {
                        scaffoldState.toolbarState.scroll {
                            scrollBy(-scaffoldState.toolbarState.height.toFloat())
                        }
                        rememberLazyListState.scrollToItem(50)
                    }
                })
        },
        body = {
             LazyColumn(modifier = Modifier.fillMaxSize(), state = rememberLazyListState) {
                items(100) {
                    Row(
                        modifier = Modifier
                            .fillMaxWidth()
                            .clickable {
                                scope.launch {
                                    rememberLazyListState.scrollToItem(50)
                                }

                            },
                    ) {
                        Text(modifier = Modifier.padding(16.dp), text = it.toString())
                    }
                }
            }
        },
        modifier = Modifier,
    )
}