Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show a composable on a fixed position inside CollapsingToolbarScaffold regardless of toolbar state? #28

Closed
pesjak opened this issue Jan 14, 2022 · 3 comments · Fixed by #31
Labels
api Improvement of existing library contracts that may break backwards compatibility feature New feature or request

Comments

@pesjak
Copy link

pesjak commented Jan 14, 2022

Hey,

The library is amazing, but I have an issue that I don't know how to solve.

I want to put the Button inside CollapsingToolbarScaffold, but I want it to be always shown, no matter the state of CollapsingToolbarScaffold. Currently if you put it inside it won't show until the state of the toolbar collapses.

1 solution I tried is to put the Button outside of CollapsingToolbarScaffold, but then you have a button that is not part of the content that you want to show.

For example if you have an AnimatedNavHost inside the content of CollapsingToolbarScaffold to manage the screens, the button inside those screens is different, but won't be shown at the bottom of the screen (over the content), but it will be shown at the bottom of the content.

To summarize, is there any way to "flag" a composable, so that it is not influenced by the scrolling state, but is independent and still part of the CollapsingToolbarScaffold content?

@Nek-12
Copy link

Nek-12 commented Jan 15, 2022

I have similar issue here. I want to use collapsing toolbar without CollapsingToolbarScaffold() because I'd like to use regular Scaffold() to have a bottom app bar placeholder. My problem can also be solved by having bottom app bar as a pinned component just like @pesjak described

@onebone onebone added api Improvement of existing library contracts that may break backwards compatibility feature New feature or request labels Jan 22, 2022
@onebone
Copy link
Owner

onebone commented Jan 22, 2022

One possible workaround for your case is to offset the button manually according to the toolbar state.

Button(modifier = Modifier.offset { IntOffset(0, -state.offsetY) }) { ... }

I see this as a common use case, so I am planning to support such scenarios in the near future. Just as using CollapsingToolbarLayout in the Jetpack library, align() modifier will allow users to fix components in an arbitrary position in the layout.

// not possible right now, but will be available in the near future version
CollapsingToolbarScaffold(
	// ...
) {
	Button( // placed at the bottom center regardless of scroll state
		modifier = Modifier.align(Alignment.BottomCenter)
	)
}

@Nek-12
Copy link

Nek-12 commented Jan 26, 2022

Also, I ended up using CollapsingToolbarScaffold + another Scaffold for everything else except toolbar. Works fine for my case explained above , and Google seems to have ended up using multiple scaffolds too in their projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Improvement of existing library contracts that may break backwards compatibility feature New feature or request
Projects
None yet
3 participants