Line data Source code
1 : import 'package:flutter/cupertino.dart';
2 : import 'package:flutter/material.dart';
3 : import 'transitions_component.dart';
4 :
5 : class LeftToRightFadeTransition extends TransitionInterface {
6 0 : LeftToRightFadeTransition({
7 : TransitionComponent transitionComponent,
8 0 : }) : super(transitionComponent: transitionComponent);
9 :
10 0 : @override
11 : Widget buildChildWithTransition(
12 : BuildContext context,
13 : Animation<double> animation,
14 : Animation<double> secondaryAnimation,
15 : Widget child) {
16 0 : return SlideTransition(
17 0 : position: Tween<Offset>(
18 : begin: const Offset(-1.0, 0.0),
19 : end: Offset.zero,
20 0 : ).animate(animation),
21 0 : child: FadeTransition(
22 : opacity: animation,
23 0 : child: SlideTransition(
24 0 : position: Tween<Offset>(
25 : begin: Offset.zero,
26 : end: const Offset(1.0, 0.0),
27 0 : ).animate(secondaryAnimation),
28 : child: child),
29 : ),
30 : );
31 : }
32 : }
33 :
34 : class RightToLeftFadeTransition extends TransitionInterface {
35 0 : RightToLeftFadeTransition({
36 : TransitionComponent transitionComponent,
37 0 : }) : super(transitionComponent: transitionComponent);
38 :
39 0 : @override
40 : Widget buildChildWithTransition(
41 : BuildContext context,
42 : Animation<double> animation,
43 : Animation<double> secondaryAnimation,
44 : Widget child) {
45 0 : return SlideTransition(
46 0 : position: Tween<Offset>(
47 : begin: const Offset(1.0, 0.0),
48 : end: Offset.zero,
49 0 : ).animate(animation),
50 0 : child: FadeTransition(
51 : opacity: animation,
52 0 : child: SlideTransition(
53 0 : position: Tween<Offset>(
54 : begin: Offset.zero,
55 : end: const Offset(-1.0, 0.0),
56 0 : ).animate(secondaryAnimation),
57 : child: child),
58 : ),
59 : );
60 : }
61 : }
62 :
63 : class NoTransition extends TransitionInterface {
64 0 : NoTransition({
65 : TransitionComponent transitionComponent,
66 0 : }) : super(transitionComponent: transitionComponent);
67 :
68 0 : @override
69 : Widget buildChildWithTransition(
70 : BuildContext context,
71 : Animation<double> animation,
72 : Animation<double> secondaryAnimation,
73 : Widget child) {
74 0 : return transitionComponent.buildChildWithTransition(
75 : context, animation, secondaryAnimation, child);
76 : }
77 : }
78 :
79 : class FadeInTransition extends TransitionInterface {
80 1 : FadeInTransition({
81 : TransitionComponent transitionComponent,
82 1 : }) : super(transitionComponent: transitionComponent);
83 :
84 1 : @override
85 : Widget buildChildWithTransition(
86 : BuildContext context,
87 : Animation<double> animation,
88 : Animation<double> secondaryAnimation,
89 : Widget child) {
90 1 : return FadeTransition(
91 : opacity: animation,
92 2 : child: transitionComponent.buildChildWithTransition(
93 : context, animation, secondaryAnimation, child),
94 : );
95 : }
96 : }
97 :
98 : class SlideDownTransition extends TransitionInterface {
99 0 : SlideDownTransition({
100 : TransitionComponent transitionComponent,
101 0 : }) : super(transitionComponent: transitionComponent);
102 :
103 0 : @override
104 : Widget buildChildWithTransition(
105 : BuildContext context,
106 : Animation<double> animation,
107 : Animation<double> secondaryAnimation,
108 : Widget child) {
109 0 : return SlideTransition(
110 0 : position: Tween<Offset>(
111 0 : begin: Offset(0.0, 1.0),
112 : end: Offset.zero,
113 0 : ).animate(animation),
114 0 : child: transitionComponent.buildChildWithTransition(
115 : context, animation, secondaryAnimation, child),
116 : );
117 : }
118 : }
119 :
120 : class SlideLeftTransition extends TransitionInterface {
121 0 : SlideLeftTransition({
122 : TransitionComponent transitionComponent,
123 0 : }) : super(transitionComponent: transitionComponent);
124 :
125 0 : @override
126 : Widget buildChildWithTransition(
127 : BuildContext context,
128 : Animation<double> animation,
129 : Animation<double> secondaryAnimation,
130 : Widget child) {
131 0 : return SlideTransition(
132 0 : position: Tween<Offset>(
133 0 : begin: Offset(-1.0, 0.0),
134 : end: Offset.zero,
135 0 : ).animate(animation),
136 0 : child: transitionComponent.buildChildWithTransition(
137 : context, animation, secondaryAnimation, child),
138 : );
139 : }
140 : }
141 :
142 : class SlideRightTransition extends TransitionInterface {
143 0 : SlideRightTransition({
144 : TransitionComponent transitionComponent,
145 0 : }) : super(transitionComponent: transitionComponent);
146 :
147 0 : @override
148 : Widget buildChildWithTransition(
149 : BuildContext context,
150 : Animation<double> animation,
151 : Animation<double> secondaryAnimation,
152 : Widget child) {
153 0 : return SlideTransition(
154 0 : position: Tween<Offset>(
155 0 : begin: Offset(1.0, 0.0),
156 : end: Offset.zero,
157 0 : ).animate(animation),
158 0 : child: transitionComponent.buildChildWithTransition(
159 : context, animation, secondaryAnimation, child),
160 : );
161 : }
162 : }
163 :
164 : class SlideTopTransition extends TransitionInterface {
165 0 : SlideTopTransition({
166 : TransitionComponent transitionComponent,
167 0 : }) : super(transitionComponent: transitionComponent);
168 :
169 0 : @override
170 : Widget buildChildWithTransition(
171 : BuildContext context,
172 : Animation<double> animation,
173 : Animation<double> secondaryAnimation,
174 : Widget child) {
175 0 : return SlideTransition(
176 0 : position: Tween<Offset>(
177 0 : begin: Offset(0.0, -1.0),
178 : end: Offset.zero,
179 0 : ).animate(animation),
180 0 : child: transitionComponent.buildChildWithTransition(
181 : context, animation, secondaryAnimation, child),
182 : );
183 : }
184 : }
185 :
186 : class ZoomInTransition extends TransitionInterface {
187 0 : ZoomInTransition({TransitionComponent transitionComponent})
188 0 : : assert(transitionComponent != null),
189 0 : super(transitionComponent: transitionComponent);
190 :
191 0 : @override
192 : Widget buildChildWithTransition(
193 : BuildContext context,
194 : Animation<double> animation,
195 : Animation<double> secondaryAnimation,
196 : Widget child) {
197 0 : return ScaleTransition(
198 : scale: animation,
199 0 : child: transitionComponent.buildChildWithTransition(
200 : context, animation, secondaryAnimation, child),
201 : );
202 : }
203 : }
204 :
205 : abstract class TransitionInterface implements TransitionComponent {
206 : TransitionComponent transitionComponent;
207 1 : TransitionInterface({this.transitionComponent});
208 : }
|