Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

[in_app_purchase] Revert changes from PR 3897 #3976

Merged
merged 1 commit into from
May 27, 2021
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
4 changes: 0 additions & 4 deletions packages/in_app_purchase/in_app_purchase_ios/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
## 0.1.1

* Exposed most of the NSLocale object via the SKProductWrapper class.

## 0.1.0

* Initial open-source release.
Original file line number Diff line number Diff line change
Expand Up @@ -107,38 +107,10 @@ + (NSDictionary *)getMapFromNSLocale:(NSLocale *)locale {
return nil;
}
NSMutableDictionary *map = [[NSMutableDictionary alloc] init];

[map setObject:[locale objectForKey:NSLocaleIdentifier] ?: [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] ?: [NSNull null]
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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,102 +329,25 @@ 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`.
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,
});
SKPriceLocaleWrapper(
{required this.currencySymbol, required this.currencyCode});

/// 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<String, dynamic>? map) {
if (map == null) {
return SKPriceLocaleWrapper(
localeIdentifier: '',
countryCode: '',
languageCode: '',
scriptCode: '',
variantCode: '',
collationIdentifier: '',
collatorIdentifier: '',
usesMetricSystem: true,
measurementSystem: '',
decimalSeparator: '',
groupingSeparator: '',
currencySymbol: '',
currencyCode: '',
endDelimiterKey: '',
beginDelimiterKey: '',
alternateQuotationEndDelimiterKey: '',
alternateQuotationBeginDelimiterKey: '',
);
return SKPriceLocaleWrapper(currencyCode: '', currencySymbol: '');
}
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;
Expand All @@ -433,64 +356,19 @@ 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) =>
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;
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;
}

@override
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;
int get hashCode => hashValues(this.currencySymbol, this.currencyCode);
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/in_app_purchase/in_app_purchase_ios/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,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
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22
version: 0.1.1
version: 0.1.0

environment:
sdk: ">=2.12.0 <3.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,8 @@ void main() {
final SKProductDiscountWrapper wrapper =
SKProductDiscountWrapper.fromJson(<String, dynamic>{});
expect(wrapper.price, '');
expect(
wrapper.priceLocale,
SKPriceLocaleWrapper(
localeIdentifier: '',
countryCode: '',
languageCode: '',
scriptCode: '',
variantCode: '',
collationIdentifier: '',
collatorIdentifier: '',
usesMetricSystem: true,
measurementSystem: '',
decimalSeparator: '',
groupingSeparator: '',
currencySymbol: '',
currencyCode: '',
endDelimiterKey: '',
beginDelimiterKey: '',
alternateQuotationEndDelimiterKey: '',
alternateQuotationBeginDelimiterKey: '',
));
expect(wrapper.priceLocale,
SKPriceLocaleWrapper(currencyCode: '', currencySymbol: ''));
expect(wrapper.numberOfPeriods, 0);
expect(wrapper.paymentMode, SKProductDiscountPaymentMode.payAsYouGo);
expect(
Expand All @@ -88,27 +69,8 @@ void main() {
expect(wrapper.productIdentifier, '');
expect(wrapper.localizedTitle, '');
expect(wrapper.localizedDescription, '');
expect(
wrapper.priceLocale,
SKPriceLocaleWrapper(
localeIdentifier: '',
countryCode: '',
languageCode: '',
scriptCode: '',
variantCode: '',
collationIdentifier: '',
collatorIdentifier: '',
usesMetricSystem: true,
measurementSystem: '',
decimalSeparator: '',
groupingSeparator: '',
currencySymbol: '',
currencyCode: '',
endDelimiterKey: '',
beginDelimiterKey: '',
alternateQuotationEndDelimiterKey: '',
alternateQuotationBeginDelimiterKey: '',
));
expect(wrapper.priceLocale,
SKPriceLocaleWrapper(currencyCode: '', currencySymbol: ''));
expect(wrapper.subscriptionGroupIdentifier, null);
expect(wrapper.price, '');
expect(wrapper.subscriptionPeriod, null);
Expand Down
Loading