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

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

Issue 1218153005: Refactoring to support dark theme better (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: fix import issues 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/lib/widgets/floating_action_button.dart ('k') | sky/sdk/lib/widgets/material_button.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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)
);
« no previous file with comments | « sky/sdk/lib/widgets/floating_action_button.dart ('k') | sky/sdk/lib/widgets/material_button.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698