-
-
Save MarcinusX/2fc11ae9476ec780a71b4fb30450e124 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class _PriceTabState extends State<PriceTab> with TickerProviderStateMixin { | |
final double _initialPlanePaddingBottom = 16.0; | |
final double _minPlanePaddingTop = 16.0; | |
AnimationController _planeSizeAnimationController; | |
AnimationController _planeTravelController; | |
Animation _planeSizeAnimation; | |
Animation _planeTravelAnimation; | |
double get _planeTopPadding => | |
_minPlanePaddingTop + | |
(1 - _planeTravelAnimation.value) * _maxPlaneTopPadding; | |
double get _maxPlaneTopPadding => | |
widget.height - _initialPlanePaddingBottom - _planeSize; | |
double get _planeSize => _planeSizeAnimation.value; | |
@override | |
void initState() { | |
super.initState(); | |
_initSizeAnimations(); | |
_initPlaneTravelAnimations(); | |
_planeSizeAnimationController.forward(); | |
} | |
Widget _buildPlane() { | |
return AnimatedBuilder( | |
animation: _planeTravelAnimation, | |
child: Column( | |
children: <Widget>[ | |
AnimatedPlaneIcon(animation: _planeSizeAnimation), | |
], | |
), | |
builder: (context, child) => Positioned( | |
top: _planeTopPadding, | |
child: child, | |
), | |
); | |
} | |
_initSizeAnimations() { | |
_planeSizeAnimationController = AnimationController( | |
duration: const Duration(milliseconds: 340), | |
vsync: this, | |
)..addStatusListener((status) { | |
if (status == AnimationStatus.completed) { | |
Future.delayed(Duration(milliseconds: 500), | |
() => _planeTravelController.forward()); | |
} | |
}); | |
[...] | |
} | |
_initPlaneTravelAnimations() { | |
_planeTravelController = AnimationController( | |
vsync: this, | |
duration: const Duration(milliseconds: 400), | |
); | |
_planeTravelAnimation = CurvedAnimation( | |
parent: _planeTravelController, | |
curve: Curves.fastOutSlowIn, | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment