[uikit] Fix method names in UIDropSession & UIDragDropSession (#2314)
- Fixes bug #58079: UIDropSession loadObjects: is called Completion (https://bugzilla.xamarin.com/show_bug.cgi?id=58079) - Fixes bug #58081: IUIDropSession.Completion first arg should be a Class (https://bugzilla.xamarin.com/show_bug.cgi?id=58081) - Similar to `CanLoadObjects`, use `itemProviderReadingClass` as the param name in `LoadObjects`. - Provide `Type` overloads so customers don't have to do `new ObjCRuntime.Class (typeof (UIImage))` but can just do `typeof (UIImage)` instead.
This commit is contained in:
Родитель
cedb13a1ef
Коммит
feb5b13d5f
|
@ -0,0 +1,32 @@
|
|||
//
|
||||
// UIDragDropSessionExtensions.cs
|
||||
//
|
||||
// Authors:
|
||||
// Vincent Dondain <vidondai@microsoft.com>
|
||||
//
|
||||
// Copyright 2017 Microsoft
|
||||
//
|
||||
|
||||
#if !TVOS && !WATCH
|
||||
|
||||
using System;
|
||||
using XamCore.ObjCRuntime;
|
||||
using XamCore.Foundation;
|
||||
|
||||
namespace XamCore.UIKit {
|
||||
|
||||
public static class UIDragDropSessionExtensions {
|
||||
|
||||
public static NSProgress LoadObjects (this IUIDropSession session, Type type, Action<INSItemProviderReading []> completion)
|
||||
{
|
||||
return session.LoadObjects (new Class (type), completion);
|
||||
}
|
||||
|
||||
public static bool CanLoadObjects (this IUIDragDropSession session, Type type)
|
||||
{
|
||||
return session.CanLoadObjects (new Class (type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1320,6 +1320,7 @@ UIKIT_SOURCES = \
|
|||
UIKit/UIDocumentInteractionController.cs \
|
||||
UIKit/UIDocumentMenuViewController.cs \
|
||||
UIKit/UIDocumentPickerViewController.cs \
|
||||
UIKit/UIDragDropSessionExtensions.cs \
|
||||
UIKit/UIDynamicAnimator.cs \
|
||||
UIKit/UIEnumsExtensions.cs \
|
||||
UIKit/UIEvent.cs \
|
||||
|
|
|
@ -16204,7 +16204,7 @@ namespace XamCore.UIKit {
|
|||
|
||||
[Abstract]
|
||||
[Export ("canLoadObjectsOfClass:")]
|
||||
bool CanLoadObjectsOfClass (Class itemProviderReadingClass);
|
||||
bool CanLoadObjects (Class itemProviderReadingClass);
|
||||
}
|
||||
|
||||
[NoWatch, NoTV, iOS (11,0)]
|
||||
|
@ -16374,7 +16374,7 @@ namespace XamCore.UIKit {
|
|||
|
||||
[Abstract]
|
||||
[Export ("loadObjectsOfClass:completion:")]
|
||||
NSProgress Completion (INSItemProviderReading aClass, Action<INSItemProviderReading []> completion);
|
||||
NSProgress LoadObjects (Class itemProviderReadingClass, Action<INSItemProviderReading []> completion);
|
||||
}
|
||||
|
||||
[NoWatch, NoTV, iOS (11,0)]
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
//
|
||||
// Unit tests for UIDragDropSessionExtensionsTest
|
||||
//
|
||||
// Authors:
|
||||
// Vincent Dondain <vidondai@microsoft.com>
|
||||
//
|
||||
//
|
||||
// Copyright 2017 Microsoft.
|
||||
//
|
||||
|
||||
#if !__TVOS__ && !__WATCHOS__
|
||||
|
||||
using System;
|
||||
#if XAMCORE_2_0
|
||||
using CoreGraphics;
|
||||
using Foundation;
|
||||
using ObjCRuntime;
|
||||
using UIKit;
|
||||
#else
|
||||
using MonoTouch.CoreGraphics;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.ObjCRuntime;
|
||||
using MonoTouch.UIKit;
|
||||
#endif
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace MonoTouchFixtures.UIKit {
|
||||
[TestFixture]
|
||||
[Preserve (AllMembers = true)]
|
||||
public class UIDragDropSessionExtensionsTest {
|
||||
|
||||
[Test]
|
||||
public void LoadObjectsTest ()
|
||||
{
|
||||
if (!TestRuntime.CheckXcodeVersion (9,0))
|
||||
Assert.Ignore ("Ignoring tests: Requires iOS11+");
|
||||
|
||||
var test = new DropSession ();
|
||||
test.CanLoadObjects (typeof (UIImage));
|
||||
test.LoadObjects (typeof (UIImage), null);
|
||||
}
|
||||
}
|
||||
|
||||
class DropSession : NSObject, IUIDropSession {
|
||||
public IUIDragSession LocalDragSession => throw new NotImplementedException ();
|
||||
|
||||
public UIDropSessionProgressIndicatorStyle ProgressIndicatorStyle { get => throw new NotImplementedException (); set => throw new NotImplementedException (); }
|
||||
|
||||
public UIDragItem [] Items => throw new NotImplementedException ();
|
||||
|
||||
public bool AllowsMoveOperation => throw new NotImplementedException ();
|
||||
|
||||
public bool RestrictedToDraggingApplication => throw new NotImplementedException ();
|
||||
|
||||
public bool CanLoadObjects (Class itemProviderReadingClass)
|
||||
{
|
||||
Assert.That (itemProviderReadingClass.Handle, Is.EqualTo (new Class (typeof (UIImage)).Handle), "UIDragDropSessionExtensionsTest did not convert the type properly for 'CanLoadObjects'.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool HasConformingItems (string [] typeIdentifiers)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
|
||||
public NSProgress LoadObjects (Class itemProviderReadingClass, Action<INSItemProviderReading []> completion)
|
||||
{
|
||||
Assert.That (itemProviderReadingClass.Handle, Is.EqualTo (new Class (typeof (UIImage)).Handle), "UIDragDropSessionExtensionsTest did not convert the type properly for 'LoadObjects'.");
|
||||
return new NSProgress ();
|
||||
}
|
||||
|
||||
public CGPoint LocationInView (UIView view)
|
||||
{
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // !__TVOS__ && !__WATCHOS__
|
|
@ -656,6 +656,7 @@
|
|||
<Compile Include="HomeKit\HMMutableSignificantTimeEventTest.cs" />
|
||||
<Compile Include="HomeKit\HMPresenceEventTest.cs" />
|
||||
<Compile Include="HomeKit\HMSignificantTimeEventTest.cs" />
|
||||
<Compile Include="UIKit\UIDragDropSessionExtensionsTest.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
|
|
Загрузка…
Ссылка в новой задаче