Commit c68494eb authored by Adam Barth's avatar Adam Barth

Merge pull request #3015 from abarth/snackbar_fade

Snackbar opacity animation shouldn't trigger on reverse
parents 11974318 da987ed2
......@@ -95,6 +95,25 @@ class Interval extends Curve {
}
}
/// A curve that is 0.0 until it hits the threshold, then it jumps to 1.0.
class Step extends Curve {
const Step(this.threshold);
/// The value before which the curve is 0.0 and after which the curve is 1.0.
///
/// At exactly step, the curve has the value 1.0.
final double threshold;
@override
double transform(double t) {
assert(threshold >= 0.0);
assert(threshold <= 1.0);
if (t == 0.0 || t == 1.0)
return t;
return t < threshold ? 0.0 : 1.0;
}
}
/// A cubic polynomial mapping of the unit interval.
class Cubic extends Curve {
const Cubic(this.a, this.b, this.c, this.d);
......
......@@ -82,7 +82,7 @@ class _DropDownMenu<T> extends StatusTransitionWidget {
for (int itemIndex = 0; itemIndex < route.items.length; ++itemIndex) {
CurvedAnimation opacity;
if (itemIndex == route.selectedIndex) {
opacity = new CurvedAnimation(parent: route.animation, curve: const Interval(0.0, 0.001), reverseCurve: const Interval(0.75, 1.0));
opacity = new CurvedAnimation(parent: route.animation, curve: const Step(0.0), reverseCurve: const Interval(0.75, 1.0));
} else {
final double start = (0.5 + (itemIndex + 1) * unit).clamp(0.0, 1.0);
final double end = (start + 1.5 * unit).clamp(0.0, 1.0);
......@@ -112,7 +112,7 @@ class _DropDownMenu<T> extends StatusTransitionWidget {
final CurvedAnimation resize = new CurvedAnimation(
parent: route.animation,
curve: const Interval(0.25, 0.5),
reverseCurve: const Interval(0.0, 0.001)
reverseCurve: const Step(0.0)
);
final Tween<double> menuTop = new Tween<double>(
......
......@@ -105,7 +105,7 @@ class SnackBar extends StatelessWidget {
if (action != null)
children.add(action);
CurvedAnimation heightAnimation = new CurvedAnimation(parent: animation, curve: _snackBarHeightCurve);
CurvedAnimation fadeAnimation = new CurvedAnimation(parent: animation, curve: _snackBarFadeCurve);
CurvedAnimation fadeAnimation = new CurvedAnimation(parent: animation, curve: _snackBarFadeCurve, reverseCurve: const Step(0.0));
ThemeData theme = Theme.of(context);
return new ClipRect(
child: new AnimatedBuilder(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment