mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Stars giveaways
This commit is contained in:
parent
1867308531
commit
df62e25f5a
@ -12844,3 +12844,10 @@ Sorry for the inconvenience.";
|
||||
"Chat.Giveaway.Info.Stars.EndedIntro" = "The giveaway was sponsored by the admins of **%1$@**, who acquired %2$@ for its followers.";
|
||||
"Chat.Giveaway.Info.Stars.Group.OngoingIntro" = "The giveaway is sponsored by the admins of **%1$@**, who acquired %2$@ for its members.";
|
||||
"Chat.Giveaway.Info.Stars.Group.EndedIntro" = "The giveaway was sponsored by the admins of **%1$@**, who acquired %2$@ for its members.";
|
||||
|
||||
"Stars.Transaction.Giveaway.Title" = "Received Prize";
|
||||
"Stars.Transaction.Giveaway.Reason" = "Reason";
|
||||
"Stars.Transaction.Giveaway.Giveaway" = "Giveaway";
|
||||
"Stars.Transaction.Giveaway.Prize" = "Prize";
|
||||
"Stars.Transaction.Giveaway.Stars_1" = "%@ Star";
|
||||
"Stars.Transaction.Giveaway.Stars_any" = "%@ Stars";
|
||||
|
@ -1576,7 +1576,7 @@ private func monetizationEntries(
|
||||
|
||||
if canViewRevenue {
|
||||
entries.append(.adsTonBalanceTitle(presentationData.theme, presentationData.strings.Monetization_TonBalanceTitle))
|
||||
entries.append(.adsTonBalance(presentationData.theme, data, isCreator && data.balances.availableBalance > 0, monetizationConfiguration.withdrawalAvailable))
|
||||
entries.append(.adsTonBalance(presentationData.theme, data, isCreator && data.balances.availableBalance > 0, data.balances.withdrawEnabled))
|
||||
|
||||
if isCreator {
|
||||
let withdrawalInfoText: String
|
||||
|
@ -106,7 +106,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1113113093] = { return Api.BotMenuButton.parse_botMenuButtonCommands($0) }
|
||||
dict[1966318984] = { return Api.BotMenuButton.parse_botMenuButtonDefault($0) }
|
||||
dict[602479523] = { return Api.BotPreviewMedia.parse_botPreviewMedia($0) }
|
||||
dict[-2076642874] = { return Api.BroadcastRevenueBalances.parse_broadcastRevenueBalances($0) }
|
||||
dict[-1006669337] = { return Api.BroadcastRevenueBalances.parse_broadcastRevenueBalances($0) }
|
||||
dict[1434332356] = { return Api.BroadcastRevenueTransaction.parse_broadcastRevenueTransactionProceeds($0) }
|
||||
dict[1121127726] = { return Api.BroadcastRevenueTransaction.parse_broadcastRevenueTransactionRefund($0) }
|
||||
dict[1515784568] = { return Api.BroadcastRevenueTransaction.parse_broadcastRevenueTransactionWithdrawal($0) }
|
||||
|
@ -772,14 +772,15 @@ public extension Api {
|
||||
}
|
||||
public extension Api {
|
||||
enum BroadcastRevenueBalances: TypeConstructorDescription {
|
||||
case broadcastRevenueBalances(currentBalance: Int64, availableBalance: Int64, overallRevenue: Int64)
|
||||
case broadcastRevenueBalances(flags: Int32, currentBalance: Int64, availableBalance: Int64, overallRevenue: Int64)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .broadcastRevenueBalances(let currentBalance, let availableBalance, let overallRevenue):
|
||||
case .broadcastRevenueBalances(let flags, let currentBalance, let availableBalance, let overallRevenue):
|
||||
if boxed {
|
||||
buffer.appendInt32(-2076642874)
|
||||
buffer.appendInt32(-1006669337)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(currentBalance, buffer: buffer, boxed: false)
|
||||
serializeInt64(availableBalance, buffer: buffer, boxed: false)
|
||||
serializeInt64(overallRevenue, buffer: buffer, boxed: false)
|
||||
@ -789,23 +790,26 @@ public extension Api {
|
||||
|
||||
public func descriptionFields() -> (String, [(String, Any)]) {
|
||||
switch self {
|
||||
case .broadcastRevenueBalances(let currentBalance, let availableBalance, let overallRevenue):
|
||||
return ("broadcastRevenueBalances", [("currentBalance", currentBalance as Any), ("availableBalance", availableBalance as Any), ("overallRevenue", overallRevenue as Any)])
|
||||
case .broadcastRevenueBalances(let flags, let currentBalance, let availableBalance, let overallRevenue):
|
||||
return ("broadcastRevenueBalances", [("flags", flags as Any), ("currentBalance", currentBalance as Any), ("availableBalance", availableBalance as Any), ("overallRevenue", overallRevenue as Any)])
|
||||
}
|
||||
}
|
||||
|
||||
public static func parse_broadcastRevenueBalances(_ reader: BufferReader) -> BroadcastRevenueBalances? {
|
||||
var _1: Int64?
|
||||
_1 = reader.readInt64()
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int64?
|
||||
_3 = reader.readInt64()
|
||||
var _4: Int64?
|
||||
_4 = reader.readInt64()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.BroadcastRevenueBalances.broadcastRevenueBalances(currentBalance: _1!, availableBalance: _2!, overallRevenue: _3!)
|
||||
let _c4 = _4 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 {
|
||||
return Api.BroadcastRevenueBalances.broadcastRevenueBalances(flags: _1!, currentBalance: _2!, availableBalance: _3!, overallRevenue: _4!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -23,20 +23,24 @@ public struct RevenueStats: Equatable, Codable {
|
||||
case currentBalance
|
||||
case availableBalance
|
||||
case overallRevenue
|
||||
case withdrawEnabled
|
||||
}
|
||||
|
||||
public let currentBalance: Int64
|
||||
public let availableBalance: Int64
|
||||
public let overallRevenue: Int64
|
||||
public let withdrawEnabled: Bool
|
||||
|
||||
init(
|
||||
currentBalance: Int64,
|
||||
availableBalance: Int64,
|
||||
overallRevenue: Int64
|
||||
overallRevenue: Int64,
|
||||
withdrawEnabled: Bool
|
||||
) {
|
||||
self.currentBalance = currentBalance
|
||||
self.availableBalance = availableBalance
|
||||
self.overallRevenue = overallRevenue
|
||||
self.withdrawEnabled = withdrawEnabled
|
||||
}
|
||||
|
||||
public init(from decoder: Decoder) throws {
|
||||
@ -44,6 +48,7 @@ public struct RevenueStats: Equatable, Codable {
|
||||
self.currentBalance = try container.decode(Int64.self, forKey: .currentBalance)
|
||||
self.availableBalance = try container.decode(Int64.self, forKey: .availableBalance)
|
||||
self.overallRevenue = try container.decode(Int64.self, forKey: .overallRevenue)
|
||||
self.withdrawEnabled = try container.decode(Bool.self, forKey: .withdrawEnabled)
|
||||
}
|
||||
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
@ -51,6 +56,7 @@ public struct RevenueStats: Equatable, Codable {
|
||||
try container.encode(self.currentBalance, forKey: .currentBalance)
|
||||
try container.encode(self.availableBalance, forKey: .availableBalance)
|
||||
try container.encode(self.overallRevenue, forKey: .overallRevenue)
|
||||
try container.encode(self.withdrawEnabled, forKey: .withdrawEnabled)
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,8 +128,8 @@ extension RevenueStats {
|
||||
extension RevenueStats.Balances {
|
||||
init(apiRevenueBalances: Api.BroadcastRevenueBalances) {
|
||||
switch apiRevenueBalances {
|
||||
case let .broadcastRevenueBalances(currentBalance, availableBalance, overallRevenue):
|
||||
self.init(currentBalance: currentBalance, availableBalance: availableBalance, overallRevenue: overallRevenue)
|
||||
case let .broadcastRevenueBalances(flags, currentBalance, availableBalance, overallRevenue):
|
||||
self.init(currentBalance: currentBalance, availableBalance: availableBalance, overallRevenue: overallRevenue, withdrawEnabled: ((flags & (1 << 0)) != 0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -300,7 +300,18 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
||||
}
|
||||
}
|
||||
case let .transaction(transaction, parentPeer):
|
||||
if let _ = transaction.subscriptionPeriod {
|
||||
if let giveawayMessageIdValue = transaction.giveawayMessageId {
|
||||
titleText = strings.Stars_Transaction_Giveaway_Title
|
||||
descriptionText = ""
|
||||
count = transaction.count
|
||||
transactionId = transaction.id
|
||||
date = transaction.date
|
||||
giveawayMessageId = giveawayMessageIdValue
|
||||
if case let .peer(peer) = transaction.peer {
|
||||
toPeer = peer
|
||||
}
|
||||
transactionPeer = transaction.peer
|
||||
} else if let _ = transaction.subscriptionPeriod {
|
||||
titleText = strings.Stars_Transaction_SubscriptionFee
|
||||
descriptionText = ""
|
||||
count = transaction.count
|
||||
@ -447,11 +458,11 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
||||
toPeer = state.peerMap[message.id.peerId]
|
||||
}
|
||||
} else if case let .prizeStars(countValue, _, boostPeerId, _, giveawayMessageIdValue) = action.action {
|
||||
titleText = "Received Prize"
|
||||
titleText = strings.Stars_Transaction_Giveaway_Title
|
||||
|
||||
count = countValue
|
||||
countOnTop = true
|
||||
transactionId = nil//transactionIdValue
|
||||
transactionId = nil
|
||||
giveawayMessageId = giveawayMessageIdValue
|
||||
if let boostPeerId {
|
||||
toPeer = state.peerMap[boostPeerId]
|
||||
@ -526,7 +537,7 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
||||
} else {
|
||||
imageSubject = .none
|
||||
}
|
||||
if isSubscription || isSubscriber || isSubscriptionFee {
|
||||
if isSubscription || isSubscriber || isSubscriptionFee || giveawayMessageId != nil {
|
||||
imageIcon = .star
|
||||
} else {
|
||||
imageIcon = nil
|
||||
@ -646,19 +657,19 @@ private final class StarsTransactionSheetContent: CombinedComponent {
|
||||
if let giveawayMessageId {
|
||||
tableItems.append(.init(
|
||||
id: "prize",
|
||||
title: "Prize",
|
||||
title: strings.Stars_Transaction_Giveaway_Prize,
|
||||
component: AnyComponent(
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: "\(count) Stars", font: tableFont, textColor: tableTextColor)))
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: strings.Stars_Transaction_Giveaway_Stars(Int32(count)), font: tableFont, textColor: tableTextColor)))
|
||||
)
|
||||
))
|
||||
|
||||
tableItems.append(.init(
|
||||
id: "reason",
|
||||
title: "Reason",
|
||||
title: strings.Stars_Transaction_Giveaway_Reason,
|
||||
component: AnyComponent(
|
||||
Button(
|
||||
content: AnyComponent(
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: "Giveaway", font: tableFont, textColor: tableLinkColor)))
|
||||
MultilineTextComponent(text: .plain(NSAttributedString(string: strings.Stars_Transaction_Giveaway_Giveaway, font: tableFont, textColor: tableLinkColor)))
|
||||
),
|
||||
action: {
|
||||
component.openMessage(giveawayMessageId)
|
||||
|
Loading…
x
Reference in New Issue
Block a user