Index: sky/sdk/lib/widgets/material.dart |
diff --git a/sky/sdk/lib/widgets/material.dart b/sky/sdk/lib/widgets/material.dart |
index e5ae5fc82948509e9a9293e70ab39cbb69f69e3c..8b6311931f89afcf987ffa87798471ccd5cb6ae8 100644 |
--- a/sky/sdk/lib/widgets/material.dart |
+++ b/sky/sdk/lib/widgets/material.dart |
@@ -27,14 +27,16 @@ class Material extends AnimatedComponent { |
Material({ |
String key, |
this.child, |
- this.type: MaterialType.card, |
+ MaterialType type: MaterialType.card, |
int level: 0, |
Color color: null |
}) : super(key: key) { |
if (level == null) level = 0; |
Hixie
2015/07/09 20:58:40
This constructor is getting out of control. Widget
Matt Perry
2015/07/09 21:03:13
Is there a method that gets called after construct
|
_container = new AnimatedContainer() |
..shadow = new AnimatedType<double>(level.toDouble()) |
- ..backgroundColor = new AnimatedColor(_getBackgroundColor(color)); |
+ ..backgroundColor = new AnimatedColor(_getBackgroundColor(type, color)) |
+ ..borderRadius = edges[type] |
+ ..shape = type == MaterialType.circle ? Shape.circle : Shape.rectangle; |
watchPerformance(_container.createPerformance( |
_container.shadow, duration: _kAnimateShadowDuration)); |
watchPerformance(_container.createPerformance( |
@@ -42,21 +44,19 @@ class Material extends AnimatedComponent { |
} |
Widget child; |
- MaterialType type; |
AnimatedContainer _container; |
void syncFields(Material source) { |
child = source.child; |
- type = source.type; |
_container.syncFields(source._container); |
super.syncFields(source); |
} |
- Color _getBackgroundColor(Color color) { |
+ Color _getBackgroundColor(MaterialType type, Color color) { |
if (color != null) |
return color; |
- switch(type) { |
+ switch (type) { |
case MaterialType.canvas: |
return Theme.of(this).canvasColor; |
case MaterialType.card: |
@@ -68,15 +68,8 @@ class Material extends AnimatedComponent { |
Widget build() { |
return _container.build( |
- new Container( |
- // TODO(mpcomplete): move the rest of this decoration into |
- // AnimatedContainer as non-animated values. |
- decoration: new BoxDecoration( |
- borderRadius: edges[type], |
- shape: type == MaterialType.circle ? Shape.circle : Shape.rectangle |
- ), |
- child: new DefaultTextStyle(style: Theme.of(this).text.body1, child: child) |
- )); |
+ new DefaultTextStyle(style: Theme.of(this).text.body1, child: child) |
+ ); |
} |
} |