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

Side by Side Diff: sky/sdk/lib/framework/components2/ink_well.dart

Issue 1165983002: Stub out InkWell and implement Sky’s fn2 menu item (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 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
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 '../fn2.dart'; 5 import '../fn2.dart';
6 import '../rendering/flex.dart';
6 import 'dart:collection'; 7 import 'dart:collection';
7 import 'dart:sky' as sky; 8 import 'dart:sky' as sky;
8 import 'ink_splash.dart'; 9 // import 'ink_splash.dart';
9 import 'scrollable.dart'; 10 import 'scrollable.dart';
10 11
11 class InkWell extends Component implements ScrollClient { 12 class InkWell extends Component implements ScrollClient {
12 static final Style _containmentStyleHack = new Style(''' 13 // static final Style _containmentStyleHack = new Style('''
13 align-items: center; 14 // align-items: center;
14 transform: translateX(0);'''); 15 // transform: translateX(0);''');
15 16
16 LinkedHashSet<SplashController> _splashes; 17 // LinkedHashSet<SplashController> _splashes;
17 18
18 String inlineStyle;
19 List<UINode> children; 19 List<UINode> children;
20 20
21 InkWell({ Object key, this.inlineStyle, this.children }) 21 // InkWell({ Object key, this.inlineStyle, this.children })
22 : super(key: key) { 22 // : super(key: key) {
23 onDidUnmount(() { 23 // onDidUnmount(() {
24 _cancelSplashes(null); 24 // _cancelSplashes(null);
25 }); 25 // });
26 // }
27
28 InkWell({ Object key, this.children }) : super(key: key);
29
30 UINode build() {
31 return new FlexContainer(direction: FlexDirection.Horizontal, children: chil dren);
32 // List<UINode> childrenIncludingSplashes = [];
33
34 // if (_splashes != null) {
35 // childrenIncludingSplashes.addAll(
36 // _splashes.map((s) => new InkSplash(s.onStyleChanged)));
37 // }
38
39 // if (children != null)
40 // childrenIncludingSplashes.addAll(children);
41
42 // return new EventListenerNode(
43 // new FlexContainer(
44 // direction: FlexDirection.Row,
45 // style: _containmentStyleHack,
46 // inlineStyle: inlineStyle,
47 // children: childrenIncludingSplashes),
48 // onGestureTapDown: _startSplash,
49 // onGestureTap: _confirmSplash
50 // );
26 } 51 }
27 52
28 UINode build() { 53 // void _startSplash(sky.GestureEvent event) {
29 List<UINode> childrenIncludingSplashes = []; 54 // setState(() {
55 // if (_splashes == null)
56 // _splashes = new LinkedHashSet<SplashController>();
57 // var splash;
58 // var root = getRoot();
59 // splash = new SplashController(root.rect, event.x, event.y,
60 // pointer: event.primaryPointer,
61 // onDone: () { _splashDone(splash); });
62 // _splashes.add(splash);
63 // UINode node = parent;
64 // while (node != null) {
65 // if (node is Scrollable)
66 // node.registerScrollClient(this);
67 // node = node.parent;
68 // }
69 // });
70 // }
30 71
31 if (_splashes != null) { 72 // bool ancestorScrolled(Scrollable ancestor) {
32 childrenIncludingSplashes.addAll( 73 // _abortSplashes();
33 _splashes.map((s) => new InkSplash(s.onStyleChanged))); 74 // return false;
34 } 75 // }
35 76
36 if (children != null) 77 // void handleRemoved() {
37 childrenIncludingSplashes.addAll(children); 78 // UINode node = parent;
79 // while (node != null) {
80 // if (node is Scrollable)
81 // node.unregisterScrollClient(this);
82 // node = node.parent;
83 // }
84 // super.handleRemoved();
85 // }
38 86
39 return new EventListenerNode( 87 // void _confirmSplash(sky.GestureEvent event) {
40 new FlexContainer( 88 // if (_splashes == null)
41 direction: FlexDirection.Row, 89 // return;
42 style: _containmentStyleHack, 90 // _splashes.where((splash) => splash.pointer == event.primaryPointer)
43 inlineStyle: inlineStyle, 91 // .forEach((splash) { splash.confirm(); });
44 children: childrenIncludingSplashes), 92 // }
45 onGestureTapDown: _startSplash,
46 onGestureTap: _confirmSplash
47 );
48 }
49 93
50 void _startSplash(sky.GestureEvent event) { 94 // void _abortSplashes() {
51 setState(() { 95 // if (_splashes == null)
52 if (_splashes == null) 96 // return;
53 _splashes = new LinkedHashSet<SplashController>(); 97 // setState(() {
54 var splash; 98 // _splashes.forEach((s) { s.abort(); });
55 var root = getRoot(); 99 // });
56 splash = new SplashController(root.rect, event.x, event.y, 100 // }
57 pointer: event.primaryPointer,
58 onDone: () { _splashDone(splash); });
59 _splashes.add(splash);
60 UINode node = parent;
61 while (node != null) {
62 if (node is Scrollable)
63 node.registerScrollClient(this);
64 node = node.parent;
65 }
66 });
67 }
68 101
69 bool ancestorScrolled(Scrollable ancestor) { 102 // void _cancelSplashes(sky.Event event) {
70 _abortSplashes(); 103 // if (_splashes == null)
71 return false; 104 // return;
72 } 105 // setState(() {
106 // var splashes = _splashes;
107 // _splashes = null;
108 // splashes.forEach((s) { s.cancel(); });
109 // });
110 // }
73 111
74 void handleRemoved() { 112 // void _splashDone(SplashController splash) {
75 UINode node = parent; 113 // if (_splashes == null)
76 while (node != null) { 114 // return;
77 if (node is Scrollable) 115 // setState(() {
78 node.unregisterScrollClient(this); 116 // _splashes.remove(splash);
79 node = node.parent; 117 // if (_splashes.length == 0)
80 } 118 // _splashes = null;
81 super.handleRemoved(); 119 // });
82 } 120 // }
83
84 void _confirmSplash(sky.GestureEvent event) {
85 if (_splashes == null)
86 return;
87 _splashes.where((splash) => splash.pointer == event.primaryPointer)
88 .forEach((splash) { splash.confirm(); });
89 }
90
91 void _abortSplashes() {
92 if (_splashes == null)
93 return;
94 setState(() {
95 _splashes.forEach((s) { s.abort(); });
96 });
97 }
98
99 void _cancelSplashes(sky.Event event) {
100 if (_splashes == null)
101 return;
102 setState(() {
103 var splashes = _splashes;
104 _splashes = null;
105 splashes.forEach((s) { s.cancel(); });
106 });
107 }
108
109 void _splashDone(SplashController splash) {
110 if (_splashes == null)
111 return;
112 setState(() {
113 _splashes.remove(splash);
114 if (_splashes.length == 0)
115 _splashes = null;
116 });
117 }
118 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698