Exemplo n.º 1
0
 public TextSelectionGestureDetector(
     Key key = null,
     GestureTapDownCallback onTapDown                  = null,
     GestureTapUpCallback onSingleTapUp                = null,
     GestureTapCancelCallback onSingleTapCancel        = null,
     GestureLongPressCallback onSingleLongTapStart     = null,
     GestureTapDownCallback onDoubleTapDown            = null,
     GestureDragStartCallback onDragSelectionStart     = null,
     DragSelectionUpdateCallback onDragSelectionUpdate = null,
     GestureDragEndCallback onDragSelectionEnd         = null,
     HitTestBehavior?behavior = null,
     Widget child             = null
     ) : base(key: key)
 {
     D.assert(child != null);
     this.onTapDown             = onTapDown;
     this.onSingleTapUp         = onSingleTapUp;
     this.onSingleTapCancel     = onSingleTapCancel;
     this.onSingleLongTapStart  = onSingleLongTapStart;
     this.onDoubleTapDown       = onDoubleTapDown;
     this.onDragSelectionStart  = onDragSelectionStart;
     this.onDragSelectionUpdate = onDragSelectionUpdate;
     this.onDragSelectionEnd    = onDragSelectionEnd;
     this.behavior = behavior;
     this.child    = child;
 }
 public BackdropPanel(
     Key key            = null,
     VoidCallback onTap = null,
     GestureDragUpdateCallback onVerticalDragUpdate = null,
     GestureDragEndCallback onVerticalDragEnd       = null,
     Widget title = null,
     Widget child = null
     ) : base(key: key)
 {
     this.onTap = onTap;
     this.onVerticalDragUpdate = onVerticalDragUpdate;
     this.onVerticalDragEnd    = onVerticalDragEnd;
     this.title = title;
     this.child = child;
 }
        public GestureDetector(
            Key key      = null,
            Widget child = null,
            GestureTapDownCallback onTapDown         = null,
            GestureTapUpCallback onTapUp             = null,
            GestureTapCallback onTap                 = null,
            GestureTapCancelCallback onTapCancel     = null,
            GestureDoubleTapCallback onDoubleTap     = null,
            GestureLongPressCallback onLongPress     = null,
            GestureLongPressUpCallback onLongPressUp = null,
            GestureLongPressDragStartCallback onLongPressDragStart   = null,
            GestureLongPressDragUpdateCallback onLongPressDragUpdate = null,
            GestureLongPressDragUpCallback onLongPressDragUp         = null,
            GestureDragDownCallback onVerticalDragDown       = null,
            GestureDragStartCallback onVerticalDragStart     = null,
            GestureDragUpdateCallback onVerticalDragUpdate   = null,
            GestureDragEndCallback onVerticalDragEnd         = null,
            GestureDragCancelCallback onVerticalDragCancel   = null,
            GestureDragDownCallback onHorizontalDragDown     = null,
            GestureDragStartCallback onHorizontalDragStart   = null,
            GestureDragUpdateCallback onHorizontalDragUpdate = null,
            GestureDragEndCallback onHorizontalDragEnd       = null,
            GestureDragCancelCallback onHorizontalDragCancel = null,
            GestureDragDownCallback onPanDown        = null,
            GestureDragStartCallback onPanStart      = null,
            GestureDragUpdateCallback onPanUpdate    = null,
            GestureDragEndCallback onPanEnd          = null,
            GestureDragCancelCallback onPanCancel    = null,
            GestureScaleStartCallback onScaleStart   = null,
            GestureScaleUpdateCallback onScaleUpdate = null,
            GestureScaleEndCallback onScaleEnd       = null,
            HitTestBehavior behavior            = HitTestBehavior.deferToChild,
            DragStartBehavior dragStartBehavior = DragStartBehavior.down
            ) : base(key)
        {
            D.assert(() => {
                bool haveVerticalDrag =
                    onVerticalDragStart != null || onVerticalDragUpdate != null ||
                    onVerticalDragEnd != null;
                bool haveHorizontalDrag =
                    onHorizontalDragStart != null || onHorizontalDragUpdate != null ||
                    onHorizontalDragEnd != null;
                bool haveLongPress     = onLongPress != null || onLongPressUp != null;
                bool haveLongPressDrag = onLongPressDragStart != null || onLongPressDragUpdate != null ||
                                         onLongPressDragUp != null;
                bool havePan   = onPanStart != null || onPanUpdate != null || onPanEnd != null;
                bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null;
                if (havePan || haveScale)
                {
                    if (havePan && haveScale)
                    {
                        throw new UIWidgetsError(
                            "Incorrect GestureDetector arguments.\n" +
                            "Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer."
                            );
                    }

                    string recognizer = havePan ? "pan" : "scale";
                    if (haveVerticalDrag && haveHorizontalDrag)
                    {
                        throw new UIWidgetsError(
                            "Incorrect GestureDetector arguments.\n" +
                            $"Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a {recognizer} gesture recognizer " +
                            $"will result in the {recognizer} gesture recognizer being ignored, since the other two will catch all drags."
                            );
                    }
                }

                if (haveLongPress && haveLongPressDrag)
                {
                    throw new UIWidgetsError(
                        "Incorrect GestureDetector arguments.\n" +
                        "Having both a long press and a long press drag recognizer is " +
                        "redundant as the long press drag is a superset of long press. " +
                        "Except long press drag allows for drags after the long press is " +
                        "triggered."
                        );
                }

                return(true);
            });

            this.child                  = child;
            this.onTapDown              = onTapDown;
            this.onTapUp                = onTapUp;
            this.onTap                  = onTap;
            this.onTapCancel            = onTapCancel;
            this.onDoubleTap            = onDoubleTap;
            this.onLongPress            = onLongPress;
            this.onLongPressUp          = onLongPressUp;
            this.onLongPressDragStart   = onLongPressDragStart;
            this.onLongPressDragUpdate  = onLongPressDragUpdate;
            this.onLongPressDragUp      = onLongPressDragUp;
            this.onVerticalDragDown     = onVerticalDragDown;
            this.onVerticalDragStart    = onVerticalDragStart;
            this.onVerticalDragUpdate   = onVerticalDragUpdate;
            this.onVerticalDragEnd      = onVerticalDragEnd;
            this.onVerticalDragCancel   = onVerticalDragCancel;
            this.onHorizontalDragDown   = onHorizontalDragDown;
            this.onHorizontalDragStart  = onHorizontalDragStart;
            this.onHorizontalDragUpdate = onHorizontalDragUpdate;
            this.onHorizontalDragEnd    = onHorizontalDragEnd;
            this.onHorizontalDragCancel = onHorizontalDragCancel;
            this.onPanDown              = onPanDown;
            this.onPanStart             = onPanStart;
            this.onPanUpdate            = onPanUpdate;
            this.onPanEnd               = onPanEnd;
            this.onPanCancel            = onPanCancel;
            this.onScaleStart           = onScaleStart;
            this.onScaleUpdate          = onScaleUpdate;
            this.onScaleEnd             = onScaleEnd;
            this.behavior               = behavior;
            this.dragStartBehavior      = dragStartBehavior;
        }
