Animate card widget on button click Tinder like swipe - flutter

Hello all I am building Tinder like swipe in Flutter. So far so good I have made the stack of cards together with the gesture detector when the user swipes left/right. However my issue come when I try to animate on click of a button. Under the stack of cards there are 2 buttons which you can like or dislike on button click. I would like to get an advice how I can approach the animation when the user clicks on either button. Below is my code for displaying the stack. Best wishes

There are several options to animate the card off screen. Since you're already using a Stack, AnimatedPosition is probably the best option.
You could also use Transform.translate to set the transform property of an AnimatedContainer. Or, if you want more control over the animation you could use a SlideTransition.
For a good overview of how to decide which animations you need, see this video from two days ago: https://www.youtube.com/watch?v=GXIJJkq_H8g
There's also https://pub.dev/packages/animations for more pre-packed options.

Related

Animation In Carousel Slider, Flutter

I have an app that I have created using Flutter. It is simple and just loads a list of slides from Firebase and displays that list in a slideshow format using the carousel_slider package. It works great but I would like an animation to be done when the user slides to the next slide. I know that sounds vague, but for a better description, I wanted an animation like what happens in Google Primer.
In this picture the animation is pretty well visible
In Primer, the slide flies down in a stylish manner and does the same but upwards if you slide up, instead of going straight back

For Flutter Mobile, How to Push a New Route by a Drag/Swipe Gesture While Controlling the Position of the Routes (Like Swipe to Pop in iOS)

As most of you already know, Flutter offers a Cupertino navigation transition that represents the native iOS behavior when navigating to previous route. You can start swiping from the left edge of the device and a navigation animation is started. Unless the user ends touching to the screen, the user is in control of the position of the current (above) and the previous (below) routes.
According to the release position and velocity, whether the screen will be popped or not and the animation controller takes the rest of the job.
I want to implement exactly opposite of this. When the user starts swiping from the right edge of the screen to the left, the gesture will be detected. The new route will be created and be positioned on the right. User can drag the new route to the left (into the scene). After the release of the touch, it will be decided to whether center the new route (complete) or let it go away (cancel).
This behavior can be observed inside Safari browser, for example. You can navigate backwards by start swiping from the left edge. Moreover, you can navigate forward by starting to swipe from the right end of the screen.
Also, it is possible to experience a similar UI/UX behavior in TikTok app. When watching a video on the “For You” screen (that’s the default home page of the TikTok), the user can start dragging the screen from right to left and when the gesture detected, the profile screen of the current content’s owner will be shown. As mentioned above, the user will be in control of the position by dragging. When the user ends touching it will complete or cancel the navigation based on the situation.
Question is:
I am a power user of Flutter since the very early beta days of it. I made quite complex UX implementations till today. However, this type of a navigation need haven’t been an issue and didn’t come to my mind.
I did a deep research on the Flutter source code, internet, Flutter issues, pub.dev, etc. Yet, I couldn’t find a logically easy solution.
Does anybody know how to do that? Indeed we can use the CupertinoPageRoute and extend upon it but my mind just stopped at the moment.
Side note: The end result could be like a parallax effect or like a PageView.

How could I animate to another screen by using a Material-like circle expanding effect with Flutter?

Here is an example from a mockup I made of what I am trying to achieve.
Right now in code, these are 2 separate screens, but they are simply using a regular built-in animation between screens. Where would I even start to begin achieving an animation like the mockup example? Could I use a Stack that has a circle as a background with a hero tag, and then change its radius? How could I guarantee it would fill the size of any screen?
Thank you!
It's quite simple, you can do it in 1 page, follow this:
Layer a full page popup menu widget (let's say the widgets on pink)
on the page 1 with Stack, hide it at initial.
Scale animation to the top left circle when pressing it
Show the hidden menu widget after scale animation
Hide and reverse the scale animation when pressing closing or back button

How to implement stories progress view in flutter

I want to know to the best way in order to develop a widget/view which can work as instagram, snapchat stories which illustrated in image below. There are many depndencies for android, but can't find any for flutter.
I'm thinking to use carousal/viewpager to move between stories of different users, but I'm unable to get how to move backward and forward in between stories of single user(either image or video) with progress bar on top of it which will move automatically to next when progress bar completes.
Try to create a custom ViewPager perhaps using Stack + Transform and use GestureDetector to switch between pages/stories.
I know this question has been asked for a long time, but for those who still ask the same question, you can use this library: https://pub.dev/packages/story_view or look at it's source to implement the same thing.
Not sure if you also want to give the user a chance to manually switch to the next image.
Here are some basic ingredients you want to use for an animated "story":
AnimationController with duration depending on the number of images in the story. Start the animation to go through the images and to animate the progress bar. The animation controller usually has a range from 0.0 to 1.0. Let's say you have 5 images. You would display the first image from 0.0 to 0.2, the second image from 0.2 to 0.4...
AnimatedBuilder that listens to the animation controller. The content inside the animation builder will be rebuilt every frame while the animation runs. Inside of the builder, calculate which image must be shown.
CustomPaint to manually draw a progress bar with sections for the single image. Pass the current animation value and the number of images to your CustomPainter.
Image widget to draw the image.

Touch feedback during swipe left and right

My app has a master-detail structure, where the user can tap on a master item to go to the detail view and then swipe left or right to navigate to other details items.
I'm using on-swipe-left and on-swipe-right to let users swipe between the detail views, however, when the user swipes, there is no visual feedback that there is a swipe happening. Only after the user has fully swiped does anything happen. I thought I could use the slide box, because the slidebox does provide visual feedback as soon as you start swiping, however, my views have vertical scroll and that conflicts with the left and right swipe actions due to the swipe sensitivity. In other words, when the user touches the screen to begin scrolling down, the swipe action takes over and it tries to swipe left or right instead of scrolling down.
So, what are my options? Is there any way I can provide some kind of an animation with on-swipe-left and on-swipe-right so that there is some kind of visual feedback (may be an ink trail on the screen) I can show the user? Or is there any way I can make the slidebox approach work so that the horizontal swipe and vertical scroll can function harmoniously? I have seen other apps that have scroll and swipe functions working harmoniously--gmail and pinterest are examples. Just not able to get it working with ionic.
Or is there another UI pattern that I am not thinking of? Worst case, I could provide buttons for next and previous, but this is a mobile app, so I really shouldn't have to resort to that.
Thanks!