Esempio n. 1
0
 public override InteractiveInkFeature create(
     MaterialInkController controller = null,
     RenderBox referenceBox           = null,
     Offset position           = null,
     Color color               = null,
     bool containedInkWell     = false,
     RectCallback rectCallback = null,
     BorderRadius borderRadius = null,
     ShapeBorder customBorder  = null,
     float?radius              = null,
     VoidCallback onRemoved    = null
     )
 {
     D.assert(controller != null);
     D.assert(referenceBox != null);
     D.assert(position != null);
     D.assert(color != null);
     return(new InkRipple(
                controller: controller,
                referenceBox: referenceBox,
                position: position,
                color: color,
                containedInkWell: containedInkWell,
                rectCallback: rectCallback,
                borderRadius: borderRadius,
                customBorder: customBorder,
                radius: radius,
                onRemoved: onRemoved));
 }
Esempio n. 2
0
        public InkHighlight(
            MaterialInkController controller = null,
            RenderBox referenceBox           = null,
            Color color               = null,
            BoxShape shape            = BoxShape.rectangle,
            BorderRadius borderRadius = null,
            ShapeBorder customBorder  = null,
            RectCallback rectCallback = null,
            VoidCallback onRemoved    = null) : base(
                controller: controller,
                referenceBox: referenceBox,
                color: color,
                onRemoved: onRemoved)
        {
            D.assert(color != null);
            D.assert(controller != null);
            D.assert(referenceBox != null);
            this._shape        = shape;
            this._borderRadius = borderRadius ?? BorderRadius.zero;
            this._customBorder = customBorder;
            this._rectCallback = rectCallback;

            this._alphaController = new AnimationController(
                duration: InkHighlightUtils._kHighlightFadeDuration,
                vsync: controller.vsync);
            this._alphaController.addListener(controller.markNeedsPaint);
            this._alphaController.addStatusListener(this._handleAlphaStatusChanged);
            this._alphaController.forward();

            this._alpha = this._alphaController.drive(new IntTween(
                                                          begin: 0, end: color.alpha));

            this.controller.addInkFeature(this);
        }
Esempio n. 3
0
 public abstract InteractiveInkFeature create(
     MaterialInkController controller = null,
     RenderBox referenceBox           = null,
     Offset position           = null,
     Color color               = null,
     bool containedInkWell     = false,
     RectCallback rectCallback = null,
     BorderRadius borderRadius = null,
     ShapeBorder customBorder  = null,
     float?radius              = null,
     VoidCallback onRemoved    = null);
Esempio n. 4
0
 public InkFeature(
     MaterialInkController controller = null,
     RenderBox referenceBox           = null,
     VoidCallback onRemoved           = null)
 {
     D.assert(controller != null);
     D.assert(referenceBox != null);
     this._controller  = (_RenderInkFeatures)controller;
     this.referenceBox = referenceBox;
     this.onRemoved    = onRemoved;
 }
Esempio n. 5
0
 public InteractiveInkFeature(
     MaterialInkController controller = null,
     RenderBox referenceBox           = null,
     Color color            = null,
     VoidCallback onRemoved = null
     ) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved)
 {
     D.assert(controller != null);
     D.assert(referenceBox != null);
     this._color = color;
 }