Exemplo n.º 4
0
        public override Widget build(BuildContext context)
        {
            base.build(context); // See AutomaticKeepAliveClientMixin.
            if (!this.widget.enabled ||
                (this.widget.actionDelegate == null || this.widget.actionDelegate.actionCount == 0) &&
                (this.widget.secondaryActionDelegate == null || this.widget.secondaryActionDelegate.actionCount == 0))
            {
                return(this.widget.child);
            }

            var content = this.widget.child;

            if (this.actionType == CustomDismissibleActionType.primary && this.widget.actionDelegate != null &&
                this.widget.actionDelegate.actionCount > 0 ||
                this.actionType == CustomDismissibleActionType.secondary &&
                this.widget.secondaryActionDelegate != null && this.widget.secondaryActionDelegate.actionCount > 0)
            {
                if (this.dismissible)
                {
                    content = this.widget.slideToDismissDelegate.buildActions(
                        context,
                        new CustomDismissibleDelegateContext(this), this.widget.dismissibleDelegate
                        );

                    if (this._resizeAnimation != null)
                    {
                        D.assert(() => {
                            if (this._resizeAnimation.status != AnimationStatus.forward)
                            {
                                D.assert(this._resizeAnimation.status == AnimationStatus.completed);
                            }

                            return(true);
                        });
                        return(new SizeTransition(
                                   sizeFactor: this._resizeAnimation,
                                   axis: this.directionIsXAxis ? Axis.vertical : Axis.horizontal,
                                   child: new SizedBox(
                                       width: this._sizePriorToCollapse.width,
                                       height: this._sizePriorToCollapse.height,
                                       child: content
                                       )
                                   ));
                    }
                }
                else
                {
                    content = this.widget.dismissibleDelegate.buildActions(
                        context,
                        new CustomDismissibleDelegateContext(this)
                        );
                }
            }

            GestureDragStartCallback  onHorizontalDragStart  = null;
            GestureDragUpdateCallback onHorizontalDragUpdate = null;
            GestureDragEndCallback    onHorizontalDragEnd    = null;
            GestureDragStartCallback  onVerticalDragStart    = this._handleDragStart;
            GestureDragUpdateCallback onVerticalDragUpdate   = this._handleDragUpdate;
            GestureDragEndCallback    onVerticalDragEnd      = this._handleDragEnd;

            if (this.directionIsXAxis)
            {
                onHorizontalDragStart  = this._handleDragStart;
                onHorizontalDragUpdate = this._handleDragUpdate;
                onHorizontalDragEnd    = this._handleDragEnd;
                onVerticalDragStart    = null;
                onVerticalDragUpdate   = null;
                onVerticalDragEnd      = null;
            }

            return(new GestureDetector(
                       onHorizontalDragStart: onHorizontalDragStart,
                       onHorizontalDragUpdate: onHorizontalDragUpdate,
                       onHorizontalDragEnd: onHorizontalDragEnd,
                       onVerticalDragStart: onVerticalDragStart,
                       onVerticalDragUpdate: onVerticalDragUpdate,
                       onVerticalDragEnd: onVerticalDragEnd,
                       behavior: HitTestBehavior.opaque,
                       child: content
                       ));
        }
