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

[UIKit] Update for Xcode10. #4253

Merged
merged 9 commits into from
Jun 18, 2018
22 changes: 20 additions & 2 deletions src/UIKit/UIEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1851,7 +1851,7 @@ public enum UITraitEnvironmentLayoutDirection : long
RightToLeft = UIUserInterfaceLayoutDirection.RightToLeft
}

[TV (10,0), NoWatch, NoiOS]
[TV (10,0), NoWatch, iOS (12,0)]
[Native]
public enum UIUserInterfaceStyle : long
{
Expand Down Expand Up @@ -2253,5 +2253,23 @@ public enum UIDocumentBrowserErrorCode : long
Generic = 1,
}


[iOS (12,0), TV (12,0), NoWatch]
[Native]
public enum UIGraphicsImageRendererFormatRange : long
{
Unspecified = -1,
Automatic = 0,
Extended,
Standard,
}

[iOS (12,0), NoTV, NoWatch]
[Native]
public enum UIPrintErrorCode : long
{
NotAvailableError = 1,
NoContentError,
UnknownImageFormatError,
JobFailedError
}
}
184 changes: 170 additions & 14 deletions src/uikit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5121,7 +5121,7 @@ interface UICollisionBehaviorDelegate {
// Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: do not call -[UIDocument init] - the designated initializer is -[UIDocument initWithFileURL:
[DisableDefaultCtor]
[ThreadSafe]
interface UIDocument : NSFilePresenter, NSProgressReporting {
interface UIDocument : NSFilePresenter, NSProgressReporting, UIUserActivityRestoring {
[Export ("localizedName", ArgumentSemantic.Copy)]
string LocalizedName { get; }

Expand Down Expand Up @@ -5235,7 +5235,7 @@ interface UIDocument : NSFilePresenter, NSProgressReporting {

[iOS (8,0)]
[Export ("restoreUserActivityState:")]
void RestoreUserActivityState (NSUserActivity userActivity);
new void RestoreUserActivityState (NSUserActivity userActivity);
Copy link
Member

Choose a reason for hiding this comment

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

Can you try locally to remove this method, so that we get the one from the protocol, and see what happens to the api diff? I think it won't be a breaking change, in which case it's better to remove it.


[iOS (8,0)]
[Field ("NSUserActivityDocumentURLKey")]
Expand Down Expand Up @@ -5703,8 +5703,8 @@ public enum UIFontTextStyle {
[Field ("UIFontTextStyleCallout")]
Callout,

[NoWatch, NoTV]
[iOS (11,0)]
[NoTV]
[iOS (11,0), Watch (5,0)]
[Field ("UIFontTextStyleLargeTitle")]
LargeTitle,
}
Expand Down Expand Up @@ -6133,6 +6133,10 @@ interface UIGraphicsImageRendererFormat
[Export ("opaque")]
bool Opaque { get; set; }

[Introduced (PlatformName.iOS, 10, 0, message: "Use the 'PreferredRange' property instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the Introduced here

[Deprecated (PlatformName.iOS, 12, 0, message: "Use the 'PreferredRange' property instead.")]
[Introduced (PlatformName.TvOS, 10, 0, message: "Use the 'PreferredRange' property instead.")]
Copy link
Contributor

Choose a reason for hiding this comment

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

same

[Deprecated (PlatformName.TvOS, 12, 0, message: "Use the 'PreferredRange' property instead.")]
[Export ("prefersExtendedRange")]
bool PrefersExtendedRange { get; set; }

Expand All @@ -6145,6 +6149,10 @@ interface UIGraphicsImageRendererFormat
[Static]
[Export ("formatForTraitCollection:")]
UIGraphicsImageRendererFormat GetFormat (UITraitCollection traitCollection);

[TV (12, 0), iOS (12, 0)]
[Export ("preferredRange", ArgumentSemantic.Assign)]
UIGraphicsImageRendererFormatRange PreferredRange { get; set; }
}

[iOS (10,0), TV (10,0)]
Expand Down Expand Up @@ -6321,6 +6329,10 @@ interface UITextInputTraits {
[iOS (11,0), TV (11,0)]
[Export ("smartInsertDeleteType", ArgumentSemantic.Assign)]
UITextSmartInsertDeleteType SmartInsertDeleteType { get; set; }

[iOS (12, 0)]
[NullAllowed, Export ("passwordRules", ArgumentSemantic.Copy)]
UITextInputPasswordRules PasswordRules { get; set; }
}

interface UIKeyboardEventArgs {
Expand Down Expand Up @@ -7987,6 +7999,10 @@ interface UILabel : UIContentSizeCategoryAdjusting {
[iOS (9,0)]
[Export ("allowsDefaultTighteningForTruncation")]
bool AllowsDefaultTighteningForTruncation { get; set; }

[TV (12, 0), NoWatch, NoiOS]
[Export ("enablesMarqueeWhenAncestorFocused")]
bool EnablesMarqueeWhenAncestorFocused { get; set; }
}

[BaseType (typeof (UIView))]
Expand Down Expand Up @@ -8449,7 +8465,7 @@ interface UIImagePickerControllerDelegate {
[BaseType (typeof (UIDocument))]
// *** Assertion failure in -[UIManagedDocument init], /SourceCache/UIKit_Sim/UIKit-1914.84/UIDocument.m:258
[DisableDefaultCtor]
interface UIManagedDocument {
interface UIManagedDocument : UIManagedDocument {
// note: ctor are not inherited, but this is how the documentation tells you to create an UIManagedDocument
// https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIManagedDocument_Class/Reference/Reference.html
[Export ("initWithFileURL:")]
Expand Down Expand Up @@ -9712,7 +9728,7 @@ partial interface UIReferenceLibraryViewController : NSCoding {
}

[BaseType (typeof (NSObject))]
interface UIResponder : UIAccessibilityAction, UIAccessibilityFocus
interface UIResponder : UIAccessibilityAction, UIAccessibilityFocus, UIUserActivityRestoring
#if !TVOS
, UIAccessibilityDragging
#endif // !TVOS
Expand Down Expand Up @@ -9864,7 +9880,7 @@ interface UIResponder : UIAccessibilityAction, UIAccessibilityFocus

[iOS (8,0)]
[Export ("restoreUserActivityState:")]
void RestoreUserActivityState (NSUserActivity activity);
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah the argument here was activity and not userActivity therefore removing it and using the interface is a breaking change...

Copy link
Member

Choose a reason for hiding this comment

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

mmm, we have allowed parameter name changes in the past, but since the UIUserActivityRestoring protocol just got added lets just rename userActivity to activity to avoid the breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, also, braking change is probably a too "strong" adjective. API will change, not break ;)

Doing it nevertheless

Copy link
Member

Choose a reason for hiding this comment

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

It is a breaking change because of named parameters for example if anyone is doing RestoreUserActivityState (activity: x); it would not compile anymore, but yeah not very likely

new void RestoreUserActivityState (NSUserActivity activity);

[iOS (9,0)]
[Export ("pressesBegan:withEvent:")]
Expand Down Expand Up @@ -10024,15 +10040,15 @@ UIScreenMode CurrentMode {
}

[BaseType (typeof (UIView), Delegates=new string [] { "WeakDelegate" }, Events=new Type [] {typeof(UIScrollViewDelegate)})]
interface UIScrollView {
interface UIScrollView : UIFocusItemScrollableContainer {
[Export ("initWithFrame:")]
IntPtr Constructor (CGRect frame);

[Export ("contentOffset")]
CGPoint ContentOffset { get; set; }
new CGPoint ContentOffset { get; set; }

[Export ("contentSize")]
CGSize ContentSize { get; set; }
new CGSize ContentSize { get; set; }
Copy link
Member

Choose a reason for hiding this comment

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

Can this be removed as well, so that we get it from UIFocusItemScrollableContainer instead, or will the api diff complain?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, in this case the protocol just exposes the get, but not the set.


[Export ("contentInset")]
UIEdgeInsets ContentInset { get; set; }
Expand Down Expand Up @@ -12886,7 +12902,7 @@ interface UIVideoEditorControllerDelegate {
}

[BaseType (typeof (UIResponder))]
interface UIView : UIAppearance, UIAppearanceContainer, UIAccessibility, UIDynamicItem, NSCoding, UIAccessibilityIdentification, UITraitEnvironment, UICoordinateSpace, UIFocusItem, CALayerDelegate {
interface UIView : UIAppearance, UIAppearanceContainer, UIAccessibility, UIDynamicItem, NSCoding, UIAccessibilityIdentification, UITraitEnvironment, UICoordinateSpace, UIFocusItem, CALayerDelegate, UIFocusItemContainer {
[DesignatedInitializer]
[Export ("initWithFrame:")]
IntPtr Constructor (CGRect frame);
Expand Down Expand Up @@ -14320,7 +14336,7 @@ partial interface UITraitCollection : NSCopying, NSSecureCoding {
[Export ("userInterfaceIdiom")]
UIUserInterfaceIdiom UserInterfaceIdiom { get; }

[TV (10, 0), NoWatch, NoiOS]
[TV (10, 0), NoWatch, iOS (12,0)]
[Export ("userInterfaceStyle")]
UIUserInterfaceStyle UserInterfaceStyle { get; }

Expand Down Expand Up @@ -14355,7 +14371,7 @@ partial interface UITraitCollection : NSCopying, NSSecureCoding {
[Static, Export ("traitCollectionWithForceTouchCapability:")]
UITraitCollection FromForceTouchCapability (UIForceTouchCapability capability);

[TV (10, 0), NoWatch, NoiOS]
[TV (10, 0), NoWatch, iOS (12,0)]
[Static]
[Export ("traitCollectionWithUserInterfaceStyle:")]
UITraitCollection FromUserInterfaceStyle (UIUserInterfaceStyle userInterfaceStyle);
Expand Down Expand Up @@ -14862,6 +14878,14 @@ interface UITextContentType {
[iOS (11,0), TV (11,0)]
[Field ("UITextContentTypePassword")]
NSString Password { get; }

[TV (12, 0), iOS (12, 0)]
[Field ("UITextContentTypeNewPassword")]
NSString NewPassword { get; }

[TV (12, 0), iOS (12, 0)]
[Field ("UITextContentTypeOneTimeCode")]
NSString OneTimeCode { get; }
}

[BaseType (typeof (UIViewController), Delegates=new string [] { "WeakDelegate" }, Events=new Type [] {typeof(UISplitViewControllerDelegate)})]
Expand Down Expand Up @@ -16679,6 +16703,27 @@ interface UIFocusGuide {
IUIFocusEnvironment[] PreferredFocusEnvironments { get; set; }
}

[TV (12,0), iOS (12,0)]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface UIFocusMovementHint : NSCopying
{
[Export ("movementDirection")]
CGVector MovementDirection { get; }

[Export ("perspectiveTransform")]
CATransform3D PerspectiveTransform { get; }

[Export ("rotation")]
CGVector Rotation { get; }

[Export ("translation")]
CGVector Translation { get; }

[Export ("interactionTransform")]
CATransform3D InteractionTransform { get; }
}

interface IUIFocusItem {}
[iOS (10,0)]
[Protocol]
Expand All @@ -16687,6 +16732,19 @@ interface UIFocusItem : UIFocusEnvironment
[Abstract]
[Export ("canBecomeFocused")]
bool CanBecomeFocused { get; }

// FIXME: declared as a @required, but this breaks compatibilit
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor typo: "compatibility"

// Radar: 41121416
#if XAMCORE_4_0
Copy link
Member

Choose a reason for hiding this comment

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

Only the [Abstract] need to be in XAMCORE_4_0:

#if XAMCORE_4_0
    [Abstract]
#endif
    [TV (12, 0), iOS (12, 0), NoWatch]
    [Export ("frame")]
    CGRect Frame { get; }

[TV (12, 0), iOS (12, 0), NoWatch]
[Abstract]
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 a breaking change: can't add new [Abstract] members to an existing protocol.

It should go into a #if XAMCORE_4_0 block.

[Export ("frame")]
CGRect Frame { get; }
#endif

[TV (12, 0), iOS (12, 0), NoWatch]
[Export ("didHintFocusMovement:")]
void DidHintFocusMovement (UIFocusMovementHint hint);
}

[DisableDefaultCtor] // [Assert] -init is not a useful initializer for this class. Use one of the designated initializers instead
Expand Down Expand Up @@ -16747,6 +16805,24 @@ interface UIFocusSystem {
// The 2 values associated with the 'UIFocusSoundIdentifier' smart enum cannot be used.
// See https://developer.apple.com/documentation/uikit/uifocussystem/2887479-register
// Do not specify one of the UIKit sound identifiers (such as default); doing so will cause an immediate assertion failure and crash your app.

[TV (12, 0), iOS (12, 0)]
[NullAllowed, Export ("focusedItem", ArgumentSemantic.Weak)]
IUIFocusItem FocusedItem { get; }

[TV (12,0), iOS (12,0)]
[Static]
[Export ("focusSystemForEnvironment:")]
[return: NullAllowed]
UIFocusSystem Create (IUIFocusEnvironment environment);

[TV (12,0), iOS (12,0)]
[Export ("requestFocusUpdateToEnvironment:")]
void RequestFocusUpdate (IUIFocusEnvironment environment);

[TV (12,0), iOS (12,0)]
[Export ("updateFocusIfNeeded")]
void UpdateFocusIfNeeded ();
}

interface IUIFocusDebuggerOutput {}
Expand Down Expand Up @@ -16930,7 +17006,33 @@ interface UIFocusEnvironment {
[Export ("soundIdentifierForFocusUpdateInContext:")]
[return: NullAllowed]
NSString GetSoundIdentifier (UIFocusUpdateContext context);


// FIXME: declared as a @required, but this breaks compatibility
// Radar: 41121293
#if XAMCORE_4_0
[TV (12, 0), iOS (12, 0)]
[Abstract]
Copy link
Member

Choose a reason for hiding this comment

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

Breaking change.

Copy link
Member Author

Choose a reason for hiding this comment

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

So XAMCORE_4_0 then

[NullAllowed, Export ("parentFocusEnvironment", ArgumentSemantic.Weak)]
IUIFocusEnvironment ParentFocusEnvironment { get; }

[TV (12, 0), iOS (12, 0)]
[Abstract]
Copy link
Member

Choose a reason for hiding this comment

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

Breaking change.

[NullAllowed, Export ("focusItemContainer")]
IUIFocusItemContainer FocusItemContainer { get; }
#endif
}

[TV (12,0), iOS (12,0)]
[BaseType (typeof(NSObject))]
[DisableDefaultCtor]
interface UITextInputPasswordRules : NSSecureCoding, NSCopying
{
[Export ("passwordRulesDescriptor")]
string PasswordRulesDescriptor { get; }

[Static]
[Export ("passwordRulesWithDescriptor:")]
UITextInputPasswordRules Create (string passwordRulesDescriptor);
}
#endif // !WATCH

Expand Down Expand Up @@ -18235,6 +18337,48 @@ interface UIDocumentBrowserAction {
[Export ("supportsMultipleItems")]
bool SupportsMultipleItems { get; set; }
}

interface IUIFocusItemContainer {}
[iOS (12,0), TV (12,0), NoWatch]
[Protocol]
interface UIFocusItemContainer
{
[Abstract]
[Export ("coordinateSpace")]
IUICoordinateSpace CoordinateSpace { get; }

[Abstract]
[Export ("focusItemsInRect:")]
IUIFocusItem[] GetFocusItems (CGRect rect);
}

[iOS (12,0), TV(12,0), NoWatch]
[Protocol]
interface UIFocusItemScrollableContainer : UIFocusItemContainer
{
[Abstract]
[Export ("contentOffset", ArgumentSemantic.Assign)]
CGPoint ContentOffset { get; set; }

[Abstract]
[Export ("contentSize")]
CGSize ContentSize { get; }

[Abstract]
[Export ("visibleSize")]
CGSize VisibleSize { get; }
}

[iOS (8,0), TV (8,0), NoWatch] // it was added on 8,0, but was not binded and the method was added in 12,0
Copy link
Contributor

Choose a reason for hiding this comment

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

tvOS started with 9.0 so remove it's attribute (which means it's always been available)

[Protocol]
interface UIUserActivityRestoring
{
[Abstract]
[iOS (8,0), TV(12,0)]
[Export ("restoreUserActivityState:")]
void RestoreUserActivityState (NSUserActivity userActivity);
Copy link
Member

Choose a reason for hiding this comment

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

Rename userActivity to activity to avoid a breaking change.

}

#endif // !WATCH

[Watch (4,0), TV (11,0), iOS (11,0)]
Expand Down Expand Up @@ -18276,4 +18420,16 @@ interface UIFontMetrics {
nfloat GetScaledValue (nfloat value, [NullAllowed] UITraitCollection traitCollection);
#endif // !WATCH
}

[Static]
[iOS (12,0), TV (12,0), Watch (5,0)]
interface UIKitVersion {

[Field ("UIKitVersionNumber")]
double UIKitVersionNumber { get; }

[Field ("UIKitVersionString")]
NSString UIKitVersionString { get; }

}
Copy link
Contributor

Choose a reason for hiding this comment

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

remove those and put them in UIKit.ignore
we're doing the same in other semi-versioned frameworks

}
Loading