From 061fb5c7da8b2b024618155f44e5e1fcda4ed435 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 17 May 2021 09:23:33 +0200 Subject: [PATCH 1/7] Expose remaining "simple" fields from NSLocale on SKProductWrapper. --- .../ios/Classes/FIAObjectTranslator.m | 31 ++++ .../sk_product_wrapper.dart | 153 ++++++++++++++++-- .../store_kit_wrappers/sk_product_test.dart | 58 +++++-- .../sk_test_stub_objects.dart | 27 +++- 4 files changed, 236 insertions(+), 33 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m b/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m index 5d6e0a244a96..336d472c21ea 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m +++ b/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m @@ -107,10 +107,41 @@ + (NSDictionary *)getMapFromNSLocale:(NSLocale *)locale { return nil; } NSMutableDictionary *map = [[NSMutableDictionary alloc] init]; + + [map setObject:[locale objectForKey:NSLocaleLocaleIdentifier] ?: [NSNull null] + forKey:@"localeIdentifier"]; + [map setObject:[locale objectForKey:NSLocaleCountryCode] ?: [NSNull null] + forKey:@"countryCode"]; + [map setObject:[locale objectForKey:NSLocaleLanguageCode] ?: [NSNull null] + forKey:@"languageCode"]; + [map setObject:[locale objectForKey:NSLocaleScriptCode] ?: [NSNull null] + forKey:@"scriptCode"]; + [map setObject:[locale objectForKey:NSLocaleVariantCode] ?: [NSNull null] + forKey:@"variantCode"]; + [map setObject:[locale objectForKey:NSLocaleCollationIdentifier] ?: [NSNull null] + forKey:@"collationIdentifier"]; + [map setObject:[locale objectForKey:NSLocaleCollatorIdentifier] ?: [NSNull null] + forKey:@"collatorIdentifier"]; + [map setObject:([locale objectForKey:NSLocaleUsesMetricSystem] == 1) + forKey:@"usesMetricSystem"]; + [map setObject:[locale objectForKey:NSLocaleMeasurementSystem] ?: [NSNull null] + forKey:@"measurementSystem"]; + [map setObject:[locale objectForKey:NSLocaleDecimalSeparator] ?: [NSNull null] + forKey:@"decimalSeparator"]; + [map setObject:[locale objectForKey:NSLocaleGroupingSeparator] ?: [NSNull null] + forKey:@"groupingSeparator"]; [map setObject:[locale objectForKey:NSLocaleCurrencySymbol] ?: [NSNull null] forKey:@"currencySymbol"]; [map setObject:[locale objectForKey:NSLocaleCurrencyCode] ?: [NSNull null] forKey:@"currencyCode"]; + [map setObject:[locale objectForKey:NSLocaleQuotationEndDelimiterKey] ?: [NSNull null] + forKey:@"endDelimiterKey"]; + [map setObject:[locale objectForKey:NSLocaleQuotationBeginDelimiterKey] ?: [NSNull null] + forKey:@"beginDelimiterKey"]; + [map setObject:[locale objectForKey:NSLocaleAlternateQuotationEndDelimiterKey] ?: [NSNull null] + forKey:@"alternateQuotationEndDelimiterKey"]; + [map setObject:[locale objectForKey:NSLocaleAlternateQuotationBeginDelimiterKey] ?: [NSNull null] + forKey:@"alternateQuotationBeginDelimiterKey"]; return map; } diff --git a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart index ef0e6671d177..d692d6c2fa5c 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart @@ -335,19 +335,99 @@ class SKProductWrapper { @JsonSerializable() class SKPriceLocaleWrapper { /// Creates a new price locale for `currencySymbol` and `currencyCode`. - SKPriceLocaleWrapper( - {required this.currencySymbol, required this.currencyCode}); + SKPriceLocaleWrapper({ + required this.localeIdentifier, + required this.countryCode, + required this.languageCode, + required this.scriptCode, + required this.variantCode, + required this.collationIdentifier, + required this.collatorIdentifier, + required this.usesMetricSystem, + required this.measurementSystem, + required this.decimalSeparator, + required this.groupingSeparator, + required this.currencySymbol, + required this.currencyCode, + required this.endDelimiterKey, + required this.beginDelimiterKey, + required this.alternateQuotationEndDelimiterKey, + required this.alternateQuotationBeginDelimiterKey, + }); /// Constructing an instance from a map from the Objective-C layer. /// /// This method should only be used with `map` values returned by [SKProductWrapper.fromJson] and [SKProductDiscountWrapper.fromJson]. factory SKPriceLocaleWrapper.fromJson(Map? map) { if (map == null) { - return SKPriceLocaleWrapper(currencyCode: '', currencySymbol: ''); + return SKPriceLocaleWrapper( + localeIdentifier: '', + countryCode: '', + languageCode: '', + scriptCode: '', + variantCode: '', + collationIdentifier: '', + collatorIdentifier: '', + usesMetricSystem: true, + measurementSystem: '', + decimalSeparator: '', + groupingSeparator: '', + currencySymbol: '', + currencyCode: '', + endDelimiterKey: '', + beginDelimiterKey: '', + alternateQuotationEndDelimiterKey: '', + alternateQuotationBeginDelimiterKey: '', + ); } return _$SKPriceLocaleWrapperFromJson(map); } + ///The identifier for the locale, e.g. "en_US" for US locale. + @JsonKey(defaultValue: '') + final String localeIdentifier; + + ///The country or region code for the locale, e.g. "US" for en_US locale. + @JsonKey(defaultValue: '') + final String countryCode; + + ///The language code for the locale, e.g. "en" for en_US locale. + @JsonKey(defaultValue: '') + final String languageCode; + + ///The script code for the locale, e.g. "Latn" for en_US locale. + @JsonKey(defaultValue: '') + final String scriptCode; + + ///The variant code for the locale, e.g. "POSIX". + @JsonKey(defaultValue: '') + final String variantCode; + + ///The collation associated with the locale, e.g. "pinyin". + @JsonKey(defaultValue: '') + final String collationIdentifier; + + ///The collation identifier for the locale, e.g. "en". + @JsonKey(defaultValue: '') + final String collatorIdentifier; + + ///A flag whether the locale uses the metric system. + ///If the value is false, you can typically assume American measurement units (e.g. miles). + @JsonKey(defaultValue: true) + final bool usesMetricSystem; + + ///The measurement associated with the locale, e.g. "Metric" or "U.S.". + @JsonKey(defaultValue: '') + final String measurementSystem; + + ///The decimal separator associated with the locale, e.g. "." or ",". + @JsonKey(defaultValue: '') + final String decimalSeparator; + + ///The numeric grouping separator associated with the locale, e.g. "," or " ". + @JsonKey(defaultValue: '') + final String groupingSeparator; + ///The currency symbol for the locale, e.g. $ for US locale. @JsonKey(defaultValue: '') final String currencySymbol; @@ -356,19 +436,62 @@ class SKPriceLocaleWrapper { @JsonKey(defaultValue: '') final String currencyCode; + ///The end quotation symbol associated with the locale, e.g. "”", "“", "»", or "」". + @JsonKey(defaultValue: '') + final String endDelimiterKey; + + ///The begin quotation symbol associated with the locale, e.g. "“", "„", "«", or "「". + @JsonKey(defaultValue: '') + final String beginDelimiterKey; + + ///The alternate end quotation symbol associated with the locale, e.g. "“", "„", "«", or "「". + @JsonKey(defaultValue: '') + final String alternateQuotationEndDelimiterKey; + + ///The alternating begin quotation symbol associated with the locale, e.g. "“", "„", "«", or "「". + @JsonKey(defaultValue: '') + final String alternateQuotationBeginDelimiterKey; + @override - bool operator ==(Object other) { - if (identical(other, this)) { - return true; - } - if (other.runtimeType != runtimeType) { - return false; - } - final SKPriceLocaleWrapper typedOther = other as SKPriceLocaleWrapper; - return typedOther.currencySymbol == currencySymbol && - typedOther.currencyCode == currencyCode; - } + bool operator ==(Object other) => + identical(this, other) || + other is SKPriceLocaleWrapper && + runtimeType == other.runtimeType && + localeIdentifier == other.localeIdentifier && + countryCode == other.countryCode && + languageCode == other.languageCode && + scriptCode == other.scriptCode && + variantCode == other.variantCode && + collationIdentifier == other.collationIdentifier && + collatorIdentifier == other.collatorIdentifier && + usesMetricSystem == other.usesMetricSystem && + measurementSystem == other.measurementSystem && + decimalSeparator == other.decimalSeparator && + groupingSeparator == other.groupingSeparator && + currencySymbol == other.currencySymbol && + currencyCode == other.currencyCode && + endDelimiterKey == other.endDelimiterKey && + beginDelimiterKey == other.beginDelimiterKey && + alternateQuotationEndDelimiterKey == other.alternateQuotationEndDelimiterKey && + alternateQuotationBeginDelimiterKey == other.alternateQuotationBeginDelimiterKey; @override - int get hashCode => hashValues(this.currencySymbol, this.currencyCode); + int get hashCode => + localeIdentifier.hashCode ^ + countryCode.hashCode ^ + languageCode.hashCode ^ + scriptCode.hashCode ^ + variantCode.hashCode ^ + collationIdentifier.hashCode ^ + collatorIdentifier.hashCode ^ + usesMetricSystem.hashCode ^ + measurementSystem.hashCode ^ + decimalSeparator.hashCode ^ + groupingSeparator.hashCode ^ + currencySymbol.hashCode ^ + currencyCode.hashCode ^ + endDelimiterKey.hashCode ^ + beginDelimiterKey.hashCode ^ + alternateQuotationEndDelimiterKey.hashCode ^ + alternateQuotationBeginDelimiterKey.hashCode; } diff --git a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart index 9454a9d4ebee..3598f4cd89de 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart @@ -41,17 +41,33 @@ void main() { test( 'SKProductDiscountWrapper should have properties to be default if map is empty', () { - final SKProductDiscountWrapper wrapper = - SKProductDiscountWrapper.fromJson({}); + final SKProductDiscountWrapper wrapper = SKProductDiscountWrapper.fromJson({}); expect(wrapper.price, ''); - expect(wrapper.priceLocale, - SKPriceLocaleWrapper(currencyCode: '', currencySymbol: '')); + expect( + wrapper.priceLocale, + SKPriceLocaleWrapper( + localeIdentifier: '', + countryCode: '', + languageCode: '', + scriptCode: '', + variantCode: '', + collationIdentifier: '', + collatorIdentifier: '', + usesMetricSystem: true, + measurementSystem: '', + decimalSeparator: '', + groupingSeparator: '', + currencySymbol: '', + currencyCode: '', + endDelimiterKey: '', + beginDelimiterKey: '', + alternateQuotationEndDelimiterKey: '', + alternateQuotationBeginDelimiterKey: '', + )); expect(wrapper.numberOfPeriods, 0); expect(wrapper.paymentMode, SKProductDiscountPaymentMode.payAsYouGo); - expect( - wrapper.subscriptionPeriod, - SKProductSubscriptionPeriodWrapper( - numberOfUnits: 0, unit: SKSubscriptionPeriodUnit.day)); + expect(wrapper.subscriptionPeriod, + SKProductSubscriptionPeriodWrapper(numberOfUnits: 0, unit: SKSubscriptionPeriodUnit.day)); }); test('SKProductWrapper should have property values consistent with map', @@ -64,13 +80,31 @@ void main() { test( 'SKProductWrapper should have properties to be default if map is empty', () { - final SKProductWrapper wrapper = - SKProductWrapper.fromJson({}); + final SKProductWrapper wrapper = SKProductWrapper.fromJson({}); expect(wrapper.productIdentifier, ''); expect(wrapper.localizedTitle, ''); expect(wrapper.localizedDescription, ''); - expect(wrapper.priceLocale, - SKPriceLocaleWrapper(currencyCode: '', currencySymbol: '')); + expect( + wrapper.priceLocale, + SKPriceLocaleWrapper( + localeIdentifier: '', + countryCode: '', + languageCode: '', + scriptCode: '', + variantCode: '', + collationIdentifier: '', + collatorIdentifier: '', + usesMetricSystem: true, + measurementSystem: '', + decimalSeparator: '', + groupingSeparator: '', + currencySymbol: '', + currencyCode: '', + endDelimiterKey: '', + beginDelimiterKey: '', + alternateQuotationEndDelimiterKey: '', + alternateQuotationBeginDelimiterKey: '', + )); expect(wrapper.subscriptionGroupIdentifier, null); expect(wrapper.price, ''); expect(wrapper.subscriptionPeriod, null); diff --git a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart index d6c24460761e..0d3c5ee19d5f 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart @@ -23,8 +23,7 @@ final SKPaymentTransactionWrapper dummyOriginalTransaction = error: dummyError, ); -final SKPaymentTransactionWrapper dummyTransaction = - SKPaymentTransactionWrapper( +final SKPaymentTransactionWrapper dummyTransaction = SKPaymentTransactionWrapper( transactionState: SKPaymentTransactionStateWrapper.purchased, payment: dummyPayment, originalTransaction: dummyOriginalTransaction, @@ -33,11 +32,27 @@ final SKPaymentTransactionWrapper dummyTransaction = error: dummyError, ); -final SKPriceLocaleWrapper dummyLocale = - SKPriceLocaleWrapper(currencySymbol: '\$', currencyCode: 'USD'); +final SKPriceLocaleWrapper dummyLocale = SKPriceLocaleWrapper( + localeIdentifier: 'en_US', + countryCode: 'US', + languageCode: 'en', + scriptCode: 'Latn', + variantCode: 'POSIX', + collationIdentifier: '', + collatorIdentifier: 'en', + usesMetricSystem: true, + measurementSystem: 'Metric', + decimalSeparator: '.', + groupingSeparator: ',', + currencySymbol: '\$', + currencyCode: 'USD', + endDelimiterKey: '”', + beginDelimiterKey: '“', + alternateQuotationEndDelimiterKey: '”', + alternateQuotationBeginDelimiterKey: '“', +); -final SKProductSubscriptionPeriodWrapper dummySubscription = - SKProductSubscriptionPeriodWrapper( +final SKProductSubscriptionPeriodWrapper dummySubscription = SKProductSubscriptionPeriodWrapper( numberOfUnits: 1, unit: SKSubscriptionPeriodUnit.month, ); From 45a9c71de33438d80ac1035cb6976925a6839ee9 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 17 May 2021 09:42:06 +0200 Subject: [PATCH 2/7] Fix tests --- .../sk_product_wrapper.g.dart | 34 +++++++++++++++++++ .../sk_test_stub_objects.dart | 17 +++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.g.dart b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.g.dart index 8c2eed3d6070..fd6ab372ed76 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.g.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.g.dart @@ -110,14 +110,48 @@ Map _$SKProductWrapperToJson(SKProductWrapper instance) => SKPriceLocaleWrapper _$SKPriceLocaleWrapperFromJson(Map json) { return SKPriceLocaleWrapper( + localeIdentifier: json['localeIdentifier'] as String? ?? '', + countryCode: json['countryCode'] as String? ?? '', + languageCode: json['languageCode'] as String? ?? '', + scriptCode: json['scriptCode'] as String? ?? '', + variantCode: json['variantCode'] as String? ?? '', + collationIdentifier: json['collationIdentifier'] as String? ?? '', + collatorIdentifier: json['collatorIdentifier'] as String? ?? '', + usesMetricSystem: json['usesMetricSystem'] as bool? ?? true, + measurementSystem: json['measurementSystem'] as String? ?? '', + decimalSeparator: json['decimalSeparator'] as String? ?? '', + groupingSeparator: json['groupingSeparator'] as String? ?? '', currencySymbol: json['currencySymbol'] as String? ?? '', currencyCode: json['currencyCode'] as String? ?? '', + endDelimiterKey: json['endDelimiterKey'] as String? ?? '', + beginDelimiterKey: json['beginDelimiterKey'] as String? ?? '', + alternateQuotationEndDelimiterKey: + json['alternateQuotationEndDelimiterKey'] as String? ?? '', + alternateQuotationBeginDelimiterKey: + json['alternateQuotationBeginDelimiterKey'] as String? ?? '', ); } Map _$SKPriceLocaleWrapperToJson( SKPriceLocaleWrapper instance) => { + 'localeIdentifier': instance.localeIdentifier, + 'countryCode': instance.countryCode, + 'languageCode': instance.languageCode, + 'scriptCode': instance.scriptCode, + 'variantCode': instance.variantCode, + 'collationIdentifier': instance.collationIdentifier, + 'collatorIdentifier': instance.collatorIdentifier, + 'usesMetricSystem': instance.usesMetricSystem, + 'measurementSystem': instance.measurementSystem, + 'decimalSeparator': instance.decimalSeparator, + 'groupingSeparator': instance.groupingSeparator, 'currencySymbol': instance.currencySymbol, 'currencyCode': instance.currencyCode, + 'endDelimiterKey': instance.endDelimiterKey, + 'beginDelimiterKey': instance.beginDelimiterKey, + 'alternateQuotationEndDelimiterKey': + instance.alternateQuotationEndDelimiterKey, + 'alternateQuotationBeginDelimiterKey': + instance.alternateQuotationBeginDelimiterKey, }; diff --git a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart index 0d3c5ee19d5f..93213f3b400e 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart @@ -84,8 +84,23 @@ final SkProductResponseWrapper dummyProductResponseWrapper = Map buildLocaleMap(SKPriceLocaleWrapper local) { return { + 'localeIdentifier': local.localeIdentifier, + 'countryCode': local.countryCode, + 'languageCode': local.languageCode, + 'scriptCode': local.scriptCode, + 'variantCode': local.variantCode, + 'collationIdentifier': local.collationIdentifier, + 'collatorIdentifier': local.collatorIdentifier, + 'usesMetricSystem': local.usesMetricSystem, + 'measurementSystem': local.measurementSystem, + 'decimalSeparator': local.decimalSeparator, + 'groupingSeparator': local.groupingSeparator, 'currencySymbol': local.currencySymbol, - 'currencyCode': local.currencyCode + 'currencyCode': local.currencyCode, + 'endDelimiterKey': local.endDelimiterKey, + 'beginDelimiterKey': local.beginDelimiterKey, + 'alternateQuotationEndDelimiterKey': local.alternateQuotationEndDelimiterKey, + 'alternateQuotationBeginDelimiterKey': local.alternateQuotationBeginDelimiterKey }; } From 0a673ee7fbce445e234d65d3fcc58d8d16a52624 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 17 May 2021 11:33:57 +0200 Subject: [PATCH 3/7] Fix serialization --- .../in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m | 4 ++-- .../lib/src/store_kit_wrappers/sk_product_wrapper.dart | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m b/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m index 336d472c21ea..a3774a7be48e 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m +++ b/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m @@ -108,7 +108,7 @@ + (NSDictionary *)getMapFromNSLocale:(NSLocale *)locale { } NSMutableDictionary *map = [[NSMutableDictionary alloc] init]; - [map setObject:[locale objectForKey:NSLocaleLocaleIdentifier] ?: [NSNull null] + [map setObject:[locale objectForKey:NSLocaleIdentifier] ?: [NSNull null] forKey:@"localeIdentifier"]; [map setObject:[locale objectForKey:NSLocaleCountryCode] ?: [NSNull null] forKey:@"countryCode"]; @@ -122,7 +122,7 @@ + (NSDictionary *)getMapFromNSLocale:(NSLocale *)locale { forKey:@"collationIdentifier"]; [map setObject:[locale objectForKey:NSLocaleCollatorIdentifier] ?: [NSNull null] forKey:@"collatorIdentifier"]; - [map setObject:([locale objectForKey:NSLocaleUsesMetricSystem] == 1) + [map setObject:[locale objectForKey:NSLocaleUsesMetricSystem] ?: [NSNull null] forKey:@"usesMetricSystem"]; [map setObject:[locale objectForKey:NSLocaleMeasurementSystem] ?: [NSNull null] forKey:@"measurementSystem"]; diff --git a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart index d692d6c2fa5c..03f8a8108a39 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart @@ -329,9 +329,6 @@ class SKProductWrapper { /// Object that indicates the locale of the price /// /// It is a thin wrapper of [NSLocale](https://developer.apple.com/documentation/foundation/nslocale?language=objc). -// TODO(cyanglaz): NSLocale is a complex object, want to see the actual need of getting this expanded. -// Matching android to only get the currencySymbol for now. -// https://github.com/flutter/flutter/issues/26610 @JsonSerializable() class SKPriceLocaleWrapper { /// Creates a new price locale for `currencySymbol` and `currencyCode`. From e8759fc651331b34a28ad1d06345f7f8b09b7059 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 17 May 2021 11:41:21 +0200 Subject: [PATCH 4/7] Format code --- .../ios/Classes/FIAObjectTranslator.m | 9 +++------ .../src/store_kit_wrappers/sk_product_wrapper.dart | 6 ++++-- .../test/store_kit_wrappers/sk_product_test.dart | 12 ++++++++---- .../store_kit_wrappers/sk_test_stub_objects.dart | 12 ++++++++---- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m b/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m index a3774a7be48e..e03a9a72a766 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m +++ b/packages/in_app_purchase/in_app_purchase_ios/ios/Classes/FIAObjectTranslator.m @@ -110,14 +110,11 @@ + (NSDictionary *)getMapFromNSLocale:(NSLocale *)locale { [map setObject:[locale objectForKey:NSLocaleIdentifier] ?: [NSNull null] forKey:@"localeIdentifier"]; - [map setObject:[locale objectForKey:NSLocaleCountryCode] ?: [NSNull null] - forKey:@"countryCode"]; + [map setObject:[locale objectForKey:NSLocaleCountryCode] ?: [NSNull null] forKey:@"countryCode"]; [map setObject:[locale objectForKey:NSLocaleLanguageCode] ?: [NSNull null] forKey:@"languageCode"]; - [map setObject:[locale objectForKey:NSLocaleScriptCode] ?: [NSNull null] - forKey:@"scriptCode"]; - [map setObject:[locale objectForKey:NSLocaleVariantCode] ?: [NSNull null] - forKey:@"variantCode"]; + [map setObject:[locale objectForKey:NSLocaleScriptCode] ?: [NSNull null] forKey:@"scriptCode"]; + [map setObject:[locale objectForKey:NSLocaleVariantCode] ?: [NSNull null] forKey:@"variantCode"]; [map setObject:[locale objectForKey:NSLocaleCollationIdentifier] ?: [NSNull null] forKey:@"collationIdentifier"]; [map setObject:[locale objectForKey:NSLocaleCollatorIdentifier] ?: [NSNull null] diff --git a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart index 03f8a8108a39..8518cc0ac193 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/lib/src/store_kit_wrappers/sk_product_wrapper.dart @@ -469,8 +469,10 @@ class SKPriceLocaleWrapper { currencyCode == other.currencyCode && endDelimiterKey == other.endDelimiterKey && beginDelimiterKey == other.beginDelimiterKey && - alternateQuotationEndDelimiterKey == other.alternateQuotationEndDelimiterKey && - alternateQuotationBeginDelimiterKey == other.alternateQuotationBeginDelimiterKey; + alternateQuotationEndDelimiterKey == + other.alternateQuotationEndDelimiterKey && + alternateQuotationBeginDelimiterKey == + other.alternateQuotationBeginDelimiterKey; @override int get hashCode => diff --git a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart index 3598f4cd89de..55161dcec15d 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_product_test.dart @@ -41,7 +41,8 @@ void main() { test( 'SKProductDiscountWrapper should have properties to be default if map is empty', () { - final SKProductDiscountWrapper wrapper = SKProductDiscountWrapper.fromJson({}); + final SKProductDiscountWrapper wrapper = + SKProductDiscountWrapper.fromJson({}); expect(wrapper.price, ''); expect( wrapper.priceLocale, @@ -66,8 +67,10 @@ void main() { )); expect(wrapper.numberOfPeriods, 0); expect(wrapper.paymentMode, SKProductDiscountPaymentMode.payAsYouGo); - expect(wrapper.subscriptionPeriod, - SKProductSubscriptionPeriodWrapper(numberOfUnits: 0, unit: SKSubscriptionPeriodUnit.day)); + expect( + wrapper.subscriptionPeriod, + SKProductSubscriptionPeriodWrapper( + numberOfUnits: 0, unit: SKSubscriptionPeriodUnit.day)); }); test('SKProductWrapper should have property values consistent with map', @@ -80,7 +83,8 @@ void main() { test( 'SKProductWrapper should have properties to be default if map is empty', () { - final SKProductWrapper wrapper = SKProductWrapper.fromJson({}); + final SKProductWrapper wrapper = + SKProductWrapper.fromJson({}); expect(wrapper.productIdentifier, ''); expect(wrapper.localizedTitle, ''); expect(wrapper.localizedDescription, ''); diff --git a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart index 93213f3b400e..1298c60bf8a2 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart +++ b/packages/in_app_purchase/in_app_purchase_ios/test/store_kit_wrappers/sk_test_stub_objects.dart @@ -23,7 +23,8 @@ final SKPaymentTransactionWrapper dummyOriginalTransaction = error: dummyError, ); -final SKPaymentTransactionWrapper dummyTransaction = SKPaymentTransactionWrapper( +final SKPaymentTransactionWrapper dummyTransaction = + SKPaymentTransactionWrapper( transactionState: SKPaymentTransactionStateWrapper.purchased, payment: dummyPayment, originalTransaction: dummyOriginalTransaction, @@ -52,7 +53,8 @@ final SKPriceLocaleWrapper dummyLocale = SKPriceLocaleWrapper( alternateQuotationBeginDelimiterKey: '“', ); -final SKProductSubscriptionPeriodWrapper dummySubscription = SKProductSubscriptionPeriodWrapper( +final SKProductSubscriptionPeriodWrapper dummySubscription = + SKProductSubscriptionPeriodWrapper( numberOfUnits: 1, unit: SKSubscriptionPeriodUnit.month, ); @@ -99,8 +101,10 @@ Map buildLocaleMap(SKPriceLocaleWrapper local) { 'currencyCode': local.currencyCode, 'endDelimiterKey': local.endDelimiterKey, 'beginDelimiterKey': local.beginDelimiterKey, - 'alternateQuotationEndDelimiterKey': local.alternateQuotationEndDelimiterKey, - 'alternateQuotationBeginDelimiterKey': local.alternateQuotationBeginDelimiterKey + 'alternateQuotationEndDelimiterKey': + local.alternateQuotationEndDelimiterKey, + 'alternateQuotationBeginDelimiterKey': + local.alternateQuotationBeginDelimiterKey }; } From 07fe2f50db37a081847ac0299c809a47a11c2224 Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 17 May 2021 11:46:41 +0200 Subject: [PATCH 5/7] Updated version and changelog --- .../example/ios/Runner.xcodeproj/project.pbxproj | 9 +++++---- .../in_app_purchase/in_app_purchase_ios/pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj index 2de5b9bd557f..2e9b51f55328 100644 --- a/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj @@ -181,6 +181,7 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; + DevelopmentTeam = 7624MWN53C; SystemCapabilities = { com.apple.InAppPurchase = { enabled = 1; @@ -415,7 +416,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 7624MWN53C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -427,7 +428,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.inAppPurchaseExample; + PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.example.iap; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -439,7 +440,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = ""; + DEVELOPMENT_TEAM = 7624MWN53C; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -451,7 +452,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.inAppPurchaseExample; + PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.example.iap; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml index fcc7c5149ab8..c847fb4f5700 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml @@ -1,7 +1,7 @@ name: in_app_purchase_ios description: An implementation for the iOS platform of the Flutter `in_app_purchase` plugin. This uses the iOS StoreKit Framework. repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase_ios -version: 0.1.0 +version: 0.1.1 flutter: plugin: From 44717cec8af6ba5cf49978cef421862f888c15af Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 17 May 2021 11:48:52 +0200 Subject: [PATCH 6/7] Revert "Updated version and changelog" This reverts commit 07fe2f50db37a081847ac0299c809a47a11c2224. --- .../example/ios/Runner.xcodeproj/project.pbxproj | 9 ++++----- .../in_app_purchase/in_app_purchase_ios/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj b/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj index 2e9b51f55328..2de5b9bd557f 100644 --- a/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/in_app_purchase/in_app_purchase/example/ios/Runner.xcodeproj/project.pbxproj @@ -181,7 +181,6 @@ TargetAttributes = { 97C146ED1CF9000F007C117D = { CreatedOnToolsVersion = 7.3.1; - DevelopmentTeam = 7624MWN53C; SystemCapabilities = { com.apple.InAppPurchase = { enabled = 1; @@ -416,7 +415,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 7624MWN53C; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -428,7 +427,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.example.iap; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.inAppPurchaseExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; @@ -440,7 +439,7 @@ buildSettings = { ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_TEAM = 7624MWN53C; + DEVELOPMENT_TEAM = ""; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", @@ -452,7 +451,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.example.iap; + PRODUCT_BUNDLE_IDENTIFIER = io.flutter.plugins.inAppPurchaseExample; PRODUCT_NAME = "$(TARGET_NAME)"; VERSIONING_SYSTEM = "apple-generic"; }; diff --git a/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml index c847fb4f5700..fcc7c5149ab8 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml @@ -1,7 +1,7 @@ name: in_app_purchase_ios description: An implementation for the iOS platform of the Flutter `in_app_purchase` plugin. This uses the iOS StoreKit Framework. repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase_ios -version: 0.1.1 +version: 0.1.0 flutter: plugin: From cbba31007d8474000b5c5f013ff37d0d29a3dabd Mon Sep 17 00:00:00 2001 From: "Bodhi Mulders (BeMacized)" Date: Mon, 17 May 2021 11:49:44 +0200 Subject: [PATCH 7/7] Updated version and changelog --- packages/in_app_purchase/in_app_purchase_ios/CHANGELOG.md | 4 ++++ packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/in_app_purchase/in_app_purchase_ios/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_ios/CHANGELOG.md index d46c124b9011..d9fdfeccc1f7 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.1.1 + +* Exposed most of the NSLocale object via the SKProductWrapper class. + ## 0.1.0 * Initial open-source release. \ No newline at end of file diff --git a/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml index fcc7c5149ab8..c847fb4f5700 100644 --- a/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml @@ -1,7 +1,7 @@ name: in_app_purchase_ios description: An implementation for the iOS platform of the Flutter `in_app_purchase` plugin. This uses the iOS StoreKit Framework. repository: https://github.com/flutter/plugins/tree/master/packages/in_app_purchase/in_app_purchase_ios -version: 0.1.0 +version: 0.1.1 flutter: plugin: