Kavantix / sliver_tools

A set of useful sliver tools that are missing from the flutter framework
MIT License
652 stars 64 forks source link

SliverFloatingHeader #11

Open Kavantix opened 4 years ago

Kavantix commented 4 years ago

A sliver that acts like a SliverToBoxAdapter when the user scrolls towards the leading edge but acts like a pinned header when the user scrolls back

Requirements:

Questions:

obiwanzenobi commented 4 years ago

I found a widget that acts like you described: https://gist.github.com/tomaszpolanski/cf0edb7961d2304c2f293da9971cd4c9

Kavantix commented 4 years ago

@obiwanzenobi thanks for linking that gist. I think I already looked at this one, it indeed might be a good starting point. Can I assume you are looking for a widget with this behavior? If so do you perhaps have input on the two questions I posed?

pavittarsingh315 commented 2 years ago

Was about to open an enhancement request till I saw this. Is there any such functionality like this within the sliver_tools package?

I have a NestedScrollView whose headerSliverBuilder returns a SliverPersistentHeader and a SliverPinnedHeader but I want the pinned header to hide when we scroll to the bottom but show itself when we scroll to the top. This is basically the floating functionality on SliverAppBar and the functionality described here.

I tried using the gist provided but its fairly outdated and didn't seem to work.

ABausG commented 2 years ago

I actually use this to achieve a certain behaviour. Regarding your questions I think it already behaves like I would expect it.

Regarding your questions

What if this is combined with a regular pinned header before/after it If all FloatingHeader are in a Group of PersistentHeaders (Pinned, Floating) In that case the FloatingHeader should scroll away but not be effecting by Overscroll Effects when dragging down For example

What should the behavior be when multiple of these headers are added to a viewport If there is a non persistent Sliver between multiple of these headers it should behave more or less like a SliverToBoxAdapter

marcoredz commented 2 years ago

Was about to open an enhancement request till I saw this. Is there any such functionality like this within the sliver_tools package?

I have a NestedScrollView whose headerSliverBuilder returns a SliverPersistentHeader and a SliverPinnedHeader but I want the pinned header to hide when we scroll to the bottom but show itself when we scroll to the top. This is basically the floating functionality on SliverAppBar and the functionality described here.

I tried using the gist provided but its fairly outdated and didn't seem to work.

I tried the example in the gist of tomaszpolanski and for me it actually works well. In fact I merged the SliverPinnedHeader of this package and the code of that gist and created an hybrid that takes a parameter named floating that triggers the floating behavior. I used it in a real scenario with the first sliver header set as floating and the second one pinned (without setting floating: true) and it works fine.

Here the new widget that I named SliverFlexibleHeader: https://gist.github.com/marcoredz/b2a37ff2cd11f81fa4ff7fb004fbb0ab

@Kavantix any opinions about this? maybe it could be a nice feature to add to your package

Kavantix commented 2 years ago

@marcoredz I took a quick look at your implementation and it looks like a good starting point. You can open a PR for it if you want

marcoredz commented 2 years ago

@Kavantix what do you suggest between: taking the existing SliverPinnedHeader and editing it, or creating a new widget?

Kavantix commented 2 years ago

I would create a new one for this

AlaaEldeenYsr commented 9 months ago

It doesn't work when it's put inside MultiSliver or SliverMainAxisGroup