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

Side by Side Diff: sky/framework/components/material.dart

Issue 1006053002: Allow Effen Styles to be extendable (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: sdfsd Created 5 years, 9 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
« no previous file with comments | « sky/framework/components/input.dart ('k') | sky/framework/components/menu_divider.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 '../fn.dart'; 5 import '../fn.dart';
6 import '../theme/shadows.dart'; 6 import '../theme/shadows.dart';
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
9 import 'ink_splash.dart'; 9 import 'ink_splash.dart';
10 10
(...skipping 11 matching lines...) Expand all
22 null, 22 null,
23 new Style('box-shadow: ${Shadow[1]}'), 23 new Style('box-shadow: ${Shadow[1]}'),
24 new Style('box-shadow: ${Shadow[2]}'), 24 new Style('box-shadow: ${Shadow[2]}'),
25 new Style('box-shadow: ${Shadow[3]}'), 25 new Style('box-shadow: ${Shadow[3]}'),
26 new Style('box-shadow: ${Shadow[4]}'), 26 new Style('box-shadow: ${Shadow[4]}'),
27 new Style('box-shadow: ${Shadow[5]}'), 27 new Style('box-shadow: ${Shadow[5]}'),
28 ]; 28 ];
29 29
30 LinkedHashSet<SplashAnimation> _splashes; 30 LinkedHashSet<SplashAnimation> _splashes;
31 31
32 List<Style> styles; 32 Style style;
33 String inlineStyle; 33 String inlineStyle;
34 List<Node> children; 34 List<Node> children;
35 int level; 35 int level;
36 36
37 Material({ 37 Material({
38 Object key, 38 Object key,
39 this.styles, 39 this.style,
40 this.inlineStyle, 40 this.inlineStyle,
41 this.children, 41 this.children,
42 this.level: 0 }) : super(key: key) { 42 this.level: 0 }) : super(key: key) {
43 events.listen('gesturescrollstart', _cancelSplashes); 43 events.listen('gesturescrollstart', _cancelSplashes);
44 events.listen('wheel', _cancelSplashes); 44 events.listen('wheel', _cancelSplashes);
45 events.listen('pointerdown', _startSplash); 45 events.listen('pointerdown', _startSplash);
46 } 46 }
47 47
48 Node build() { 48 Node build() {
49 List<Node> childrenIncludingSplashes = []; 49 List<Node> childrenIncludingSplashes = [];
50 50
51 if (_splashes != null) { 51 if (_splashes != null) {
52 childrenIncludingSplashes.add(new Container( 52 childrenIncludingSplashes.add(new Container(
53 styles: [_splashesStyle], 53 style: _splashesStyle,
54 children: new List.from(_splashes.map( 54 children: new List.from(_splashes.map(
55 (s) => new InkSplash(s.onStyleChanged))), 55 (s) => new InkSplash(s.onStyleChanged))),
56 key: 'Splashes' 56 key: 'Splashes'
57 )); 57 ));
58 } 58 }
59 59
60 if (children != null) 60 if (children != null)
61 childrenIncludingSplashes.addAll(children); 61 childrenIncludingSplashes.addAll(children);
62 62
63 List<Style> stylesIncludingShadow = styles; 63 return new Container(
64 if (level > 0) { 64 key: 'Material',
65 stylesIncludingShadow = new List.from(styles); 65 style: level > 0 ? style.extend(shadowStyle[level]) : style,
66 stylesIncludingShadow.add(shadowStyle[level]); 66 inlineStyle: inlineStyle,
67 } 67 children: childrenIncludingSplashes
68 68 );
69 return new Container(key: 'Material', styles: stylesIncludingShadow,
70 inlineStyle: inlineStyle, children: childrenIncludingSplashes);
71 } 69 }
72 70
73 sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingCli entRect(); 71 sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingCli entRect();
74 72
75 void _startSplash(sky.PointerEvent event) { 73 void _startSplash(sky.PointerEvent event) {
76 setState(() { 74 setState(() {
77 if (_splashes == null) { 75 if (_splashes == null) {
78 _splashes = new LinkedHashSet<SplashAnimation>(); 76 _splashes = new LinkedHashSet<SplashAnimation>();
79 } 77 }
80 78
(...skipping 27 matching lines...) Expand all
108 } 106 }
109 107
110 setState(() { 108 setState(() {
111 _splashes.remove(splash); 109 _splashes.remove(splash);
112 if (_splashes.length == 0) { 110 if (_splashes.length == 0) {
113 _splashes = null; 111 _splashes = null;
114 } 112 }
115 }); 113 });
116 } 114 }
117 } 115 }
OLDNEW
« no previous file with comments | « sky/framework/components/input.dart ('k') | sky/framework/components/menu_divider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698