-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[animations] Add fillColor property to shared axis transitions #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
3f39081
448c7ce
5987ef6
968faa3
46a191f
dd12425
de91965
fb10277
6053935
f54dc0e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,11 +80,17 @@ class SharedAxisPageTransitionsBuilder extends PageTransitionsBuilder { | |
| /// Construct a [SharedAxisPageTransitionsBuilder]. | ||
| const SharedAxisPageTransitionsBuilder({ | ||
| this.transitionType, | ||
| this.fillColor, | ||
| }); | ||
|
|
||
| /// Determines which [SharedAxisTransitionType] to build. | ||
| final SharedAxisTransitionType transitionType; | ||
|
|
||
| /// The color to use for the background color during the transition. | ||
| /// | ||
| /// This defaults to the [Theme]'s [ThemeData.canvasColor]. | ||
| final Color fillColor; | ||
|
|
||
| @override | ||
| Widget buildTransitions<T>( | ||
| PageRoute<T> route, | ||
|
|
@@ -97,6 +103,7 @@ class SharedAxisPageTransitionsBuilder extends PageTransitionsBuilder { | |
| animation: animation, | ||
| secondaryAnimation: secondaryAnimation, | ||
| transitionType: transitionType, | ||
| fillColor: fillColor, | ||
| child: child, | ||
| ); | ||
| } | ||
|
|
@@ -186,6 +193,7 @@ class SharedAxisTransition extends StatefulWidget { | |
| @required this.animation, | ||
| @required this.secondaryAnimation, | ||
| @required this.transitionType, | ||
| this.fillColor, | ||
| this.child, | ||
| }) : assert(transitionType != null), | ||
| super(key: key); | ||
|
|
@@ -215,6 +223,11 @@ class SharedAxisTransition extends StatefulWidget { | |
| /// axis transition types. | ||
| final SharedAxisTransitionType transitionType; | ||
|
|
||
| /// The color to use for the background color during the transition. | ||
| /// | ||
| /// This defaults to the [Theme]'s [ThemeData.canvasColor]. | ||
| final Color fillColor; | ||
|
|
||
| /// The widget below this widget in the tree. | ||
| /// | ||
| /// This widget will transition in and out as driven by [animation] and | ||
|
|
@@ -341,6 +354,7 @@ class _SharedAxisTransitionState extends State<SharedAxisTransition> { | |
| animation: _flip(widget.animation), | ||
| transitionType: widget.transitionType, | ||
| reverse: true, | ||
| fillColor: widget.fillColor, | ||
| child: child, | ||
| ); | ||
| } | ||
|
|
@@ -355,6 +369,7 @@ class _SharedAxisTransitionState extends State<SharedAxisTransition> { | |
| return _ExitTransition( | ||
| animation: widget.secondaryAnimation, | ||
| transitionType: widget.transitionType, | ||
| fillColor: widget.fillColor, | ||
| child: child, | ||
| ); | ||
| case AnimationStatus.dismissed: | ||
|
|
@@ -453,13 +468,15 @@ class _ExitTransition extends StatelessWidget { | |
| this.animation, | ||
| this.transitionType, | ||
| this.reverse = false, | ||
| this.fillColor, | ||
| this.child, | ||
| }); | ||
|
|
||
| final Animation<double> animation; | ||
| final SharedAxisTransitionType transitionType; | ||
| final Widget child; | ||
| final bool reverse; | ||
| final Color fillColor; | ||
| final Widget child; | ||
|
|
||
| static final Animatable<double> _fadeOutTransition = FlippedCurveTween( | ||
| curve: accelerateEasing, | ||
|
|
@@ -487,7 +504,7 @@ class _ExitTransition extends StatelessWidget { | |
| return FadeTransition( | ||
| opacity: _fadeOutTransition.animate(animation), | ||
| child: Container( | ||
| color: Theme.of(context).canvasColor, | ||
| color: fillColor ?? Theme.of(context).canvasColor, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did we have to give this a background color at all? Couldn't it just be unopinionated and let whatever color is behind it shine through?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this was an oversight. Would it be better to just remove the color parameter from the
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think so. It seems the transition shouldn't really have an opinion about the background color.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I actually remember why now. This becomes a problem if you use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, that makes sense. |
||
| child: Transform.translate( | ||
| offset: slideOutTransition.evaluate(animation), | ||
| child: child, | ||
|
|
@@ -504,7 +521,7 @@ class _ExitTransition extends StatelessWidget { | |
| return FadeTransition( | ||
| opacity: _fadeOutTransition.animate(animation), | ||
| child: Container( | ||
| color: Theme.of(context).canvasColor, | ||
| color: fillColor ?? Theme.of(context).canvasColor, | ||
| child: Transform.translate( | ||
| offset: slideOutTransition.evaluate(animation), | ||
| child: child, | ||
|
|
@@ -516,7 +533,7 @@ class _ExitTransition extends StatelessWidget { | |
| return FadeTransition( | ||
| opacity: _fadeOutTransition.animate(animation), | ||
| child: Container( | ||
| color: Theme.of(context).canvasColor, | ||
| color: fillColor ?? Theme.of(context).canvasColor, | ||
| child: ScaleTransition( | ||
| scale: (!reverse ? _scaleUpTransition : _scaleDownTransition) | ||
| .animate(animation), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe just have the header say
## [1.0.1-dev] - TBDand remove the explanation below. When we release, we can just remove the dev and insert the date and the next change after the release would just add the TBD header again.(For the release version, we wouldn't want that explanation in the changelog.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, then we can decide for every change we add which version number to bump (major.minor.bugfix).