FlexibleSpaceBar should not include transparent widgets (#3527)
This commit is contained in:
@@ -80,18 +80,21 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
|
|||||||
curve: new Interval(math.max(0.0, fadeStart), math.min(fadeEnd, 1.0))
|
curve: new Interval(math.max(0.0, fadeStart), math.min(fadeEnd, 1.0))
|
||||||
);
|
);
|
||||||
final double parallax = new Tween<double>(begin: 0.0, end: appBarHeight / 4.0).evaluate(_scaffoldAnimation);
|
final double parallax = new Tween<double>(begin: 0.0, end: appBarHeight / 4.0).evaluate(_scaffoldAnimation);
|
||||||
children.add(new Positioned(
|
final double opacity = new Tween<double>(begin: 1.0, end: 0.0).evaluate(opacityCurve);
|
||||||
top: -parallax,
|
if (opacity > 0.0) {
|
||||||
left: 0.0,
|
children.add(new Positioned(
|
||||||
right: 0.0,
|
top: -parallax,
|
||||||
child: new Opacity(
|
left: 0.0,
|
||||||
opacity: new Tween<double>(begin: 1.0, end: 0.0).evaluate(opacityCurve),
|
right: 0.0,
|
||||||
child: new SizedBox(
|
child: new Opacity(
|
||||||
height: appBarHeight + statusBarHeight,
|
opacity: opacity,
|
||||||
child: config.background
|
child: new SizedBox(
|
||||||
|
height: appBarHeight + statusBarHeight,
|
||||||
|
child: config.background
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
));
|
||||||
));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// title
|
// title
|
||||||
@@ -102,34 +105,37 @@ class _FlexibleSpaceBarState extends State<FlexibleSpaceBar> {
|
|||||||
parent: _scaffoldAnimation,
|
parent: _scaffoldAnimation,
|
||||||
curve: new Interval(fadeStart, fadeEnd)
|
curve: new Interval(fadeStart, fadeEnd)
|
||||||
);
|
);
|
||||||
TextStyle titleStyle = Theme.of(context).primaryTextTheme.title;
|
final int alpha = new Tween<double>(begin: 255.0, end: 0.0).evaluate(opacityCurve).toInt();
|
||||||
titleStyle = titleStyle.copyWith(
|
if (alpha > 0) {
|
||||||
color: titleStyle.color.withAlpha(new Tween<double>(begin: 255.0, end: 0.0).evaluate(opacityCurve).toInt())
|
TextStyle titleStyle = Theme.of(context).primaryTextTheme.title;
|
||||||
);
|
titleStyle = titleStyle.copyWith(
|
||||||
final double yAlignStart = 1.0;
|
color: titleStyle.color.withAlpha(alpha)
|
||||||
final double yAlignEnd = (statusBarHeight + kToolBarHeight / 2.0) / toolBarHeight;
|
);
|
||||||
final double scaleAndAlignEnd = (appBarHeight - toolBarHeight) / appBarHeight;
|
final double yAlignStart = 1.0;
|
||||||
final CurvedAnimation scaleAndAlignCurve = new CurvedAnimation(
|
final double yAlignEnd = (statusBarHeight + kToolBarHeight / 2.0) / toolBarHeight;
|
||||||
parent: _scaffoldAnimation,
|
final double scaleAndAlignEnd = (appBarHeight - toolBarHeight) / appBarHeight;
|
||||||
curve: new Interval(0.0, scaleAndAlignEnd)
|
final CurvedAnimation scaleAndAlignCurve = new CurvedAnimation(
|
||||||
);
|
parent: _scaffoldAnimation,
|
||||||
children.add(new Padding(
|
curve: new Interval(0.0, scaleAndAlignEnd)
|
||||||
padding: const EdgeInsets.only(left: 72.0, bottom: 14.0),
|
);
|
||||||
child: new Align(
|
children.add(new Padding(
|
||||||
alignment: new Tween<FractionalOffset>(
|
padding: const EdgeInsets.only(left: 72.0, bottom: 14.0),
|
||||||
begin: new FractionalOffset(0.0, yAlignStart),
|
child: new Align(
|
||||||
end: new FractionalOffset(0.0, yAlignEnd)
|
alignment: new Tween<FractionalOffset>(
|
||||||
).evaluate(scaleAndAlignCurve),
|
begin: new FractionalOffset(0.0, yAlignStart),
|
||||||
child: new ScaleTransition(
|
end: new FractionalOffset(0.0, yAlignEnd)
|
||||||
alignment: FractionalOffset.bottomLeft,
|
).evaluate(scaleAndAlignCurve),
|
||||||
scale: new Tween<double>(begin: 1.5, end: 1.0).animate(scaleAndAlignCurve),
|
child: new ScaleTransition(
|
||||||
child: new Align(
|
alignment: FractionalOffset.bottomLeft,
|
||||||
alignment: new FractionalOffset(0.0, 1.0),
|
scale: new Tween<double>(begin: 1.5, end: 1.0).animate(scaleAndAlignCurve),
|
||||||
child: new DefaultTextStyle(style: titleStyle, child: config.title)
|
child: new Align(
|
||||||
|
alignment: new FractionalOffset(0.0, 1.0),
|
||||||
|
child: new DefaultTextStyle(style: titleStyle, child: config.title)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
));
|
||||||
));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ClipRect(child: new Stack(children: children));
|
return new ClipRect(child: new Stack(children: children));
|
||||||
|
|||||||
Reference in New Issue
Block a user