dxvid-pts / miniplayer

A lightweight flutter package to simplify the creation of a miniplayer.
https://pub.dev/packages/miniplayer
MIT License
107 stars 79 forks source link

Ability to go from expanded to min size on back button #8

Closed alberduris closed 3 years ago

alberduris commented 3 years ago

The usual behaviour when pressing the back button is to minimise the bottom sheet, not going to the previous screen or exiting the app (i.e., YouTube Music, Spotify or Google Maps).

Is it possible to get this? Thanks!

dxvid-pts commented 3 years ago

Sure! For now, you can build this by yourself by using WillPopScope and the controller, but I'll add this feature in the next days.

dxvid-pts commented 3 years ago

I just added the feature. Feedback if everything works as expected is appreciated.

alberduris commented 3 years ago

HI @peterscodee, I will try it later today and I will let you know. Have you updated the docs or something to point out how to get this behaviour? Or it is the default behaviour now? Thanks!

alberduris commented 3 years ago

Hi again @peterscodee, I don't know how to test the new version of the package if it is not yet released to pub.dev, if you guide through it I am willing to test this dev version

dxvid-pts commented 3 years ago

Hi again @peterscodee, I don't know how to test the new version of the package if it is not yet released to pub.dev

Take a look at that: https://stackoverflow.com/questions/54022704/how-to-add-a-package-from-github-flutter

Or it is the default behaviour now?

Yes.

alberduris commented 3 years ago

Hi @peterscodee, thank you for your help!

I've been able to test it and I think it is not working correctly.

This is, the behaviour is exactly the same as in version ^0.6.1

By the way, I am using the second method to get persistence to show the Miniplayer, and I am following the sample you gave me in #7

This means that I already have an WillPopScope widget as parent of the Scaffold

dxvid-pts commented 3 years ago

Hi @peterscodee, thank you for your help!

I've been able to test it and I think it is not working correctly.

  • When I click the back button while the player is maximized it doesn't minimise, and the previous screen goes back.

This is, the behaviour is exactly the same as in version ^0.6.1

By the way, I am using the second method to get persistence to show the Miniplayer, and I am following the sample you gave me in #7

This means that I already have an WillPopScope widget as parent of the Scaffold

Ok, thank you for your help. I indeed only tested using the first method, so there could be a problem with nested navigators that needs further investigation. A quick fix, for now, would be pasting the code from my commit in your WillPopScope manually.

alberduris commented 3 years ago

Thank you for your answer.

I've tried that but it doesn't seem that easy. From my WillPopUp widget I don't have access to the heightNotifier property or _snapToPosition method. So as I am still developing the app I think I prefer to wait until the next release when you get that working in a general way.

But please, if you need help during that time, let me know and I will assist the development to the best of my ability.

dxvid-pts commented 3 years ago

I've tried that but it doesn't seem that easy. From my WillPopUp widget I don't have access to the heightNotifier property or _snapToPosition method. So as I am still developing the app I think I prefer to wait until the next release when you get that working in a general way.

You can get the current height through a custom valueNotifier and animate to a position with a controller.

alberduris commented 3 years ago

I think I prefer to wait for the release :sweat_smile:

dxvid-pts commented 3 years ago

I have long thought about how to implement this feature and ended up introducing MiniplayerWillPopScope as a drop-in replacement for WillPopScope for the cleanest solution in a nested environment.

Just replace the two and you are good to go!