markolazic88 / SwipeCardView

MIT License
173 stars 38 forks source link

Animate current Card #5

Closed leroygumede closed 6 years ago

leroygumede commented 6 years ago

Hey,

Less of a issue and more of a question but how did you make the card change colour when swiping between left and right , I went through your code but found no reference of it . Great plugin 👍

SwipedLeftCommand="{Binding SwipeCommand}"
SwipedRightCommand="{Binding SwipeCommand}"
markolazic88 commented 6 years ago

I am glad you like it.

The code piece from HandleTouch method:

                if (Math.Abs((int)this.cardDistance) > this.CardMoveDistance)
                {
                    if (this.cardDistance > this.CardMoveDistance)
                    {
                        topCard.BackgroundColor = Color.FromHex(SwipeRightBackgroundColor);
                    }
                    else
                    {
                        topCard.BackgroundColor = Color.FromHex(SwipeLeftBackgroundColor);
                    }
                }
                else
                {
                    topCard.BackgroundColor = Color.FromHex(DefaultCardBackgroundColor);
                }

While you are moving card HandleTouch method is being invoked many times. Whenever HandleTouch is invoked I check how much card has moved horizontally. If it passes the limit, I update the background color.

leroygumede commented 6 years ago

Awesome. I was using the Nuget but looks like I'll have to switch SwipeCardView Class provided in your sample code to access it . Thanks again for the quick reply :)