예제 #1
0
        public override Widget build(BuildContext context)
        {
            Dictionary <Type, GestureRecognizerFactory> gestures = new Dictionary <Type, GestureRecognizerFactory>();

            gestures.Add(typeof(TapGestureRecognizer), new GestureRecognizerFactoryWithHandlers <TapGestureRecognizer>(
                             () => new TapGestureRecognizer(debugOwner: this),
                             instance => {
                instance.onTapDown   = this._handleTapDown;
                instance.onTapUp     = this._handleTapUp;
                instance.onTapCancel = this._handleTapCancel;
            }
                             )
                         );

            if (this.widget.onSingleLongTapStart != null ||
                this.widget.onSingleLongTapMoveUpdate != null ||
                this.widget.onSingleLongTapEnd != null
                )
            {
                gestures[typeof(LongPressGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <LongPressGestureRecognizer>(
                        () => new LongPressGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.touch),
                        instance => {
                    instance.onLongPressStart      = this._handleLongPressStart;
                    instance.onLongPressMoveUpdate = this._handleLongPressMoveUpdate;
                    instance.onLongPressEnd        = this._handleLongPressEnd;
                });
            }

            if (this.widget.onDragSelectionStart != null ||
                this.widget.onDragSelectionUpdate != null ||
                this.widget.onDragSelectionEnd != null)
            {
                gestures.Add(typeof(HorizontalDragGestureRecognizer),
                             new GestureRecognizerFactoryWithHandlers <HorizontalDragGestureRecognizer>(
                                 () => new HorizontalDragGestureRecognizer(debugOwner: this, kind: PointerDeviceKind.mouse),
                                 instance => {
                    instance.dragStartBehavior = DragStartBehavior.down;
                    instance.onStart           = this._handleDragStart;
                    instance.onUpdate          = this._handleDragUpdate;
                    instance.onEnd             = this._handleDragEnd;
                }
                                 )
                             );
            }

            // TODO: if (this.widget.onForcePressStart != null || this.widget.onForcePressEnd != null) {
            // }

            return(new RawGestureDetector(
                       gestures: gestures,
                       behavior: this.widget.behavior,
                       child: this.widget.child
                       ));
        }
        public override Widget build(BuildContext context)
        {
            var gestures = new Dictionary <Type, GestureRecognizerFactory>();

            if (this.onTapDown != null ||
                this.onTapUp != null ||
                this.onTap != null ||
                this.onTapCancel != null)
            {
                gestures[typeof(TapGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <TapGestureRecognizer>(
                        () => new TapGestureRecognizer(debugOwner: this),
                        instance => {
                    instance.onTapDown   = this.onTapDown;
                    instance.onTapUp     = this.onTapUp;
                    instance.onTap       = this.onTap;
                    instance.onTapCancel = this.onTapCancel;
                }
                        );
            }

            if (this.onDoubleTap != null)
            {
                gestures[typeof(DoubleTapGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <DoubleTapGestureRecognizer>(
                        () => new DoubleTapGestureRecognizer(debugOwner: this),
                        instance => { instance.onDoubleTap = this.onDoubleTap; }
                        );
            }

            if (this.onLongPress != null || this.onLongPressUp != null)
            {
                gestures[typeof(LongPressGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <LongPressGestureRecognizer>(
                        () => new LongPressGestureRecognizer(debugOwner: this),
                        instance => { instance.onLongPress = this.onLongPress; }
                        );
            }

            if (this.onLongPressDragStart != null || this.onLongPressDragUpdate != null ||
                this.onLongPressDragUp != null)
            {
                gestures[typeof(LongPressDragGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <LongPressDragGestureRecognizer>(
                        () => new LongPressDragGestureRecognizer(debugOwner: this),
                        (LongPressDragGestureRecognizer instance) => {
                    instance.onLongPressStart      = this.onLongPressDragStart;
                    instance.onLongPressDragUpdate = this.onLongPressDragUpdate;
                    instance.onLongPressUp         = this.onLongPressDragUp;
                }
                        );
            }

            if (this.onVerticalDragDown != null ||
                this.onVerticalDragStart != null ||
                this.onVerticalDragUpdate != null ||
                this.onVerticalDragEnd != null ||
                this.onVerticalDragCancel != null)
            {
                gestures[typeof(VerticalDragGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <VerticalDragGestureRecognizer>(
                        () => new VerticalDragGestureRecognizer(debugOwner: this),
                        instance => {
                    instance.onDown            = this.onVerticalDragDown;
                    instance.onStart           = this.onVerticalDragStart;
                    instance.onUpdate          = this.onVerticalDragUpdate;
                    instance.onEnd             = this.onVerticalDragEnd;
                    instance.onCancel          = this.onVerticalDragCancel;
                    instance.dragStartBehavior = this.dragStartBehavior;
                }
                        );
            }

            if (this.onHorizontalDragDown != null ||
                this.onHorizontalDragStart != null ||
                this.onHorizontalDragUpdate != null ||
                this.onHorizontalDragEnd != null ||
                this.onHorizontalDragCancel != null)
            {
                gestures[typeof(HorizontalDragGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <HorizontalDragGestureRecognizer>(
                        () => new HorizontalDragGestureRecognizer(debugOwner: this),
                        instance => {
                    instance.onDown            = this.onHorizontalDragDown;
                    instance.onStart           = this.onHorizontalDragStart;
                    instance.onUpdate          = this.onHorizontalDragUpdate;
                    instance.onEnd             = this.onHorizontalDragEnd;
                    instance.onCancel          = this.onHorizontalDragCancel;
                    instance.dragStartBehavior = this.dragStartBehavior;
                }
                        );
            }

            if (this.onPanDown != null ||
                this.onPanStart != null ||
                this.onPanUpdate != null ||
                this.onPanEnd != null ||
                this.onPanCancel != null)
            {
                gestures[typeof(PanGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <PanGestureRecognizer>(
                        () => new PanGestureRecognizer(debugOwner: this),
                        instance => {
                    instance.onDown            = this.onPanDown;
                    instance.onStart           = this.onPanStart;
                    instance.onUpdate          = this.onPanUpdate;
                    instance.onEnd             = this.onPanEnd;
                    instance.onCancel          = this.onPanCancel;
                    instance.dragStartBehavior = this.dragStartBehavior;
                }
                        );
            }

            if (this.onScaleStart != null ||
                this.onScaleUpdate != null ||
                this.onScaleEnd != null)
            {
                gestures[typeof(ScaleGestureRecognizer)] =
                    new GestureRecognizerFactoryWithHandlers <ScaleGestureRecognizer>(
                        () => new ScaleGestureRecognizer(debugOwner: this),
                        instance => {
                    instance.onStart  = this.onScaleStart;
                    instance.onUpdate = this.onScaleUpdate;
                    instance.onEnd    = this.onScaleEnd;
                }
                        );
            }

            return(new RawGestureDetector(
                       gestures: gestures,
                       behavior: this.behavior,
                       child: this.child
                       ));
        }