| Index: sky/framework/components/ink_well.dart
|
| diff --git a/sky/framework/components/material.dart b/sky/framework/components/ink_well.dart
|
| similarity index 52%
|
| copy from sky/framework/components/material.dart
|
| copy to sky/framework/components/ink_well.dart
|
| index 12ee60724a5c2aee480af1e9117ca0f11c212b0d..601e3c75102a31e812146ae690548a3d9a8ac5c2 100644
|
| --- a/sky/framework/components/material.dart
|
| +++ b/sky/framework/components/ink_well.dart
|
| @@ -3,34 +3,19 @@
|
| // found in the LICENSE file.
|
|
|
| import '../fn.dart';
|
| -import '../theme/shadows.dart';
|
| import 'dart:collection';
|
| import 'dart:sky' as sky;
|
| import 'ink_splash.dart';
|
|
|
| -class Material extends Component {
|
| - static final List<Style> shadowStyle = [
|
| - null,
|
| - new Style('box-shadow: ${Shadow[1]}'),
|
| - new Style('box-shadow: ${Shadow[2]}'),
|
| - new Style('box-shadow: ${Shadow[3]}'),
|
| - new Style('box-shadow: ${Shadow[4]}'),
|
| - new Style('box-shadow: ${Shadow[5]}'),
|
| - ];
|
| -
|
| - LinkedHashSet<SplashAnimation> _splashes;
|
| +class InkWell extends Component {
|
| + LinkedHashSet<SplashController> _splashes;
|
|
|
| Style style;
|
| String inlineStyle;
|
| List<Node> children;
|
| - int level;
|
|
|
| - Material({
|
| - Object key,
|
| - this.style,
|
| - this.inlineStyle,
|
| - this.children,
|
| - this.level: 0 }) : super(key: key);
|
| + InkWell({ Object key, this.style, this.inlineStyle, this.children })
|
| + : super(key: key);
|
|
|
| Node build() {
|
| List<Node> childrenIncludingSplashes = [];
|
| @@ -45,36 +30,38 @@ class Material extends Component {
|
|
|
| return new EventTarget(
|
| new Container(
|
| - style: level > 0 ? style.extend(shadowStyle[level]) : style,
|
| + style: style,
|
| inlineStyle: inlineStyle,
|
| children: childrenIncludingSplashes),
|
| - onGestureScrollStart: _cancelSplashes,
|
| - onWheel: _cancelSplashes,
|
| - onPointerDown: _startSplash
|
| + onGestureTapDown: _startSplash,
|
| + onGestureTap: _confirmSplash
|
| );
|
| }
|
|
|
| sky.ClientRect _getBoundingRect() => (getRoot() as sky.Element).getBoundingClientRect();
|
|
|
| - void _startSplash(sky.PointerEvent event) {
|
| + void _startSplash(sky.GestureEvent event) {
|
| setState(() {
|
| - if (_splashes == null) {
|
| - _splashes = new LinkedHashSet<SplashAnimation>();
|
| - }
|
| -
|
| + if (_splashes == null)
|
| + _splashes = new LinkedHashSet<SplashController>();
|
| var splash;
|
| - splash = new SplashAnimation(_getBoundingRect(), event.x, event.y,
|
| - onDone: () { _splashDone(splash); });
|
| -
|
| + splash = new SplashController(_getBoundingRect(), event.x, event.y,
|
| + pointer: event.primaryPointer,
|
| + onDone: () { _splashDone(splash); });
|
| _splashes.add(splash);
|
| });
|
| }
|
|
|
| - void _cancelSplashes(sky.Event event) {
|
| - if (_splashes == null) {
|
| + void _confirmSplash(sky.GestureEvent event) {
|
| + if (_splashes == null)
|
| return;
|
| - }
|
| + _splashes.where((splash) => splash.pointer == event.primaryPointer)
|
| + .forEach((splash) { splash.confirm(); });
|
| + }
|
|
|
| + void _cancelSplashes(sky.Event event) {
|
| + if (_splashes == null)
|
| + return;
|
| setState(() {
|
| var splashes = _splashes;
|
| _splashes = null;
|
| @@ -86,16 +73,13 @@ class Material extends Component {
|
| _cancelSplashes(null);
|
| }
|
|
|
| - void _splashDone(SplashAnimation splash) {
|
| - if (_splashes == null) {
|
| + void _splashDone(SplashController splash) {
|
| + if (_splashes == null)
|
| return;
|
| - }
|
| -
|
| setState(() {
|
| _splashes.remove(splash);
|
| - if (_splashes.length == 0) {
|
| + if (_splashes.length == 0)
|
| _splashes = null;
|
| - }
|
| });
|
| }
|
| }
|
|
|