compose-collapsing-toolbar
compose-collapsing-toolbar copied to clipboard
Snap on release
Hey @onebone, would it be possible to snap the header to its nearest edge when a scroll is released?
Personally, I have not found such a feature in the lib. I also need it and I want to implement it this week.
@onebone are there any specific guidelines for contributors?
@RareScrap No I did not have wrote such guidelines, but it would be fine if the code is consistent with the original code base; such as indenting and continuation by tabs and something like that.
For now I implemented basics of snapping feature. Snapping is configured by the SnapStrategy instance (almost like the ScrollStrategy) to match the library code style. I have successfully implemented snapping for ExitUntilCollapsed scroll strategy, but with others there is some problems...
I can easily animate the toolbar because I have access to its state object. But in the case when the toolbar moves outside the screen (EnterAlways EnterAlwaysCollapsed), this is of little use - I need to animate the offsetY of CollapsingToolbarScaffoldState, not the CollapsingToolbarState. Now this gives me some architectural difficulties. @onebone, I would be glad to hear your opinion on how best to do this. And feel free to review draft PR
Okay, the snap is working as it should. However, there are a few things that bother me:
- Suspicious jump in toolbar animation speed
- I think it's worth implementing a snap animation canceling if the
onPreScrollwas called during the animation - Choreographer "Frame time is X ms in the future" issue
@RareScrap Thank you for sharing, I will review your PR within this week!
Hi, I have already created PR for this: https://github.com/onebone/compose-collapsing-toolbar/pull/83
By the way, if you want to use this feature, I created a separated remote dependency, while this PR is under review:
Add it in your root build.gradle at the end of repositories:
all projects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency
dependencies {
implementation 'com.github.GIGAMOLE:ComposeCollapsingToolbar:latest-version'
}
Or you can simply download it from there:
https://github.com/GIGAMOLE/ComposeCollapsingToolbar/releases
Is this implemented into the library?