public bool OnDrag(AViews.View v, DragEvent e) { switch (e.Action) { case DragAction.Started: break; case DragAction.Entered: System.Diagnostics.Debug.WriteLine($"DragAction.Entered from {v.GetType()}"); if (!(v is AWidget.ListView)) { var dragItem = (DragItem)e.LocalState; var targetPosition = InsertOntoView(v, dragItem); dragItem.Index = targetPosition; // Keep a list of items that has translation so we can reset // them once the drag'n'drop is finished. _translatedItems.Add(v); _listView.Invalidate(); } break; case DragAction.Location: //_currentPosition = (int)e.GetY(); //System.Diagnostics.Debug.WriteLine($"DragAction.Location from {v.GetType()} => {_currentPosition}"); break; case DragAction.Exited: System.Diagnostics.Debug.WriteLine($"DragAction.Entered from {v.GetType()}"); if (!(v is AWidget.ListView)) { var positionEntered = GetListPositionForView(v); var item1 = _listAdapter.GetItem(positionEntered); System.Diagnostics.Debug.WriteLine($"DragAction.Exited index {positionEntered}"); } break; case DragAction.Drop: System.Diagnostics.Debug.WriteLine($"DragAction.Drop from {v.GetType()}"); //} break; case DragAction.Ended: if (!(v is AWidget.ListView)) { return(false); } System.Diagnostics.Debug.WriteLine($"DragAction.Ended from {v.GetType()}"); var mobileItem = (DragItem)e.LocalState; mobileItem.View.Visibility = ViewStates.Visible; foreach (var view in _translatedItems) { view.TranslationY = 0; } _translatedItems.Clear(); if (_element.ItemsSource is IOrderable orderable) { orderable.ChangeOrdinal(mobileItem.OriginalIndex, mobileItem.Index); } break; } return(true); }
public bool OnDrag(AViews.View view, AViews.DragEvent e) { switch (e.Action) { case AViews.DragAction.Started: break; case AViews.DragAction.Entered: System.Diagnostics.Debug.WriteLine($"DragAction.Entered from {view.GetType()}"); if (!(view is AWidget.ListView)) { var dragItem = (DragItem)e.LocalState; var targetPosition = InsertOntoView(view, dragItem); dragItem.Index = targetPosition; // Keep a list of items that has translation so we can reset // them once the drag'n'drop is finished. translatedItems.Add(view); listView.Invalidate(); } break; case AViews.DragAction.Location: break; case AViews.DragAction.Exited: System.Diagnostics.Debug.WriteLine($"DragAction.Entered from {view.GetType()}"); if (!(view is AWidget.ListView)) { var positionEntered = GetListPositionForView(view); System.Diagnostics.Debug.WriteLine($"DragAction.Exited index {positionEntered}"); } break; case AViews.DragAction.Drop: System.Diagnostics.Debug.WriteLine($"DragAction.Drop from {view.GetType()}"); break; case AViews.DragAction.Ended: System.Diagnostics.Debug.WriteLine($"DragAction.Ended from {view.GetType()}"); if (!(view is AWidget.ListView)) { return(false); } var mobileItem = (DragItem)e.LocalState; mobileItem.View.Visibility = AViews.ViewStates.Visible; foreach (var v in translatedItems) { v.TranslationY = 0; } translatedItems.Clear(); if (element.ItemsSource is IOrderableCollection orderable) { orderable.ChangeOrder(mobileItem.OriginalIndex, mobileItem.Index); } break; } return(true); }