Exemplo n.º 5
0
        public GestureDetector(
            Key key      = null,
            Widget child = null,
            GestureTapDownCallback onTapDown                 = null,
            GestureTapUpCallback onTapUp                     = null,
            GestureTapCallback onTap                         = null,
            GestureTapCancelCallback onTapCancel             = null,
            GestureDoubleTapCallback onDoubleTap             = null,
            GestureLongPressCallback onLongPress             = null,
            GestureDragDownCallback onVerticalDragDown       = null,
            GestureDragStartCallback onVerticalDragStart     = null,
            GestureDragUpdateCallback onVerticalDragUpdate   = null,
            GestureDragEndCallback onVerticalDragEnd         = null,
            GestureDragCancelCallback onVerticalDragCancel   = null,
            GestureDragDownCallback onHorizontalDragDown     = null,
            GestureDragStartCallback onHorizontalDragStart   = null,
            GestureDragUpdateCallback onHorizontalDragUpdate = null,
            GestureDragEndCallback onHorizontalDragEnd       = null,
            GestureDragCancelCallback onHorizontalDragCancel = null,
            GestureDragDownCallback onPanDown                = null,
            GestureDragStartCallback onPanStart              = null,
            GestureDragUpdateCallback onPanUpdate            = null,
            GestureDragEndCallback onPanEnd                  = null,
            GestureDragCancelCallback onPanCancel            = null,
            HitTestBehavior behavior                         = HitTestBehavior.deferToChild) : base(key)
        {
            D.assert(() => {
                bool haveVerticalDrag =
                    onVerticalDragStart != null || onVerticalDragUpdate != null ||
                    onVerticalDragEnd != null;
                bool haveHorizontalDrag =
                    onHorizontalDragStart != null || onHorizontalDragUpdate != null ||
                    onHorizontalDragEnd != null;
                bool havePan = onPanStart != null || onPanUpdate != null || onPanEnd != null;
                if (havePan)
                {
                    if (haveVerticalDrag && haveHorizontalDrag)
                    {
                        throw new UIWidgetsError(
                            "Incorrect GestureDetector arguments.\n" +
                            "Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a pan gesture recognizer " +
                            "will result in the pan gesture recognizer being ignored, since the other two will catch all drags."
                            );
                    }
                }

                return(true);
            });

            this.child                  = child;
            this.onTapDown              = onTapDown;
            this.onTapUp                = onTapUp;
            this.onTap                  = onTap;
            this.onTapCancel            = onTapCancel;
            this.onDoubleTap            = onDoubleTap;
            this.onLongPress            = onLongPress;
            this.onVerticalDragDown     = onVerticalDragDown;
            this.onVerticalDragStart    = onVerticalDragStart;
            this.onVerticalDragUpdate   = onVerticalDragUpdate;
            this.onVerticalDragEnd      = onVerticalDragEnd;
            this.onVerticalDragCancel   = onVerticalDragCancel;
            this.onHorizontalDragDown   = onHorizontalDragDown;
            this.onHorizontalDragStart  = onHorizontalDragStart;
            this.onHorizontalDragUpdate = onHorizontalDragUpdate;
            this.onHorizontalDragEnd    = onHorizontalDragEnd;
            this.onHorizontalDragCancel = onHorizontalDragCancel;
            this.onPanDown              = onPanDown;
            this.onPanStart             = onPanStart;
            this.onPanUpdate            = onPanUpdate;
            this.onPanEnd               = onPanEnd;
            this.onPanCancel            = onPanCancel;
            this.behavior               = behavior;
        }
