Visitar URL original
Adds animations package with open container transition by goderbauer · Pull Request #30 · flutter/packages · GitHub
Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
formatting fixes
  • Loading branch information
goderbauer committed Aug 31, 2019
commit 42435892ff98191aea90bd2e9d381e3749db3ea3
54 changes: 30 additions & 24 deletions packages/animations/lib/src/open_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ class _OpenContainerRoute extends ModalRoute<void> {
final ShapeBorderTween _shapeTween;
final _FlippableTweenSequence<Color> _colorTween;

final _FlippableTweenSequence<double> _closedChildOpacityTween =
final _FlippableTweenSequence<double> _closedOpacityTween =
_FlippableTweenSequence<double>(<TweenSequenceItem<double>>[
TweenSequenceItem<double>(
tween: Tween<double>(begin: 1.0, end: 0.0),
Expand All @@ -286,7 +286,7 @@ class _OpenContainerRoute extends ModalRoute<void> {
weight: 8 / 12,
),
]);
final _FlippableTweenSequence<double> _openChildOpacityTween =
final _FlippableTweenSequence<double> _openOpacityTween =
_FlippableTweenSequence<double>(<TweenSequenceItem<double>>[
TweenSequenceItem<double>(
tween: ConstantTween<double>(0.0),
Expand All @@ -298,7 +298,7 @@ class _OpenContainerRoute extends ModalRoute<void> {
),
]);

final GlobalKey _openChildKey = GlobalKey();
final GlobalKey _openBuilderKey = GlobalKey();
Comment thread
goderbauer marked this conversation as resolved.
Resolved

// Defines the position of the container on screen.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

container => OpenContainer (?)

And it's not really the "screen", it's the bounds of the enclosing navigator (which is often the same size as the screen of course).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

final RectTween _insetsTween = RectTween(end: Rect.zero);
Expand Down Expand Up @@ -434,7 +434,7 @@ class _OpenContainerRoute extends ModalRoute<void> {
color: openColor,
elevation: openElevation,
child: Builder(
key: _openChildKey,
key: _openBuilderKey,
builder: (BuildContext context) {
return openBuilder(context, closeContainer);
},
Expand All @@ -450,23 +450,23 @@ class _OpenContainerRoute extends ModalRoute<void> {
_transitionWasInterrupted ? null : Curves.fastOutSlowIn.flipped,
);
TweenSequence<Color> colorTween;
TweenSequence<double> closedChildOpacityTween, openChildOpacityTween;
TweenSequence<double> closedOpacityTween, openOpacityTween;
switch (animation.status) {
case AnimationStatus.dismissed:
case AnimationStatus.forward:
closedChildOpacityTween = _closedChildOpacityTween;
openChildOpacityTween = _openChildOpacityTween;
closedOpacityTween = _closedOpacityTween;
openOpacityTween = _openOpacityTween;
colorTween = _colorTween;
break;
case AnimationStatus.reverse:
if (_transitionWasInterrupted) {
closedChildOpacityTween = _closedChildOpacityTween;
openChildOpacityTween = _openChildOpacityTween;
closedOpacityTween = _closedOpacityTween;
openOpacityTween = _openOpacityTween;
colorTween = _colorTween;
break;
}
closedChildOpacityTween = _closedChildOpacityTween.flipped;
openChildOpacityTween = _openChildOpacityTween.flipped;
closedOpacityTween = _closedOpacityTween.flipped;
openOpacityTween = _openOpacityTween.flipped;
colorTween = _colorTween.flipped;
break;
case AnimationStatus.completed:
Expand All @@ -478,7 +478,11 @@ class _OpenContainerRoute extends ModalRoute<void> {

return Container(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a Padding widget

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.

padding: EdgeInsets.fromLTRB(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why we don't have EdgeInsets.fromRect()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That seems like a good addition. Filed flutter/flutter#45576.

rect.left, rect.top, rect.right, rect.bottom),
rect.left,
rect.top,
rect.right,
rect.bottom,
),
child: SizedBox(
width: size.width,
height: size.height,
Expand All @@ -498,16 +502,18 @@ class _OpenContainerRoute extends ModalRoute<void> {
child: SizedBox(
width: _sizeTween.begin.width,
height: _sizeTween.begin.height,
child: hideableKey.currentState.placeholder == null ? null : Opacity(
opacity: closedChildOpacityTween.evaluate(animation),
child: Builder(
builder: (BuildContext context) {
// Passing in a dummy "open container" callback
// since we are in the process of opening.
return closedBuilder(context, () {});
},
),
),
child: hideableKey.currentState.placeholder == null
? null
Comment thread
goderbauer marked this conversation as resolved.
Resolved
: Opacity(
opacity: closedOpacityTween.evaluate(animation),
child: Builder(
builder: (BuildContext context) {
// Use dummy "open container" callback
// since we are in the process of opening.
return closedBuilder(context, () {});
},
),
),
),
),

Expand All @@ -519,9 +525,9 @@ class _OpenContainerRoute extends ModalRoute<void> {
width: _sizeTween.end.width,
height: _sizeTween.end.height,
child: Opacity(
opacity: openChildOpacityTween.evaluate(animation),
opacity: openOpacityTween.evaluate(animation),
child: Builder(
key: _openChildKey,
key: _openBuilderKey,
builder: (BuildContext context) {
return openBuilder(context, closeContainer);
},
Expand Down