Switch SlideTransition over to using Offset (#12369)

Previously, we used `Alignment`, which was difficult to understand. Now,
we just use an `Offset` scaled to the child's size, which is much easier
to understand.
This commit is contained in:
Adam Barth
2017-10-02 23:30:14 -07:00
committed by GitHub
parent 31b6ac049c
commit 6128f48c80
9 changed files with 93 additions and 76 deletions

View File

@@ -47,9 +47,9 @@ class NavigationIconView {
return new FadeTransition(
opacity: _animation,
child: new SlideTransition(
position: new AlignmentTween(
begin: const Alignment(0.0, 0.4), // Slightly down.
end: Alignment.center,
position: new Tween<Offset>(
begin: const Offset(0.0, 0.02), // Slightly down.
end: Offset.zero,
).animate(_animation),
child: new IconTheme(
data: new IconThemeData(

View File

@@ -25,7 +25,7 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
AnimationController _controller;
Animation<double> _drawerContentsOpacity;
Animation<Alignment> _drawerDetailsPosition;
Animation<Offset> _drawerDetailsPosition;
bool _showDrawerContents = true;
@override
@@ -39,9 +39,9 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
parent: new ReverseAnimation(_controller),
curve: Curves.fastOutSlowIn,
);
_drawerDetailsPosition = new AlignmentTween(
begin: const Alignment(0.0, -2.0),
end: Alignment.center,
_drawerDetailsPosition = new Tween<Offset>(
begin: const Offset(0.0, -1.0),
end: Offset.zero,
).animate(new CurvedAnimation(
parent: _controller,
curve: Curves.fastOutSlowIn,