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

[mapkit] Add new bindings up to beta 3 #2334

Merged
merged 3 commits into from
Jul 18, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/MapKit/MKEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public enum MKMapType : nuint_compat_int {
Satellite,
Hybrid,
SatelliteFlyover,
HybridFlyover
HybridFlyover,
[iOS (11,0)][TV (11,0)][Mac (10,13, onlyOn64: true)]
MutedStandard,
}

// NSUInteger -> MKDistanceFormatter.h
Expand Down Expand Up @@ -116,6 +118,28 @@ public enum MKSearchCompletionFilterType : nint {
AndQueries = 0,
Only
}

[TV (11,0)][NoWatch][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Native]
public enum MKAnnotationViewCollisionMode : nint {
Rectangle,
Circle,
}

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

[TV (11,0)][NoWatch][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Native]
public enum MKFeatureVisibility : nint {
Adaptive,
Hidden,
Visible,
}
}

#endif
16 changes: 16 additions & 0 deletions src/MapKit/MKFeatureDisplayPriority.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#if XAMCORE_2_0 || !MONOMAC
using System;
using XamCore.ObjCRuntime;

namespace XamCore.MapKit {

// .net does not allow float-based enumerations
[TV (11,0)][NoWatch][iOS (11,0)][Mac (10,13, onlyOn64: true)]
public static class MKFeatureDisplayPriority {
public const float Required = 1000f;
public const float DefaultHigh = 750f;
public const float DefaultLow = 250f;
}
}

#endif
1 change: 1 addition & 0 deletions src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,7 @@ MAPKIT_CORE_SOURCES = \
MAPKIT_SOURCES = \
MapKit/MKCircle.cs \
MapKit/MKDirections.cs \
MapKit/MKFeatureDisplayPriority.cs \
MapKit/MKGeodesicPolyline.cs \
MapKit/MKLocalSearch.cs \
MapKit/MKMapItem.cs \
Expand Down
172 changes: 166 additions & 6 deletions src/mapkit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@
using UIEdgeInsets=XamCore.AppKit.NSEdgeInsets;
using UIColor=XamCore.AppKit.NSColor;
#endif
#if WATCH
// helper for [NoWatch]
using MKMapView=XamCore.Foundation.NSObject;
using MKAnnotationView=XamCore.Foundation.NSObject;
#endif

