From 132158d943af3d0df1a65d8780d3e325594f6a7a Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 28 Aug 2022 17:22:19 +0200 Subject: [PATCH] Various fixes --- .../PremiumUI/Sources/PremiumGiftScreen.swift | 20 +++++++++++++------ .../Sources/PremiumIntroScreen.swift | 2 +- .../PrivacyAndSecurityController.swift | 2 ++ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/submodules/PremiumUI/Sources/PremiumGiftScreen.swift b/submodules/PremiumUI/Sources/PremiumGiftScreen.swift index 2554a09a50..780dcc5039 100644 --- a/submodules/PremiumUI/Sources/PremiumGiftScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumGiftScreen.swift @@ -234,11 +234,11 @@ private final class PremiumGiftScreenContentComponent: CombinedComponent { UIColor(rgb: 0xb36eee) ] - let shortestOptionPrice: Int64 + let shortestOptionPrice: (Int64, NSDecimalNumber) if let product = products.last { - shortestOptionPrice = Int64(Float(product.storeProduct.priceCurrencyAndAmount.amount) / Float(product.months)) + shortestOptionPrice = (Int64(Float(product.storeProduct.priceCurrencyAndAmount.amount) / Float(product.months)), product.storeProduct.priceValue.dividing(by: NSDecimalNumber(value: product.months))) } else { - shortestOptionPrice = 1 + shortestOptionPrice = (1, NSDecimalNumber(decimal: 1)) } for product in products { @@ -249,7 +249,7 @@ private final class PremiumGiftScreenContentComponent: CombinedComponent { giftTitle = strings.Premium_Gift_Months(product.months) } - let discountValue = Int((1.0 - Float(product.storeProduct.priceCurrencyAndAmount.amount) / Float(product.months) / Float(shortestOptionPrice)) * 100.0) + let discountValue = Int((1.0 - Float(product.storeProduct.priceCurrencyAndAmount.amount) / Float(product.months) / Float(shortestOptionPrice.0)) * 100.0) let discount: String if discountValue > 0 { discount = "-\(discountValue)%" @@ -257,15 +257,23 @@ private final class PremiumGiftScreenContentComponent: CombinedComponent { discount = "" } - let pricePerMonth = product.storeProduct.pricePerMonth(Int(product.months)) + let defaultPrice = product.storeProduct.defaultPrice(shortestOptionPrice.1, monthsCount: Int(product.months)) + var subtitle = "" + var pricePerMonth = product.storeProduct.pricePerMonth(Int(product.months)) + pricePerMonth = environment.strings.Premium_PricePerMonth(pricePerMonth).string + + if discountValue > 0 { + subtitle = "**\(defaultPrice)** \(product.price)" + } + items.append(SectionGroupComponent.Item( AnyComponentWithIdentity( id: product.id, component: AnyComponent( PremiumOptionComponent( title: giftTitle, - subtitle: product.price, + subtitle: subtitle, labelPrice: pricePerMonth, discount: discount, selected: product.id == component.selectedProductId, diff --git a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift index 83a7196038..732f2a3428 100644 --- a/submodules/PremiumUI/Sources/PremiumIntroScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumIntroScreen.swift @@ -1285,7 +1285,7 @@ private final class PremiumIntroScreenContentComponent: CombinedComponent { if months > 1 { pricePerMonth = product.pricePerMonth(Int(months)) - if defaultPrice != product.price { + if discountValue > 0 { subtitle = "**\(defaultPrice)** \(product.price)" if months == 12 { subtitle = environment.strings.Premium_PricePerYear(subtitle).string diff --git a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift index 6a7e2615c5..8db8d65b7d 100644 --- a/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift +++ b/submodules/SettingsUI/Sources/Privacy and Security/PrivacyAndSecurityController.swift @@ -472,7 +472,9 @@ private func privacyAndSecurityControllerEntries( } entries.append(.twoStepVerification(presentationData.theme, presentationData.strings.PrivacySettings_TwoStepAuth, twoStepAuthString, twoStepAuthData)) + if loginEmail != nil { entries.append(.loginEmail(presentationData.theme, presentationData.strings.PrivacySettings_LoginEmail, loginEmail)) + } entries.append(.privacyHeader(presentationData.theme, presentationData.strings.PrivacySettings_PrivacyTitle)) if let privacySettings = privacySettings {