compose-collapsing-toolbar icon indicating copy to clipboard operation
compose-collapsing-toolbar copied to clipboard

Can't collapse the toolbar when swiping up from the toolbar content

Open eitand opened this issue 3 years ago • 4 comments

Hi,

I have rather big tool bar that holds an image pager (Google Accompanist pager) and the toolbar does not collapsed while swiping up. I tested it on simpler toolbar as well.

eitand avatar Oct 28 '21 13:10 eitand

Can you clarify what is your expected behavior? Do you mean that when scrolling the main content, the toolbar does not get collapsed until the pager (VerticalPager?) hits the bottom?

onebone avatar Oct 28 '21 15:10 onebone

Hi, Sorry for the late response.

I have a screen with a collapsing toolbar and a list, when i try to scroll up and the gesture start from within the toolbar it self. its not collapsing.

I finally managed to proxy the event by using this code:

 CollapsingToolbarScaffold(
        modifier = Modifier
            .fillMaxSize()
            .scrollable(
                orientation = Orientation.Vertical,
                // allow to scroll from within the toolbar
                state = rememberScrollableState { delta ->
                    collapsingToolbarState.toolbarState.dispatchRawDelta(delta)
                    delta
                }
            ),
        state = collapsingToolbarState,
        .
        .
        .

eitand avatar Nov 09 '21 15:11 eitand

I have confirmed that the Android's CollapsingToolbarLayout consumes scrolling gestures from toolbar. Thank you for reporting!

onebone avatar Nov 10 '21 09:11 onebone

I have a way to deal with it temporarily

toolbarModifier = Modifier.verticalScroll(rememberScrollState())

CollapsingToolbarScaffold(
		modifier = Modifier.fillMaxSize(),
		state = rememberCollapsingToolbarScaffoldState(),
		toolbarModifier = Modifier.verticalScroll(rememberScrollState()),
		scrollStrategy = ScrollStrategy.ExitUntilCollapsed,
		toolbar = {
			// toolbar contents...
		}
	) {
		// body contents...
	}

Like this, slide the toolbar and the NestedScrollConnection can receive events

JackieHou avatar Sep 13 '22 01:09 JackieHou