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

Side by Side Diff: sky/sdk/lib/widgets/material.dart

Issue 1232403004: Trivial code style changes in animation code. (Closed) Base URL: https://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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 import 'package:sky/animation/animation_performance.dart'; 5 import 'package:sky/animation/animation_performance.dart';
6 import 'package:sky/painting/box_painter.dart'; 6 import 'package:sky/painting/box_painter.dart';
7 import 'package:sky/widgets/animated_component.dart'; 7 import 'package:sky/widgets/animated_component.dart';
8 import 'package:sky/widgets/animation_builder.dart'; 8 import 'package:sky/widgets/animation_builder.dart';
9 import 'package:sky/widgets/basic.dart'; 9 import 'package:sky/widgets/basic.dart';
10 import 'package:sky/widgets/default_text_style.dart'; 10 import 'package:sky/widgets/default_text_style.dart';
(...skipping 21 matching lines...) Expand all
32 this.color 32 this.color
33 }) : super(key: key) { 33 }) : super(key: key) {
34 assert(level != null); 34 assert(level != null);
35 } 35 }
36 36
37 Widget child; 37 Widget child;
38 MaterialType type; 38 MaterialType type;
39 int level; 39 int level;
40 Color color; 40 Color color;
41 41
42 AnimationBuilder _builder; 42 final AnimationBuilder _builder = new AnimationBuilder();
Matt Perry 2015/07/13 17:32:55 Wouldn't this cause us to allocate a new object fo
abarth-chromium 2015/07/13 17:41:06 Constructors for final fields are called lazily th
abarth-chromium 2015/07/13 17:44:59 s/Constructors/initializers/
43 43
44 void initState() { 44 void initState() {
45 _builder = new AnimationBuilder() 45 _builder
46 ..shadow = new AnimatedType<double>(level.toDouble()) 46 ..shadow = new AnimatedType<double>(level.toDouble())
47 ..backgroundColor = _getBackgroundColor(type, color) 47 ..backgroundColor = _getBackgroundColor(type, color)
48 ..borderRadius = edges[type] 48 ..borderRadius = edges[type]
49 ..shape = type == MaterialType.circle ? Shape.circle : Shape.rectangle; 49 ..shape = type == MaterialType.circle ? Shape.circle : Shape.rectangle;
50 watchPerformance(_builder.createPerformance( 50 watchPerformance(_builder.createPerformance(
51 [_builder.shadow], duration: _kAnimateShadowDuration)); 51 [_builder.shadow],
52 duration: _kAnimateShadowDuration
53 ));
52 watchPerformance(_builder.createPerformance( 54 watchPerformance(_builder.createPerformance(
53 [_builder.backgroundColor], duration: _kAnimateColorDuration)); 55 [_builder.backgroundColor],
56 duration: _kAnimateColorDuration
57 ));
54 super.initState(); 58 super.initState();
55 } 59 }
56 60
57 void syncFields(Material source) { 61 void syncFields(Material source) {
58 child = source.child; 62 child = source.child;
59 type = source.type; 63 type = source.type;
60 level = source.level; 64 level = source.level;
61 color = source.color; 65 color = source.color;
62 _builder.updateFields( 66 _builder.updateFields(
63 shadow: new AnimatedType<double>(level.toDouble()), 67 shadow: new AnimatedType<double>(level.toDouble()),
(...skipping 20 matching lines...) Expand all
84 return color == null ? null : new AnimatedColor(color); 88 return color == null ? null : new AnimatedColor(color);
85 } 89 }
86 90
87 Widget build() { 91 Widget build() {
88 return _builder.build( 92 return _builder.build(
89 new DefaultTextStyle(style: Theme.of(this).text.body1, child: child) 93 new DefaultTextStyle(style: Theme.of(this).text.body1, child: child)
90 ); 94 );
91 } 95 }
92 96
93 } 97 }
OLDNEW
« sky/sdk/lib/widgets/animation_builder.dart ('K') | « sky/sdk/lib/widgets/animation_builder.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698