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

SliverPinnedFooter #20

Open
volser opened this issue Jan 5, 2021 · 25 comments
Open

SliverPinnedFooter #20

volser opened this issue Jan 5, 2021 · 25 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@volser
Copy link

volser commented Jan 5, 2021

Is it possible to implement SliverPinnedFooter?

@Kavantix
Copy link
Owner

Kavantix commented Jan 5, 2021

Can you elaborate on how this widget should work?

@volser
Copy link
Author

volser commented Jan 5, 2021

the same as header, but pin at the bottom next header in the list

@volser
Copy link
Author

volser commented Jan 5, 2021

actually, I have a reversed list and need to implement pinned header, but for reversed list it works like footer :-)

@volser
Copy link
Author

volser commented Jan 5, 2021

in this demo https://raw.githubusercontent.com/Kavantix/sliver_tools/master/gifs/demo2.gif
"Next button" should be pinned to the bottom if list is longer than screen

@Kavantix
Copy link
Owner

Kavantix commented Jan 5, 2021

Hmm ok
And what if there are multiple?
I guess only 1 should be visible?

@volser
Copy link
Author

volser commented Jan 5, 2021

yes, only 1, the same as header, but reversed logic, when scroll up, prev (I mean footer above) footer should shift next (footer below)

@Kavantix
Copy link
Owner

Kavantix commented Jan 6, 2021

That does complicate things somewhat since they would need to communicate with each other in order to achieve this within the current flutter sliver implementation.
Possibly it would even need a parent inherited widget above the viewport to make this work.

Thanks for the suggestion though, I'll put it on the project but I won't have time to work on this in the near future, feel free to make a PR

@Kavantix Kavantix added this to To do in sliver_tools via automation Jan 6, 2021
@Kavantix Kavantix added enhancement New feature or request help wanted Extra attention is needed labels Jan 6, 2021
@saibotma
Copy link

saibotma commented Jan 3, 2022

@Kavantix Would be great if you could elaborate on why the whole thing would get complicated. I want to build the same thing, and I am struggling with it, but I am also new to slivers. Any tips & trick or hints are appreciated.

@Kavantix
Copy link
Owner

Kavantix commented Jan 3, 2022

@saibotma could you elaborate a bit more on the exact usecase you are trying to implement because only a subset of usecases would be as complicated as I mentioned

@saibotma
Copy link

saibotma commented Jan 3, 2022

I am actually trying to have a bottom (tab) bar for navigation, where scrollable content scrolls beneath it. I want to make the bottom bar opaque in order to add a blur filter and create an iOS style frosted glass effect.
Currently, I have implemented it using a Stack. The bottom bar is above the scrolled content and aligned to the bottom. The scrolled content has padding bottom as high as the bottom bar. However, this feels very hacky, and you always have to know the height of the bottom bar (which can change in my case).

@Kavantix
Copy link
Owner

Kavantix commented Jan 3, 2022

Ah I see, that usecase is indeed quite a bit simpler than what I was talking about since you only have 1 tab bar and thus don't need any logic for having multiple.

However, the part you mention where it should draw on top of the other content makes it rather difficult.
The thing with slivers is that they are painted in the reverse order, this is why a SliverPinnedHeadere is painted on top of the other widgets.
This means that in order to have a footer draw over content it needs to be earlier in the list of slivers which would remove the ability to fill up space in the bottom.

So making this a Sliver is probably not the best option.
Just keep using the Stack.
To solve the problem of not knowing the size of the tab bar you can put an invisible widget at the end of the CustomScrollView that sizes in the same way as the tab bar does (you could even start by actually putting the tab bar there but invisible)

@koiralapankaj7
Copy link

koiralapankaj7 commented Aug 22, 2022

This might be another use case where SliverPinnedFooter makes sense. I want to pin the Total row at the bottom but as of now without using shrinkWrap I am not being able to do so. Is there any better way to achieve this behaviour?

image

    Column(
         mainAxisSize: MainAxisSize.min,
         children: [
            // Header
            const _Header(),

            // Body
            Flexible(
                  child: CustomScrollView(
                    // Shrink wrapping the content of the scroll view is
                    // significantly more expensive than expanding to the
                    // maximum allowed size because the content can expand
                    // and contract during scrolling, which means the size
                    // of the scroll view needs to be recomputed whenever
                    // the scroll position changes.
                    shrinkWrap: provider.body.rows.length < 30,
                    physics: const ClampingScrollPhysics(),
                    slivers: const [_Body()],
                  ),
             ),

            // Footer
            const _Header(header: false),
       ],
  ),

@Kavantix Kavantix mentioned this issue Sep 3, 2022
2 tasks
@Kavantix
Copy link
Owner

Kavantix commented Sep 3, 2022

@volser @koiralapankaj7 I just opened a draft PR #59 that should serve your needs. I would like some feedback if you have time to test it :)

@Kavantix Kavantix moved this from To do to In progress in sliver_tools Sep 4, 2022
@koiralapankaj7
Copy link

koiralapankaj7 commented Sep 5, 2022

@Kavantix Thank you so much for this update. I just tested it and it is working perfectly fine. I have one suggestion:

  1. Footer should push pinned children if there are any.

@Kavantix
Copy link
Owner

Kavantix commented Sep 5, 2022

Great to hear it works!
But can you elaborate a bit on the question?

@koiralapankaj7
Copy link

Screen.Recording.2022-09-05.at.11.19.46.AM.mov

In this video, the footer is going below the header while scrolling. What I meant was can we push the header when the footer reaches there? (header in this context is SliverPinnedHeader.)

@Kavantix
Copy link
Owner

Kavantix commented Sep 5, 2022

You can try wrapping the multisliver with the sliverwithpinnedfooter

@koiralapankaj7
Copy link

image

If I am using MultiSliver correctly, it seems like it is not working for SliverWithPinnedFooter.

@Kavantix
Copy link
Owner

Kavantix commented Sep 5, 2022

Well I meant try using it like this:

SliverWithPinnedFooter(
  sliver: MultiSliver(
    pushPinnedChildren: true,
    children: [...],
  ),
  footer: FooterWidget(),
)

@koiralapankaj7
Copy link

image

If I use MultiSliver inside SliverWithPinnedFooter then the footer is behaving quite differently. If you need I will attach a video as well.

@Kavantix
Copy link
Owner

Kavantix commented Sep 5, 2022

video would be helpful

@koiralapankaj7
Copy link

Screen.Recording.2022-09-05.at.11.45.33.AM.mov

If you notice at the bottom. Footer appears before the header.

@Kavantix
Copy link
Owner

Kavantix commented Sep 5, 2022

Hmmm, supporting this might require the widget to be changed to SliverWithPinnedFooterAndHeader
I'll have to think about it a bit more

@folaoluwafemi
Copy link

Hello, please where are we with this feature?

I need it for a similarly described usecase in 2 of my apps; both for pinning a "Enter comment" text field to the bottom of the screen while the user scrolls.

Also I can't find the SliverWithPinnedFooter class in my current version of sliver_tools.

@Kavantix
Copy link
Owner

Kavantix commented Jun 1, 2024

If anyone would like to contribute that would be welcome but I do not have the need or time for this sliver at the moment.

@Kavantix Kavantix moved this from In progress to To do in sliver_tools Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
Status: To do
sliver_tools
  
To do
Development

Successfully merging a pull request may close this issue.

5 participants