-
Notifications
You must be signed in to change notification settings - Fork 248
[104] Add branded icon menu nav animation #28
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 54 commits
4736f4d
f35a5ee
6a68899
4ff1bdd
cbdec91
01a8917
f5089c4
4e454e5
ac5749b
5ebbe30
fcefb2f
b038b96
6261855
cd0c5e3
77b4eb9
081fcb8
76766c1
330acb6
ff206b7
fa3c1af
d9c47a5
fdbe581
061d0da
d17bcf4
84ee656
871d445
8281cc2
322e4bc
1d44d1e
55474b5
8a48536
36e5157
f3d01c8
4a00a80
7389a02
aae57c9
24dfbdd
f775045
d848b07
36a82d3
91ec150
d096aea
bb16b35
889869b
ae2df64
d4ff197
2a4a3dd
4e557d5
f412345
2a5f058
556a43a
807d459
bf2bc80
57358be
50a6f03
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 |
---|---|---|
|
@@ -58,43 +58,83 @@ class _FrontLayer extends StatelessWidget { | |
} | ||
|
||
class _BackdropTitle extends AnimatedWidget { | ||
// final Widget customIcon; | ||
final Function onPress; | ||
final Widget frontTitle; | ||
final Widget backTitle; | ||
|
||
const _BackdropTitle({ | ||
Key key, | ||
Listenable listenable, | ||
this.frontTitle, | ||
this.backTitle, | ||
}) : super(key: key, listenable: listenable); | ||
this.onPress, | ||
@required this.frontTitle, | ||
@required this.backTitle, | ||
}) : assert(frontTitle != null), | ||
assert(backTitle != null), | ||
super(key: key, listenable: listenable); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final Animation<double> animation = this.listenable; | ||
|
||
return DefaultTextStyle( | ||
style: Theme.of(context).primaryTextTheme.title, | ||
softWrap: false, | ||
overflow: TextOverflow.ellipsis, | ||
// Here, we do a custom cross fade between backTitle and frontTitle. | ||
// This makes a smooth animation between the two texts. | ||
child: Stack( | ||
children: <Widget>[ | ||
Opacity( | ||
opacity: CurvedAnimation( | ||
parent: ReverseAnimation(animation), | ||
curve: Interval(0.5, 1.0), | ||
).value, | ||
child: backTitle, | ||
), | ||
Opacity( | ||
opacity: CurvedAnimation( | ||
parent: animation, | ||
curve: Interval(0.5, 1.0), | ||
).value, | ||
child: frontTitle, | ||
child: Row(children: <Widget>[ | ||
// branded icon | ||
SizedBox( | ||
width: 72.0, | ||
child: IconButton( | ||
padding: EdgeInsets.only(right: 8.0), | ||
onPressed: this.onPress, | ||
icon: Stack(children: <Widget>[ | ||
Opacity( | ||
opacity: animation.value, | ||
child: ImageIcon(AssetImage('assets/slanted_menu.png')), | ||
), | ||
FractionalTranslation( | ||
translation: Tween<Offset>( | ||
begin: Offset.zero, | ||
end: Offset(1.0, 0.0), | ||
).animate(animation).value, | ||
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. .animate(animation).value => .evaluate(animation) Using .animate here would work but you don't need to create a new animation that's listening to 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. Should we change this in the backdrop layer animation too? |
||
child: ImageIcon(AssetImage('assets/diamond.png')), | ||
)]), | ||
), | ||
], | ||
), | ||
), | ||
// Here, we do a custom cross fade between backTitle and frontTitle. | ||
// This makes a smooth animation between the two texts. | ||
Stack( | ||
children: <Widget>[ | ||
Opacity( | ||
opacity: CurvedAnimation( | ||
parent: ReverseAnimation(animation), | ||
curve: Interval(0.5, 1.0), | ||
).value, | ||
child: FractionalTranslation( | ||
translation: Tween<Offset>( | ||
begin: Offset.zero, | ||
end: Offset(0.5, 0.0), | ||
).animate(animation).value, | ||
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. Same comment as before (and again below) |
||
child: backTitle, | ||
), | ||
), | ||
Opacity( | ||
opacity: CurvedAnimation( | ||
parent: animation, | ||
curve: Interval(0.5, 1.0), | ||
).value, | ||
child: FractionalTranslation( | ||
translation: Tween<Offset>( | ||
begin: Offset(-0.25, 0.0), | ||
end: Offset.zero, | ||
).animate(animation).value, | ||
child: frontTitle, | ||
), | ||
), | ||
], | ||
) | ||
]), | ||
); | ||
} | ||
} | ||
|
@@ -146,7 +186,7 @@ class _BackdropState extends State<Backdrop> | |
@override | ||
void didUpdateWidget(Backdrop old) { | ||
super.didUpdateWidget(old); | ||
|
||
if (widget.currentCategory != old.currentCategory) { | ||
_toggleBackdropLayerVisibility(); | ||
} else if (!_frontLayerVisible) { | ||
|
@@ -199,34 +239,15 @@ class _BackdropState extends State<Backdrop> | |
|
||
@override | ||
Widget build(BuildContext context) { | ||
var brandedIcon = Row(children: <Widget>[ | ||
ImageIcon(AssetImage('assets/slanted_menu.png')), | ||
ImageIcon(AssetImage('assets/diamond.png')), | ||
]); | ||
|
||
var appBar = AppBar( | ||
brightness: Brightness.light, | ||
elevation: 0.0, | ||
titleSpacing: 0.0, | ||
title: _BackdropTitle( | ||
listenable: _controller.view, | ||
frontTitle: Row( | ||
children: <Widget>[ | ||
SizedBox( | ||
width: 72.0, | ||
child: IconButton( | ||
padding: EdgeInsets.only(left: 20.0), | ||
onPressed: _toggleBackdropLayerVisibility, | ||
icon: brandedIcon, | ||
), | ||
), | ||
widget.frontTitle, | ||
], | ||
), | ||
backTitle: IconButton( | ||
onPressed: _toggleBackdropLayerVisibility, | ||
icon: Icon(Icons.close), | ||
), | ||
onPress: _toggleBackdropLayerVisibility, | ||
frontTitle: widget.frontTitle, | ||
backTitle: widget.backTitle, | ||
), | ||
actions: <Widget>[ | ||
new IconButton( | ||
|
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.
Intentional?