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

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

Issue 1234073005: Simplify the Drawer animation (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
« no previous file with comments | « sky/sdk/BUILD.gn ('k') | sky/sdk/lib/widgets/drawer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/sdk/lib/widgets/animated.dart
diff --git a/sky/sdk/lib/widgets/animated.dart b/sky/sdk/lib/widgets/animated.dart
new file mode 100644
index 0000000000000000000000000000000000000000..46c5388eed51a05b120d19f4ad527824d1bfeffa
--- /dev/null
+++ b/sky/sdk/lib/widgets/animated.dart
@@ -0,0 +1,68 @@
+// 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 'package:sky/animation/animation_performance.dart';
+import 'package:sky/widgets/animated_component.dart';
+import 'package:sky/widgets/animation_builder.dart';
+import 'package:sky/widgets/basic.dart';
+import 'package:vector_math/vector_math.dart';
+
+class PositionAnimation extends AnimatedComponent {
Matt Perry 2015/07/15 00:20:18 nit: I like AnimatedFoo convention for animated co
+ PositionAnimation({
+ String key,
+ this.child,
+ this.performance,
+ this.position
+ }) : super(key: key);
+
+ Widget child;
+ AnimatedType<Point> position;
+ AnimationPerformance performance;
+
+ void initState() {
+ watch(performance);
+ }
+
+ void syncFields(PositionAnimation source) {
+ child = source.child;
+ position = source.position;
+ assert(performance == source.performance);
+ }
+
+ Widget build() {
+ Matrix4 transform = new Matrix4.identity();
+ transform.translate(position.value.x, position.value.y);
+ return new Transform(transform: transform, child: child);
+ }
+}
+
+class ColorAnimation extends AnimatedComponent {
+ ColorAnimation({
+ String key,
+ this.child,
+ this.performance,
+ this.color
+ }) : super(key: key);
+
+ Widget child;
+ AnimatedColor color;
+ AnimationPerformance performance;
+
+ void initState() {
+ watch(performance);
+ }
+
+ void syncFields(ColorAnimation source) {
+ child = source.child;
+ color = source.color;
+ assert(performance == source.performance);
+ }
+
+ Widget build() {
+ return new Container(
+ decoration: new BoxDecoration(backgroundColor: color.value),
Matt Perry 2015/07/15 00:20:18 One of the problems I ran into with animating Mate
abarth-chromium 2015/07/15 00:23:53 Yeah, IMHO ColorAnimation should grow to be Contai
+ child: child
+ );
+ }
+}
« no previous file with comments | « sky/sdk/BUILD.gn ('k') | sky/sdk/lib/widgets/drawer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698