Skip to content

Commit 2a5f058

Browse files
committed
Responded to comments
1 parent f412345 commit 2a5f058

File tree

1 file changed

+40
-41
lines changed

1 file changed

+40
-41
lines changed

mdc_100_series/lib/backdrop.dart

Lines changed: 40 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ class _BackdropTitle extends AnimatedWidget {
6666
Key key,
6767
Listenable listenable,
6868
this.customIcon,
69-
this.frontTitle,
70-
this.backTitle,
71-
}) : super(key: key, listenable: listenable);
69+
@required this.frontTitle,
70+
@required this.backTitle,
71+
}) : assert(frontTitle != null),
72+
assert(backTitle != null),
73+
super(key: key, listenable: listenable);
7274

7375
@override
7476
Widget build(BuildContext context) {
@@ -79,43 +81,41 @@ class _BackdropTitle extends AnimatedWidget {
7981
rowContents.add(this.customIcon);
8082
}
8183

82-
if (this.frontTitle != null && this.backTitle != null) {
83-
Animation<Offset> backSlide = new Tween<Offset>(
84-
begin: Offset(0.0, 0.0),
85-
end: Offset(0.5, 0.0),
86-
).animate(animation);
87-
Animation<Offset> frontSlide = new Tween<Offset>(
88-
begin: Offset(-0.25, 0.0),
89-
end: Offset(0.0, 0.0),
90-
).animate(animation);
84+
Animation<Offset> backSlide = new Tween<Offset>(
85+
begin: Offset.zero,
86+
end: Offset(0.5, 0.0),
87+
).animate(animation);
88+
Animation<Offset> frontSlide = new Tween<Offset>(
89+
begin: Offset(-0.25, 0.0),
90+
end: Offset.zero,
91+
).animate(animation);
9192

92-
rowContents.add(Stack(
93-
// Here, we do a custom cross fade between backTitle and frontTitle.
94-
// This makes a smooth animation between the two texts.
95-
children: <Widget>[
96-
Opacity(
97-
opacity: CurvedAnimation(
98-
parent: ReverseAnimation(animation),
99-
curve: Interval(0.5, 1.0),
100-
).value,
101-
child: SlideTransition(
102-
position: backSlide,
103-
child: backTitle,
104-
),
93+
rowContents.add(Stack(
94+
// Here, we do a custom cross fade between backTitle and frontTitle.
95+
// This makes a smooth animation between the two texts.
96+
children: <Widget>[
97+
Opacity(
98+
opacity: CurvedAnimation(
99+
parent: ReverseAnimation(animation),
100+
curve: Interval(0.5, 1.0),
101+
).value,
102+
child: SlideTransition(
103+
position: backSlide,
104+
child: backTitle,
105105
),
106-
Opacity(
107-
opacity: CurvedAnimation(
108-
parent: animation,
109-
curve: Interval(0.5, 1.0),
110-
).value,
111-
child: SlideTransition(
112-
position: frontSlide,
113-
child: frontTitle,
114-
),
106+
),
107+
Opacity(
108+
opacity: CurvedAnimation(
109+
parent: animation,
110+
curve: Interval(0.5, 1.0),
111+
).value,
112+
child: SlideTransition(
113+
position: frontSlide,
114+
child: frontTitle,
115115
),
116-
],
117-
));
118-
}
116+
),
117+
],
118+
));
119119

120120
return DefaultTextStyle(
121121
style: Theme.of(context).primaryTextTheme.title,
@@ -176,8 +176,7 @@ class _BackdropState extends State<Backdrop>
176176
if (widget.currentCategory != old.currentCategory) {
177177
setState(() {
178178
_controller.fling(
179-
velocity:
180-
_frontLayerVisible ? -_kFlingVelocity : _kFlingVelocity);
179+
velocity: _frontLayerVisible ? -_kFlingVelocity : _kFlingVelocity);
181180
});
182181
} else if (!_frontLayerVisible) {
183182
setState(() {
@@ -242,7 +241,7 @@ class _BackdropState extends State<Backdrop>
242241
);
243242

244243
Animation<Offset> slide = new Tween<Offset>(
245-
begin: Offset(0.0, 0.0),
244+
begin: Offset.zero,
246245
end: Offset(1.0, 0.0),
247246
).animate(_controller.view);
248247
var diamondIcon = SlideTransition(
@@ -252,7 +251,7 @@ class _BackdropState extends State<Backdrop>
252251
width: 72.0,
253252
child: IconButton(
254253
padding: EdgeInsets.only(right: 8.0),
255-
onPressed: _toggleBackdropPanelVisibility,
254+
onPressed: _toggleBackdropLayerVisibility,
256255
icon: Stack(children: <Widget>[menuIcon, diamondIcon]),
257256
),
258257
);

0 commit comments

Comments
 (0)