Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(750)

Unified Diff: sky/sdk/lib/widgets/drawer.dart

Issue 1223073002: AnimatedContainer: generalized Container widget that handles animating values (Closed) Base URL: git@github.com:/domokit/mojo.git@master
Patch Set: . Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/sdk/lib/widgets/drawer.dart
diff --git a/sky/sdk/lib/widgets/drawer.dart b/sky/sdk/lib/widgets/drawer.dart
index ca4f9de1416844fdcffb3336f96cfabfc04bf20a..461dc9cfe50163a53ed974a6d4ec06e5b9252aa9 100644
--- a/sky/sdk/lib/widgets/drawer.dart
+++ b/sky/sdk/lib/widgets/drawer.dart
@@ -8,6 +8,7 @@ import '../animation/animation_performance.dart';
import '../animation/curves.dart';
import '../theme/shadows.dart';
import 'animated_component.dart';
+import 'animated_container.dart';
import 'basic.dart';
import 'theme.dart';
@@ -26,7 +27,7 @@ import 'theme.dart';
const double _kWidth = 304.0;
const double _kMinFlingVelocity = 0.4;
-const int _kBaseSettleDurationMS = 246;
+const Duration _kBaseSettleDuration = const Duration(milliseconds: 246);
// TODO(mpcomplete): The curve must be linear if we want the drawer to track
// the user's finger. Odeon remedies this by attaching spring forces to the
// initial timeline when animating (so it doesn't look linear).
@@ -36,16 +37,19 @@ typedef void DrawerStatusChangeHandler (bool showing);
class DrawerController {
DrawerController(this.onStatusChange) {
- performance = new AnimationPerformance()
- ..duration = new Duration(milliseconds: _kBaseSettleDurationMS)
- ..variable = position;
+ container = new AnimatedContainer()
+ ..position = new AnimatedType<Point>(
+ new Point(-_kWidth, 0.0), end: Point.origin, curve: _kAnimationCurve);
+ performance = container.createPerformance(
+ container.position, duration: _kBaseSettleDuration);
performance.timeline.onValueChanged.listen(_checkValue);
}
final DrawerStatusChangeHandler onStatusChange;
AnimationPerformance performance;
- final AnimatedPosition position = new AnimatedPosition(
- new Point(-_kWidth, 0.0), Point.origin, curve: _kAnimationCurve);
+ AnimatedContainer container;
+
+ double get xPosition => container.position.value.x;
bool _oldClosedState = true;
void _checkValue(_) {
@@ -57,7 +61,7 @@ class DrawerController {
}
bool get isClosed => performance.isDismissed;
- bool get _isMostlyClosed => position.value.x <= -_kWidth/2;
+ bool get _isMostlyClosed => xPosition <= -_kWidth/2;
void open() => performance.play();
@@ -128,7 +132,7 @@ class Drawer extends AnimatedComponent {
onGestureTap: controller.handleMaskTap
);
- Widget content = controller.position.build(
+ Widget content = controller.container.build(
new Container(
decoration: new BoxDecoration(
backgroundColor: Theme.of(this).canvasColor,

Powered by Google App Engine
This is Rietveld 408576698