OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |