@@ -329,25 +329,102 @@ class SKProductWrapper {
329
329
/// Object that indicates the locale of the price
330
330
///
331
331
/// It is a thin wrapper of [NSLocale] (https://developer.apple.com/documentation/foundation/nslocale?language=objc).
332
- // TODO(cyanglaz): NSLocale is a complex object, want to see the actual need of getting this expanded.
333
- // Matching android to only get the currencySymbol for now.
334
- // https://github.com/flutter/flutter/issues/26610
335
332
@JsonSerializable ()
336
333
class SKPriceLocaleWrapper {
337
334
/// Creates a new price locale for `currencySymbol` and `currencyCode` .
338
- SKPriceLocaleWrapper (
339
- {required this .currencySymbol, required this .currencyCode});
335
+ SKPriceLocaleWrapper ({
336
+ required this .localeIdentifier,
337
+ required this .countryCode,
338
+ required this .languageCode,
339
+ required this .scriptCode,
340
+ required this .variantCode,
341
+ required this .collationIdentifier,
342
+ required this .collatorIdentifier,
343
+ required this .usesMetricSystem,
344
+ required this .measurementSystem,
345
+ required this .decimalSeparator,
346
+ required this .groupingSeparator,
347
+ required this .currencySymbol,
348
+ required this .currencyCode,
349
+ required this .endDelimiterKey,
350
+ required this .beginDelimiterKey,
351
+ required this .alternateQuotationEndDelimiterKey,
352
+ required this .alternateQuotationBeginDelimiterKey,
353
+ });
340
354
341
355
/// Constructing an instance from a map from the Objective-C layer.
342
356
///
343
357
/// This method should only be used with `map` values returned by [SKProductWrapper.fromJson] and [SKProductDiscountWrapper.fromJson] .
344
358
factory SKPriceLocaleWrapper .fromJson (Map <String , dynamic >? map) {
345
359
if (map == null ) {
346
- return SKPriceLocaleWrapper (currencyCode: '' , currencySymbol: '' );
360
+ return SKPriceLocaleWrapper (
361
+ localeIdentifier: '' ,
362
+ countryCode: '' ,
363
+ languageCode: '' ,
364
+ scriptCode: '' ,
365
+ variantCode: '' ,
366
+ collationIdentifier: '' ,
367
+ collatorIdentifier: '' ,
368
+ usesMetricSystem: true ,
369
+ measurementSystem: '' ,
370
+ decimalSeparator: '' ,
371
+ groupingSeparator: '' ,
372
+ currencySymbol: '' ,
373
+ currencyCode: '' ,
374
+ endDelimiterKey: '' ,
375
+ beginDelimiterKey: '' ,
376
+ alternateQuotationEndDelimiterKey: '' ,
377
+ alternateQuotationBeginDelimiterKey: '' ,
378
+ );
347
379
}
348
380
return _$SKPriceLocaleWrapperFromJson (map);
349
381
}
350
382
383
+ ///The identifier for the locale, e.g. "en_US" for US locale.
384
+ @JsonKey (defaultValue: '' )
385
+ final String localeIdentifier;
386
+
387
+ ///The country or region code for the locale, e.g. "US" for en_US locale.
388
+ @JsonKey (defaultValue: '' )
389
+ final String countryCode;
390
+
391
+ ///The language code for the locale, e.g. "en" for en_US locale.
392
+ @JsonKey (defaultValue: '' )
393
+ final String languageCode;
394
+
395
+ ///The script code for the locale, e.g. "Latn" for en_US locale.
396
+ @JsonKey (defaultValue: '' )
397
+ final String scriptCode;
398
+
399
+ ///The variant code for the locale, e.g. "POSIX".
400
+ @JsonKey (defaultValue: '' )
401
+ final String variantCode;
402
+
403
+ ///The collation associated with the locale, e.g. "pinyin".
404
+ @JsonKey (defaultValue: '' )
405
+ final String collationIdentifier;
406
+
407
+ ///The collation identifier for the locale, e.g. "en".
408
+ @JsonKey (defaultValue: '' )
409
+ final String collatorIdentifier;
410
+
411
+ ///A flag whether the locale uses the metric system.
412
+ ///If the value is false, you can typically assume American measurement units (e.g. miles).
413
+ @JsonKey (defaultValue: true )
414
+ final bool usesMetricSystem;
415
+
416
+ ///The measurement associated with the locale, e.g. "Metric" or "U.S.".
417
+ @JsonKey (defaultValue: '' )
418
+ final String measurementSystem;
419
+
420
+ ///The decimal separator associated with the locale, e.g. "." or ",".
421
+ @JsonKey (defaultValue: '' )
422
+ final String decimalSeparator;
423
+
424
+ ///The numeric grouping separator associated with the locale, e.g. "," or " ".
425
+ @JsonKey (defaultValue: '' )
426
+ final String groupingSeparator;
427
+
351
428
///The currency symbol for the locale, e.g. $ for US locale.
352
429
@JsonKey (defaultValue: '' )
353
430
final String currencySymbol;
@@ -356,19 +433,64 @@ class SKPriceLocaleWrapper {
356
433
@JsonKey (defaultValue: '' )
357
434
final String currencyCode;
358
435
436
+ ///The end quotation symbol associated with the locale, e.g. "”", "“", "»", or "」".
437
+ @JsonKey (defaultValue: '' )
438
+ final String endDelimiterKey;
439
+
440
+ ///The begin quotation symbol associated with the locale, e.g. "“", "„", "«", or "「".
441
+ @JsonKey (defaultValue: '' )
442
+ final String beginDelimiterKey;
443
+
444
+ ///The alternate end quotation symbol associated with the locale, e.g. "“", "„", "«", or "「".
445
+ @JsonKey (defaultValue: '' )
446
+ final String alternateQuotationEndDelimiterKey;
447
+
448
+ ///The alternating begin quotation symbol associated with the locale, e.g. "“", "„", "«", or "「".
449
+ @JsonKey (defaultValue: '' )
450
+ final String alternateQuotationBeginDelimiterKey;
451
+
359
452
@override
360
- bool operator == (Object other) {
361
- if (identical (other, this )) {
362
- return true ;
363
- }
364
- if (other.runtimeType != runtimeType) {
365
- return false ;
366
- }
367
- final SKPriceLocaleWrapper typedOther = other as SKPriceLocaleWrapper ;
368
- return typedOther.currencySymbol == currencySymbol &&
369
- typedOther.currencyCode == currencyCode;
370
- }
453
+ bool operator == (Object other) =>
454
+ identical (this , other) ||
455
+ other is SKPriceLocaleWrapper &&
456
+ runtimeType == other.runtimeType &&
457
+ localeIdentifier == other.localeIdentifier &&
458
+ countryCode == other.countryCode &&
459
+ languageCode == other.languageCode &&
460
+ scriptCode == other.scriptCode &&
461
+ variantCode == other.variantCode &&
462
+ collationIdentifier == other.collationIdentifier &&
463
+ collatorIdentifier == other.collatorIdentifier &&
464
+ usesMetricSystem == other.usesMetricSystem &&
465
+ measurementSystem == other.measurementSystem &&
466
+ decimalSeparator == other.decimalSeparator &&
467
+ groupingSeparator == other.groupingSeparator &&
468
+ currencySymbol == other.currencySymbol &&
469
+ currencyCode == other.currencyCode &&
470
+ endDelimiterKey == other.endDelimiterKey &&
471
+ beginDelimiterKey == other.beginDelimiterKey &&
472
+ alternateQuotationEndDelimiterKey ==
473
+ other.alternateQuotationEndDelimiterKey &&
474
+ alternateQuotationBeginDelimiterKey ==
475
+ other.alternateQuotationBeginDelimiterKey;
371
476
372
477
@override
373
- int get hashCode => hashValues (this .currencySymbol, this .currencyCode);
478
+ int get hashCode =>
479
+ localeIdentifier.hashCode ^
480
+ countryCode.hashCode ^
481
+ languageCode.hashCode ^
482
+ scriptCode.hashCode ^
483
+ variantCode.hashCode ^
484
+ collationIdentifier.hashCode ^
485
+ collatorIdentifier.hashCode ^
486
+ usesMetricSystem.hashCode ^
487
+ measurementSystem.hashCode ^
488
+ decimalSeparator.hashCode ^
489
+ groupingSeparator.hashCode ^
490
+ currencySymbol.hashCode ^
491
+ currencyCode.hashCode ^
492
+ endDelimiterKey.hashCode ^
493
+ beginDelimiterKey.hashCode ^
494
+ alternateQuotationEndDelimiterKey.hashCode ^
495
+ alternateQuotationBeginDelimiterKey.hashCode;
374
496
}
0 commit comments