mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 14:20:20 +00:00
Various improvements
This commit is contained in:
@@ -371,7 +371,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
} else {
|
||||
fatalError()
|
||||
}
|
||||
case let .starGift(starGift):
|
||||
case let .starGift(starGift, _):
|
||||
finalPrice = starGift.price
|
||||
if self.includeUpgrade, let upgradeStars = starGift.upgradeStars {
|
||||
finalPrice += upgradeStars
|
||||
@@ -403,7 +403,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
return
|
||||
}
|
||||
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel, case let .starGift(starGift) = component.subject {
|
||||
if peerId.namespace == Namespaces.Peer.CloudChannel, case let .starGift(starGift, _) = component.subject {
|
||||
var controllers = navigationController.viewControllers
|
||||
controllers = controllers.filter { !($0 is GiftSetupScreen) && !($0 is GiftOptionsScreenProtocol) }
|
||||
navigationController.setViewControllers(controllers, animated: true)
|
||||
@@ -555,6 +555,10 @@ final class GiftSetupScreenComponent: Component {
|
||||
self.hideName = true
|
||||
}
|
||||
|
||||
if case let .starGift(gift, true) = component.subject, gift.upgradeStars != nil {
|
||||
self.includeUpgrade = true
|
||||
}
|
||||
|
||||
let _ = (component.context.engine.data.get(
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: component.peerId),
|
||||
TelegramEngine.EngineData.Item.Peer.Peer(id: component.context.account.peerId),
|
||||
@@ -684,7 +688,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
self.options = options
|
||||
})
|
||||
|
||||
if case let .starGift(gift) = component.subject {
|
||||
if case let .starGift(gift, _) = component.subject {
|
||||
if let _ = gift.upgradeStars {
|
||||
self.previewPromise.set(
|
||||
component.context.engine.payments.starGiftUpgradePreview(giftId: gift.id)
|
||||
@@ -742,7 +746,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
contentHeight += environment.navigationHeight
|
||||
contentHeight += 26.0
|
||||
|
||||
if case let .starGift(starGift) = component.subject, let availability = starGift.availability {
|
||||
if case let .starGift(starGift, _) = component.subject, let availability = starGift.availability {
|
||||
let remains: Int32 = availability.remains
|
||||
let total: Int32 = availability.total
|
||||
let position = CGFloat(remains) / CGFloat(total)
|
||||
@@ -909,7 +913,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
let (currency, amount) = product.storeProduct?.priceCurrencyAndAmount ?? ("USD", 1)
|
||||
subject = .premium(months: product.months, amount: amount, currency: currency)
|
||||
}
|
||||
case let .starGift(gift):
|
||||
case let .starGift(gift, _):
|
||||
subject = .starGift(gift: gift)
|
||||
upgradeStars = gift.upgradeStars
|
||||
}
|
||||
@@ -1061,13 +1065,17 @@ final class GiftSetupScreenComponent: Component {
|
||||
contentHeight += starsSectionSize.height
|
||||
contentHeight += sectionSpacing
|
||||
}
|
||||
case let .starGift(gift):
|
||||
case let .starGift(gift, forceUnique):
|
||||
if let upgradeStars = gift.upgradeStars, component.peerId != component.context.account.peerId {
|
||||
let upgradeFooterRawString: String
|
||||
if isChannelGift {
|
||||
upgradeFooterRawString = environment.strings.Gift_SendChannel_Upgrade_Info(peerName).string
|
||||
} else {
|
||||
upgradeFooterRawString = environment.strings.Gift_Send_Upgrade_Info(peerName).string
|
||||
if forceUnique {
|
||||
upgradeFooterRawString = environment.strings.Gift_Send_Upgrade_ForcedInfo(peerName).string
|
||||
} else {
|
||||
upgradeFooterRawString = environment.strings.Gift_Send_Upgrade_Info(peerName).string
|
||||
}
|
||||
}
|
||||
let parsedString = parseMarkdownIntoAttributedString(upgradeFooterRawString, attributes: footerAttributes)
|
||||
|
||||
@@ -1136,8 +1144,8 @@ final class GiftSetupScreenComponent: Component {
|
||||
)
|
||||
)),
|
||||
], alignment: .left, spacing: 2.0)),
|
||||
accessory: .toggle(ListActionItemComponent.Toggle(style: .regular, isOn: self.includeUpgrade, action: { [weak self] _ in
|
||||
guard let self else {
|
||||
accessory: .toggle(ListActionItemComponent.Toggle(style: .regular, isOn: self.includeUpgrade, isEnabled: !forceUnique, action: { [weak self] _ in
|
||||
guard let self, !forceUnique else {
|
||||
return
|
||||
}
|
||||
self.includeUpgrade = !self.includeUpgrade
|
||||
@@ -1263,7 +1271,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
let amountString = product.price
|
||||
buttonString = "\(environment.strings.Gift_Send_Send) \(amountString)"
|
||||
}
|
||||
case let .starGift(starGift):
|
||||
case let .starGift(starGift, _):
|
||||
var finalPrice: Int64 = starGift.price
|
||||
if self.includeUpgrade, let upgradePrice = starGift.upgradeStars {
|
||||
finalPrice += upgradePrice
|
||||
@@ -1685,7 +1693,7 @@ final class GiftSetupScreenComponent: Component {
|
||||
public final class GiftSetupScreen: ViewControllerComponentContainer {
|
||||
public enum Subject: Equatable {
|
||||
case premium(PremiumGiftProduct)
|
||||
case starGift(StarGift.Gift)
|
||||
case starGift(StarGift.Gift, Bool)
|
||||
}
|
||||
|
||||
private let context: AccountContext
|
||||
|
||||
Reference in New Issue
Block a user