예제 #1
0
        void _updateCircleColor()
        {
            float colorProgress = LikeButtonUtil.clamp(this.outerCircleRadiusProgress, 0.5f, 1);

            colorProgress          = LikeButtonUtil.mapValueFromRangeToRange(colorProgress, 0.5f, 1, 0, 1);
            this.circlePaint.color = Color.lerp(this.circleColor.start, this.circleColor.end, colorProgress);
        }
예제 #2
0
        void _updateBubblesPaints()
        {
            float progress1 = LikeButtonUtil.clamp(this.m_CurrentProgress, 0.6f, 1);
            int   alpha     =
                (int)LikeButtonUtil.mapValueFromRangeToRange(progress1, 0.6f, 1, 255, 0);

            if (this.m_CurrentProgress < 0.5)
            {
                float progress2 =
                    LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0, 0.5f, 0, 1);
                this.m_CirclePaints[0].color = Color.lerp(this.m_Color1, this.m_Color2, progress2).withAlpha(alpha);
                this.m_CirclePaints[1].color = Color.lerp(this.m_Color2, this.m_Color3, progress2).withAlpha(alpha);
                this.m_CirclePaints[2].color = Color.lerp(this.m_Color3, this.m_Color4, progress2).withAlpha(alpha);
                this.m_CirclePaints[3].color = Color.lerp(this.m_Color4, this.m_Color1, progress2).withAlpha(alpha);
            }
            else
            {
                float progress3 =
                    LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0.5f, 1, 0, 1);
                this.m_CirclePaints[0].color = Color.lerp(this.m_Color2, this.m_Color3, progress3).withAlpha(alpha);
                this.m_CirclePaints[1].color = Color.lerp(this.m_Color3, this.m_Color4, progress3).withAlpha(alpha);
                this.m_CirclePaints[2].color = Color.lerp(this.m_Color4, this.m_Color1, progress3).withAlpha(alpha);
                this.m_CirclePaints[3].color = Color.lerp(this.m_Color1, this.m_Color2, progress3).withAlpha(alpha);
            }
        }
예제 #3
0
 void _updateInnerBubblesPosition()
 {
     this.m_CurrentRadius2 = this.m_CurrentProgress < 0.3f
         ? LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0, 0.3f, 0, this.m_MaxInnerDotsRadius)
         : this.m_MaxInnerDotsRadius;
     if (this.m_CurrentProgress == 0)
     {
         this.m_CurrentDotSize2 = 0;
     }
     else if (this.m_CurrentProgress < 0.2f)
     {
         this.m_CurrentDotSize2 = this.m_MaxDotSize;
     }
     else if (this.m_CurrentProgress < 0.5f)
     {
         this.m_CurrentDotSize2 = LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0.2f, 0.5f,
                                                                          this.m_MaxDotSize, 0.3f * this.m_MaxDotSize);
     }
     else
     {
         this.m_CurrentDotSize2 =
             LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0.5f, 1, this.m_MaxDotSize * 0.3f,
                                                     0);
     }
 }
예제 #4
0
        void _updateOuterBubblesPosition()
        {
            if (this.m_CurrentProgress < 0.3f)
            {
                this.m_CurrentRadius1 = LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0, 0.3f, 0,
                                                                                this.m_MaxOuterDotsRadius * 0.8f);
            }
            else
            {
                this.m_CurrentRadius1 = LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0.3f, 1,
                                                                                0.8f * this.m_MaxOuterDotsRadius, this.m_MaxOuterDotsRadius);
            }

            if (this.m_CurrentProgress == 0)
            {
                this.m_CurrentDotSize1 = 0;
            }
            else if (this.m_CurrentProgress < 0.7f)
            {
                this.m_CurrentDotSize1 = this.m_MaxDotSize;
            }
            else
            {
                this.m_CurrentDotSize1 =
                    LikeButtonUtil.mapValueFromRangeToRange(this.m_CurrentProgress, 0.7f, 1, this.m_MaxDotSize, 0);
            }
        }
예제 #5
0
        void _drawOuterBubblesFrame(Canvas canvas)
        {
            if (this.m_CirclePaints.Count == 0)
            {
                return;
            }

            for (int i = 0; i < this.m_BubblesCount; i++)
            {
                float cX = this.m_CenterX + this.m_CurrentRadius1 *
                           Mathf.Cos(i * LikeButtonUtil.degToRad(deg: this.m_OuterBubblesPositionAngle));
                float cY = this.m_CenterY + this.m_CurrentRadius1 *
                           Mathf.Sin(i * LikeButtonUtil.degToRad(deg: this.m_OuterBubblesPositionAngle));
                canvas.drawCircle(new Offset(dx: cX, dy: cY), radius: this.m_CurrentDotSize1,
                                  this.m_CirclePaints[i % this.m_CirclePaints.Count]);
            }
        }
예제 #6
0
        Widget _buildLikeButtonWidget()
        {
            return(new AnimatedBuilder(
                       animation: this._controller,
                       builder: (c, w) => {
                float left = 0.0f;
                float right = 0.0f;
                float top = 0.0f;
                float bottom = 0.0f;
                if (this.widget.likeButtonPadding != null)
                {
                    left = this.widget.likeButtonPadding.left;
                    right = this.widget.likeButtonPadding.right;
                    top = this.widget.likeButtonPadding.top;
                    bottom = this.widget.likeButtonPadding.bottom;
                }

                List <Widget> children = new List <Widget>();
                if (this.widget.isShowBubbles)
                {
                    children.Add(
                        new Positioned(
                            top: (this.widget.size + top + bottom - this.widget.bubblesSize) / 2.0f,
                            left: (this.widget.size + left + right - this.widget.bubblesSize) / 2.0f,
                            child: new CustomPaint(
                                size: new Size(this.widget.bubblesSize, this.widget.bubblesSize),
                                painter: new BubblesPainter(
                                    currentProgress: this._bubblesAnimation.value,
                                    color1: this.widget.bubblesColor.dotPrimaryColor,
                                    color2: this.widget.bubblesColor.dotSecondaryColor,
                                    color3: this.widget.bubblesColor.dotThirdColorReal,
                                    color4: this.widget.bubblesColor.dotLastColorReal
                                    )
                                )
                            )
                        );
                }

                children.Add(
                    new Positioned(
                        top: (this.widget.size + top + bottom - this.widget.circleSize) / 2.0f,
                        left: (this.widget.size + left + right - this.widget.circleSize) / 2.0f,
                        child: new CustomPaint(
                            size: new Size(this.widget.circleSize, this.widget.circleSize),
                            painter: new CirclePainter(
                                innerCircleRadiusProgress: this._innerCircleAnimation.value,
                                outerCircleRadiusProgress: this._outerCircleAnimation.value,
                                circleColor: this.widget.circleColor
                                )
                            )
                        )
                    );
                var likeWidget = this.widget.likeBuilder?.Invoke(this._isLiked) ??
                                 LikeButtonUtil.defaultWidgetBuilder(this._isLiked, this.widget.size);
                children.Add(
                    new Container(
                        padding: this.widget.likeButtonPadding,
                        child: Transform.scale(
                            alignment: Alignment.center,
                            scale: this._isLiked && this._controller.isAnimating
                                    ? this._scaleAnimation.value
                                    : 1,
                            child: new SizedBox(
                                child: likeWidget,
                                height: this.widget.size,
                                width: this.widget.size
                                )
                            )
                        )
                    );
                return new Stack(
                    overflow: Overflow.visible,
                    children: children
                    );
            }
                       ));
        }