Skip to content

Commit

Permalink
Opened properties for customizing animations
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMisiukevich committed Feb 2, 2018
1 parent 2efc680 commit 579de8f
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 48 deletions.
3 changes: 3 additions & 0 deletions PanCardView.Droid/CardsViewRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
using PanCardView.Droid;
using PanCardView;
using Android.Views;
using Android.Runtime;

[assembly: ExportRenderer(typeof(CardsView), typeof(CardsViewRenderer))]
namespace PanCardView.Droid
{
[Preserve(AllMembers = true)]
public class CardsViewRenderer : VisualElementRenderer<CardsView>
{
private bool _panStarted;
Expand All @@ -17,6 +19,7 @@ public CardsViewRenderer(Context context) : base(context)
{
}

[Obsolete("You needn't have to call this method. Now, Cards ViewRenderer is marked by Preserve attribute")]
public static void Init()
{
var now = DateTime.Now;
Expand Down
38 changes: 19 additions & 19 deletions PanCardView.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>CardsView</id>
<version>1.2.5</version>
<version>1.2.6</version>
<title>CardsView</title>
<authors>Andrei Misiukevich</authors>
<owners>Andrei Misiukevich</owners>
Expand All @@ -11,37 +11,37 @@
<iconUrl>https://cdn3.iconfinder.com/data/icons/google-material-design-icons/48/ic_view_carousel_48px-256.png</iconUrl>
<description>Cards View</description>
<summary>This package provides opportunity to create swipeable CardsView like in Tinder app has</summary>
<tags>xamarin, carouselview, cardsview, forms, carousel, xamarin.forms, android, ios, card, cards, cardview, panView, pan</tags>
<tags>xamarin, carouselview, cardsview, forms, carousel, xamarin.forms, android, card, cards, cardview, panView, pan, swipeview, swiperview, swipe</tags>
<dependencies>
<group>
<dependency id="Xamarin.Forms" version="2.4" />
</group>
</dependencies>
</metadata>
<files>
<!--Net Standard-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\netstandard1.0\PanCardView.dll" />
<!--Net Standard-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\netstandard1.0\PanCardView.dll" />

<!--Core PCL-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\portable-win+net45+wp80+win81+wpa81\PanCardView.dll" />
<!--Core PCL-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\portable-win+net45+wp80+win81+wpa81\PanCardView.dll" />

<!--Xamarin.Android-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\MonoAndroid10\PanCardView.dll" />
<file src="PanCardView.Droid\bin\Release\PanCardView.Droid.dll" target="lib\MonoAndroid10\PanCardView.Droid.dll" />
<!--Xamarin.Android-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\MonoAndroid10\PanCardView.dll" />
<file src="PanCardView.Droid\bin\Release\PanCardView.Droid.dll" target="lib\MonoAndroid10\PanCardView.Droid.dll" />

<!--Xamarin.iOS-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\Xamarin.iOS10\PanCardView.dll" />
<!--Xamarin.iOS-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\Xamarin.iOS10\PanCardView.dll" />

<!--Xamarin.Mac-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\Xamarin.Mac20\PanCardView.dll" />
<!--Xamarin.Mac-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\Xamarin.Mac20\PanCardView.dll" />

<!--Windows WinUWP-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\uap\PanCardView.dll" />
<!--Windows WinUWP-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\uap\PanCardView.dll" />

<!--Windows WinRT-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\win81\PanCardView.dll" />
<!--Windows WinRT-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\win81\PanCardView.dll" />

<!--Windows RT Phone-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\wpa81\PanCardView.dll" />
<!--Windows RT Phone-->
<file src="PanCardView\bin\Release\PanCardView.dll" target="lib\wpa81\PanCardView.dll" />
</files>
</package>
14 changes: 11 additions & 3 deletions PanCardView/CardsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class CardsView : AbsoluteLayout

public static readonly BindableProperty MoveDistanceProperty = BindableProperty.Create(nameof(MoveDistance), typeof(double), typeof(CardsView), -1.0);

public static readonly BindableProperty MoveWidthPercentageProperty = BindableProperty.Create(nameof(MoveWidthPercentage), typeof(double), typeof(CardsView), .32);

public static readonly BindableProperty IsOnlyForwardDirectionProperty = BindableProperty.Create(nameof(IsOnlyForwardDirection), typeof(bool), typeof(CardsView), false);

public static readonly BindableProperty PanDelayProperty = BindableProperty.Create(nameof(PanDelay), typeof(int), typeof(CardsView), 200);
Expand All @@ -68,9 +70,9 @@ public class CardsView : AbsoluteLayout

public static readonly BindableProperty IsAutoNavigatingProperty = BindableProperty.Create(nameof(IsAutoNavigating), typeof(bool), typeof(CardsView), false, BindingMode.OneWayToSource);

public static readonly BindableProperty MaxChildrenCountProperty = BindableProperty.Create(nameof(MaxChildrenCount), typeof(int), typeof(CardsView), 18);
public static readonly BindableProperty MaxChildrenCountProperty = BindableProperty.Create(nameof(MaxChildrenCount), typeof(int), typeof(CardsView), 12);

public static readonly BindableProperty DesiredMaxChildrenCountProperty = BindableProperty.Create(nameof(DesiredMaxChildrenCount), typeof(int), typeof(CardsView), 9);
public static readonly BindableProperty DesiredMaxChildrenCountProperty = BindableProperty.Create(nameof(DesiredMaxChildrenCount), typeof(int), typeof(CardsView), 6);

public static readonly BindableProperty PanStartedCommandProperty = BindableProperty.Create(nameof(PanStartedCommand), typeof(ICommand), typeof(CardsView), null);

Expand Down Expand Up @@ -181,11 +183,17 @@ public double MoveDistance
var dist = (double)GetValue(MoveDistanceProperty);
return dist > 0
? dist
: Width * 0.35;
: Width * MoveWidthPercentage;
}
set => SetValue(MoveDistanceProperty, value);
}

public double MoveWidthPercentage
{
get => (double)GetValue(MoveWidthPercentageProperty);
set => SetValue(MoveWidthPercentageProperty, value);
}

public int PanDelay
{
get => IsPanInCourse ? _inCoursePanDelay : (int)GetValue(PanDelayProperty);
Expand Down
1 change: 1 addition & 0 deletions PanCardView/CarouselView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public CarouselView(ICardProcessor frontViewProcessor, ICardProcessor backViewPr
{
IsClippedToBounds = true;
IsRecycled = true;
MoveWidthPercentage = 0.3;
}
}
}
1 change: 1 addition & 0 deletions PanCardView/PanCardView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
<Compile Include="Processors\BaseCarouselBackViewProcessor.cs" />
<Compile Include="Processors\BaseCarouselFrontViewProcessor.cs" />
<Compile Include="CarouselView.cs" />
<Compile Include="Processors\Constants.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Xamarin.Forms.Core">
Expand Down
17 changes: 8 additions & 9 deletions PanCardView/Processors/BaseCardBackViewProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,25 @@
using Xamarin.Forms;
using System.Threading.Tasks;
using PanCardView.Enums;
using static PanCardView.Processors.Constants;

namespace PanCardView.Processors
{
public class BaseCardBackViewProcessor : ICardProcessor
{
private const double Rad = 57.2958;
public double InitialScale { get; set; } = 0.8;

protected double InitialScale { get; set; } = 0.8;
public uint ApplyAnimationLength { get; set; } = 200;

protected uint ApplyAnimationLength { get; set; } = 200;
public uint ResetAnimationLength { get; set; } = 150;

protected uint ResetAnimationLength { get; set; } = 150;
public uint AutoNavigateAnimationLength { get; set; } = 150;

protected uint AutoNavigateAnimationLength { get; set; } = 150;
public Easing ApplyEasing { get; set; } = Easing.Linear;

protected Easing ApplyEasing { get; set; } = Easing.SinOut;
public Easing ResetEasing { get; set; } = Easing.CubicInOut;

protected Easing ResetEasing { get; set; } = Easing.SinIn;

protected Easing AutoNavigateEasing { get; set; } = Easing.Linear;
public Easing AutoNavigateEasing { get; set; } = Easing.Linear;

public virtual void InitView(View view, CardsView cardsView, PanItemPosition panItemPosition)
{
Expand Down
11 changes: 5 additions & 6 deletions PanCardView/Processors/BaseCardFrontViewProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
using Xamarin.Forms;
using System.Threading.Tasks;
using PanCardView.Enums;
using static PanCardView.Processors.Constants;

namespace PanCardView.Processors
{
public class BaseCardFrontViewProcessor : ICardProcessor
{
private const double Rad = 57.2958;
public uint ResetAnimationLength { get; set; } = 150;

protected uint ResetAnimationLength { get; set; } = 150;
public uint AutoNavigateAnimationLength { get; set; } = 150;

protected uint AutoNavigateAnimationLength { get; set; } = 150;
public Easing ResetEasing { get; set; } = Easing.CubicInOut;

protected Easing ResetEasing { get; set; } = Easing.SinIn;

protected Easing AutoNavigateEasing { get; set; } = Easing.Linear;
public Easing AutoNavigateEasing { get; set; } = Easing.Linear;

public virtual void InitView(View view, CardsView cardsView, PanItemPosition panItemPosition)
=> ResetInitialState(view);
Expand Down
4 changes: 2 additions & 2 deletions PanCardView/Processors/BaseCarouselBackViewProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace PanCardView.Processors
{
public class BaseCarouselBackViewProcessor : ICardProcessor
{
protected uint AnimationLength { get; set; } = 250;
public uint AnimationLength { get; set; } = 300;

protected Easing AnimEasing { get; set; } = Easing.SinIn;
public Easing AnimEasing { get; set; } = Easing.CubicInOut;

public virtual void InitView(View view, CardsView cardsView, PanItemPosition panItemPosition)
{
Expand Down
4 changes: 2 additions & 2 deletions PanCardView/Processors/BaseCarouselFrontViewProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace PanCardView.Processors
{
public class BaseCarouselFrontViewProcessor : ICardProcessor
{
protected uint AnimationLength { get; set; } = 250;
public uint AnimationLength { get; set; } = 300;

protected Easing AnimEasing { get; set; } = Easing.SinIn;
public Easing AnimEasing { get; set; } = Easing.CubicInOut;

public virtual void InitView(View view, CardsView cardsView, PanItemPosition panItemPosition)
{
Expand Down
8 changes: 8 additions & 0 deletions PanCardView/Processors/Constants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

namespace PanCardView.Processors
{
public static class Constants
{
public const double Rad = 57.2958;
}
}
8 changes: 1 addition & 7 deletions PanCardViewSample/Droid/MainActivity.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
using System;


using Android.App;
using Android.Content;
using Android.Content.PM;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using Xamarin.Forms;
using PanCardView.Droid;
using FFImageLoading.Forms.Droid;

namespace PanCardViewSample.Droid
Expand Down

0 comments on commit 579de8f

Please sign in to comment.