Example #1
0
        void _startSplash(TapDownDetails details = null, BuildContext context = null)
        {
            D.assert(details != null || context != null);

            Offset globalPosition;

            if (context != null)
            {
                RenderBox referenceBox = context.findRenderObject() as RenderBox;
                D.assert(referenceBox.hasSize, () => "InkResponse must be done with layout before starting a splash.");
                globalPosition = referenceBox.localToGlobal(referenceBox.paintBounds.center);
            }
            else
            {
                globalPosition = details.globalPosition;
            }

            InteractiveInkFeature splash = _createInkFeature(globalPosition);

            _splashes = _splashes ?? new HashSet <InteractiveInkFeature>();
            _splashes.Add(splash);
            _currentSplash = splash;
            updateKeepAlive();
            updateHighlight(_HighlightType.pressed, value: true);
        }
 void _handleDoubleTap()
 {
     this._currentSplash?.confirm();
     this._currentSplash = null;
     if (this.widget.onDoubleTap != null)
     {
         this.widget.onDoubleTap();
     }
 }
Example #3
0
 void _handleDoubleTap()
 {
     _currentSplash?.confirm();
     _currentSplash = null;
     if (widget.onDoubleTap != null)
     {
         widget.onDoubleTap();
     }
 }
 void _handleLongPress(BuildContext context)
 {
     this._currentSplash?.confirm();
     this._currentSplash = null;
     if (this.widget.onLongPress != null)
     {
         this.widget.onLongPress();
     }
 }
Example #5
0
 void _handleTap(BuildContext context)
 {
     _currentSplash?.confirm();
     _currentSplash = null;
     updateHighlight(_HighlightType.pressed, value: false);
     if (widget.onTap != null)
     {
         widget.onTap();
     }
 }
 void _handleTap(BuildContext context)
 {
     this._currentSplash?.confirm();
     this._currentSplash = null;
     this.updateHighlight(false);
     if (this.widget.onTap != null)
     {
         this.widget.onTap();
     }
 }
        void _handleTapCancel()
        {
            this._currentSplash?.cancel();
            this._currentSplash = null;
            if (this.widget.onTapCancel != null)
            {
                this.widget.onTapCancel();
            }

            this.updateHighlight(false);
        }
Example #8
0
        void _handleTapCancel()
        {
            _currentSplash?.cancel();
            _currentSplash = null;
            if (widget.onTapCancel != null)
            {
                widget.onTapCancel();
            }

            updateHighlight(_HighlightType.pressed, value: false);
        }
Example #9
0
        void _startSplash(Offset globalPosition)
        {
            if (this._effectiveFocusNode.hasFocus)
            {
                return;
            }

            InteractiveInkFeature splash = this._createInkFeature(globalPosition);

            this._splashes = this._splashes ?? new HashSet <InteractiveInkFeature>();
            this._splashes.Add(splash);
            this._currentSplash = splash;
            this.updateKeepAlive();
        }
        void _startSplash(TapDownDetails details)
        {
            if (this._effectiveFocusNode.hasFocus)
            {
                return;
            }

            InteractiveInkFeature splash = this._createInkFeature(details);

            this._splashes = this._splashes ?? new HashSet <InteractiveInkFeature>();
            this._splashes.Add(splash);
            this._currentSplash = splash;
            this.updateKeepAlive();
        }
        void _handleTapDown(TapDownDetails details)
        {
            InteractiveInkFeature splash = this._createInkFeature(details);

            this._splashes = this._splashes ?? new HashSet <InteractiveInkFeature>();
            this._splashes.Add(splash);
            this._currentSplash = splash;
            if (this.widget.onTapDown != null)
            {
                this.widget.onTapDown(details);
            }

            this.updateKeepAlive();
            this.updateHighlight(true);
        }
        public override void deactivate()
        {
            if (this._splashes != null)
            {
                HashSet <InteractiveInkFeature> splashes = this._splashes;
                this._splashes = null;
                foreach (InteractiveInkFeature splash in splashes)
                {
                    splash.dispose();
                }

                this._currentSplash = null;
            }

            D.assert(this._currentSplash == null);
            base.deactivate();
        }
