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

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

Issue 993033003: Move example fn widgets into sky/framework/components (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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/ink_splash.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 part of widgets; 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
3 // found in the LICENSE file.
2 4
3 abstract class MaterialComponent extends Component { 5 import '../fn.dart';
6 import 'dart:sky' as sky;
7 import 'dart:collection';
8 import 'ink_splash.dart';
4 9
10 abstract class Material extends Component {
5 static const _splashesKey = const Object(); 11 static const _splashesKey = const Object();
6 12
7 static Style _style = new Style(''' 13 static final Style _style = new Style('''
8 transform: translateX(0); 14 transform: translateX(0);
9 position: absolute; 15 position: absolute;
10 top: 0; 16 top: 0;
11 left: 0; 17 left: 0;
12 right: 0; 18 right: 0;
13 bottom: 0''' 19 bottom: 0'''
14 ); 20 );
15 21
16 LinkedHashSet<SplashAnimation> _splashes; 22 LinkedHashSet<SplashAnimation> _splashes;
17 23
18 MaterialComponent({ Object key }) : super(key: key); 24 Material({ Object key }) : super(key: key) {
25 events.listen('gesturescrollstart', _cancelSplashes);
26 events.listen('wheel', _cancelSplashes);
27 events.listen('pointerdown', _startSplash);
28 }
19 29
20 Node build() { 30 Node build() {
21 List<Node> children = []; 31 List<Node> children = [];
22 32
23 if (_splashes != null) { 33 if (_splashes != null) {
24 children.addAll(_splashes.map((s) => new InkSplash(s.onStyleChanged))); 34 children.addAll(_splashes.map((s) => new InkSplash(s.onStyleChanged)));
25 } 35 }
26 36
27 return new Container( 37 return new Container(
28 style: _style, 38 style: _style,
29 children: children, 39 children: children,
30 key: _splashesKey 40 key: _splashesKey
31 )..events.listen('gesturescrollstart', _cancelSplashes) 41 );
32 ..events.listen('wheel', _cancelSplashes)
33 ..events.listen('pointerdown', _startSplash);
34 } 42 }
35 43
36 sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingCli entRect(); 44 sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingCli entRect();
37 45
38 void _startSplash(sky.PointerEvent event) { 46 void _startSplash(sky.PointerEvent event) {
39 setState(() { 47 setState(() {
40 if (_splashes == null) { 48 if (_splashes == null) {
41 _splashes = new LinkedHashSet<SplashAnimation>(); 49 _splashes = new LinkedHashSet<SplashAnimation>();
42 } 50 }
43 51
(...skipping 27 matching lines...) Expand all
71 } 79 }
72 80
73 setState(() { 81 setState(() {
74 _splashes.remove(splash); 82 _splashes.remove(splash);
75 if (_splashes.length == 0) { 83 if (_splashes.length == 0) {
76 _splashes = null; 84 _splashes = null;
77 } 85 }
78 }); 86 });
79 } 87 }
80 } 88 }
OLDNEW
« no previous file with comments | « sky/framework/components/ink_splash.dart ('k') | sky/framework/components/menu_divider.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698