private void OnDragging(object sender, DraggingCardEventArgs e) { var view = (Xamarin.Forms.View)sender; var directionLabel = view.FindByName <Label>("DirectionLabel"); directionLabel.Text = e.Direction.ToString(); var positionLabel = view.FindByName <Label>("PositionLabel"); positionLabel.Text = e.Position.ToString(); switch (e.Position) { case DraggingCardPosition.Start: break; case DraggingCardPosition.UnderThreshold: view.BackgroundColor = Color.DarkTurquoise; break; case DraggingCardPosition.OverThreshold: switch (e.Direction) { case SwipeCardDirection.Left: view.BackgroundColor = Color.FromHex("#FF6A4F"); break; case SwipeCardDirection.Right: view.BackgroundColor = Color.FromHex("#63DD99"); break; case SwipeCardDirection.Up: view.BackgroundColor = Color.FromHex("#2196F3"); break; case SwipeCardDirection.Down: view.BackgroundColor = Color.MediumPurple; break; } break; case DraggingCardPosition.FinishedUnderThreshold: view.BackgroundColor = Color.Beige; break; case DraggingCardPosition.FinishedOverThreshold: view.BackgroundColor = Color.Beige; directionLabel.Text = string.Empty; positionLabel.Text = string.Empty; break; default: throw new ArgumentOutOfRangeException(); } }
private void ExecuteCardDraggingCommand(DraggingCardEventArgs args) { try { if (args.Direction == SwipeCardDirection.Right) { _userService.SaveFavouriteUser(args.Item as UserDetails); } } catch (Exception e) { AlertService.ShowError(e.Message); Logger.LogError(e); } }
private void OnDragging(object sender, DraggingCardEventArgs args) { var view = (View)sender; var nopeFrame = view.FindByName <Frame>("NopeFrame"); var likeFrame = view.FindByName <Frame>("LikeFrame"); switch (args.Position) { case DraggingCardPosition.Start: case DraggingCardPosition.FinishedUnderThreshold: case DraggingCardPosition.FinishedOverThreshold: nopeFrame.Opacity = 0; likeFrame.Opacity = 0; nopeButton.Scale = 1; likeButton.Scale = 1; break; case DraggingCardPosition.UnderThreshold: case DraggingCardPosition.OverThreshold: if (args.Direction == SwipeCardDirection.Left) { nopeFrame.Opacity = 1; nopeButton.Scale = 0.75; likeFrame.Opacity = 0; likeButton.Scale = 1; } else if (args.Direction == SwipeCardDirection.Right) { likeFrame.Opacity = 1; likeButton.Scale = 0.75; nopeFrame.Opacity = 0; nopeButton.Scale = 1; } break; default: throw new ArgumentOutOfRangeException(); } }
private void OnDragging(object sender, DraggingCardEventArgs e) { var view = (Xamarin.Forms.View)sender; switch (e.Position) { case DraggingCardPosition.Start: break; case DraggingCardPosition.UnderThreshold: view.BackgroundColor = Color.AntiqueWhite; break; case DraggingCardPosition.OverThreshold: switch (e.Direction) { case SwipeCardDirection.Left: view.BackgroundColor = Color.FromHex("#FF6A4F"); break; case SwipeCardDirection.Right: view.BackgroundColor = Color.FromHex("#63DD99"); break; } break; case DraggingCardPosition.FinishedUnderThreshold: view.BackgroundColor = Color.White; break; case DraggingCardPosition.FinishedOverThreshold: view.BackgroundColor = Color.White; break; default: throw new ArgumentOutOfRangeException(); } }
private void OnDragging(object sender, DraggingCardEventArgs e) { var view = (Xamarin.Forms.View)sender; var nopeFrame = view.FindByName <Frame>("NopeFrame"); //var timerValue = view.FindByName<Label>("Timer"); var endDateValue = view.FindByName <Label>("EndDate"); var likeFrame = view.FindByName <Frame>("LikeFrame"); var superLikeFrame = view.FindByName <Frame>("SuperLikeFrame"); var threshold = (this.BindingContext as TinderPageViewModel).Threshold; var draggedXPercent = e.DistanceDraggedX / threshold; var draggedYPercent = e.DistanceDraggedY / threshold; switch (e.Position) { case DraggingCardPosition.Start: nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 0; nopeButton.Scale = 1; likeButton.Scale = 1; superLikeButton.Scale = 1; Timer(endDateValue.Text, sender); break; case DraggingCardPosition.UnderThreshold: if (e.Direction == SwipeCardDirection.Left) { nopeFrame.Opacity = (-1) * draggedXPercent; nopeButton.Scale = 1 + draggedXPercent / 2; superLikeFrame.Opacity = 0; superLikeButton.Scale = 1; } else if (e.Direction == SwipeCardDirection.Right) { likeFrame.Opacity = draggedXPercent; likeButton.Scale = 1 - draggedXPercent / 2; superLikeFrame.Opacity = 0; superLikeButton.Scale = 1; } else if (e.Direction == SwipeCardDirection.Up) { nopeFrame.Opacity = 0; likeFrame.Opacity = 0; nopeButton.Scale = 1; likeButton.Scale = 1; superLikeFrame.Opacity = (-1) * draggedYPercent; superLikeButton.Scale = 1 + draggedYPercent / 2; } break; case DraggingCardPosition.OverThreshold: if (e.Direction == SwipeCardDirection.Left) { nopeFrame.Opacity = 1; superLikeFrame.Opacity = 0; } else if (e.Direction == SwipeCardDirection.Right) { likeFrame.Opacity = 1; superLikeFrame.Opacity = 0; } else if (e.Direction == SwipeCardDirection.Up) { nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 1; } break; case DraggingCardPosition.FinishedUnderThreshold: nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 0; nopeButton.Scale = 1; likeButton.Scale = 1; superLikeButton.Scale = 1; break; case DraggingCardPosition.FinishedOverThreshold: nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 0; nopeButton.Scale = 1; likeButton.Scale = 1; superLikeButton.Scale = 1; break; default: throw new ArgumentOutOfRangeException(); } }
private void OnDragging(object sender, DraggingCardEventArgs e) { var view = (View)sender; var nopeFrame = view.FindByName <Frame>("NopeFrame"); var likeFrame = view.FindByName <Frame>("LikeFrame"); var superLikeFrame = view.FindByName <Frame>("SuperLikeFrame"); var threshold = (uint)(FormsApp.ScreenWidth / 3); var draggedXPercent = e.DistanceDraggedX / threshold; var draggedYPercent = e.DistanceDraggedY / threshold; switch (e.Position) { case DraggingCardPosition.Start: nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 0; //nopeButton.Scale = 1; //likeButton.Scale = 1; //superLikeButton.Scale = 1; break; case DraggingCardPosition.UnderThreshold: if (e.Direction == SwipeCardDirection.Left) { nopeFrame.Opacity = (-1) * draggedXPercent; //nopeButton.Scale = 1 + draggedXPercent / 2; superLikeFrame.Opacity = 0; //superLikeButton.Scale = 1; } else if (e.Direction == SwipeCardDirection.Right) { likeFrame.Opacity = draggedXPercent; //likeButton.Scale = 1 - draggedXPercent / 2; superLikeFrame.Opacity = 0; //superLikeButton.Scale = 1; } else if (e.Direction == SwipeCardDirection.Up) { nopeFrame.Opacity = 0; likeFrame.Opacity = 0; //nopeButton.Scale = 1; //likeButton.Scale = 1; superLikeFrame.Opacity = (-1) * draggedYPercent; //superLikeButton.Scale = 1 + draggedYPercent / 2; } break; case DraggingCardPosition.OverThreshold: if (e.Direction == SwipeCardDirection.Left) { nopeFrame.Opacity = 1; superLikeFrame.Opacity = 0; } else if (e.Direction == SwipeCardDirection.Right) { likeFrame.Opacity = 1; superLikeFrame.Opacity = 0; } else if (e.Direction == SwipeCardDirection.Up) { nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 1; } break; case DraggingCardPosition.FinishedUnderThreshold: nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 0; //nopeButton.Scale = 1; //likeButton.Scale = 1; //superLikeButton.Scale = 1; break; case DraggingCardPosition.FinishedOverThreshold: nopeFrame.Opacity = 0; likeFrame.Opacity = 0; superLikeFrame.Opacity = 0; //nopeButton.Scale = 1; //likeButton.Scale = 1; //superLikeButton.Scale = 1; break; default: throw new ArgumentOutOfRangeException(); } }
private void OnDragging(object sender, DraggingCardEventArgs e) { }
private void OnDragging(object sender, DraggingCardEventArgs e) { var view = (View)sender; var nopeFrame = view.FindByName <Frame>("NopeFrame"); var likeFrame = view.FindByName <Frame>("AddFrame"); var threshold = (BindingContext as SetupTripViewModel).Threshold; var draggedXPercent = e.DistanceDraggedX / threshold; var lightColor = (Color)Application.Current.Resources["LightSecondaryPageBackgroundColor"]; var darkColor = (Color)Application.Current.Resources["DarkSecondaryPageBackgroundColor"]; switch (e.Position) { case DraggingCardPosition.Start: view.SetAppThemeColor(BackgroundColorProperty, lightColor, darkColor); nopeFrame.Opacity = 0; likeFrame.Opacity = 0; break; case DraggingCardPosition.UnderThreshold: view.SetAppThemeColor(BackgroundColorProperty, lightColor, darkColor); if (e.Direction == SwipeCardDirection.Left) { nopeFrame.Opacity = -1 * draggedXPercent; } else if (e.Direction == SwipeCardDirection.Right) { likeFrame.Opacity = draggedXPercent; } else if (e.Direction == SwipeCardDirection.Up) { nopeFrame.Opacity = 0; likeFrame.Opacity = 0; } break; case DraggingCardPosition.OverThreshold: switch (e.Direction) { case SwipeCardDirection.Left: view.BackgroundColor = Color.FromHex("#FF6A4F"); nopeFrame.Opacity = 1; break; case SwipeCardDirection.Right: view.BackgroundColor = Color.FromHex("#63DD99"); likeFrame.Opacity = 1; break; case SwipeCardDirection.Up: view.SetAppThemeColor(BackgroundColorProperty, lightColor, darkColor); nopeFrame.Opacity = 0; likeFrame.Opacity = 0; break; case SwipeCardDirection.Down: view.SetAppThemeColor(BackgroundColorProperty, lightColor, darkColor); nopeFrame.Opacity = 0; likeFrame.Opacity = 0; break; } break; case DraggingCardPosition.FinishedUnderThreshold: view.SetAppThemeColor(BackgroundColorProperty, lightColor, darkColor); nopeFrame.Opacity = 0; likeFrame.Opacity = 0; break; case DraggingCardPosition.FinishedOverThreshold: view.SetAppThemeColor(BackgroundColorProperty, lightColor, darkColor); nopeFrame.Opacity = 0; likeFrame.Opacity = 0; break; default: throw new ArgumentOutOfRangeException(); } }