-
Notifications
You must be signed in to change notification settings - Fork 284
/
loginAnimation.dart
130 lines (125 loc) · 4.23 KB
/
loginAnimation.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
import 'package:flutter/material.dart';
import 'dart:async';
class StaggerAnimation extends StatelessWidget {
StaggerAnimation({Key key, this.buttonController})
: buttonSqueezeanimation = new Tween(
begin: 320.0,
end: 70.0,
)
.animate(
new CurvedAnimation(
parent: buttonController,
curve: new Interval(
0.0,
0.150,
),
),
),
buttomZoomOut = new Tween(
begin: 70.0,
end: 1000.0,
)
.animate(
new CurvedAnimation(
parent: buttonController,
curve: new Interval(
0.550,
0.999,
curve: Curves.bounceOut,
),
),
),
containerCircleAnimation = new EdgeInsetsTween(
begin: const EdgeInsets.only(bottom: 50.0),
end: const EdgeInsets.only(bottom: 0.0),
)
.animate(
new CurvedAnimation(
parent: buttonController,
curve: new Interval(
0.500,
0.800,
curve: Curves.ease,
),
),
),
super(key: key);
final AnimationController buttonController;
final Animation<EdgeInsets> containerCircleAnimation;
final Animation buttonSqueezeanimation;
final Animation buttomZoomOut;
Future<Null> _playAnimation() async {
try {
await buttonController.forward();
await buttonController.reverse();
} on TickerCanceled {}
}
Widget _buildAnimation(BuildContext context, Widget child) {
return new Padding(
padding: buttomZoomOut.value == 70
? const EdgeInsets.only(bottom: 50.0)
: containerCircleAnimation.value,
child: new InkWell(
onTap: () {
_playAnimation();
},
child: new Hero(
tag: "fade",
child: buttomZoomOut.value <= 300
? new Container(
width: buttomZoomOut.value == 70
? buttonSqueezeanimation.value
: buttomZoomOut.value,
height:
buttomZoomOut.value == 70 ? 60.0 : buttomZoomOut.value,
alignment: FractionalOffset.center,
decoration: new BoxDecoration(
color: const Color.fromRGBO(247, 64, 106, 1.0),
borderRadius: buttomZoomOut.value < 400
? new BorderRadius.all(const Radius.circular(30.0))
: new BorderRadius.all(const Radius.circular(0.0)),
),
child: buttonSqueezeanimation.value > 75.0
? new Text(
"Sign In",
style: new TextStyle(
color: Colors.white,
fontSize: 20.0,
fontWeight: FontWeight.w300,
letterSpacing: 0.3,
),
)
: buttomZoomOut.value < 300.0
? new CircularProgressIndicator(
value: null,
strokeWidth: 1.0,
valueColor: new AlwaysStoppedAnimation<Color>(
Colors.white),
)
: null)
: new Container(
width: buttomZoomOut.value,
height: buttomZoomOut.value,
decoration: new BoxDecoration(
shape: buttomZoomOut.value < 500
? BoxShape.circle
: BoxShape.rectangle,
color: const Color.fromRGBO(247, 64, 106, 1.0),
),
),
)),
);
}
@override
Widget build(BuildContext context) {
buttonController.addListener(() {
if (buttonController.isCompleted) {
Navigator.pushNamed(context, "/home");
}
});
return new AnimatedBuilder(
builder: _buildAnimation,
animation: buttonController,
);
}
}