Esempio n. 1
0
        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");
        }
Esempio n. 2
0
        public BulletinPopupPage()
        {
            BackgroundColor = Colors.BulletinPopupBackground;

            _swipeView = new SwipeCardView()
            {
                Padding        = new Thickness(30, 20, 30, 45),
                ItemTemplate   = new DataTemplate(ContentView),
                IsVisible      = true,
                BindingContext = BulletinService.Instance,
            };
            _swipeView.SetBinding(SwipeCardView.ItemsSourceProperty, nameof(BulletinService.Bulletins));

            _swipeView.Swiped += (sender, args) =>
            {
                var bulletin = (Bulletin)args.Item;

                if (BulletinService.Instance.Bulletins.IndexOf(bulletin) >= BulletinService.Instance.Bulletins.Count - 1)
                {
                    BulletinService.Instance.ClearBulletins();
                }
            };

            Content = _swipeView;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 private void OnLikeClicked(object sender, EventArgs e)
 {
     SwipeCardView.InvokeSwipe(SwipeCardDirection.Right);
 }
 private void OnNopeClicked(object sender, EventArgs e)
 {
     SwipeCardView.InvokeSwipe(SwipeCardDirection.Left);
 }
Esempio n. 6
0
 private async void AcceptCard_Clicked(object sender, EventArgs e)
 {
     await SwipeCardView.InvokeSwipe(SwipeCardDirection.Right, 20, 10, new TimeSpan(1), new TimeSpan(200));
 }