-
-
Save MarcinusX/6a244d1a10c70f2be33512aa3a66ec52 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 _TicketsPageState extends State<TicketsPage> | |
with TickerProviderStateMixin { | |
AnimationController cardEntranceAnimationController; | |
List<Animation> ticketAnimations; | |
Animation fabAnimation; | |
@override | |
void initState() { | |
super.initState(); | |
cardEntranceAnimationController = new AnimationController( | |
vsync: this, | |
duration: Duration(milliseconds: 1100), | |
); | |
ticketAnimations = stops.map((stop) { | |
int index = stops.indexOf(stop); | |
double start = index * 0.1; | |
double duration = 0.6; | |
double end = duration + start; | |
return new Tween<double>(begin: 800.0, end: 0.0).animate( | |
new CurvedAnimation( | |
parent: cardEntranceAnimationController, | |
curve: new Interval(start, end, curve: Curves.decelerate))); | |
}).toList(); | |
fabAnimation = new CurvedAnimation( | |
parent: cardEntranceAnimationController, | |
curve: Interval(0.7, 1.0, curve: Curves.decelerate)); | |
cardEntranceAnimationController.forward(); | |
} | |
Iterable<Widget> _buildTickets() { | |
return stops.map((stop) { | |
int index = stops.indexOf(stop); | |
return AnimatedBuilder( | |
animation: cardEntranceAnimationController, | |
child: Padding( | |
padding: const EdgeInsets.symmetric(vertical: 4.0, horizontal: 8.0), | |
child: TicketCard(stop: stop), | |
), | |
builder: (context, child) => new Transform.translate( | |
offset: Offset(0.0, ticketAnimations[index].value), | |
child: child, | |
), | |
); | |
}); | |
} | |
_buildFab() { | |
return ScaleTransition( | |
scale: fabAnimation, | |
child: FloatingActionButton( | |
onPressed: () => Navigator.of(context).pop(), | |
child: new Icon(Icons.fingerprint), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment