mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-11-07 09:20:08 +00:00
Merge commit '689a5e04277ef6cfedb53e99cc563e86d7a9c97a'
This commit is contained in:
commit
64076541cd
@ -13,6 +13,18 @@ private let productIdentifiers = [
|
|||||||
"org.telegram.telegramPremium.threeMonths"
|
"org.telegram.telegramPremium.threeMonths"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
private extension NSDecimalNumber {
|
||||||
|
func round(_ decimals: Int) -> NSDecimalNumber {
|
||||||
|
return self.rounding(accordingToBehavior:
|
||||||
|
NSDecimalNumberHandler(roundingMode: .down,
|
||||||
|
scale: Int16(decimals),
|
||||||
|
raiseOnExactness: false,
|
||||||
|
raiseOnOverflow: false,
|
||||||
|
raiseOnUnderflow: false,
|
||||||
|
raiseOnDivideByZero: false))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public final class InAppPurchaseManager: NSObject {
|
public final class InAppPurchaseManager: NSObject {
|
||||||
public final class Product: Equatable {
|
public final class Product: Equatable {
|
||||||
private lazy var numberFormatter: NumberFormatter = {
|
private lazy var numberFormatter: NumberFormatter = {
|
||||||
@ -47,7 +59,7 @@ public final class InAppPurchaseManager: NSObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func pricePerMonth(_ monthsCount: Int) -> String {
|
public func pricePerMonth(_ monthsCount: Int) -> String {
|
||||||
let price = self.skProduct.price.dividing(by: NSDecimalNumber(value: monthsCount))
|
let price = self.skProduct.price.dividing(by: NSDecimalNumber(value: monthsCount)).round(2)
|
||||||
return self.numberFormatter.string(from: price) ?? ""
|
return self.numberFormatter.string(from: price) ?? ""
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +69,7 @@ public final class InAppPurchaseManager: NSObject {
|
|||||||
|
|
||||||
public var priceCurrencyAndAmount: (currency: String, amount: Int64) {
|
public var priceCurrencyAndAmount: (currency: String, amount: Int64) {
|
||||||
if let currencyCode = self.numberFormatter.currencyCode,
|
if let currencyCode = self.numberFormatter.currencyCode,
|
||||||
let amount = fractionalToCurrencyAmount(value: self.priceValue.doubleValue, currency: currencyCode) {
|
let amount = fractionalToCurrencyAmount(value: self.priceValue.doubleValue, currency: currencyCode) {
|
||||||
return (currencyCode, amount)
|
return (currencyCode, amount)
|
||||||
} else {
|
} else {
|
||||||
return ("", 0)
|
return ("", 0)
|
||||||
|
|||||||
@ -1259,7 +1259,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
if let undoOverlayController = strongSelf.undoOverlayController {
|
if let undoOverlayController = strongSelf.undoOverlayController {
|
||||||
undoOverlayController.content = .image(image: image ?? UIImage(), text: text)
|
undoOverlayController.content = .image(image: image ?? UIImage(), text: text)
|
||||||
} else {
|
} else {
|
||||||
let undoOverlayController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: false, action: { [weak self] action in
|
var elevatedLayout = true
|
||||||
|
if let layout = strongSelf.validLayout, case .regular = layout.metrics.widthClass {
|
||||||
|
elevatedLayout = false
|
||||||
|
}
|
||||||
|
let undoOverlayController = UndoOverlayController(presentationData: presentationData, content: .image(image: image ?? UIImage(), text: text), elevatedLayout: elevatedLayout, action: { [weak self] action in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -1271,7 +1275,11 @@ public final class MediaPickerScreen: ViewController, AttachmentContainable {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
strongSelf.present(undoOverlayController, in: .current)
|
if let layout = strongSelf.validLayout, case .regular = layout.metrics.widthClass {
|
||||||
|
strongSelf.present(undoOverlayController, in: .current)
|
||||||
|
} else {
|
||||||
|
strongSelf.present(undoOverlayController, in: .window(.root))
|
||||||
|
}
|
||||||
strongSelf.undoOverlayController = undoOverlayController
|
strongSelf.undoOverlayController = undoOverlayController
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user