Skip to content

Commit be3532d

Browse files
clocksmithTian Lun Lee
authored and
Tian Lun Lee
committed
[104] Add branded icon menu nav animation (#28)
* [101] Correcting widget class. * [101] Complete code. [102] Starter code. * [102] Minor copy correction. * [101] Update for Dart 2 * [102] Complete code. [103] Starter code. * [102] Correcting home being stateful. * [103] Correcting order of fields. (#10) * [102] Removing unneeded value. * [102] Dart 2. * [102] Data correction. * [103] Completed code. [104] Starter code. * [103] Removing unneeded directory. * [103] Unused icons code. * [103] Moving supplemental files. * [103] Using recent changes. * [103] Removing unused import. * [103] Data correction. * [103] Adding body2 styling. * [103] Dart 2 * [103] Color const correction. * [102] Complete code. [103] Starter code. * [103] Completed code. [104] Starter code. * [103] Completed code. [104] Starter code. * [103] Correcting order of fields. (#10) * add backdrop and working menu with filtering * [104] Minor visual changes. * [103] Using recent changes. * [104] Visual detail. * [104] Newline at EOF. * [104] License stanzas. * [104] Removing files from merge. * [104] Sync. * [104] Correcting license * [104] Adding license stanza * [104] Decrease backdrop radius size to match mocks. (#21) * [104] PR feedback. * [104] Removing an unnecessary widget. * [104] Formatting. * [104] Replaces regular hamburger menu behavior with a branded version (#22) * [104] Replaces regular hamburger menu behavior with a branded icon version. * Fixed space nit and refactored branded icon into its own var. * whitespace * [104] Changing "Panel" to "Layer" (#24) * [104] Clarifying backdrop. * [104] Changing panel to layer. * Start to reconfigure the _BackdropTitle to handle custom transition animations. * Added a customIcon to _BackdropTitle with the correct animations for branded icon. * Added front and back title sliding to the branded icon animation. * [104] Merge sync. (#27) * Start to reconfigure the _BackdropTitle to handle custom transition animations. * Added a customIcon to _BackdropTitle with the correct animations for branded icon. * Added front and back title sliding to the branded icon animation. * rebase fixes * Responded to comments * merge fix * Rearranged the animations and used nested widgets instead of transitions with no local vars. * Fix bad rebase * Respond to comments by replacing .animate with .evaluate
1 parent d5e58c6 commit be3532d

File tree

1 file changed

+65
-45
lines changed

1 file changed

+65
-45
lines changed

mdc_100_series/lib/backdrop.dart

+65-45
Original file line numberDiff line numberDiff line change
@@ -58,43 +58,82 @@ class _FrontLayer extends StatelessWidget {
5858
}
5959

6060
class _BackdropTitle extends AnimatedWidget {
61+
final Function onPress;
6162
final Widget frontTitle;
6263
final Widget backTitle;
6364

6465
const _BackdropTitle({
6566
Key key,
6667
Listenable listenable,
67-
this.frontTitle,
68-
this.backTitle,
69-
}) : super(key: key, listenable: listenable);
68+
this.onPress,
69+
@required this.frontTitle,
70+
@required this.backTitle,
71+
}) : assert(frontTitle != null),
72+
assert(backTitle != null),
73+
super(key: key, listenable: listenable);
7074

7175
@override
7276
Widget build(BuildContext context) {
7377
final Animation<double> animation = this.listenable;
78+
7479
return DefaultTextStyle(
7580
style: Theme.of(context).primaryTextTheme.title,
7681
softWrap: false,
7782
overflow: TextOverflow.ellipsis,
78-
// Here, we do a custom cross fade between backTitle and frontTitle.
79-
// This makes a smooth animation between the two texts.
80-
child: Stack(
81-
children: <Widget>[
82-
Opacity(
83-
opacity: CurvedAnimation(
84-
parent: ReverseAnimation(animation),
85-
curve: Interval(0.5, 1.0),
86-
).value,
87-
child: backTitle,
88-
),
89-
Opacity(
90-
opacity: CurvedAnimation(
91-
parent: animation,
92-
curve: Interval(0.5, 1.0),
93-
).value,
94-
child: frontTitle,
83+
child: Row(children: <Widget>[
84+
// branded icon
85+
SizedBox(
86+
width: 72.0,
87+
child: IconButton(
88+
padding: EdgeInsets.only(right: 8.0),
89+
onPressed: this.onPress,
90+
icon: Stack(children: <Widget>[
91+
Opacity(
92+
opacity: animation.value,
93+
child: ImageIcon(AssetImage('assets/slanted_menu.png')),
94+
),
95+
FractionalTranslation(
96+
translation: Tween<Offset>(
97+
begin: Offset.zero,
98+
end: Offset(1.0, 0.0),
99+
).evaluate(animation),
100+
child: ImageIcon(AssetImage('assets/diamond.png')),
101+
)]),
95102
),
96-
],
97-
),
103+
),
104+
// Here, we do a custom cross fade between backTitle and frontTitle.
105+
// This makes a smooth animation between the two texts.
106+
Stack(
107+
children: <Widget>[
108+
Opacity(
109+
opacity: CurvedAnimation(
110+
parent: ReverseAnimation(animation),
111+
curve: Interval(0.5, 1.0),
112+
).value,
113+
child: FractionalTranslation(
114+
translation: Tween<Offset>(
115+
begin: Offset.zero,
116+
end: Offset(0.5, 0.0),
117+
).evaluate(animation),
118+
child: backTitle,
119+
),
120+
),
121+
Opacity(
122+
opacity: CurvedAnimation(
123+
parent: animation,
124+
curve: Interval(0.5, 1.0),
125+
).value,
126+
child: FractionalTranslation(
127+
translation: Tween<Offset>(
128+
begin: Offset(-0.25, 0.0),
129+
end: Offset.zero,
130+
).evaluate(animation),
131+
child: frontTitle,
132+
),
133+
),
134+
],
135+
)
136+
]),
98137
);
99138
}
100139
}
@@ -146,7 +185,7 @@ class _BackdropState extends State<Backdrop>
146185
@override
147186
void didUpdateWidget(Backdrop old) {
148187
super.didUpdateWidget(old);
149-
188+
150189
if (widget.currentCategory != old.currentCategory) {
151190
_toggleBackdropLayerVisibility();
152191
} else if (!_frontLayerVisible) {
@@ -199,34 +238,15 @@ class _BackdropState extends State<Backdrop>
199238

200239
@override
201240
Widget build(BuildContext context) {
202-
var brandedIcon = Row(children: <Widget>[
203-
ImageIcon(AssetImage('assets/slanted_menu.png')),
204-
ImageIcon(AssetImage('assets/diamond.png')),
205-
]);
206-
207241
var appBar = AppBar(
208242
brightness: Brightness.light,
209243
elevation: 0.0,
210244
titleSpacing: 0.0,
211245
title: _BackdropTitle(
212246
listenable: _controller.view,
213-
frontTitle: Row(
214-
children: <Widget>[
215-
SizedBox(
216-
width: 72.0,
217-
child: IconButton(
218-
padding: EdgeInsets.only(left: 20.0),
219-
onPressed: _toggleBackdropLayerVisibility,
220-
icon: brandedIcon,
221-
),
222-
),
223-
widget.frontTitle,
224-
],
225-
),
226-
backTitle: IconButton(
227-
onPressed: _toggleBackdropLayerVisibility,
228-
icon: Icon(Icons.close),
229-
),
247+
onPress: _toggleBackdropLayerVisibility,
248+
frontTitle: widget.frontTitle,
249+
backTitle: widget.backTitle,
230250
),
231251
actions: <Widget>[
232252
new IconButton(

0 commit comments

Comments
 (0)