Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

replaced container frame with transparent StackLayout #11

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Prev Previous commit
fix android
Marco Bellini committed May 31, 2018
commit 52db0cf20661aab9413aee02144abb7f3d97ebc3
33 changes: 19 additions & 14 deletions SwipeCards.Controls/Views/CardStackView.xaml.cs
Original file line number Diff line number Diff line change
@@ -66,18 +66,20 @@ public ICommand SwipedLeftCommand
public CardStackView()
{
InitializeComponent();

var panGesture = new PanGestureRecognizer();
panGesture.PanUpdated += OnPanUpdated;

CardStack.GestureRecognizers.Add(panGesture);

MessagingCenter.Subscribe<object>(this, "UP", async (arg) =>

if (Device.RuntimePlatform == Device.iOS)
{
Debug.WriteLine($"FakeCompleted: {_cardDistance}");
var panGesture = new PanGestureRecognizer();
panGesture.PanUpdated += OnPanUpdated;
CardStack.GestureRecognizers.Add(panGesture);
}

await HandleTouchCompleted();
});
//MessagingCenter.Subscribe<object>(this, "UP", async (arg) =>
//{
// Debug.WriteLine($"FakeCompleted: {_cardDistance}");
//
// await HandleTouchCompleted();
//});

/* put this in MainActivity for workaround to work -> https://github.com/xamarin/Xamarin.Forms/issues/1495

@@ -183,7 +185,7 @@ private async void OnPanUpdated(object sender, PanUpdatedEventArgs e)
private double _lastX;
private const double DeltaX = 100;

private void HandleTouchStart()
public void HandleTouchStart()
{
if (_itemIndex >= ItemsSource.Count)
return;
@@ -198,7 +200,7 @@ private void HandleTouchStart()
StartedDragging?.Invoke(this, new DraggingEventArgs(ItemsSource[_itemIndex], 0));
}

private void HandleTouchRunning(float horizontalTraslation)
public void HandleTouchRunning(float horizontalTraslation)
{
if (_itemIndex >= ItemsSource.Count)
return;
@@ -231,8 +233,11 @@ private void HandleTouchRunning(float horizontalTraslation)
backCard.Opacity = Math.Min(_defaultSubcardOpacity + Math.Abs((_cardDistance / CardMoveDistance) * _defaultSubcardOpacity), 1);
}

private async Task HandleTouchCompleted()
{
public async Task HandleTouchCompleted()
{
if (_itemIndex >= ItemsSource.Count - 1)
NoMoreCards?.Invoke(this, new EventArgs());

if (_itemIndex >= ItemsSource.Count || !_isDragging)
return;