Exemplo n.º 6
0
        public GestureDetector(
            Key key      = null,
            Widget child = null,
            GestureTapDownCallback onTapDown                         = null,
            GestureTapUpCallback onTapUp                             = null,
            GestureTapCallback onTap                                 = null,
            GestureTapCancelCallback onTapCancel                     = null,
            GestureTapDownCallback onSecondaryTapDown                = null,
            GestureTapUpCallback onSecondaryTapUp                    = null,
            GestureTapCancelCallback onSecondaryTapCancel            = null,
            GestureDoubleTapCallback onDoubleTap                     = null,
            GestureLongPressCallback onLongPress                     = null,
            GestureLongPressStartCallback onLongPressStart           = null,
            GestureLongPressMoveUpdateCallback onLongPressMoveUpdate = null,
            GestureLongPressUpCallback onLongPressUp                 = null,
            GestureLongPressEndCallback onLongPressEnd               = null,
            GestureDragDownCallback onVerticalDragDown               = null,
            GestureDragStartCallback onVerticalDragStart             = null,
            GestureDragUpdateCallback onVerticalDragUpdate           = null,
            GestureDragEndCallback onVerticalDragEnd                 = null,
            GestureDragCancelCallback onVerticalDragCancel           = null,
            GestureDragDownCallback onHorizontalDragDown             = null,
            GestureDragStartCallback onHorizontalDragStart           = null,
            GestureDragUpdateCallback onHorizontalDragUpdate         = null,
            GestureDragEndCallback onHorizontalDragEnd               = null,
            GestureDragCancelCallback onHorizontalDragCancel         = null,
            GestureForcePressStartCallback onForcePressStart         = null,
            GestureForcePressPeakCallback onForcePressPeak           = null,
            GestureForcePressUpdateCallback onForcePressUpdate       = null,
            GestureForcePressEndCallback onForcePressEnd             = null,
            GestureDragDownCallback onPanDown                        = null,
            GestureDragStartCallback onPanStart                      = null,
            GestureDragUpdateCallback onPanUpdate                    = null,
            GestureDragEndCallback onPanEnd                          = null,
            GestureDragCancelCallback onPanCancel                    = null,
            GestureScaleStartCallback onScaleStart                   = null,
            GestureScaleUpdateCallback onScaleUpdate                 = null,
            GestureScaleEndCallback onScaleEnd                       = null,
            HitTestBehavior behavior                                 = HitTestBehavior.deferToChild,
            DragStartBehavior dragStartBehavior                      = DragStartBehavior.down
            ) : base(key)
        {
            D.assert(() => {
                bool haveVerticalDrag =
                    onVerticalDragStart != null || onVerticalDragUpdate != null ||
                    onVerticalDragEnd != null;
                bool haveHorizontalDrag =
                    onHorizontalDragStart != null || onHorizontalDragUpdate != null ||
                    onHorizontalDragEnd != null;
                bool havePan   = onPanStart != null || onPanUpdate != null || onPanEnd != null;
                bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null;
                if (havePan || haveScale)
                {
                    if (havePan && haveScale)
                    {
                        throw new UIWidgetsError(new List <DiagnosticsNode> {
                            new ErrorSummary("Incorrect GestureDetector arguments."),
                            new ErrorDescription(
                                "Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan."
                                ),
                            new ErrorHint("Just use the scale gesture recognizer.")
                        });
                    }

                    string recognizer = havePan ? "pan" : "scale";
                    if (haveVerticalDrag && haveHorizontalDrag)
                    {
                        throw new UIWidgetsError(
                            "Incorrect GestureDetector arguments.\n" +
                            $"Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a {recognizer} gesture recognizer " +
                            $"will result in the {recognizer} gesture recognizer being ignored, since the other two will catch all drags."
                            );
                    }
                }

                return(true);
            });

            this.child                  = child;
            this.onTapDown              = onTapDown;
            this.onTapUp                = onTapUp;
            this.onTap                  = onTap;
            this.onTapCancel            = onTapCancel;
            this.onSecondaryTapDown     = onSecondaryTapDown;
            this.onSecondaryTapUp       = onSecondaryTapUp;
            this.onSecondaryTapCancel   = onSecondaryTapCancel;
            this.onDoubleTap            = onDoubleTap;
            this.onLongPress            = onLongPress;
            this.onLongPressUp          = onLongPressUp;
            this.onLongPressStart       = onLongPressStart;
            this.onLongPressMoveUpdate  = onLongPressMoveUpdate;
            this.onLongPressEnd         = onLongPressEnd;
            this.onVerticalDragDown     = onVerticalDragDown;
            this.onVerticalDragStart    = onVerticalDragStart;
            this.onVerticalDragUpdate   = onVerticalDragUpdate;
            this.onVerticalDragEnd      = onVerticalDragEnd;
            this.onVerticalDragCancel   = onVerticalDragCancel;
            this.onHorizontalDragDown   = onHorizontalDragDown;
            this.onHorizontalDragStart  = onHorizontalDragStart;
            this.onHorizontalDragUpdate = onHorizontalDragUpdate;
            this.onHorizontalDragEnd    = onHorizontalDragEnd;
            this.onHorizontalDragCancel = onHorizontalDragCancel;
            this.onForcePressEnd        = onForcePressEnd;
            this.onForcePressPeak       = onForcePressPeak;
            this.onForcePressStart      = onForcePressStart;
            this.onForcePressUpdate     = onForcePressUpdate;
            this.onPanDown              = onPanDown;
            this.onPanStart             = onPanStart;
            this.onPanUpdate            = onPanUpdate;
            this.onPanEnd               = onPanEnd;
            this.onPanCancel            = onPanCancel;
            this.onScaleStart           = onScaleStart;
            this.onScaleUpdate          = onScaleUpdate;
            this.onScaleEnd             = onScaleEnd;
            this.behavior               = behavior;
            this.dragStartBehavior      = dragStartBehavior;
        }