public async Task Swipe_ObservableCollection_UpdatesTopItem() { var swipeCardView = new SwipeCardView { ItemTemplate = new DataTemplate(() => { var stackLayout = new StackLayout(); var label = new Label(); label.SetBinding(Label.TextProperty, "."); stackLayout.Children.Add(label); return(stackLayout); }) }; swipeCardView.ItemsSource = new ObservableCollection <string>() { "Item1", "Item2" }; var swipeCardDirection = SwipeCardDirection.None; swipeCardView.Swiped += (sender, args) => { swipeCardDirection = args.Direction; }; var initialTopItem = swipeCardView.TopItem; await swipeCardView.InvokeSwipe(SwipeCardDirection.Right); var afterSwipeTopItem = swipeCardView.TopItem; Assert.AreEqual(swipeCardDirection, SwipeCardDirection.Right); Assert.AreEqual(swipeCardView.ItemsSource.Count, 2); Assert.AreNotEqual(initialTopItem, afterSwipeTopItem); Assert.AreEqual(initialTopItem, "Item1"); Assert.AreEqual(afterSwipeTopItem, "Item2"); }
public async Task Swipe_EmptyObservableCollection_ShouldNotInvoke() { var cardItems = new ObservableCollection <string>(); var swipeCardView = new SwipeCardView(); var swipeCardDirection = SwipeCardDirection.None; swipeCardView.ItemsSource = cardItems; swipeCardView.Swiped += (sender, args) => { swipeCardDirection = args.Direction; }; await swipeCardView.InvokeSwipe(SwipeCardDirection.Right); Assert.AreEqual(swipeCardDirection, SwipeCardDirection.None); Assert.AreEqual(swipeCardView.ItemsSource.Count, 0); }
private void OnLikeClicked(object sender, EventArgs e) { SwipeCardView.InvokeSwipe(SwipeCardDirection.Right); }
private void OnNopeClicked(object sender, EventArgs e) { SwipeCardView.InvokeSwipe(SwipeCardDirection.Left); }
private async void AcceptCard_Clicked(object sender, EventArgs e) { await SwipeCardView.InvokeSwipe(SwipeCardDirection.Right, 20, 10, new TimeSpan(1), new TimeSpan(200)); }
public async void InvokeSwipe() { await _swipeView.InvokeSwipe(SwipeCardDirection.Right); }