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)); }
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); }
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);
protected void paintInkCircle( Canvas canvas, Matrix4 transform, Paint paint, Offset center, float radius, TextDirection?textDirection = null, ShapeBorder customBorder = null, BorderRadius borderRadius = null, RectCallback clipCallback = null) { borderRadius = borderRadius ?? BorderRadius.zero; D.assert(canvas != null); D.assert(transform != null); D.assert(paint != null); D.assert(center != null); D.assert(borderRadius != null); Offset originOffset = MatrixUtils.getAsTranslation(transform); canvas.save(); if (originOffset == null) { canvas.transform(transform.storage); } else { canvas.translate(originOffset.dx, originOffset.dy); } if (clipCallback != null) { Rect rect = clipCallback(); if (customBorder != null) { canvas.clipPath(customBorder.getOuterPath(rect, textDirection: textDirection)); } else if (borderRadius != BorderRadius.zero) { canvas.clipRRect(RRect.fromRectAndCorners( rect, topLeft: borderRadius.topLeft, topRight: borderRadius.topRight, bottomLeft: borderRadius.bottomLeft, bottomRight: borderRadius.bottomRight )); } else { canvas.clipRect(rect); } } canvas.drawCircle(center, radius, paint); canvas.restore(); }
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); }
public static RectCallback _getClipCallback(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback) { if (rectCallback != null) { D.assert(containedInkWell); return(rectCallback); } if (containedInkWell) { return(() => Offset.zero & referenceBox.size); } return(null); }
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); }
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); }
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, Offset position) { Size size = rectCallback != null?rectCallback().size : referenceBox.size; float d1 = size.bottomRight(Offset.zero).distance; float d2 = (size.topRight(Offset.zero) - size.bottomLeft(Offset.zero)).distance; return(Mathf.Max(d1, d2) / 2.0f); }
public static float _getTargetRadius(RenderBox referenceBox, bool containedInkWell, RectCallback rectCallback, Offset position) { if (containedInkWell) { Size size = rectCallback != null?rectCallback().size : referenceBox.size; return(_getSplashRadiusForPositionInSize(size, position)); } return(Material.defaultSplashRadius); }