namespace XamCore.MapKit {

[BaseType (typeof (NSObject))]
[Model]
[Protocol]
Expand Down Expand Up @@ -175,7 +180,22 @@ interface MKAnnotationView {
[Export ("rightCalloutOffset")]
CGPoint RightCallpoutOffset { get; set; }
#endif

[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[NullAllowed, Export ("clusteringIdentifier")]
string ClusteringIdentifier { get; set; }

[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[NullAllowed, Export ("clusterAnnotationView", ArgumentSemantic.Weak)]
MKAnnotationView ClusterAnnotationView { get; }

[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Advice ("Pre-defined constants are available from 'MKFeatureDisplayPriority'.")]
[Export ("displayPriority")]
float DisplayPriority { get; set; }

[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Export ("collisionMode", ArgumentSemantic.Assign)]
MKAnnotationViewCollisionMode CollisionMode { get; set; }
}

[ThreadSafe]
Expand Down Expand Up @@ -258,7 +278,11 @@ interface MKDirectionsRequest {
[Since (6,0)]
[TV (9,2)]
[Mac (10,9, onlyOn64 : true)]
interface MKMapItem {
interface MKMapItem
#if IOS_NOT_BOUND_YET // https://bugzilla.xamarin.com/show_bug.cgi?id=58203
: NSItemProviderReading, NSItemProviderWriting
#endif
{
[Export ("placemark", ArgumentSemantic.Retain)]
MKPlacemark Placemark { get; }

Expand Down Expand Up @@ -343,6 +367,10 @@ interface MKMapItem {
[iOS (9,0), Mac(10,11)]
[NullAllowed]
NSTimeZone TimeZone { get; set; }

[iOS (11,0)][Mac (10,13)][Mac (10,13, onlyOn64 : true)][Watch (4,0)]
[Field ("MKMapItemTypeIdentifier")]
NSString TypeIdentifier { get; }
}

#if !WATCH
Expand Down Expand Up @@ -452,8 +480,21 @@ interface MKMapView {
#endif

[Export ("dequeueReusableAnnotationViewWithIdentifier:")]
[return: NullAllowed]
MKAnnotationView DequeueReusableAnnotation (string withViewIdentifier);

[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Export ("dequeueReusableAnnotationViewWithIdentifier:forAnnotation:")]
MKAnnotationView DequeueReusableAnnotation (string identifier, IMKAnnotation annotation);

[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Export ("registerClass:forAnnotationViewWithReuseIdentifier:")]
void Register ([NullAllowed] Class viewClass, string identifier);

[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Wrap ("Register (viewType == null ? null : new Class (viewType), identifier)")]
void Register ([NullAllowed] Type viewType, string identifier);

[Export ("selectAnnotation:animated:")]
[PostGet ("SelectedAnnotations")]
#if XAMCORE_2_0
Expand Down Expand Up @@ -664,6 +705,17 @@ interface MKMapView {
#endif
}

[Static]
[TV (11,0)][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[NoWatch]
interface MKMapViewDefault {
[Field ("MKMapViewDefaultAnnotationViewReuseIdentifier")]
NSString AnnotationViewReuseIdentifier { get; }

[Field ("MKMapViewDefaultClusterAnnotationViewReuseIdentifier")]
NSString ClusterAnnotationViewReuseIdentifier { get; }
}

[BaseType (typeof (NSObject))]
[Model]
[Protocol]
Expand Down Expand Up @@ -764,6 +816,10 @@ interface MKMapViewDelegate {

[Since (7,0), Export ("mapViewDidFinishRenderingMap:fullyRendered:"), EventArgs ("MKDidFinishRenderingMap")]
void DidFinishRenderingMap (MKMapView mapView, bool fullyRendered);

[TV (11,0)][NoWatch][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[Export ("mapView:clusterAnnotationForMemberAnnotations:"), DelegateName ("MKCreateClusterAnnotation"), DefaultValue (null)]
MKClusterAnnotation CreateClusterAnnotation (MKMapView mapView, IMKAnnotation[] memberAnnotations);
}

[BaseType (typeof (MKAnnotationView))]
Expand Down Expand Up @@ -845,13 +901,14 @@ interface MKPlacemark : MKAnnotation, NSCopying {
#endif // !MONOMAC && !WATCH

[Watch (3,0)][TV (10,0)][iOS (10,0)]
[NoMac]
[Mac (10,12, onlyOn64 : true)]
[Export ("initWithCoordinate:")]
IntPtr Constructor (CLLocationCoordinate2D coordinate);

#if !TVOS && !MONOMAC && XAMCORE_2_0
#if !TVOS && XAMCORE_2_0
[Watch (3,0)][iOS (10,0)]
[NoTV][NoMac]
[Mac (10,12, onlyOn64 : true)]
[NoTV]
[Export ("initWithCoordinate:postalAddress:")]
IntPtr Constructor (CLLocationCoordinate2D coordinate, CNPostalAddress postalAddress);
#endif
Expand Down Expand Up @@ -1828,5 +1885,108 @@ interface NSUserActivity_MKMapItem {
[Export ("setMapItem:")]
void SetMapItem (MKMapItem item);
}

[TV (11,0)][NoWatch][iOS (11,0)][Mac (10,13, onlyOn64: true)]
[BaseType (typeof (NSObject))]
[DisableDefaultCtor]
interface MKClusterAnnotation : MKAnnotation {
[NullAllowed, Export ("title")]
new string Title { get; set; }

[NullAllowed, Export ("subtitle")]
new string Subtitle { get; set; }

[Export ("memberAnnotations")]
IMKAnnotation[] MemberAnnotations { get; }

[Export ("initWithMemberAnnotations:")]
[DesignatedInitializer]
IntPtr Constructor (IMKAnnotation[] memberAnnotations);
}

[NoTV][iOS (11,0)][NoMac][NoWatch]
[BaseType (typeof (UIView))]
[DisableDefaultCtor]
interface MKCompassButton {
[Static]
[Export ("compassButtonWithMapView:")]
MKCompassButton FromMapView ([NullAllowed] MKMapView mapView);

[NullAllowed, Export ("mapView", ArgumentSemantic.Weak)]
MKMapView MapView { get; set; }

[Export ("compassVisibility", ArgumentSemantic.Assign)]
MKFeatureVisibility CompassVisibility { get; set; }
}

[TV (11,0)][NoWatch][iOS (11,0)][NoMac]
[BaseType (typeof (MKAnnotationView))]
interface MKMarkerAnnotationView {

// inlined from base type
[Export ("initWithAnnotation:reuseIdentifier:")]
[PostGet ("Annotation")]
IntPtr Constructor (IMKAnnotation annotation, [NullAllowed] string reuseIdentifier);

[Export ("titleVisibility", ArgumentSemantic.Assign)]
MKFeatureVisibility TitleVisibility { get; set; }

[Export ("subtitleVisibility", ArgumentSemantic.Assign)]
MKFeatureVisibility SubtitleVisibility { get; set; }

[Appearance]
[NullAllowed, Export ("markerTintColor", ArgumentSemantic.Copy)]
UIColor MarkerTintColor { get; set; }

[Appearance]
[NullAllowed, Export ("glyphTintColor", ArgumentSemantic.Copy)]
UIColor GlyphTintColor { get; set; }

[Appearance]
[NullAllowed, Export ("glyphText")]
string GlyphText { get; set; }

[Appearance]
[NullAllowed, Export ("glyphImage", ArgumentSemantic.Copy)]
UIImage GlyphImage { get; set; }

[Appearance]
[NullAllowed, Export ("selectedGlyphImage", ArgumentSemantic.Copy)]
UIImage SelectedGlyphImage { get; set; }

[Export ("animatesWhenAdded")]
bool AnimatesWhenAdded { get; set; }
}

[TV (11,0)][NoWatch][iOS (11,0)][NoMac]
[BaseType (typeof (UIView))]
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we need a DisableDefaultCtor here? also since this inherits from UIView, maybe we also need the initWithFrame ctor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the API to create this UI item I do not think you're allowed to set the frame of that UI element. If I'm wrong this it's easy to add later. However good call on [DisableDefaultCtor].

[DisableDefaultCtor]
interface MKScaleView {

[Static]
[Export ("scaleViewWithMapView:")]
MKScaleView FromMapView ([NullAllowed] MKMapView mapView);

[NullAllowed, Export ("mapView", ArgumentSemantic.Weak)]
MKMapView MapView { get; set; }

[Export ("scaleVisibility", ArgumentSemantic.Assign)]
MKFeatureVisibility ScaleVisibility { get; set; }

[Export ("legendAlignment", ArgumentSemantic.Assign)]
MKScaleViewAlignment LegendAlignment { get; set; }
}

[NoTV][iOS (11,0)][NoWatch][NoMac]
[BaseType (typeof (UIView))]
Copy link
Member

Choose a reason for hiding this comment

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

same, maybe DisableDefaultCtor here and inline initWithFrame ctor

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Based on the API to create this UI item I do not think you're allowed to set the frame of that UI element. If I'm wrong this it's easy to add later. However good call on [DisableDefaultCtor].

[DisableDefaultCtor]
interface MKUserTrackingButton {
[Static]
[Export ("userTrackingButtonWithMapView:")]
MKUserTrackingButton FromMapView ([NullAllowed] MKMapView mapView);

[NullAllowed, Export ("mapView", ArgumentSemantic.Weak)]
MKMapView MapView { get; set; }
}
}
#endif // XAMCORE_2_0 || !MONOMAC
5 changes: 5 additions & 0 deletions tests/introspection/ApiCtorInitTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,11 @@ protected virtual bool Match (ConstructorInfo ctor, Type type)
if (ctor.ToString () == "Void .ctor(String, NSBundle)")
return true;
break;
case "MKCompassButton":
case "MKScaleView":
case "MKUserTrackingButton":
// Xcode9 added types that are created only from static methods (no init)
return true;
#if __TVOS__
case "UISearchBar":
// - (nullable instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER __TVOS_PROHIBITED;
Expand Down