letsar / flutter_slidable

A Flutter implementation of slidable list item with directional slide actions.
MIT License
2.72k stars 588 forks source link

ItemBuilder for animated SlideAction #1

Closed Solido closed 6 years ago

Solido commented 6 years ago

So the idea would be using an itemBuilder for SlideAction that mimics the AnimatedList so we can access the Animation when creating the child. This way I can also animate Opacity in my case.

letsar commented 6 years ago

Nice one 😃. Very useful suggestion. I don't think it will be backward compatible though, if I want to keep it simple.

Solido commented 6 years ago

If you don't want to break the current API you can use the same trick than color property on Container.

You can set color field only if decoration field is not present.

Maybe you can keep child under SlideAction but make it invalid if this part is not present

builder : (Context c, Animation a) {}

letsar commented 6 years ago

What I had in mind about breaking changes, was more about custom slidable delegate. If I want to keep the API simple, I will only expose the builders, and not the widget list anymore for slidable actions. I'm planning to work on this today on another branch. Once I have something working, would you mind telling me what you think?

Solido commented 6 years ago

Show me the code when it's done ! It's already in my project, should be straightforward to tell you how the API 'feels' and if I can reach the required effect on my app.

letsar commented 6 years ago

You can checkout the branch feature/1_itembuilder to see the code.

I added a new constructor, called Slidable.builder that allows you to set left and right SlidableActionDelegate. There are two SlidableActionDelegate, one for supporting List<Widget> if we don't care about animation. The other, called SlidableActionBuilderDelegate for the enhancement you are proposing.

I modified my example if you want an example which opacifies the slidable actions while the list item is sliding.

Let me know what you think about this API.

Solido commented 6 years ago

I really love the API, when you getting confortable with builder you want them anywhere. It is transparent with the rest of the Flutter API and the effect I wanted is implemented easily. What is great is that I can reuse the same code that what I use in AnimatedList.

letsar commented 6 years ago

Ok great 😄 . I will add some documentation and merge it into the master branch. But I will wait to finish #2 before publishing a new version if you don't mind.

letsar commented 6 years ago

Available on version 0.2.0