Exemple #1
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);
        }
Exemple #2
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);
        }