Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Drag and drop #11537

Merged
merged 15 commits into from
Jul 30, 2020
Merged

Drag and drop #11537

merged 15 commits into from
Jul 30, 2020

Conversation

PureWeen
Copy link
Contributor

@PureWeen PureWeen commented Jul 24, 2020

Description of Change

Preview release of Drag and Drop

FYI only works on iOS11+ because that's when the drag and drop apis were added

Issues Resolved

API Changes

DropGestureRecognizer

public class DropGestureRecognizer
{
     public bool AllowDrop;
     public DragEventArgs DragOver;
     public ICommand DragOverCommand;
     public object DragOverCommandParameter;

     public DropEventArgs Drop;
     public ICommand DropCommand;
     public object DropCommandParameter;

}

DragGestureRecognizer

public class DragGestureRecognizer
{
     public bool CanDrag;
     public DropCompletedEventArgs DropCompleted;
     public ICommand DropCompletedCommand;
     public object DropCompletedCommandParameter;

     public DragItemsStartingEventArgs DragStarting;
     public ICommand DragStartingCommand;
     public object DragStartingCommandParameter;
}

DragItemsStartingEventArgs

public class DragItemsStartingEventArgs
{
     bool Cancel;
     DataPackage Data;
}

DataPackageOperation

[Flags]
public enum DataPackageOperation
{
     None, Copy
}

DragEventArgs

public class DragEventArgs
{
     DataPackage Data;
     DataPackageOperation AcceptedOperation
}

DropCompletedEventArgs

public class DropCompletedEventArgs
{
}

DropEventArgs

public class DropEventArgs
{
     DataPackageView Data;
     bool Handled;
}

DataPackage

This is used to setup the data for transfer

public class DataPackage
{
     public ImageSource Image {Get;set;}
     public string Text;
     public DataPackageView View
}

DataPackageView

This is a read-only copy of the DataPackage object.
This is all the user gets on the drop event to retrieve the data. They can't modify the package

public class DataPackageView
{
     public ImageSource GetImageAsync();
     public string GetTextAsync();
}

Platforms Affected

  • Core/XAML (all platforms)
  • iOS 11+
  • Android
  • UWP

Testing Procedure

  • Galleries Tests Provided

PR Checklist

  • Targets the correct branch
  • Tests are passing (or failures are unrelated)

@PureWeen PureWeen added the DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. label Jul 24, 2020
@rmarinho
Copy link
Member

Testing a comment

@PureWeen PureWeen added blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. and removed DO-NOT-MERGE-!!! 🛑 This is in progress and needs to be updated before it can be merged. labels Jul 24, 2020
@PureWeen PureWeen added this to the 4.8.0 milestone Jul 24, 2020
@samhouts samhouts added this to Ready for Review (PRs) in Sprint 174 Jul 27, 2020
@samhouts samhouts added a/DragAndDrop API-change Heads-up to reviewers that this PR may contain an API change a/gestures 🖖 proposal-accepted roadmap and removed proposal-open labels Jul 27, 2020
@samhouts
Copy link
Member

Should you have a null image source? No. Was it the first thing I tried? Yes.

        <Image x:Name="Image" Margin="10,292,10,0" HeightRequest="338" BackgroundColor="Aqua">
            <Image.GestureRecognizers>
                <DragGestureRecognizer CanDrag="True"></DragGestureRecognizer>
            </Image.GestureRecognizers>
        </Image>
	at Xamarin.Forms.Platform.Android.DragAndDropGestureHandler.ConvertToClipDataItem (Xamarin.Forms.ImageSource source, System.Collections.Generic.List`1[T] mimeTypes) [0x0008a] in D:\agent\1\s\Xamarin.Forms.Platform.Android\DragAndDropGestureHandler.cs:321
	at Xamarin.Forms.Platform.Android.DragAndDropGestureHandler+<>c__DisplayClass18_0.<OnLongPress>b__0 (Xamarin.Forms.DragGestureRecognizer rec) [0x000dd] in D:\agent\1\s\Xamarin.Forms.Platform.Android\DragAndDropGestureHandler.cs:245
	at Xamarin.Forms.Platform.Android.DragAndDropGestureHandler.SendEventArgs[TRecognizer] (System.Action`1[T] func, Xamarin.Forms.View view) [0x00066] in D:\agent\1\s\Xamarin.Forms.Platform.Android\DragAndDropGestureHandler.cs:113
	at Xamarin.Forms.Platform.Android.DragAndDropGestureHandler.OnLongPress (Android.Views.MotionEvent e) [0x00028] in D:\agent\1\s\Xamarin.Forms.Platform.Android\DragAndDropGestureHandler.cs:218
	at Xamarin.Forms.Platform.Android.InnerGestureListener.Android.Views.GestureDetector.IOnGestureListener.OnLongPress (Android.Views.MotionEvent e) [0x00009] in D:\agent\1\s\Xamarin.Forms.Platform.Android\InnerGestureListener.cs:120
	at Android.Views.GestureDetector+IOnGestureListenerInvoker.n_OnLongPress_Landroid_view_MotionEvent_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_e) [0x0000f] in <a522ecdee49144d0b8411a1cab7b9ada>:0
	at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.49(intptr,intptr,intptr) in :0```

@samhouts
Copy link
Member

HotPotato.zip

Works great on Android.
Doesn't seem to work at all on iOS.
UWP just crashes for me, but that's another story.

PureWeen and others added 5 commits July 28, 2020 16:32
@samhouts samhouts merged commit bc51d24 into 4.8.0 Jul 30, 2020
Sprint 174 automation moved this from Ready for Review (PRs) to Done Jul 30, 2020
@samhouts samhouts deleted the DragAndDrop branch July 30, 2020 00:32
@samhouts samhouts added this to Done in vCurrent (4.8.0) Jul 30, 2020
@BurkusCat
Copy link
Contributor

@PureWeen I really like this API. I've been using it a little bit on UWP and it seems very solid :) (I've posted one issue around the UWP cursor and a docs issue around how to use commands but other than that it is pretty great!)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a/DragAndDrop a/gestures 🖖 API-change Heads-up to reviewers that this PR may contain an API change blocker Issue blocks next stable release. Prioritize fixing and reviewing this issue. ControlGallery m/high impact ⬛ p/Android p/iOS 🍎 p/UWP proposal-accepted roadmap t/enhancement ➕
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

None yet

4 participants