| Index: sky/sdk/lib/widgets/material.dart
|
| diff --git a/sky/sdk/lib/widgets/material.dart b/sky/sdk/lib/widgets/material.dart
|
| index 44b686493029fe96d0bc0a330447fa8c3883e75b..444434f7d053daa5e8178aef3d9ba5b73ee04a95 100644
|
| --- a/sky/sdk/lib/widgets/material.dart
|
| +++ b/sky/sdk/lib/widgets/material.dart
|
| @@ -4,14 +4,20 @@
|
|
|
| import '../animation/animated_value.dart';
|
| import '../painting/box_painter.dart';
|
| -import '../theme/edges.dart';
|
| import '../theme/shadows.dart';
|
| import 'animated_component.dart';
|
| import 'basic.dart';
|
| import 'default_text_style.dart';
|
| import 'theme.dart';
|
|
|
| -export '../theme/edges.dart' show MaterialEdge;
|
| +enum MaterialType { canvas, card, circle, button }
|
| +
|
| +const Map<MaterialType, double> edges = const {
|
| + MaterialType.canvas: null,
|
| + MaterialType.card: 2.0,
|
| + MaterialType.circle: null,
|
| + MaterialType.button: 2.0,
|
| +};
|
|
|
| const double _kAnimateShadowDurationMS = 100.0;
|
|
|
| @@ -34,7 +40,7 @@ class Material extends AnimatedComponent {
|
| Material({
|
| String key,
|
| this.child,
|
| - this.edge: MaterialEdge.card,
|
| + this.type: MaterialType.card,
|
| int level: 0,
|
| this.color
|
| }) : super(key: key) {
|
| @@ -43,13 +49,13 @@ class Material extends AnimatedComponent {
|
| }
|
|
|
| Widget child;
|
| - MaterialEdge edge;
|
| + MaterialType type;
|
| AnimatedValue level;
|
| Color color;
|
|
|
| void syncFields(Material source) {
|
| child = source.child;
|
| - edge = source.edge;
|
| + type = source.type;
|
| // TODO(mpcomplete): duration is wrong, because the current level may be
|
| // anything. We really want |rate|.
|
| if (level.value != source.level.value)
|
| @@ -58,15 +64,28 @@ class Material extends AnimatedComponent {
|
| super.syncFields(source);
|
| }
|
|
|
| + Color get backgroundColor {
|
| + if (color != null)
|
| + return color;
|
| + switch(type) {
|
| + case MaterialType.canvas:
|
| + return Theme.of(this).canvasColor;
|
| + case MaterialType.card:
|
| + return Theme.of(this).cardColor;
|
| + default:
|
| + return null;
|
| + }
|
| + }
|
| +
|
| // TODO(mpcomplete): make this animate color changes.
|
|
|
| Widget build() {
|
| return new Container(
|
| decoration: new BoxDecoration(
|
| boxShadow: _computeShadow(level.value),
|
| - borderRadius: edges[edge],
|
| - backgroundColor: color,
|
| - shape: edge == MaterialEdge.circle ? Shape.circle : Shape.rectangle
|
| + borderRadius: edges[type],
|
| + backgroundColor: backgroundColor,
|
| + shape: type == MaterialType.circle ? Shape.circle : Shape.rectangle
|
| ),
|
| child: new DefaultTextStyle(style: Theme.of(this).text.body1, child: child)
|
| );
|
|
|