Esempio n. 6
0
        public InkSplash(
            MaterialInkController controller = null,
            RenderBox referenceBox           = null,
            TextDirection?textDirection      = null,
            Offset position           = null,
            Color color               = null,
            bool containedInkWell     = false,
            RectCallback rectCallback = null,
            BorderRadius borderRadius = null,
            ShapeBorder customBorder  = null,
            float?radius              = null,
            VoidCallback onRemoved    = null
            ) : base(
                controller: controller,
                referenceBox: referenceBox,
                color: color,
                onRemoved: onRemoved)
        {
            D.assert(controller != null);
            D.assert(referenceBox != null);
            D.assert(textDirection != null);
            _position     = position;
            _borderRadius = borderRadius ?? BorderRadius.zero;
            _customBorder = customBorder;
            _targetRadius =
                radius ?? InkSplashUtils._getTargetRadius(referenceBox, containedInkWell, rectCallback, position);
            _clipCallback             = InkSplashUtils._getClipCallback(referenceBox, containedInkWell, rectCallback);
            _repositionToReferenceBox = !containedInkWell;
            _textDirection            = textDirection.Value;

            D.assert(_borderRadius != null);
            _radiusController = new AnimationController(
                duration: InkSplashUtils._kUnconfirmedSplashDuration,
                vsync: controller.vsync);
            _radiusController.addListener(controller.markNeedsPaint);
            _radiusController.forward();
            _radius = _radiusController.drive(new FloatTween(
                                                  begin: InkSplashUtils._kSplashInitialSize,
                                                  end: _targetRadius));

            _alphaController = new AnimationController(
                duration: InkSplashUtils._kSplashFadeDuration,
                vsync: controller.vsync);
            _alphaController.addListener(controller.markNeedsPaint);
            _alphaController.addStatusListener(_handleAlphaStatusChanged);
            _alpha = _alphaController.drive(new IntTween(
                                                begin: color.alpha,
                                                end: 0));

            controller.addInkFeature(this);
        }
Esempio n. 7
0
 public InkDecoration(
     Decoration decoration            = null,
     ImageConfiguration configuration = null,
     MaterialInkController controller = null,
     RenderBox referenceBox           = null,
     VoidCallback onRemoved           = null
     ) : base(controller: controller, referenceBox: referenceBox, onRemoved: onRemoved)
 {
     D.assert(configuration != null);
     D.assert(controller != null);
     D.assert(referenceBox != null);
     _configuration  = configuration;
     this.decoration = decoration;
     this.controller.addInkFeature(this);
 }
Esempio n. 8
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);
        }
Esempio n. 9
0
        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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
0
        public InkRipple(
            MaterialInkController controller = null,
            RenderBox referenceBox           = null,
            Offset position           = null,
            Color color               = null,
            bool containedInkWell     = false,
            RectCallback rectCallback = null,
            BorderRadius borderRadius = null,
            ShapeBorder customBorder  = null,
            float?radius              = null,
            VoidCallback onRemoved    = null
            ) : base(
                controller: controller,
                referenceBox: referenceBox,
                color: color,
                onRemoved: onRemoved)
        {
            D.assert(controller != null);
            D.assert(referenceBox != null);
            D.assert(color != null);
            D.assert(position != null);

            this._position     = position;
            this._borderRadius = borderRadius ?? BorderRadius.zero;
            this._customBorder = customBorder;
            this._targetRadius =
                radius ?? InkRippleUtils._getTargetRadius(referenceBox, containedInkWell, rectCallback, position);
            this._clipCallback = InkRippleUtils._getClipCallback(referenceBox, containedInkWell, rectCallback);

            D.assert(this._borderRadius != null);

            this._fadeInController =
                new AnimationController(duration: InkRippleUtils._kFadeInDuration, vsync: controller.vsync);
            this._fadeInController.addListener(controller.markNeedsPaint);
            this._fadeInController.forward();
            this._fadeIn = this._fadeInController.drive(new IntTween(
                                                            begin: 0,
                                                            end: color.alpha
                                                            ));

            this._radiusController = new AnimationController(
                duration: InkRippleUtils._kUnconfirmedRippleDuration,
                vsync: controller.vsync);
            this._radiusController.addListener(controller.markNeedsPaint);
            this._radiusController.forward();
            this._radius = this._radiusController.drive(new FloatTween(
                                                            begin: this._targetRadius * 0.30f,
                                                            end: this._targetRadius + 5.0f
                                                            ).chain(_easeCurveTween)
                                                        );

            this._fadeOutController = new AnimationController(
                duration: InkRippleUtils._kFadeOutDuration,
                vsync: controller.vsync);
            this._fadeOutController.addListener(controller.markNeedsPaint);
            this._fadeOutController.addStatusListener(this._handleAlphaStatusChanged);
            this._fadeOut = this._fadeOutController.drive(new IntTween(
                                                              begin: color.alpha,
                                                              end: 0
                                                              ).chain(_fadeOutIntervalTween)
                                                          );

            controller.addInkFeature(this);
        }