コード例 #1
0
        private async void OnSwipe(SwipedCardEventArgs obj)
        {
            switch (obj.Direction)
            {
            case SwipeCardDirection.Right:
                await AcceptCandidateAsync((Candidate)obj.Item);

                break;

            case SwipeCardDirection.Left:
                await RejectCandidateAsync((Candidate)obj.Item);

                break;
            }
        }
コード例 #2
0
        private async void SwipeView1_Swiped(object sender, SwipedCardEventArgs e)
        {
            if (e.Direction.ToString() == "Right")
            {
                var animal = await App.Database.GetAnimalAsync();

                var        a  = animal.ElementAt(iterator);
                UserAnimal ua = new UserAnimal
                {
                    UserId   = Database.LoggedUser.UserId,
                    AnimalId = a.AnimalId
                };
                await App.Database.SaveUserAnimalAsync(ua);


                // iterator++;
            }

            iterator++;
        }
コード例 #3
0
        private async void OnSwiping(object sender, SwipedCardEventArgs e)
        {
            if (finished)
            {
                if (!nopeVisible)
                {
                    if (((Number)e.Item).Id == LastNumber.Id)
                    {
                        bool answer = await DisplayAlert("Next game?", "Play another game?", "Yes", "No");

                        if (answer)
                        {
                            await  finish_fun(0);
                        }
                        else
                        {
                            await finish_fun(1);
                        }
                    }
                }
                return;
            }
            uint timeout = 50;

            if ((e.Direction == SwipeCardDirection.Left && !((Number)e.Item).Prime)
                ||
                (e.Direction == SwipeCardDirection.Right && ((Number)e.Item).Prime))
            {
                ((Number)e.Item).Correct = true;


                ViewModel.ViewExtensions.CancelAnimation(MyStack);
                MyStack.ColorTo(Color.Green, Color.White, c => MyStack.BackgroundColor = c, 500);
                var v = new AnimationView();
                v.Animation     = "4964-check-mark-success-animation.json";
                v.IsPlaying     = true;
                v.WidthRequest  = 25;
                v.HeightRequest = 25;


                FlexL.Children.Add(v);

                timer = Math.Min(sec15, timer - stopwatch.Elapsed.TotalMilliseconds + 1000);
                var segment = (float)Math.Min(1, 1 - (timer) / sec15);
                MyAnimationView.PlayProgressSegment((float)segment, 1);
                stopwatch.Restart();
            }
            else if ((e.Direction == SwipeCardDirection.Left && ((Number)e.Item).Prime)
                     ||
                     (e.Direction == SwipeCardDirection.Right && !((Number)e.Item).Prime))
            {
                ((Number)e.Item).Correct = false;
                ViewModel.ViewExtensions.CancelAnimation(MyStack);
                MyStack.ColorTo(Color.Red, Color.White, c => MyStack.BackgroundColor = c, 500);
                await MyStack.TranslateTo(-15, 0, timeout);

                await MyStack.TranslateTo(15, 0, timeout);

                await MyStack.TranslateTo(-9, 0, timeout);

                await MyStack.TranslateTo(9, 0, timeout);

                await MyStack.TranslateTo(-5, 0, timeout);

                await MyStack.TranslateTo(5, 0, timeout);

                await MyStack.TranslateTo(-2, 0, timeout);

                await MyStack.TranslateTo(2, 0, timeout);

                MyStack.TranslationX = 0;

                var v = new AnimationView();
                v.Animation     = "4970-unapproved-cross.json";
                v.IsPlaying     = true;
                v.WidthRequest  = 25;
                v.HeightRequest = 25;

                timer = Math.Max(0, timer - stopwatch.Elapsed.TotalMilliseconds - 2000);
                var segment = (float)Math.Min(1, 1 - (timer) / sec15);
                MyAnimationView.PlayProgressSegment((float)segment, 1);
                stopwatch.Restart();


                FlexL.Children.Add(v);
            }
            else if (e.Direction == SwipeCardDirection.Up)
            {
                ViewModel.ViewExtensions.CancelAnimation(MyStack);
                MyStack.ColorTo(Color.Yellow, Color.White, c => MyStack.BackgroundColor = c, 500);

                var v = new AnimationView();
                v.Animation     = "4975-question-mark.json";
                v.IsPlaying     = true;
                v.WidthRequest  = 25;
                v.HeightRequest = 25;


                FlexL.Children.Add(v);
            }
        }