Example #13
0
        InteractiveInkFeature _createInkFeature(Offset globalPosition)
        {
            MaterialInkController inkController = Material.of(context);
            RenderBox             referenceBox  = context.findRenderObject() as RenderBox;
            Offset       position     = referenceBox.globalToLocal(globalPosition);
            Color        color        = widget.splashColor ?? Theme.of(context).splashColor;
            RectCallback rectCallback = widget.containedInkWell ? widget.getRectCallback(referenceBox) : null;
            BorderRadius borderRadius = widget.borderRadius;
            ShapeBorder  customBorder = widget.customBorder;

            InteractiveInkFeature splash = null;

            void OnRemoved()
            {
                if (_splashes != null)
                {
                    D.assert(_splashes.Contains(splash));
                    _splashes.Remove(splash);
                    if (_currentSplash == splash)
                    {
                        _currentSplash = null;
                    }

                    updateKeepAlive();
                }
            }

            splash = (widget.splashFactory ?? Theme.of(context).splashFactory).create(
                controller: inkController,
                referenceBox: referenceBox,
                position: position,
                color: color,
                containedInkWell: widget.containedInkWell,
                rectCallback: rectCallback,
                radius: widget.radius,
                borderRadius: borderRadius,
                customBorder: customBorder,
                onRemoved: OnRemoved,
                textDirection: Directionality.of(context));

            return(splash);
        }
        InteractiveInkFeature _createInkFeature(TapDownDetails details)
        {
            MaterialInkController inkController = Material.of(this.context);
            RenderBox             referenceBox  = (RenderBox)this.context.findRenderObject();
            Offset       position     = referenceBox.globalToLocal(details.globalPosition);
            Color        color        = this.widget.splashColor ?? Theme.of(this.context).splashColor;
            RectCallback rectCallback = this.widget.containedInkWell ? this.widget.getRectCallback(referenceBox) : null;
            BorderRadius borderRadius = this.widget.borderRadius;
            ShapeBorder  customBorder = this.widget.customBorder;

            InteractiveInkFeature splash = null;

            void OnRemoved()
            {
                if (this._splashes != null)
                {
                    D.assert(this._splashes.Contains(splash));
                    this._splashes.Remove(splash);
                    if (this._currentSplash == splash)
                    {
                        this._currentSplash = null;
                    }

                    this.updateKeepAlive();
                }
            }

            splash = (this.widget.splashFactory ?? Theme.of(this.context).splashFactory).create(
                controller: inkController,
                referenceBox: referenceBox,
                position: position,
                color: color,
                containedInkWell: this.widget.containedInkWell,
                rectCallback: rectCallback,
                radius: this.widget.radius,
                borderRadius: borderRadius,
                customBorder: customBorder,
                onRemoved: OnRemoved);

            return(splash);
        }
Example #15
0
        InteractiveInkFeature _createInkFeature(Offset globalPosition)
        {
            MaterialInkController inkController   = Material.of(this.context);
            ThemeData             themeData       = Theme.of(this.context);
            BuildContext          editableContext = this._editableTextKey.currentContext;
            RenderBox             referenceBox    =
                (RenderBox)(InputDecorator.containerOf(editableContext) ?? editableContext.findRenderObject());
            Offset position = referenceBox.globalToLocal(globalPosition);
            Color  color    = themeData.splashColor;

            InteractiveInkFeature splash = null;

            void handleRemoved()
            {
                if (this._splashes != null)
                {
                    D.assert(this._splashes.Contains(splash));
                    this._splashes.Remove(splash);
                    if (this._currentSplash == splash)
                    {
                        this._currentSplash = null;
                    }

                    this.updateKeepAlive();
                } // else we're probably in deactivate()
            }

            splash = themeData.splashFactory.create(
                controller: inkController,
                referenceBox: referenceBox,
                position: position,
                color: color,
                containedInkWell: true,
                borderRadius: BorderRadius.zero,
                onRemoved: handleRemoved
                );

            return(splash);
        }
Example #16
0
        public override void deactivate()
        {
            if (_splashes != null)
            {
                HashSet <InteractiveInkFeature> splashes = _splashes;
                _splashes = null;
                foreach (InteractiveInkFeature splash in splashes)
                {
                    splash.dispose();
                }

                _currentSplash = null;
            }

            D.assert(_currentSplash == null);
            foreach (_HighlightType highlight in _highlights.Keys.ToList())
            {
                _highlights[highlight]?.dispose();
                _highlights[highlight] = null;
            }

            base.deactivate();
        }
 void _confirmCurrentSplash()
 {
     this._currentSplash?.confirm();
     this._currentSplash = null;
 }