mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Renamed AnimatedType to AnimatedValue
This commit is contained in:
parent
f3e07210b0
commit
0fd3302ebe
@ -9,6 +9,7 @@ dart_pkg("sky") {
|
||||
"CHANGELOG.md",
|
||||
"bin/init.dart",
|
||||
"lib/animation/animated_simulation.dart",
|
||||
"lib/animation/animated_value.dart",
|
||||
"lib/animation/animation_performance.dart",
|
||||
"lib/animation/curves.dart",
|
||||
"lib/animation/forces.dart",
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:sky/editing/input.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/widgets/animated_component.dart';
|
||||
import 'package:sky/widgets/animation_builder.dart';
|
||||
import 'package:sky/theme/colors.dart' as colors;
|
||||
@ -280,10 +280,10 @@ class StockHome extends AnimatedComponent {
|
||||
void _handleStockPurchased() {
|
||||
setState(() {
|
||||
_snackbarTransform = new AnimationBuilder()
|
||||
..position = new AnimatedType<Point>(const Point(0.0, 45.0), end: Point.origin);
|
||||
..position = new AnimatedValue<Point>(const Point(0.0, 45.0), end: Point.origin);
|
||||
var performance = _snackbarTransform.createPerformance(
|
||||
[_snackbarTransform.position], duration: _kSnackbarSlideDuration);
|
||||
watch(performance);
|
||||
watch(performance); // TODO(mpcomplete): need to unwatch
|
||||
performance.play();
|
||||
});
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/base/lerp.dart';
|
||||
@ -100,7 +101,7 @@ class CardCollectionApp extends App {
|
||||
assert(card.performance == null);
|
||||
card.performance = new AnimationPerformance()
|
||||
..duration = const Duration(milliseconds: 300)
|
||||
..variable = new AnimatedType<double>(
|
||||
..variable = new AnimatedValue<double>(
|
||||
card.height + kCardMargins.top + kCardMargins.bottom,
|
||||
end: 0.0,
|
||||
curve: ease,
|
||||
|
||||
79
packages/flutter/lib/animation/animated_value.dart
Normal file
79
packages/flutter/lib/animation/animated_value.dart
Normal file
@ -0,0 +1,79 @@
|
||||
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import "dart:sky";
|
||||
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/base/lerp.dart';
|
||||
|
||||
abstract class AnimatedVariable {
|
||||
void setProgress(double t);
|
||||
String toString();
|
||||
}
|
||||
|
||||
class Interval {
|
||||
final double start;
|
||||
final double end;
|
||||
|
||||
double adjustTime(double t) {
|
||||
return ((t - start) / (end - start)).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
Interval(this.start, this.end) {
|
||||
assert(start >= 0.0);
|
||||
assert(start <= 1.0);
|
||||
assert(end >= 0.0);
|
||||
assert(end <= 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
class AnimatedValue<T extends dynamic> extends AnimatedVariable {
|
||||
AnimatedValue(this.begin, { this.end, this.interval, this.curve: linear }) {
|
||||
value = begin;
|
||||
}
|
||||
|
||||
T value;
|
||||
T begin;
|
||||
T end;
|
||||
Interval interval;
|
||||
Curve curve;
|
||||
|
||||
void setProgress(double t) {
|
||||
if (end != null) {
|
||||
double adjustedTime = interval == null ? t : interval.adjustTime(t);
|
||||
if (adjustedTime == 1.0) {
|
||||
value = end;
|
||||
} else {
|
||||
// TODO(mpcomplete): Reverse the timeline and curve.
|
||||
value = begin + (end - begin) * curve.transform(adjustedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String toString() => 'AnimatedValue(begin=$begin, end=$end, value=$value)';
|
||||
}
|
||||
|
||||
class AnimatedList extends AnimatedVariable {
|
||||
List<AnimatedVariable> variables;
|
||||
Interval interval;
|
||||
|
||||
AnimatedList(this.variables, { this.interval });
|
||||
|
||||
void setProgress(double t) {
|
||||
double adjustedTime = interval == null ? t : interval.adjustTime(t);
|
||||
for (AnimatedVariable variable in variables)
|
||||
variable.setProgress(adjustedTime);
|
||||
}
|
||||
|
||||
String toString() => 'AnimatedList([$variables])';
|
||||
}
|
||||
|
||||
class AnimatedColor extends AnimatedValue<Color> {
|
||||
AnimatedColor(Color begin, { Color end, Curve curve: linear })
|
||||
: super(begin, end: end, curve: curve);
|
||||
|
||||
void setProgress(double t) {
|
||||
value = lerpColor(begin, end, t);
|
||||
}
|
||||
}
|
||||
@ -4,71 +4,9 @@
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:sky/animation/timeline.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/forces.dart';
|
||||
|
||||
abstract class AnimatedVariable {
|
||||
void setFraction(double t);
|
||||
String toString();
|
||||
}
|
||||
|
||||
class Interval {
|
||||
final double start;
|
||||
final double end;
|
||||
|
||||
double adjustTime(double t) {
|
||||
return ((t - start) / (end - start)).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
Interval(this.start, this.end) {
|
||||
assert(start >= 0.0);
|
||||
assert(start <= 1.0);
|
||||
assert(end >= 0.0);
|
||||
assert(end <= 1.0);
|
||||
}
|
||||
}
|
||||
|
||||
class AnimatedType<T extends dynamic> extends AnimatedVariable {
|
||||
AnimatedType(this.begin, { this.end, this.interval, this.curve: linear }) {
|
||||
value = begin;
|
||||
}
|
||||
|
||||
T value;
|
||||
T begin;
|
||||
T end;
|
||||
Interval interval;
|
||||
Curve curve;
|
||||
|
||||
void setFraction(double t) {
|
||||
if (end != null) {
|
||||
double adjustedTime = interval == null ? t : interval.adjustTime(t);
|
||||
if (adjustedTime == 1.0) {
|
||||
value = end;
|
||||
} else {
|
||||
// TODO(mpcomplete): Reverse the timeline and curve.
|
||||
value = begin + (end - begin) * curve.transform(adjustedTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String toString() => 'AnimatedType(begin=$begin, end=$end, value=$value)';
|
||||
}
|
||||
|
||||
class AnimatedList extends AnimatedVariable {
|
||||
List<AnimatedVariable> variables;
|
||||
Interval interval;
|
||||
|
||||
AnimatedList(this.variables, { this.interval });
|
||||
|
||||
void setFraction(double t) {
|
||||
double adjustedTime = interval == null ? t : interval.adjustTime(t);
|
||||
for (AnimatedVariable variable in variables)
|
||||
variable.setFraction(adjustedTime);
|
||||
}
|
||||
|
||||
String toString() => 'AnimatedList([$variables])';
|
||||
}
|
||||
import 'package:sky/animation/timeline.dart';
|
||||
|
||||
// This class manages a "performance" - a collection of values that change
|
||||
// based on a timeline. For example, a performance may handle an animation
|
||||
@ -82,7 +20,6 @@ class AnimationPerformance {
|
||||
_timeline = new Timeline(_tick);
|
||||
}
|
||||
|
||||
// TODO(mpcomplete): make this a list, or composable somehow.
|
||||
AnimatedVariable variable;
|
||||
// TODO(mpcomplete): duration should be on a director.
|
||||
Duration duration;
|
||||
@ -142,7 +79,7 @@ class AnimationPerformance {
|
||||
}
|
||||
|
||||
void _tick(double t) {
|
||||
variable.setFraction(t);
|
||||
variable.setProgress(t);
|
||||
_notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,6 +83,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
||||
}
|
||||
}
|
||||
|
||||
// Set during layout if overflow occurred on the main axis
|
||||
TextBaseline _textBaseline;
|
||||
TextBaseline get textBaseline => _textBaseline;
|
||||
void set textBaseline (TextBaseline value) {
|
||||
@ -92,8 +93,6 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin<RenderBox, Fl
|
||||
}
|
||||
}
|
||||
|
||||
// Set during layout if overflow occurred on the main axis
|
||||
double _overflow;
|
||||
|
||||
void setupParentData(RenderBox child) {
|
||||
if (child.parentData is! FlexBoxParentData)
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
import 'package:vector_math/vector_math.dart';
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/base/lerp.dart';
|
||||
@ -11,21 +12,21 @@ import 'package:sky/painting/box_painter.dart';
|
||||
import 'package:sky/widgets/basic.dart';
|
||||
import 'package:sky/widgets/animated_component.dart';
|
||||
|
||||
class AnimatedBoxConstraintsValue extends AnimatedType<BoxConstraints> {
|
||||
class AnimatedBoxConstraintsValue extends AnimatedValue<BoxConstraints> {
|
||||
AnimatedBoxConstraintsValue(BoxConstraints begin, { BoxConstraints end, Curve curve: linear })
|
||||
: super(begin, end: end, curve: curve);
|
||||
|
||||
void setFraction(double t) {
|
||||
void setProgress(double t) {
|
||||
// TODO(abarth): We should lerp the BoxConstraints.
|
||||
value = end;
|
||||
}
|
||||
}
|
||||
|
||||
class AnimatedBoxDecorationValue extends AnimatedType<BoxDecoration> {
|
||||
class AnimatedBoxDecorationValue extends AnimatedValue<BoxDecoration> {
|
||||
AnimatedBoxDecorationValue(BoxDecoration begin, { BoxDecoration end, Curve curve: linear })
|
||||
: super(begin, end: end, curve: curve);
|
||||
|
||||
void setFraction(double t) {
|
||||
void setProgress(double t) {
|
||||
if (t == 1.0) {
|
||||
value = end;
|
||||
return;
|
||||
@ -34,11 +35,11 @@ class AnimatedBoxDecorationValue extends AnimatedType<BoxDecoration> {
|
||||
}
|
||||
}
|
||||
|
||||
class AnimatedEdgeDimsValue extends AnimatedType<EdgeDims> {
|
||||
class AnimatedEdgeDimsValue extends AnimatedValue<EdgeDims> {
|
||||
AnimatedEdgeDimsValue(EdgeDims begin, { EdgeDims end, Curve curve: linear })
|
||||
: super(begin, end: end, curve: curve);
|
||||
|
||||
void setFraction(double t) {
|
||||
void setProgress(double t) {
|
||||
if (t == 1.0) {
|
||||
value = end;
|
||||
return;
|
||||
@ -54,7 +55,7 @@ class AnimatedEdgeDimsValue extends AnimatedType<EdgeDims> {
|
||||
|
||||
class ImplicitlyAnimatedValue<T> {
|
||||
final AnimationPerformance performance = new AnimationPerformance();
|
||||
final AnimatedType<T> _variable;
|
||||
final AnimatedValue<T> _variable;
|
||||
|
||||
ImplicitlyAnimatedValue(this._variable, Duration duration) {
|
||||
performance
|
||||
@ -168,21 +169,21 @@ class AnimatedContainer extends AnimatedComponent {
|
||||
|
||||
void _updateTransform() {
|
||||
_updateField(transform, _transform, () {
|
||||
_transform = new ImplicitlyAnimatedValue<Matrix4>(new AnimatedType<Matrix4>(transform), duration);
|
||||
_transform = new ImplicitlyAnimatedValue<Matrix4>(new AnimatedValue<Matrix4>(transform), duration);
|
||||
watch(_transform.performance);
|
||||
});
|
||||
}
|
||||
|
||||
void _updateWidth() {
|
||||
_updateField(width, _width, () {
|
||||
_width = new ImplicitlyAnimatedValue<double>(new AnimatedType<double>(width), duration);
|
||||
_width = new ImplicitlyAnimatedValue<double>(new AnimatedValue<double>(width), duration);
|
||||
watch(_width.performance);
|
||||
});
|
||||
}
|
||||
|
||||
void _updateHeight() {
|
||||
_updateField(height, _height, () {
|
||||
_height = new ImplicitlyAnimatedValue<double>( new AnimatedType<double>(height), duration);
|
||||
_height = new ImplicitlyAnimatedValue<double>( new AnimatedValue<double>(height), duration);
|
||||
watch(_height.performance);
|
||||
});
|
||||
}
|
||||
|
||||
@ -4,9 +4,8 @@
|
||||
|
||||
import 'package:vector_math/vector_math.dart';
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/base/lerp.dart';
|
||||
import 'package:sky/painting/box_painter.dart';
|
||||
import 'package:sky/theme/shadows.dart';
|
||||
import 'package:sky/widgets/basic.dart';
|
||||
@ -18,9 +17,9 @@ class AnimationBuilder {
|
||||
|
||||
AnimationBuilder();
|
||||
|
||||
AnimatedType<double> opacity;
|
||||
AnimatedType<Point> position;
|
||||
AnimatedType<double> shadow;
|
||||
AnimatedValue<double> opacity;
|
||||
AnimatedValue<Point> position;
|
||||
AnimatedValue<double> shadow;
|
||||
AnimatedColor backgroundColor;
|
||||
|
||||
// These don't animate, but are used to build the AnimationBuilder anyway.
|
||||
@ -30,7 +29,7 @@ class AnimationBuilder {
|
||||
Map<AnimatedVariable, AnimationPerformance> _variableToPerformance =
|
||||
new Map<AnimatedVariable, AnimationPerformance>();
|
||||
|
||||
AnimationPerformance createPerformance(List<AnimatedType> variables,
|
||||
AnimationPerformance createPerformance(List<AnimatedValue> variables,
|
||||
{ Duration duration }) {
|
||||
AnimationPerformance performance = new AnimationPerformance()
|
||||
..duration = duration
|
||||
@ -67,7 +66,7 @@ class AnimationBuilder {
|
||||
}
|
||||
|
||||
void updateFields({
|
||||
AnimatedType<double> shadow,
|
||||
AnimatedValue<double> shadow,
|
||||
AnimatedColor backgroundColor,
|
||||
double borderRadius,
|
||||
Shape shape
|
||||
@ -78,7 +77,7 @@ class AnimationBuilder {
|
||||
this.shape = shape;
|
||||
}
|
||||
|
||||
void _updateField(AnimatedType variable, AnimatedType sourceVariable) {
|
||||
void _updateField(AnimatedValue variable, AnimatedValue sourceVariable) {
|
||||
if (variable == null)
|
||||
return; // TODO(mpcomplete): Should we handle transition from null?
|
||||
|
||||
@ -101,15 +100,6 @@ class AnimationBuilder {
|
||||
}
|
||||
}
|
||||
|
||||
class AnimatedColor extends AnimatedType<Color> {
|
||||
AnimatedColor(Color begin, { Color end, Curve curve: linear })
|
||||
: super(begin, end: end, curve: curve);
|
||||
|
||||
void setFraction(double t) {
|
||||
value = lerpColor(begin, end, t);
|
||||
}
|
||||
}
|
||||
|
||||
List<BoxShadow> _computeShadow(double level) {
|
||||
if (level < 1.0) // shadows[1] is the first shadow
|
||||
return null;
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:sky' as sky;
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/widgets/animated_component.dart';
|
||||
import 'package:sky/widgets/basic.dart';
|
||||
@ -13,7 +14,7 @@ import 'package:vector_math/vector_math.dart';
|
||||
const Duration _kCardDismissFadeout = const Duration(milliseconds: 200);
|
||||
const double _kMinFlingVelocity = 700.0;
|
||||
const double _kMinFlingVelocityDelta = 400.0;
|
||||
const double _kFlingVelocityScale = 1.0/300.0;
|
||||
const double _kFlingVelocityScale = 1.0 / 300.0;
|
||||
const double _kDismissCardThreshold = 0.6;
|
||||
|
||||
typedef void DismissedCallback();
|
||||
@ -30,8 +31,8 @@ class Dismissable extends AnimatedComponent {
|
||||
Widget child;
|
||||
DismissedCallback onDismissed;
|
||||
|
||||
AnimatedType<Point> _position;
|
||||
AnimatedType<double> _opacity;
|
||||
AnimatedValue<Point> _position;
|
||||
AnimatedValue<double> _opacity;
|
||||
AnimationPerformance _performance;
|
||||
|
||||
double _width;
|
||||
@ -39,8 +40,8 @@ class Dismissable extends AnimatedComponent {
|
||||
bool _dragUnderway = false;
|
||||
|
||||
void initState() {
|
||||
_position = new AnimatedType<Point>(Point.origin);
|
||||
_opacity = new AnimatedType<double>(1.0, end: 0.0);
|
||||
_position = new AnimatedValue<Point>(Point.origin);
|
||||
_opacity = new AnimatedValue<double>(1.0, end: 0.0);
|
||||
_performance = new AnimationPerformance()
|
||||
..duration = _kCardDismissFadeout
|
||||
..variable = new AnimatedList([_position, _opacity])
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
|
||||
import 'dart:sky' as sky;
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/theme/shadows.dart';
|
||||
import 'package:sky/theme/colors.dart' as colors;
|
||||
import 'package:sky/widgets/animated_component.dart';
|
||||
import 'package:sky/widgets/animation_builder.dart';
|
||||
import 'package:sky/widgets/basic.dart';
|
||||
import 'package:sky/widgets/navigator.dart';
|
||||
import 'package:sky/widgets/scrollable_viewport.dart';
|
||||
@ -30,7 +30,7 @@ import 'package:vector_math/vector_math.dart';
|
||||
|
||||
const double _kWidth = 304.0;
|
||||
const double _kMinFlingVelocity = 365.0;
|
||||
const double _kFlingVelocityScale = 1.0/300.0;
|
||||
const double _kFlingVelocityScale = 1.0 / 300.0;
|
||||
const Duration _kBaseSettleDuration = const Duration(milliseconds: 246);
|
||||
const Point _kOpenPosition = Point.origin;
|
||||
const Point _kClosedPosition = const Point(-_kWidth, 0.0);
|
||||
@ -60,12 +60,12 @@ class Drawer extends AnimatedComponent {
|
||||
DrawerStatusChangedCallback onStatusChanged;
|
||||
Navigator navigator;
|
||||
|
||||
AnimatedType<Point> _position;
|
||||
AnimatedValue<Point> _position;
|
||||
AnimatedColor _maskColor;
|
||||
AnimationPerformance _performance;
|
||||
|
||||
void initState() {
|
||||
_position = new AnimatedType<Point>(_kClosedPosition, end: _kOpenPosition);
|
||||
_position = new AnimatedValue<Point>(_kClosedPosition, end: _kOpenPosition);
|
||||
_maskColor = new AnimatedColor(colors.transparent, end: const Color(0x7F000000));
|
||||
_performance = new AnimationPerformance()
|
||||
..duration = _kBaseSettleDuration
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:sky' as sky;
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/rendering/box.dart';
|
||||
@ -29,7 +30,7 @@ double _getSplashTargetSize(Size bounds, Point position) {
|
||||
class InkSplash {
|
||||
InkSplash(this.pointer, this.position, this.well) {
|
||||
_targetRadius = _getSplashTargetSize(well.size, position);
|
||||
_radius = new AnimatedType<double>(
|
||||
_radius = new AnimatedValue<double>(
|
||||
_kSplashInitialSize, end: _targetRadius, curve: easeOut);
|
||||
|
||||
_performance = new AnimationPerformance()
|
||||
@ -45,7 +46,7 @@ class InkSplash {
|
||||
|
||||
double _targetRadius;
|
||||
double _pinnedRadius;
|
||||
AnimatedType<double> _radius;
|
||||
AnimatedValue<double> _radius;
|
||||
AnimationPerformance _performance;
|
||||
|
||||
void _updateVelocity(double velocity) {
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/widgets/animated_component.dart';
|
||||
@ -59,17 +60,17 @@ class Transition extends AnimatedComponent {
|
||||
Function onDismissed;
|
||||
Function onCompleted;
|
||||
|
||||
AnimatedType<Point> _position;
|
||||
AnimatedType<double> _opacity;
|
||||
AnimatedValue<Point> _position;
|
||||
AnimatedValue<double> _opacity;
|
||||
AnimationPerformance _performance;
|
||||
|
||||
void initState() {
|
||||
_position = new AnimatedType<Point>(
|
||||
_position = new AnimatedValue<Point>(
|
||||
_kTransitionStartPoint,
|
||||
end: Point.origin,
|
||||
curve: easeOut
|
||||
);
|
||||
_opacity = new AnimatedType<double>(0.0, end: 1.0)
|
||||
_opacity = new AnimatedValue<double>(0.0, end: 1.0)
|
||||
..curve = easeOut;
|
||||
_performance = new AnimationPerformance()
|
||||
..duration = _kTransitionDuration
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import 'dart:math' as math;
|
||||
import 'dart:sky' as sky;
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/painting/box_painter.dart';
|
||||
import 'package:sky/theme/colors.dart';
|
||||
@ -48,10 +49,10 @@ class PopupMenu extends AnimatedComponent {
|
||||
int level;
|
||||
Navigator navigator;
|
||||
|
||||
AnimatedType<double> _opacity;
|
||||
AnimatedType<double> _width;
|
||||
AnimatedType<double> _height;
|
||||
List<AnimatedType<double>> _itemOpacities;
|
||||
AnimatedValue<double> _opacity;
|
||||
AnimatedValue<double> _width;
|
||||
AnimatedValue<double> _height;
|
||||
List<AnimatedValue<double>> _itemOpacities;
|
||||
AnimatedList _animationList;
|
||||
AnimationPerformance _performance;
|
||||
|
||||
@ -88,14 +89,14 @@ class PopupMenu extends AnimatedComponent {
|
||||
|
||||
void _updateAnimationVariables() {
|
||||
double unit = 1.0 / (items.length + 1.5); // 1.0 for the width and 0.5 for the last item's fade.
|
||||
_opacity = new AnimatedType<double>(0.0, end: 1.0);
|
||||
_width = new AnimatedType<double>(0.0, end: 1.0, interval: new Interval(0.0, unit));
|
||||
_height = new AnimatedType<double>(0.0, end: 1.0, interval: new Interval(0.0, unit * items.length));
|
||||
_itemOpacities = new List<AnimatedType<double>>();
|
||||
_opacity = new AnimatedValue<double>(0.0, end: 1.0);
|
||||
_width = new AnimatedValue<double>(0.0, end: 1.0, interval: new Interval(0.0, unit));
|
||||
_height = new AnimatedValue<double>(0.0, end: 1.0, interval: new Interval(0.0, unit * items.length));
|
||||
_itemOpacities = new List<AnimatedValue<double>>();
|
||||
for (int i = 0; i < items.length; ++i) {
|
||||
double start = (i + 1) * unit;
|
||||
double end = (start + 1.5 * unit).clamp(0.0, 1.0);
|
||||
_itemOpacities.add(new AnimatedType<double>(
|
||||
_itemOpacities.add(new AnimatedValue<double>(
|
||||
0.0, end: 1.0, interval: new Interval(start, end)));
|
||||
}
|
||||
List<AnimatedVariable> variables = new List<AnimatedVariable>()
|
||||
@ -121,7 +122,7 @@ class PopupMenu extends AnimatedComponent {
|
||||
PopupMenuStatus status = _status;
|
||||
if (_lastStatus != null && status != _lastStatus) {
|
||||
if (status == PopupMenuStatus.inactive &&
|
||||
navigator != null &&
|
||||
navigator != null &&
|
||||
navigator.currentRoute.key == this)
|
||||
navigator.pop();
|
||||
if (onStatusChanged != null)
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
|
||||
import 'dart:sky' as sky;
|
||||
|
||||
import 'package:sky/animation/animated_value.dart';
|
||||
import 'package:sky/animation/animation_performance.dart';
|
||||
import 'package:sky/animation/curves.dart';
|
||||
import 'package:sky/widgets/animated_component.dart';
|
||||
@ -24,14 +25,14 @@ abstract class Toggleable extends AnimatedComponent {
|
||||
bool value;
|
||||
ValueChanged onChanged;
|
||||
|
||||
AnimatedType<double> _position;
|
||||
AnimatedType<double> get position => _position;
|
||||
AnimatedValue<double> _position;
|
||||
AnimatedValue<double> get position => _position;
|
||||
|
||||
AnimationPerformance _performance;
|
||||
AnimationPerformance get performance => _performance;
|
||||
|
||||
void initState() {
|
||||
_position = new AnimatedType<double>(0.0, end: 1.0);
|
||||
_position = new AnimatedValue<double>(0.0, end: 1.0);
|
||||
_performance = new AnimationPerformance()
|
||||
..variable = position
|
||||
..duration = _kCheckDuration
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user