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);
            this._lastHighlight?.dispose();
            this._lastHighlight = null;
            base.deactivate();
        }
        public void updateHighlight(bool value)
        {
            if (value == (this._lastHighlight != null && this._lastHighlight.active))
            {
                return;
            }

            if (value)
            {
                if (this._lastHighlight == null)
                {
                    RenderBox referenceBox = (RenderBox)this.context.findRenderObject();
                    this._lastHighlight = new InkHighlight(
                        controller: Material.of(this.context),
                        referenceBox: referenceBox,
                        color: this.widget.highlightColor ?? Theme.of(this.context).highlightColor,
                        shape: this.widget.highlightShape,
                        borderRadius: this.widget.borderRadius,
                        customBorder: this.widget.customBorder,
                        rectCallback: this.widget.getRectCallback(referenceBox),
                        onRemoved: this._handleInkHighlightRemoval);
                    this.updateKeepAlive();
                }
                else
                {
                    this._lastHighlight.activate();
                }
            }
            else
            {
                this._lastHighlight.deactivate();
            }

            D.assert(value == (this._lastHighlight != null && this._lastHighlight.active));
            if (this.widget.onHighlightChanged != null)
            {
                this.widget.onHighlightChanged(value);
            }
        }
 void _handleInkHighlightRemoval()
 {
     D.assert(this._lastHighlight != null);
     this._lastHighlight = null;
     this.updateKeepAlive();
 }
示例#4
0
        public void updateHighlight(_HighlightType type, bool value)
        {
            InkHighlight highlight = _highlights.getOrDefault(type);

            void handleInkRemoval()
            {
                D.assert(_highlights.getOrDefault(type) != null);
                _highlights[type] = null;
                updateKeepAlive();
            }

            if (value == (highlight != null && highlight.active))
            {
                return;
            }

            if (value)
            {
                if (highlight == null)
                {
                    RenderBox referenceBox = (RenderBox)context.findRenderObject();
                    _highlights[type] = new InkHighlight(
                        controller: Material.of(context),
                        referenceBox: referenceBox,
                        color: getHighlightColorForType(type),
                        shape: widget.highlightShape,
                        borderRadius: widget.borderRadius,
                        customBorder: widget.customBorder,
                        rectCallback: widget.getRectCallback(referenceBox),
                        onRemoved: handleInkRemoval,
                        textDirection: Directionality.of(context),
                        fadeDuration: getFadeDurationForType(type)
                        );
                    updateKeepAlive();
                }
                else
                {
                    highlight.activate();
                }
            }
            else
            {
                highlight.deactivate();
            }

            D.assert(value == (_highlights.getOrDefault(type) != null && _highlights[type].active));
            switch (type)
            {
            case _HighlightType.pressed: {
                if (widget.onHighlightChanged != null)
                {
                    widget.onHighlightChanged(value);
                }
                break;
            }

            case _HighlightType.hover: {
                if (widget.onHover != null)
                {
                    widget.onHover(value);
                }
                break;
            }

            case _HighlightType.focus:
                break;
            }
        }