Skip to content

Commit

Permalink
[passkit] Update to beta 5
Browse files Browse the repository at this point in the history
Identical to PR2475 who suffered from a fatal git issue :(

[1] xamarin#2475
  • Loading branch information
spouliot committed Aug 11, 2017
1 parent 2c1de28 commit 5a7f305
Show file tree
Hide file tree
Showing 12 changed files with 361 additions and 58 deletions.
55 changes: 0 additions & 55 deletions src/Contacts/CNPostalAddress.cs

This file was deleted.

23 changes: 23 additions & 0 deletions src/PassKit/PKEnums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public enum PKErrorCode {

// NSInteger -> PKPass.h
[iOS (6,0)]
[ErrorDomain ("PKPassKitErrorDomain")]
[Native]
public enum PKPassKitErrorCode : nint {
Unknown = -1,
Expand Down Expand Up @@ -54,9 +55,19 @@ public enum PKPassType : nuint {
public enum PKPaymentAuthorizationStatus : nint {
Success,
Failure,

[Deprecated (PlatformName.WatchOS, 4,0, message: "Use 'Failure' and 'PKPaymentRequest.CreatePaymentBillingAddressInvalidError'.")]
[Deprecated (PlatformName.iOS, 11,0, message: "Use 'Failure' and 'PKPaymentRequest.CreatePaymentBillingAddressInvalidError'.")]
InvalidBillingPostalAddress,

[Deprecated (PlatformName.WatchOS, 4,0, message: "Use 'Failure' and 'PKPaymentRequest.CreatePaymentShippingAddressInvalidError'.")]
[Deprecated (PlatformName.iOS, 11,0, message: "Use 'Failure' and 'PKPaymentRequest.CreatePaymentShippingAddressInvalidError'.")]
InvalidShippingPostalAddress,

[Deprecated (PlatformName.WatchOS, 4,0, message: "Use 'Failure' and 'PKPaymentRequest.CreatePaymentContactInvalidError'.")]
[Deprecated (PlatformName.iOS, 11,0, message: "Use 'Failure' and 'PKPaymentRequest.CreatePaymentContactInvalidError'.")]
InvalidShippingContact,

[iOS (9,2)]
PinRequired,
[iOS (9,2)]
Expand All @@ -80,6 +91,8 @@ public enum PKMerchantCapability : nuint {
}

[Watch (3,0)]
[Deprecated (PlatformName.iOS, 11,0, message: "Use 'PKContactField' instead.")]
[Deprecated (PlatformName.WatchOS, 4,0, message: "Use 'PKContactField' instead.")]
[Native]
[Flags]
public enum PKAddressField : nuint {
Expand Down Expand Up @@ -175,4 +188,14 @@ public enum PKAddPassButtonStyle : nint {
Black = 0,
Outline
}

[Watch (4,0)][iOS (11,0)]
[ErrorDomain ("PKPaymentErrorDomain")]
[Native]
public enum PKPaymentErrorCode : nint {
Unknown = -1,
ShippingContactInvalid = 1,
BillingContactInvalid,
ShippingAddressUnserviceable,
}
}
56 changes: 56 additions & 0 deletions src/PassKit/PKPaymentRequest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using System;
using XamCore.Foundation;
using XamCore.ObjCRuntime;

namespace XamCore.PassKit {

public partial class PKContactFieldsExtensions {

static public PKContactFields GetValue (NSSet set)
{
var fields = PKContactFields.None;
if (set == null)
return fields;

foreach (PKContactFields value in Enum.GetValues (typeof (PKContactFields))) {
var constant = value.GetConstant ();
// None does not have an associated native value and Contains would throw an ANE
if ((constant != null) && set.Contains (constant))
fields |= value;
}
return fields;
}

static public NSSet GetSet (PKContactFields values)
{
var set = new NSMutableSet ();
if (values == PKContactFields.None)
return set;

foreach (PKContactFields value in Enum.GetValues (typeof (PKContactFields))) {
if (values.HasFlag (value)) {
var constant = value.GetConstant ();
// None does not have an associated native value and Contains would throw an ANE
if (constant != null)
set.Add (constant);
}
}
return set;
}
}

public partial class PKPaymentRequest {

[Watch (4,0)][iOS (11,0)]
public PKContactFields RequiredBillingContactFields {
get { return PKContactFieldsExtensions.GetValue (WeakRequiredBillingContactFields); }
set { WeakRequiredBillingContactFields = PKContactFieldsExtensions.GetSet (value); }
}

[Watch (4,0)][iOS (11,0)]
public PKContactFields RequiredShippingContactFields {
get { return PKContactFieldsExtensions.GetValue (WeakRequiredShippingContactFields); }
set { WeakRequiredShippingContactFields = PKContactFieldsExtensions.GetSet (value); }
}
}
}
31 changes: 31 additions & 0 deletions src/contacts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1076,6 +1076,7 @@ interface CNPostalAddress : NSCopying, NSMutableCopying, NSSecureCoding, INSCopy
string LocalizeProperty (NSString property);
}

#if !XAMCORE_4_0
[iOS (9,0), Mac (10,11, onlyOn64: true)]
[Static]
[EditorBrowsable (EditorBrowsableState.Advanced)]
Expand Down Expand Up @@ -1107,6 +1108,31 @@ interface CNPostalAddressKey { // Can be used in KVO
[Field ("CNPostalAddressISOCountryCodeKey")]
NSString IsoCountryCode { get; }
}
#endif

[iOS (9,0), Mac (10,11, onlyOn64: true)]
public enum CNPostalAddressKeyOption {
[Field ("CNPostalAddressStreetKey")]
Street,
[Field ("CNPostalAddressCityKey")]
City,
[Field ("CNPostalAddressStateKey")]
State,
[Field ("CNPostalAddressPostalCodeKey")]
PostalCode,
[Field ("CNPostalAddressCountryKey")]
Country,
[Field ("CNPostalAddressISOCountryCodeKey")]
IsoCountryCode,

[iOS (10,3)] [Mac (10,12,4, onlyOn64: true)]
[Field ("CNPostalAddressSubLocalityKey")]
SubLocality,

[iOS (10,3)] [Mac (10,12,4, onlyOn64: true)]
[Field ("CNPostalAddressSubAdministrativeAreaKey")]
SubAdministrativeArea,
}

[iOS (9,0), Mac (10,11, onlyOn64: true)]
[BaseType (typeof (NSFormatter))]
Expand Down Expand Up @@ -1195,9 +1221,14 @@ interface CNSocialProfile : NSCopying, NSSecureCoding, INSCopying, INSSecureCodi
IntPtr Constructor ([NullAllowed] string url, [NullAllowed] string username, [NullAllowed] string userIdentifier, [NullAllowed] string service);

[Static]
[EditorBrowsable (EditorBrowsableState.Advanced)]
[Export ("localizedStringForKey:")]
string LocalizeProperty (NSString key);

[Static]
[Wrap ("LocalizeProperty (key.GetConstant ())")]
string LocalizeProperty (CNPostalAddressKeyOption key);

[Static]
[Export ("localizedStringForService:")]
string LocalizeService (NSString service);
Expand Down
4 changes: 3 additions & 1 deletion src/frameworks.sources
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ CONTACTS_SOURCES = \
Contacts/CNContactStore.cs \
Contacts/CNInstantMessageAddress.cs \
Contacts/CNObsolete.cs \
Contacts/CNPostalAddress.cs \
Contacts/CNSocialProfile.cs \

# CoreAnimation (this is really Quartz.framework)
Expand Down Expand Up @@ -1079,6 +1078,9 @@ OPENGLES_SOURCES = \

PASSKIT_API_SOURCES = \
PassKit/PKEnums.cs \

PASSKIT_SOURCES = \
PassKit/PKPaymentRequest.cs \

# PdfKit

Expand Down
2 changes: 2 additions & 0 deletions src/generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ public NamespaceManager (string prefix, string customObjCRuntimeNS, bool skipSys

if (Frameworks.HaveAudioUnit)
ImplicitNamespaces.Add (Get ("AudioUnit"));
if (Frameworks.HaveContacts && Generator.UnifiedAPI)
ImplicitNamespaces.Add (Get ("Contacts"));
if (Frameworks.HaveCoreAnimation)
ImplicitNamespaces.Add (Get ("CoreAnimation"));
if (Frameworks.HaveCoreLocation)
Expand Down
Loading

0 comments on commit 5a7f305

Please sign in to comment.