mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-22 22:25:57 +00:00
Paid media improvements
This commit is contained in:
@@ -12418,5 +12418,10 @@ Sorry for the inconvenience.";
|
||||
"Monetization.Balance.StarsInfo" = "You can withdraw Stars using Fragment, or use Stars to advertise your channel. [Learn More >]()";
|
||||
"Monetization.Balance.StarsInfo_URL" = "https://telegram.org";
|
||||
|
||||
"Monetization.StarsProceeds.Title" = "Rewards Overview";
|
||||
"Monetization.StarsProceeds.Available" = "Available Balance";
|
||||
"Monetization.StarsProceeds.Current" = "Total Balance";
|
||||
"Monetization.StarsProceeds.Total" = "Lifetime Proceeds";
|
||||
|
||||
"Premium.MessageEffects" = "Message Effects";
|
||||
"Premium.MessageEffectsInfo" = "Add over 500 animated effects to private messages.";
|
||||
|
||||
@@ -38,6 +38,11 @@ func formatBalanceText(_ value: Int64, decimalSeparator: String, showPlus: Bool
|
||||
} else if showPlus {
|
||||
balanceText.insert("+", at: balanceText.startIndex)
|
||||
}
|
||||
|
||||
if let dec = balanceText.range(of: decimalSeparator) {
|
||||
balanceText = String(balanceText[balanceText.startIndex ..< min(balanceText.endIndex, balanceText.index(dec.upperBound, offsetBy: 2))])
|
||||
}
|
||||
|
||||
return balanceText
|
||||
}
|
||||
|
||||
|
||||
@@ -211,19 +211,6 @@ private final class ValueItemNode: ASDisplayNode {
|
||||
|
||||
let (deltaLayout, deltaApply) = makeDeltaLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: delta?.0 ?? "", font: deltaFont, textColor: deltaColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: constrainedSize, alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let horizontalSpacing: CGFloat = 4.0
|
||||
let size = CGSize(width: valueLayout.size.width + horizontalSpacing + deltaLayout.size.width, height: valueLayout.size.height + titleLayout.size.height)
|
||||
return (size, {
|
||||
var themeUpdated = false
|
||||
if targetNode.currentTheme !== presentationData.theme {
|
||||
themeUpdated = true
|
||||
}
|
||||
targetNode.currentTheme = presentationData.theme
|
||||
|
||||
let _ = valueApply()
|
||||
let _ = titleApply()
|
||||
let _ = deltaApply()
|
||||
|
||||
var valueOffset: CGFloat = 0.0
|
||||
let iconName: String?
|
||||
var iconTinted = false
|
||||
@@ -239,6 +226,22 @@ private final class ValueItemNode: ASDisplayNode {
|
||||
iconName = nil
|
||||
}
|
||||
|
||||
let horizontalSpacing: CGFloat = 4.0
|
||||
let size = CGSize(
|
||||
width: max(valueOffset + valueLayout.size.width + horizontalSpacing + deltaLayout.size.width, titleLayout.size.width),
|
||||
height: valueLayout.size.height + titleLayout.size.height
|
||||
)
|
||||
return (size, {
|
||||
var themeUpdated = false
|
||||
if targetNode.currentTheme !== presentationData.theme {
|
||||
themeUpdated = true
|
||||
}
|
||||
targetNode.currentTheme = presentationData.theme
|
||||
|
||||
let _ = valueApply()
|
||||
let _ = titleApply()
|
||||
let _ = deltaApply()
|
||||
|
||||
var iconNameUpdated = false
|
||||
if targetNode.currentIconName != iconName {
|
||||
targetNode.currentIconName = iconName
|
||||
@@ -385,6 +388,7 @@ class StatsOverviewItemNode: ListViewItemNode {
|
||||
}
|
||||
|
||||
var twoColumnLayout = true
|
||||
var useMinLeftColumnWidth = true
|
||||
|
||||
var topLeftItemLayoutAndApply: (CGSize, () -> ValueItemNode)?
|
||||
var topRightItemLayoutAndApply: (CGSize, () -> ValueItemNode)?
|
||||
@@ -761,13 +765,14 @@ class StatsOverviewItemNode: ListViewItemNode {
|
||||
} else if let stats = item.stats as? RevenueStats {
|
||||
if let additionalStats = item.additionalStats as? StarsRevenueStats, additionalStats.balances.overallRevenue > 0 {
|
||||
twoColumnLayout = true
|
||||
useMinLeftColumnWidth = true
|
||||
|
||||
topLeftItemLayoutAndApply = makeTopLeftItemLayout(
|
||||
item.context,
|
||||
params.width,
|
||||
item.presentationData,
|
||||
formatBalanceText(stats.balances.availableBalance, decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator),
|
||||
"Available Balance", //item.presentationData.strings.Monetization_Overview_Available,
|
||||
item.presentationData.strings.Monetization_StarsProceeds_Available,
|
||||
(stats.balances.availableBalance == 0 ? "" : "≈\(formatUsdValue(stats.balances.availableBalance, rate: stats.usdRate))", .generic),
|
||||
.ton
|
||||
)
|
||||
@@ -777,7 +782,7 @@ class StatsOverviewItemNode: ListViewItemNode {
|
||||
params.width,
|
||||
item.presentationData,
|
||||
formatBalanceText(stats.balances.currentBalance, decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator),
|
||||
"Current Balance", //item.presentationData.strings.Monetization_Overview_Current,
|
||||
item.presentationData.strings.Monetization_StarsProceeds_Current,
|
||||
(stats.balances.currentBalance == 0 ? "" : "≈\(formatUsdValue(stats.balances.currentBalance, rate: stats.usdRate))", .generic),
|
||||
.ton
|
||||
)
|
||||
@@ -787,7 +792,7 @@ class StatsOverviewItemNode: ListViewItemNode {
|
||||
params.width,
|
||||
item.presentationData,
|
||||
formatBalanceText(stats.balances.overallRevenue, decimalSeparator: item.presentationData.dateTimeFormat.decimalSeparator),
|
||||
"Lifetime Proceeds",//item.presentationData.strings.Monetization_Overview_Total,
|
||||
item.presentationData.strings.Monetization_StarsProceeds_Total,
|
||||
(stats.balances.overallRevenue == 0 ? "" : "≈\(formatUsdValue(stats.balances.overallRevenue, rate: stats.usdRate))", .generic),
|
||||
.ton
|
||||
)
|
||||
@@ -957,8 +962,12 @@ class StatsOverviewItemNode: ListViewItemNode {
|
||||
if let bottomLeftItemLayout = bottomLeftItemLayoutAndApply?.0 {
|
||||
maxLeftWidth = max(maxLeftWidth, bottomLeftItemLayout.width)
|
||||
}
|
||||
if useMinLeftColumnWidth {
|
||||
secondColumnX = min(layout.size.width / 2.0, firstColumnX + maxLeftWidth + horizontalSpacing * 3.0)
|
||||
} else {
|
||||
secondColumnX = max(layout.size.width / 2.0, firstColumnX + maxLeftWidth + horizontalSpacing)
|
||||
}
|
||||
}
|
||||
|
||||
if let topLeftItemLayout = topLeftItemLayoutAndApply?.0 {
|
||||
strongSelf.topLeftItem.frame = CGRect(origin: CGPoint(x: firstColumnX, y: topInset), size: topLeftItemLayout)
|
||||
|
||||
@@ -55,7 +55,6 @@ public enum MessageContentKind: Equatable {
|
||||
case invoice(String)
|
||||
case story
|
||||
case giveaway
|
||||
case paidContent
|
||||
|
||||
public func isSemanticallyEqual(to other: MessageContentKind) -> Bool {
|
||||
switch self {
|
||||
@@ -191,12 +190,6 @@ public enum MessageContentKind: Equatable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .paidContent:
|
||||
if case .paidContent = other {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -246,8 +239,6 @@ public enum MessageContentKind: Equatable {
|
||||
return .story
|
||||
case .giveaway:
|
||||
return .giveaway
|
||||
case .paidContent:
|
||||
return .paidContent
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -396,6 +387,25 @@ public func mediaContentKind(_ media: EngineMedia, message: EngineMessage? = nil
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
case let .paidContent(paidContent):
|
||||
switch paidContent.extendedMedia.first {
|
||||
case let .preview(_, _, videoDuration):
|
||||
if let _ = videoDuration {
|
||||
return .video
|
||||
} else {
|
||||
return .image
|
||||
}
|
||||
case let .full(media):
|
||||
if media is TelegramMediaImage {
|
||||
return .image
|
||||
} else if media is TelegramMediaFile {
|
||||
return .video
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
@@ -455,8 +465,6 @@ public func stringForMediaKind(_ kind: MessageContentKind, strings: Presentation
|
||||
return (NSAttributedString(string: strings.Message_Story), true)
|
||||
case .giveaway:
|
||||
return (NSAttributedString(string: strings.Message_Giveaway), true)
|
||||
case .paidContent:
|
||||
return (NSAttributedString(string: "Paid Media"), true)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -382,7 +382,13 @@ public final class StarsImageComponent: Component {
|
||||
largeParticlesView.update(size: availableSize)
|
||||
largeParticlesView.frame = CGRect(origin: .zero, size: availableSize)
|
||||
|
||||
let imageSize = CGSize(width: component.diameter, height: component.diameter)
|
||||
var imageSize = CGSize(width: component.diameter, height: component.diameter)
|
||||
if case let .media(media) = component.subject, media.count > 1 {
|
||||
imageSize = CGSize(width: component.diameter - 6.0, height: component.diameter - 6.0)
|
||||
} else if case let .extendedMedia(media) = component.subject, media.count > 1 {
|
||||
imageSize = CGSize(width: component.diameter - 6.0, height: component.diameter - 6.0)
|
||||
}
|
||||
|
||||
let imageFrame = CGRect(origin: CGPoint(x: floorToScreenPixels((availableSize.width - imageSize.width) / 2.0), y: floorToScreenPixels((availableSize.height - imageSize.height) / 2.0)), size: imageSize)
|
||||
|
||||
switch component.subject {
|
||||
|
||||
@@ -623,6 +623,7 @@ private final class AmountFieldComponent: Component {
|
||||
|
||||
if let amount, let maxAmount = component.maxValue, amount > maxAmount {
|
||||
textField.text = "\(maxAmount)"
|
||||
self.textChanged(self.textField)
|
||||
self.animateError()
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -654,9 +654,7 @@ final class ChatPinnedMessageTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
}
|
||||
break
|
||||
} else if let file = fullMedia as? TelegramMediaFile {
|
||||
if !file.isInstantVideo && !file.isSticker, let representation = largestImageRepresentation(file.previewRepresentations) {
|
||||
imageDimensions = representation.dimensions.cgSize
|
||||
} else if file.isAnimated, let dimensions = file.dimensions {
|
||||
if let dimensions = file.dimensions {
|
||||
imageDimensions = dimensions.cgSize
|
||||
}
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user