Skip to content

Commit

Permalink
Added ShouldShareViewAmongSameItems + bump 2.4.3
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiMisiukevich committed Feb 10, 2020
1 parent 335ea15 commit 93a0674
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion 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>2.4.2</version>
<version>2.4.3</version>
<title>CardsView</title>
<authors>Andrei Misiukevich</authors>
<owners>Andrei Misiukevich</owners>
Expand Down
13 changes: 9 additions & 4 deletions PanCardView/CardsView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public class CardsView : AbsoluteLayout

public static readonly BindableProperty IsPanSwipeEnabledProperty = BindableProperty.Create(nameof(IsPanSwipeEnabled), typeof(bool), typeof(CardsView), true);

public static readonly BindableProperty AreAnimationsEnabledProperty = BindableProperty.Create(nameof(AreAnimationsEnabled), typeof(bool), typeof(CardsView), true);
public static readonly BindableProperty ShouldShareViewAmongSameItemsProperty = BindableProperty.Create(nameof(ShouldShareViewAmongSameItems), typeof(bool), typeof(CardsView), false);

public static readonly BindableProperty MaxChildrenCountProperty = BindableProperty.Create(nameof(MaxChildrenCount), typeof(int), typeof(CardsView), defaultValueCreator: b => b.AsCardsView().DefaultMaxChildrenCount);

Expand Down Expand Up @@ -405,10 +405,10 @@ public bool IsAutoNavigatingAnimationEnabled
set => SetValue(IsAutoNavigatingAnimationEnabledProperty, value);
}

public bool AreAnimationsEnabled
public bool ShouldShareViewAmongSameItems
{
get => (bool)GetValue(AreAnimationsEnabledProperty);
set => SetValue(AreAnimationsEnabledProperty, value);
get => (bool)GetValue(ShouldShareViewAmongSameItemsProperty);
set => SetValue(ShouldShareViewAmongSameItemsProperty, value);
}

public bool IsPanSwipeEnabled
Expand Down Expand Up @@ -1481,6 +1481,11 @@ private View CreateRetrieveView(object context, DataTemplate template, IEnumerab
?? notUsingViews.FirstOrDefault(v => !CheckIsProcessingView(v));
}

if(ShouldShareViewAmongSameItems)
{
view = bookedViews.FirstOrDefault(v => Equals(v.BindingContext, context)) ?? view;
}

if (view == null)
{
view = template.CreateView();
Expand Down
1 change: 1 addition & 0 deletions docs/CardsView.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ IsCyclical | `bool` | true | Determines if the control can cycle round from the
CurrentDiff | `double` | 0.0 | Shows current pan diff.
IsOnlyForwardDirection | `bool` | false | Determines if the control should always take next elements for putting them on sides (like Tinder).
IsPanSwipeEnabled | `bool` | true | Set to allow the control to detec swipes from fast pan movements.
ShouldShareViewAmongSameItems | `bool` | false | Set to force all same items to use the same view at the same moment.
VerticalSwipeThresholdDistance | `double` | 30.0 | **Only used in Android** Determines distance for recognizing movement as vertical swipe.
ShouldThrottlePanInteraction | `bool` | false | **Only used in Android** Set to allow throttling pan gesture interaction.
IsVerticalSwipeEnabled | `bool` | true | **Only used in Android and iOS** Determines if vertical swipes are enabled.
Expand Down

0 comments on commit 93a0674

Please sign in to comment.