提交 28d09890 编写于 作者: A Adam Barth

Cleanup events related to material splashes

This CL is a warmup for using a more sophisticated gesture disambiguation.

1) Use gesturetap instead of click. We should probably remove click events
   because folks should use gesturetap to integrate with the gesture system.

2) Handle the case where you swipe the drawer during an animation. Previously
   we had an assert which triggered in some multitouch scenarios. We'll
   eventually move this over to gestureswipe.

3) Remove an extra container for ink splashes. There's no need to group all the
   ink splashes in a container. They can all just be children of the Material
   component itself. This structure is left over from when Material was a base
   class.

R=eseidel@chromium.org

Review URL: https://codereview.chromium.org/1013713005
上级 a2904c14
......@@ -109,7 +109,7 @@ class StocksApp extends App {
new Icon(key: 'menu', style: _iconStyle,
size: 24,
type: 'navigation/menu_white')
..events.listen('click', _drawerAnimation.toggle),
..events.listen('gesturetap', _drawerAnimation.toggle),
new Container(
style: _titleStyle,
children: [title]
......@@ -117,7 +117,7 @@ class StocksApp extends App {
new Icon(key: 'search', style: _iconStyle,
size: 24,
type: 'action/search_white')
..events.listen('click', _handleSearchClick),
..events.listen('gesturetap', _handleSearchClick),
new Icon(key: 'more_white', style: _iconStyle,
size: 24,
type: 'navigation/more_vert_white')
......
......@@ -59,7 +59,7 @@ class Checkbox extends ButtonBase {
ValueChanged onChanged;
Checkbox({ Object key, this.onChanged, this.checked }) : super(key: key) {
events.listen('click', _handleClick);
events.listen('gesturetap', _handleClick);
}
void _handleClick(sky.Event e) {
......
......@@ -34,7 +34,8 @@ class DrawerAnimation extends Animation {
void handlePointerDown(_) => stop();
void handlePointerMove(sky.PointerEvent event) {
assert(!isAnimating);
if (isAnimating)
return;
value = math.min(0.0, math.max(value + event.dx, -_kWidth));
}
......
......@@ -45,25 +45,18 @@ class SplashAnimation {
}
class InkSplash extends Component {
static final Style _style = new Style('''
static final Style _clipperStyle = new Style('''
position: absolute;
pointer-events: none;
overflow: hidden;
top: 0;
left: 0;
bottom: 0;
right: 0;
''');
right: 0;''');
static final Style _splashStyle = new Style('''
position: absolute;
background-color: rgba(0, 0, 0, 0.4);
border-radius: 0;
top: 0;
left: 0;
height: 0;
width: 0;
''');
background-color: rgba(0, 0, 0, 0.4);''');
Stream<String> onStyleChanged;
......@@ -94,7 +87,7 @@ class InkSplash extends Component {
_ensureListening();
return new Container(
style: _style,
style: _clipperStyle,
children: [
new Container(
inlineStyle: _inlineStyle,
......
......@@ -9,15 +9,6 @@ import 'dart:sky' as sky;
import 'ink_splash.dart';
class Material extends Component {
static final Style _splashesStyle = new Style('''
transform: translateX(0);
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0'''
);
static final List<Style> shadowStyle = [
null,
new Style('box-shadow: ${Shadow[1]}'),
......@@ -49,23 +40,17 @@ class Material extends Component {
List<Node> childrenIncludingSplashes = [];
if (_splashes != null) {
childrenIncludingSplashes.add(new Container(
style: _splashesStyle,
children: new List.from(_splashes.map(
(s) => new InkSplash(s.onStyleChanged))),
key: 'Splashes'
));
childrenIncludingSplashes.addAll(
_splashes.map((s) => new InkSplash(s.onStyleChanged)));
}
if (children != null)
childrenIncludingSplashes.addAll(children);
return new Container(
key: 'Material',
style: level > 0 ? style.extend(shadowStyle[level]) : style,
inlineStyle: inlineStyle,
children: childrenIncludingSplashes
);
children: childrenIncludingSplashes);
}
sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingClientRect();
......
......@@ -51,7 +51,7 @@ class Radio extends ButtonBase {
this.value,
this.groupValue
}) : super(key: key) {
events.listen('click', _handleClick);
events.listen('gesturetap', _handleClick);
}
Node build() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册