Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ios11-beta1] Initial UIKit Drag and Drop support #2190

Merged
merged 11 commits into from Jul 10, 2017
252 changes: 251 additions & 1 deletion src/UIKit/UIEnums.cs
Expand Up @@ -183,6 +183,8 @@ public enum UIControlContentHorizontalAlignment : nint {
Left = 1,
Right = 2,
Fill = 3,
Leading = 4,
Trailing = 5
}

// NSUInteger -> UIControl.h
Expand Down Expand Up @@ -297,7 +299,8 @@ public enum UIButtonType : nint {
InfoLight,
InfoDark,
ContactAdd,
System = RoundedRect
Plain,
System = RoundedRect,
}

// NSInteger -> UIStringDrawing.h
Expand Down Expand Up @@ -880,6 +883,7 @@ public enum UIModalPresentationStyle : nint {
OverCurrentContext,
[NoTV]
Popover,
BlurOverFullScreen,
None = -1
}

Expand Down Expand Up @@ -1248,6 +1252,10 @@ public enum NSLayoutFormatOptions : nuint_compat_int {
DirectionLeadingToTrailing = 0 << 16, // default
DirectionLeftToRight = 1 << 16,
DirectionRightToLeft = 2 << 16,

SpacingEdgeToEdge = 0 << 19,
SpacingBaselineToBaseline = 1 << 19,
SpacingMask = 1 << 19,

DirectionMask = 0x3 << 16,
}
Expand Down Expand Up @@ -1988,4 +1996,246 @@ public enum UIScrollViewIndexDisplayMode : nint {
Automatic,
AlwaysHidden
}

[TV (11,0), iOS (11,0)]
[Native]
public enum UIScrollViewContentInsetAdjustmentBehavior : nint
{
Automatic,
ScrollableAxes,
Never,
Always
}

[iOS (11,0)]
[Native]
public enum UIAccessibilityContainerType : nint
{
None = 0,
DataTable,
List,
Landmark
}

[iOS (11,0)]
[Native]
public enum UITextSmartQuotesType : nint
{
Default,
No,
Yes
}

[iOS (11,0)]
[Native]
public enum UITextSmartDashesType : nint
{
Default,
No,
Yes
}

[iOS (11,0)]
[Native]
public enum UITextSmartInsertDeleteType : nint
{
Default,
No,
Yes
}

[iOS (11,0)]
[Native]
public enum UIAccessibilityCustomSystemRotorType : nint
{
None = 0,
Link,
VisitedLink,
Heading,
HeadingLevel1,
HeadingLevel2,
HeadingLevel3,
HeadingLevel4,
HeadingLevel5,
HeadingLevel6,
BoldText,
ItalicText,
UnderlineText,
MisspelledWord,
Image,
TextField,
Table,
List,
Landmark
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UIDropOperation : nuint
{
Cancel = 0,
Forbidden = 1,
Copy = 2,
Move = 3
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
[Flags]
public enum UITextDragOptions : nint
{
None = 0,
StripTextColorFromPreviews = (1 << 0)
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UITextDropAction : nuint
{
Insert = 0,
ReplaceSelection,
ReplaceAll
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UITextDropProgressMode : nuint
{
System = 0,
Custom
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UITextDropEditability : nuint
{
No = 0,
Temporary,
Yes
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UICollectionViewReorderingCadence : nint
{
Immediate,
Fast,
Slow
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UICollectionViewDropIntent : nint
{
Unspecified,
InsertAtDestinationIndexPath,
InsertIntoDestinationIndexPath
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UICollectionViewCellDragState : nint
{
None,
Lifting,
Dragging
}

[NoTV, iOS (11,0)]
[Native]
public enum UIImagePickerControllerImageUrlExportPreset : nint
{
Compatible = 0,
Current
}

[NoTV, iOS (11,0)]
[Native]
public enum UIContextualActionStyle : nint
{
Normal,
Destructive
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UITableViewCellDragState : nint
{
None,
Lifting,
Dragging
}

[TV (11,0), iOS (11,0)]
[Native]
public enum UITableViewSeparatorInsetReference : nint
{
CellEdges,
AutomaticInsets
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UITableViewDropIntent : nint
{
Unspecified,
InsertAtDestinationIndexPath,
InsertIntoDestinationIndexPath,
Automatic
}

[TV (11,0), iOS (11,0)]
[Native]
public enum UISplitViewControllerPrimaryEdge : nint
{
Leading,
Trailing
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UIDropSessionProgressIndicatorStyle : nuint
{
None,
Default
}

[NoWatch, NoTV, iOS (11,0)]
[Native]
public enum UISpringLoadedInteractionEffectState : nint
{
Inactive,
Possible,
Activating,
Activated
}

[NoTV, iOS (11,0)]
[Native]
public enum UIDocumentBrowserImportMode : nuint
{
None,
Copy,
Move
}

[NoTV, iOS (11,0)]
[Native]
public enum UIDocumentBrowserUserInterfaceStyle : nuint
{
White = 0,
Light,
Dark
}

[NoTV, iOS (11,0)]
[Native]
[Flags]
public enum UIDocumentBrowserActionAvailability : nint
{
Menu = 1,
NavigationBar = 1 << 1
}


}
16 changes: 16 additions & 0 deletions src/foundation.cs
Expand Up @@ -8780,6 +8780,22 @@ partial interface NSItemProvider : NSCopying {
#endif
}

interface INSItemProviderReading {}

[Watch (4,0), TV (11,0), Mac (10,13), iOS (11,0)]
[Protocol, Model]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this protocol is supposed to be implemented by existing types that can be dragged/dropped, in which case [Model] doesn't make sense, it can be only [Protocol].

[BaseType (typeof(NSObject))]
interface NSItemProviderReading
{
[Static, Abstract]
[Export ("readableTypeIdentifiersForItemProvider", ArgumentSemantic.Copy)]
string[] ReadableTypeIdentifiersForItemProvider { get; }

[Abstract]
[Export ("initWithItemProviderData:typeIdentifier:error:")]
NSObject CreateFrom (NSData providerData, string typeIdentifier, [NullAllowed] out NSError outError);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an Objective-C constructor, so I don't think binding it as an instance method will work.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, what should we do in this case?

On the one hand, we should flag the classes that implement this, and manually add the constructor there (NSAttributedString, UIColor, UIImage). The other part is more complicated, given a class that implements this interface, probably our best bet is to have a factory method as an extension class that does the work:

static class NSItemProviderExtensions {
     public INSItemProviderReading CreateFromData (INSItemProviderReading self, NSData providerData, string typeIdentifier, etc) 
     {
         // something here.
     }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

#if XAMCORE_2_0
[Static]
#endif
Expand Down