How to show smooth transition in pageview if jumpTo function id used? - flutter

I am trying to change the current page upon click event using jumpToPage().
But, it's changing it very abruptly without any animation.
The point of transition is that the user does not have to click next and plus if clicked on the wrong checkbox then he would know that if I scroll up I can change the option again.

Use animateToPage:
Animates the controlled PageView from the current page to the given page.
The animation lasts for the given duration and follows the given curve. The returned Future resolves when the animation completes.
You have to provide a duration and a curve
https://api.flutter.dev/flutter/widgets/PageController/animateToPage.html
See all the curves animations here:
https://api.flutter.dev/flutter/animation/Curves-class.html

Related

Can ScrollController.jumpTo be overridden so that it does not interrupt a user's scroll?

So it looks like by definition, a jumpTo will stop all user scrolls in progress:
Any active animation is canceled. If the user is currently scrolling, that action is canceled.
https://api.flutter.dev/flutter/widgets/ScrollController/jumpTo.html
Can this behavior be overwritten somehow? I want to jump to certain parts of the list, but that may occur while a user is scrolling and they should be able to continue scrolling without lifting their finger and tapping to scroll again.
One catch is I'm using the PrimaryScrollController as my scrollcontroller: scrollController = PrimaryScrollController.of(context);
Ok for anyone else looking to an answer, I think I found it, never know it existed, but there's two things:
scrollController.position.correctBy(pixels); //Moves in some number forward or back relative to current position
scrollController.position.correctPixels(pixels); //Moves to some absolute position
Using these will do a jumpTo and the user scroll is not interrupted..

Swift: Custom Slider (Slide To Unlock style)

I am trying to implement a slider in the known slide to unlock style from older iphones to perform an action inside my swift app. The Slider should change background color and change the text inside while dragging. When the user drags til the end, the thumbView should stick to the right side and wait for a confirmation (some event) coming in to finally present a new view.
The slider should look something like this:
First state
Second state while dragging
Third state after releasing
I have found a few things on the internet but nothing that comes close to what I want to do. How would I go about doing this? My guess would be a combination of views with drag events but I feel like there must be an easier way. Any Ideas?
Maybe a UISlider with a transparent track on a rectangle view with your text and color. You can set your image as the UISlider's thumb and receive events as the value changes and when the user touches and releases it.
You can use that to for example, animate the thumb back to the start when the user releases on any place except the end of the track. Also, you can set the slider's value from 0 to 1 and use it to calculate the color, so it changes smoothly.
When the user releases on the end of the track, you activate the activity indicator and start your process to present the next view....
Even though this is a possibility, I think I'd try doing a custom control using a pan gesture. It'd give you more control and you could for example choose how the thumb image animates when going back to the start on release.... I dont' think you can do that with UISlider's setValue(animated:).

Why are button transition animations not resetting to normal position?

When I mouseover button it works fine. But when I clicked and enter inside the credits scene and came back the default width of the credits button changed and not reset to normal position.
It should return to normal position whenever if I clicked the button and enters into any scene and return to the current scene.
After having long conversation, this is the summary and solution.
Naveen was using Unity's default animation transitions for buttons.
As, he only needed highlighted transition, he only added that animation which scales the button. But, no animation was added for the normal state. As a result, when he was switching the canvas, the scale of the button was already increased and stayed there.
There can be multiple solutions, but here's mine.
Just add keyframes in normal state, which keeps the button in normal scale.

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.

How to handle multiple button clicks in javafx?

I made a rubiks cube and its animations are working fine until I press the button for a move before the ending of the animation of a previous move. This is quite reasonable. At first I click a button for a particular move and it rotates as per my code for the button's corresponding event handling method. Now if I press the next button for the next desired move after the previous animation is finished everything goes fine. But if I press the button for the next move while animation of the previous move is on action, then my cube becomes distorted. This is so becuase two separate animations are being simultaneously played on the same cube(s) ( If I am wrong about this reason, please correct me ). In order to prevent this I want to store the button event in a queue in the sequence they are clicked and execute them one after the other after the correspomding animations of each are over. How can I achieve this ?