From 6971188ed2384a092a26cf177312dbd8d7fc5ee6 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 9 Sep 2024 18:06:46 +0800 Subject: [PATCH 1/5] product symbol locale --- .../Flare/Classes/Models/Internal/Protocols/ISKProduct.swift | 3 +++ Sources/Flare/Classes/Models/Internal/SK1StoreProduct.swift | 4 ++++ Sources/Flare/Classes/Models/Internal/SK2StoreProduct.swift | 4 ++++ Sources/Flare/Classes/Models/StoreProduct.swift | 4 ++++ 4 files changed, 15 insertions(+) diff --git a/Sources/Flare/Classes/Models/Internal/Protocols/ISKProduct.swift b/Sources/Flare/Classes/Models/Internal/Protocols/ISKProduct.swift index f37511d09..12b7628e3 100644 --- a/Sources/Flare/Classes/Models/Internal/Protocols/ISKProduct.swift +++ b/Sources/Flare/Classes/Models/Internal/Protocols/ISKProduct.swift @@ -18,6 +18,9 @@ protocol ISKProduct { /// The currency Symbol for the product's price. var currencySymbol: String? { get } + + /// The locale for the product's currency. + var locale: Locale { get } /// The price of the product in decimal format. var price: Decimal { get } diff --git a/Sources/Flare/Classes/Models/Internal/SK1StoreProduct.swift b/Sources/Flare/Classes/Models/Internal/SK1StoreProduct.swift index 06dd091ac..d1417c022 100644 --- a/Sources/Flare/Classes/Models/Internal/SK1StoreProduct.swift +++ b/Sources/Flare/Classes/Models/Internal/SK1StoreProduct.swift @@ -42,6 +42,10 @@ extension SK1StoreProduct: ISKProduct { var currencySymbol: String? { numberFormatter.currencySymbol } + + var locale: Locale { + self.product.priceLocale + } var price: Decimal { product.price as Decimal diff --git a/Sources/Flare/Classes/Models/Internal/SK2StoreProduct.swift b/Sources/Flare/Classes/Models/Internal/SK2StoreProduct.swift index c874a02ce..8823f6a7c 100644 --- a/Sources/Flare/Classes/Models/Internal/SK2StoreProduct.swift +++ b/Sources/Flare/Classes/Models/Internal/SK2StoreProduct.swift @@ -49,6 +49,10 @@ extension SK2StoreProduct: ISKProduct { var currencySymbol: String? { numberFormatter.currencySymbol } + + var locale: Locale { + self.currencyFormat.locale + } var price: Decimal { product.price diff --git a/Sources/Flare/Classes/Models/StoreProduct.swift b/Sources/Flare/Classes/Models/StoreProduct.swift index f6191d6f1..89156b144 100644 --- a/Sources/Flare/Classes/Models/StoreProduct.swift +++ b/Sources/Flare/Classes/Models/StoreProduct.swift @@ -65,6 +65,10 @@ extension StoreProduct: ISKProduct { public var currencySymbol: String? { product.currencySymbol } + + var locale: Locale { + self.product.locale + } public var price: Decimal { product.price From c7557bceea52286839be7e3a697491f294315398 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Mon, 9 Sep 2024 19:16:54 +0800 Subject: [PATCH 2/5] product symbol locale --- Sources/Flare/Classes/Models/StoreProduct.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Flare/Classes/Models/StoreProduct.swift b/Sources/Flare/Classes/Models/StoreProduct.swift index 89156b144..b13713d06 100644 --- a/Sources/Flare/Classes/Models/StoreProduct.swift +++ b/Sources/Flare/Classes/Models/StoreProduct.swift @@ -66,7 +66,7 @@ extension StoreProduct: ISKProduct { product.currencySymbol } - var locale: Locale { + public var locale: Locale { self.product.locale } From 4d3a62159fdc9bd8544a378f8deefdb90670e04d Mon Sep 17 00:00:00 2001 From: zhangyu Date: Sun, 29 Sep 2024 12:27:35 +0800 Subject: [PATCH 3/5] Update CHANGELOG.md update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae18d6037..73edc0115 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Change Log All notable changes to this project will be documented in this file. +## Added +- Implement locale for StoreProduct + - Added in Pull Request [#66](https://github.com/space-code/flare/pull/66). + ## Updated - Update `CHANGELOG.md` - Updated in Pull Request [#74](https://github.com/space-code/flare/pull/74). From b6d257d211ecc18c209f51895177498d95960330 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Sun, 29 Sep 2024 12:29:00 +0800 Subject: [PATCH 4/5] Update CHANGELOG.md update change log --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 73edc0115..714bbe5fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. ## Added - Implement locale for StoreProduct - - Added in Pull Request [#66](https://github.com/space-code/flare/pull/66). + - Added in Pull Request [#66](https://github.com/space-code/flare/pull/75). ## Updated - Update `CHANGELOG.md` From 3d759e35e4393ade45d975577103bd6f7cac2343 Mon Sep 17 00:00:00 2001 From: zhangyu Date: Sun, 29 Sep 2024 12:34:20 +0800 Subject: [PATCH 5/5] Update ProductMock.swift update product mock --- Sources/FlareMock/Mocks/ProductMock.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sources/FlareMock/Mocks/ProductMock.swift b/Sources/FlareMock/Mocks/ProductMock.swift index 49e62c562..c45bbe3d3 100644 --- a/Sources/FlareMock/Mocks/ProductMock.swift +++ b/Sources/FlareMock/Mocks/ProductMock.swift @@ -38,6 +38,16 @@ public final class ProductMock: ISKProduct { invokedCurrencyCodeGetterCount += 1 return stubbedCurrencyCode } + + public var invokedLocaleGetter = false + public var invokedLocaleGetterCount = 0 + public var stubbedLocale: Locale! + + public var locale: Locale { + invokedLocaleGetter = true + invokedLocaleGetterCount += 1 + return stubbedLocale + } public var invokedCurrencySymbolGetter = false public var invokedCurrencySymbolGetterCount = 0