Created
October 21, 2019 17:07
-
-
Save MeshkaniMohammad/6d082831994b06f9b1c93884f3e3be94 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 FirstScreen extends StatefulWidget { | |
@override | |
_FirstScreenState createState() => _FirstScreenState(); | |
} | |
class _FirstScreenState extends State<FirstScreen> with TickerProviderStateMixin { | |
Animation _profSlideAnimation; | |
Animation _profRotateAnimation; | |
AnimationController _animationController; | |
Animation<Offset> _firstOffset; | |
Animation<Offset> _secondOffset; | |
Animation<Offset> buttonOffset; | |
Animation<double> _firstFadeAnimation; | |
Animation<double> _secondFadeAnimation; | |
Animation<double> _buttonAnimation; | |
Animation<double> _tryDemoAnimation; | |
AnimationController animateToNextPageController; | |
Animation<Offset> animateToNextPageOffset; | |
@override | |
void initState() { | |
super.initState(); | |
_animationController = AnimationController(duration: const Duration(seconds: 7), vsync: this); | |
_profRotateAnimation = Tween<double>(begin: -math.pi / 4.0, end: 0).animate( | |
CurvedAnimation( | |
parent: _animationController, | |
curve: Interval(0.0, 0.7, curve: Curves.ease), | |
), | |
); | |
_profSlideAnimation = Tween( | |
begin: Offset(-1, 0.0), | |
end: Offset(0.3, 0.0), | |
).animate( | |
CurvedAnimation( | |
parent: _animationController, | |
curve: Interval(0.0, 0.4, curve: Curves.ease), | |
), | |
); | |
_firstOffset = Tween<Offset>(begin: Offset(0.3, 1.0), end: Offset(0.3, 0.0)) | |
.animate(CurvedAnimation(parent: _animationController, curve: Interval(0.4, 0.55))); | |
_secondOffset = Tween<Offset>(begin: Offset(0.1, 1.0), end: Offset(0.1, 0.0)) | |
.animate(CurvedAnimation(parent: _animationController, curve: Interval(0.55, 0.7))); | |
_firstFadeAnimation = Tween<double>(begin: 0.0, end: 1.0) | |
.animate(CurvedAnimation(parent: _animationController, curve: Interval(0.4, 0.55))); | |
_secondFadeAnimation = Tween<double>(begin: 0.0, end: 1.0) | |
.animate(CurvedAnimation(parent: _animationController, curve: Interval(0.55, 0.7))); | |
buttonOffset = Tween<Offset>(begin: Offset(0.1, 0.0), end: Offset(0.1, 0.0)) | |
.animate(CurvedAnimation(parent: _animationController, curve: Interval(0.7, 1.0))); | |
_buttonAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation( | |
parent: _animationController, curve: Interval(0.7, 1.0, curve: Curves.elasticOut))); | |
_tryDemoAnimation = Tween<double>(begin: 0.0, end: 1.0).animate(CurvedAnimation( | |
parent: _animationController, curve: Interval(0.85, 1.0, curve: Curves.elasticOut))); | |
_animationController.forward(); | |
animateToNextPageController = | |
AnimationController(vsync: this, duration: Duration(milliseconds: 300)); | |
animateToNextPageOffset = Tween<Offset>(begin: Offset(0.0, 1.0), end: Offset(0.0, 0.0)) | |
.animate(CurvedAnimation(parent: animateToNextPageController, curve: Curves.easeIn)); | |
} | |
@override | |
Widget build(BuildContext context) { | |
final _width = MediaQuery.of(context).size.width; | |
final _height = MediaQuery.of(context).size.height; | |
return Scaffold( | |
backgroundColor: colors.BACKGROUND_COLOR, | |
body: Stack( | |
children: <Widget>[ | |
Column( | |
children: <Widget>[ | |
SizedBox( | |
height: 90, | |
), | |
AnimatedBuilder( | |
animation: _animationController, | |
builder: (_, child) { | |
return SlideTransition( | |
position: _profSlideAnimation, | |
child: Transform.rotate( | |
angle: _profRotateAnimation.value, | |
child: child, | |
), | |
); | |
}, | |
child: Image.asset( | |
'assets/images/prof_icon.png', | |
height: MediaQuery.of(context).size.width / 3, | |
width: MediaQuery.of(context).size.width / 3, | |
), | |
), | |
AnimatedBuilder( | |
animation: _animationController, | |
builder: (_, child) { | |
return SlideTransition( | |
position: _firstOffset, | |
child: FadeTransition( | |
opacity: _firstFadeAnimation, | |
child: child, | |
), | |
); | |
}, | |
child: Text( | |
strings.HI_IAM_FABI, | |
textAlign: TextAlign.center, | |
style: TextStyle( | |
color: Color(0xffffffff), | |
fontWeight: FontWeight.w900, | |
fontSize: 30, | |
), | |
), | |
), | |
SizedBox( | |
height: _height / 30, | |
), | |
AnimatedBuilder( | |
animation: _animationController, | |
builder: (_, child) { | |
return SlideTransition( | |
position: _secondOffset, | |
child: FadeTransition( | |
opacity: _secondFadeAnimation, | |
child: child, | |
), | |
); | |
}, | |
child: Text( | |
strings.FABI_GUIDE, | |
textAlign: TextAlign.center, | |
style: TextStyle( | |
color: Color(0xffffffff), | |
fontWeight: FontWeight.w500, | |
fontSize: 20, | |
), | |
), | |
), | |
SizedBox( | |
height: _height / 30, | |
), | |
Center( | |
child: AnimatedBuilder( | |
animation: _animationController, | |
builder: (_, child) { | |
return Transform( | |
child: child, | |
alignment: Alignment.center, | |
transform: Matrix4.diagonal3Values( | |
_buttonAnimation.value, | |
_buttonAnimation.value, | |
1.0, | |
), | |
); | |
}, | |
child: MaterialButton( | |
onPressed: () => animateToNextPageController.forward(), | |
color: Color(0xffffffff), | |
padding: | |
EdgeInsets.fromLTRB(_width / 5, _height / 40, _width / 5, _height / 40), | |
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(35.0)), | |
child: Text( | |
strings.FABI_LETS_GO, | |
style: TextStyle( | |
color: Color(0xff6B94AD), | |
fontWeight: FontWeight.w700, | |
fontSize: 20, | |
), | |
), | |
), | |
), | |
), | |
Center( | |
child: AnimatedBuilder( | |
animation: _animationController, | |
builder: (_, child) { | |
return Transform( | |
child: child, | |
alignment: Alignment.center, | |
transform: Matrix4.diagonal3Values( | |
_buttonAnimation.value, | |
_buttonAnimation.value, | |
1.0, | |
), | |
); | |
}, | |
child: MaterialButton( | |
onPressed: () => Navigator.push( | |
context, | |
CupertinoPageRoute( | |
builder: (_) => LoginScreen(), | |
), | |
), | |
child: Text( | |
strings.ALREADY_HAVE_ACCOUNT, | |
style: TextStyle( | |
color: Color(0xffffffff), | |
fontWeight: FontWeight.w900, | |
fontSize: 20, | |
), | |
), | |
), | |
), | |
), | |
Center( | |
child: AnimatedBuilder( | |
animation: _animationController, | |
builder: (_, child) { | |
return Transform( | |
child: child, | |
alignment: Alignment.center, | |
transform: Matrix4.diagonal3Values( | |
_tryDemoAnimation.value, | |
_tryDemoAnimation.value, | |
1.0, | |
), | |
); | |
}, | |
child: MaterialButton( | |
onPressed: () {}, | |
child: Text( | |
strings.TRY_DEMO, | |
style: TextStyle( | |
color: Color(0xffffffff), | |
fontWeight: FontWeight.w900, | |
fontSize: 20, | |
), | |
), | |
), | |
), | |
) | |
], | |
), | |
Align( | |
alignment: Alignment.bottomCenter, | |
child: SlideTransition( | |
position: animateToNextPageOffset, | |
child: EnterNameScreen( | |
controller: animateToNextPageController, | |
))) | |
], | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment