Update API

This commit is contained in:
Ilya Laktyushin 2022-06-12 19:57:24 +04:00
parent 876687fa32
commit 1260c83b2e
11 changed files with 91 additions and 50 deletions

View File

@ -7729,3 +7729,5 @@ Sorry for the inconvenience.";
"Settings.Premium" = "Telegram Premium"; "Settings.Premium" = "Telegram Premium";
"Settings.AddAnotherAccount.PremiumHelp" = "You can add up to four accounts with different phone numbers."; "Settings.AddAnotherAccount.PremiumHelp" = "You can add up to four accounts with different phone numbers.";
"Stickers.TrendingPremiumStickers" = "Trending Premium Stickers";

View File

@ -955,7 +955,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1111085620] = { return Api.messages.ExportedChatInvites.parse_exportedChatInvites($0) } dict[-1111085620] = { return Api.messages.ExportedChatInvites.parse_exportedChatInvites($0) }
dict[750063767] = { return Api.messages.FavedStickers.parse_favedStickers($0) } dict[750063767] = { return Api.messages.FavedStickers.parse_favedStickers($0) }
dict[-1634752813] = { return Api.messages.FavedStickers.parse_favedStickersNotModified($0) } dict[-1634752813] = { return Api.messages.FavedStickers.parse_favedStickersNotModified($0) }
dict[-2067782896] = { return Api.messages.FeaturedStickers.parse_featuredStickers($0) } dict[-1103615738] = { return Api.messages.FeaturedStickers.parse_featuredStickers($0) }
dict[-958657434] = { return Api.messages.FeaturedStickers.parse_featuredStickersNotModified($0) } dict[-958657434] = { return Api.messages.FeaturedStickers.parse_featuredStickersNotModified($0) }
dict[-1963942446] = { return Api.messages.FoundStickerSets.parse_foundStickerSets($0) } dict[-1963942446] = { return Api.messages.FoundStickerSets.parse_foundStickerSets($0) }
dict[223655517] = { return Api.messages.FoundStickerSets.parse_foundStickerSetsNotModified($0) } dict[223655517] = { return Api.messages.FoundStickerSets.parse_foundStickerSetsNotModified($0) }

View File

@ -548,15 +548,16 @@ public extension Api.messages {
} }
public extension Api.messages { public extension Api.messages {
enum FeaturedStickers: TypeConstructorDescription { enum FeaturedStickers: TypeConstructorDescription {
case featuredStickers(hash: Int64, count: Int32, sets: [Api.StickerSetCovered], unread: [Int64]) case featuredStickers(flags: Int32, hash: Int64, count: Int32, sets: [Api.StickerSetCovered], unread: [Int64])
case featuredStickersNotModified(count: Int32) case featuredStickersNotModified(count: Int32)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .featuredStickers(let hash, let count, let sets, let unread): case .featuredStickers(let flags, let hash, let count, let sets, let unread):
if boxed { if boxed {
buffer.appendInt32(-2067782896) buffer.appendInt32(-1103615738)
} }
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt64(hash, buffer: buffer, boxed: false) serializeInt64(hash, buffer: buffer, boxed: false)
serializeInt32(count, buffer: buffer, boxed: false) serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
@ -581,32 +582,35 @@ public extension Api.messages {
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .featuredStickers(let hash, let count, let sets, let unread): case .featuredStickers(let flags, let hash, let count, let sets, let unread):
return ("featuredStickers", [("hash", String(describing: hash)), ("count", String(describing: count)), ("sets", String(describing: sets)), ("unread", String(describing: unread))]) return ("featuredStickers", [("flags", String(describing: flags)), ("hash", String(describing: hash)), ("count", String(describing: count)), ("sets", String(describing: sets)), ("unread", String(describing: unread))])
case .featuredStickersNotModified(let count): case .featuredStickersNotModified(let count):
return ("featuredStickersNotModified", [("count", String(describing: count))]) return ("featuredStickersNotModified", [("count", String(describing: count))])
} }
} }
public static func parse_featuredStickers(_ reader: BufferReader) -> FeaturedStickers? { public static func parse_featuredStickers(_ reader: BufferReader) -> FeaturedStickers? {
var _1: Int64? var _1: Int32?
_1 = reader.readInt64() _1 = reader.readInt32()
var _2: Int32? var _2: Int64?
_2 = reader.readInt32() _2 = reader.readInt64()
var _3: [Api.StickerSetCovered]? var _3: Int32?
_3 = reader.readInt32()
var _4: [Api.StickerSetCovered]?
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSetCovered.self) _4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerSetCovered.self)
} }
var _4: [Int64]? var _5: [Int64]?
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self) _5 = Api.parseVector(reader, elementSignature: 570911930, elementType: Int64.self)
} }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = _4 != nil let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 { let _c5 = _5 != nil
return Api.messages.FeaturedStickers.featuredStickers(hash: _1!, count: _2!, sets: _3!, unread: _4!) if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.messages.FeaturedStickers.featuredStickers(flags: _1!, hash: _2!, count: _3!, sets: _4!, unread: _5!)
} }
else { else {
return nil return nil

View File

@ -6382,21 +6382,6 @@ public extension Api.functions.payments {
}) })
} }
} }
public extension Api.functions.payments {
static func restorePlayMarketReceipt(receipt: Buffer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
let buffer = Buffer()
buffer.appendInt32(-781917334)
serializeBytes(receipt, buffer: buffer, boxed: false)
return (FunctionDescription(name: "payments.restorePlayMarketReceipt", parameters: [("receipt", String(describing: receipt))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
let reader = BufferReader(buffer)
var result: Api.Updates?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Updates
}
return result
})
}
}
public extension Api.functions.payments { public extension Api.functions.payments {
static func sendPaymentForm(flags: Int32, formId: Int64, invoice: Api.InputInvoice, requestedInfoId: String?, shippingOptionId: String?, credentials: Api.InputPaymentCredentials, tipAmount: Int64?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.payments.PaymentResult>) { static func sendPaymentForm(flags: Int32, formId: Int64, invoice: Api.InputInvoice, requestedInfoId: String?, shippingOptionId: String?, credentials: Api.InputPaymentCredentials, tipAmount: Int64?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.payments.PaymentResult>) {
let buffer = Buffer() let buffer = Buffer()

View File

@ -43,7 +43,7 @@ func updatedFeaturedStickerPacks(network: Network, postbox: Postbox) -> Signal<V
switch result { switch result {
case .featuredStickersNotModified: case .featuredStickersNotModified:
break break
case let .featuredStickers(_, _, sets, unread): case let .featuredStickers(flags, _, _, sets, unread):
let unreadIds = Set(unread) let unreadIds = Set(unread)
var updatedPacks: [FeaturedStickerPackItem] = [] var updatedPacks: [FeaturedStickerPackItem] = []
for set in sets { for set in sets {
@ -62,6 +62,11 @@ func updatedFeaturedStickerPacks(network: Network, postbox: Postbox) -> Signal<V
return nil return nil
} }
}) })
let isPremium = flags & (1 << 0) != 0
if let entry = CodableEntry(FeaturedStickersConfiguration(isPremium: isPremium)) {
transaction.putItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.featuredStickersConfiguration, key: ValueBoxKey(length: 0)), entry: entry)
}
} }
} }
} }
@ -75,7 +80,7 @@ public func requestOldFeaturedStickerPacks(network: Network, postbox: Postbox, o
switch result { switch result {
case .featuredStickersNotModified: case .featuredStickersNotModified:
return [] return []
case let .featuredStickers(_, _, sets, unread): case let .featuredStickers(_, _, _, sets, unread):
let unreadIds = Set(unread) let unreadIds = Set(unread)
var updatedPacks: [FeaturedStickerPackItem] = [] var updatedPacks: [FeaturedStickerPackItem] = []
for set in sets { for set in sets {

View File

@ -0,0 +1,22 @@
import Postbox
public final class FeaturedStickersConfiguration: Codable {
public let isPremium: Bool
public init(isPremium: Bool) {
self.isPremium = isPremium
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: StringCodingKey.self)
self.isPremium = try container.decode(Bool.self, forKey: "isPremium")
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: StringCodingKey.self)
try container.encode(self.isPremium, forKey: "isPremium")
}
}

View File

@ -87,6 +87,7 @@ public struct Namespaces {
public static let resolvedByPhonePeers: Int8 = 20 public static let resolvedByPhonePeers: Int8 = 20
public static let notificationSoundList: Int8 = 22 public static let notificationSoundList: Int8 = 22
public static let attachMenuBots: Int8 = 23 public static let attachMenuBots: Int8 = 23
public static let featuredStickersConfiguration: Int8 = 24
} }
public struct UnorderedItemList { public struct UnorderedItemList {

View File

@ -97,7 +97,7 @@ enum ChatMediaInputGridEntryIndex: Equatable, Comparable {
enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable { enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
case search(theme: PresentationTheme, strings: PresentationStrings) case search(theme: PresentationTheme, strings: PresentationStrings)
case trendingList(theme: PresentationTheme, strings: PresentationStrings, packs: [FeaturedStickerPackItem]) case trendingList(theme: PresentationTheme, strings: PresentationStrings, packs: [FeaturedStickerPackItem], isPremium: Bool)
case peerSpecificSetup(theme: PresentationTheme, strings: PresentationStrings, dismissed: Bool) case peerSpecificSetup(theme: PresentationTheme, strings: PresentationStrings, dismissed: Bool)
case sticker(index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, stickerPackInfo: StickerPackCollectionInfo?, canManagePeerSpecificPack: Bool?, maybeManageable: Bool, theme: PresentationTheme, isLocked: Bool) case sticker(index: ItemCollectionViewEntryIndex, stickerItem: StickerPackItem, stickerPackInfo: StickerPackCollectionInfo?, canManagePeerSpecificPack: Bool?, maybeManageable: Bool, theme: PresentationTheme, isLocked: Bool)
case trending(TrendingPanePackEntry) case trending(TrendingPanePackEntry)
@ -135,8 +135,8 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
} else { } else {
return false return false
} }
case let .trendingList(lhsTheme, lhsStrings, lhsPacks): case let .trendingList(lhsTheme, lhsStrings, lhsPacks, lhsIsPremium):
if case let .trendingList(rhsTheme, rhsStrings, rhsPacks) = rhs { if case let .trendingList(rhsTheme, rhsStrings, rhsPacks, rhsIsPremium) = rhs {
if lhsTheme !== rhsTheme { if lhsTheme !== rhsTheme {
return false return false
} }
@ -154,6 +154,9 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
return false return false
} }
} }
if lhsIsPremium != rhsIsPremium {
return false
}
return true return true
} else { } else {
return false return false
@ -210,8 +213,8 @@ enum ChatMediaInputGridEntry: Equatable, Comparable, Identifiable {
return PaneSearchBarPlaceholderItem(theme: theme, strings: strings, type: .stickers, activate: { return PaneSearchBarPlaceholderItem(theme: theme, strings: strings, type: .stickers, activate: {
inputNodeInteraction.toggleSearch(true, .sticker, "") inputNodeInteraction.toggleSearch(true, .sticker, "")
}) })
case let .trendingList(theme, strings, packs): case let .trendingList(theme, strings, packs, isPremium):
return StickerPaneTrendingListGridItem(account: account, theme: theme, strings: strings, trendingPacks: packs, inputNodeInteraction: inputNodeInteraction, dismiss: { return StickerPaneTrendingListGridItem(account: account, theme: theme, strings: strings, trendingPacks: packs, isPremium: isPremium, inputNodeInteraction: inputNodeInteraction, dismiss: {
inputNodeInteraction.dismissTrendingPacks(packs.map { $0.info.id }) inputNodeInteraction.dismissTrendingPacks(packs.map { $0.info.id })
}) })
case let .peerSpecificSetup(theme, strings, dismissed): case let .peerSpecificSetup(theme, strings, dismissed):

View File

@ -261,7 +261,7 @@ func chatMediaInputPanelGifModeEntries(theme: PresentationTheme, strings: Presen
return entries return entries
} }
func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, trendingPacks: [FeaturedStickerPackItem], installedPacks: Set<ItemCollectionId>, premiumStickers: OrderedItemListView? = nil, trendingIsDismissed: Bool = false, hasSearch: Bool = true, hasAccessories: Bool = true, strings: PresentationStrings, theme: PresentationTheme, hasPremium: Bool, isPremiumDisabled: Bool) -> [ChatMediaInputGridEntry] { func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: OrderedItemListView?, recentStickers: OrderedItemListView?, peerSpecificPack: PeerSpecificPackData?, canInstallPeerSpecificPack: CanInstallPeerSpecificPack, trendingPacks: [FeaturedStickerPackItem], installedPacks: Set<ItemCollectionId>, premiumStickers: OrderedItemListView? = nil, trendingIsDismissed: Bool = false, hasSearch: Bool = true, hasAccessories: Bool = true, strings: PresentationStrings, theme: PresentationTheme, hasPremium: Bool, isPremiumDisabled: Bool, trendingIsPremium: Bool) -> [ChatMediaInputGridEntry] {
var entries: [ChatMediaInputGridEntry] = [] var entries: [ChatMediaInputGridEntry] = []
if hasSearch && view.lower == nil { if hasSearch && view.lower == nil {
@ -295,7 +295,7 @@ func chatMediaInputGridEntries(view: ItemCollectionsView, savedStickers: Ordered
let filteredTrending = trendingPacks.filter { !installedPacks.contains($0.info.id) } let filteredTrending = trendingPacks.filter { !installedPacks.contains($0.info.id) }
if !trendingIsDismissed && !filteredTrending.isEmpty { if !trendingIsDismissed && !filteredTrending.isEmpty {
entries.append(.trendingList(theme: theme, strings: strings, packs: filteredTrending)) entries.append(.trendingList(theme: theme, strings: strings, packs: filteredTrending, isPremium: false))
} }
if let recentStickers = recentStickers, !recentStickers.items.isEmpty { if let recentStickers = recentStickers, !recentStickers.items.isEmpty {
@ -957,7 +957,7 @@ final class ChatMediaInputNode: ChatInputNode {
let itemCollectionsView = self.itemCollectionsViewPosition.get() let itemCollectionsView = self.itemCollectionsViewPosition.get()
|> distinctUntilChanged |> distinctUntilChanged
|> mapToSignal { position -> Signal<(ItemCollectionsView, StickerPacksCollectionUpdate), NoError> in |> mapToSignal { position -> Signal<(ItemCollectionsView, StickerPacksCollectionUpdate), NoError> in
let orderedItemListCollectionIds: [Int32] = [Namespaces.OrderedItemList.CloudSavedStickers, Namespaces.OrderedItemList.CloudRecentStickers, Namespaces.OrderedItemList.PremiumStickers] let orderedItemListCollectionIds: [Int32] = [Namespaces.OrderedItemList.CloudSavedStickers, Namespaces.OrderedItemList.CloudRecentStickers, Namespaces.OrderedItemList.PremiumStickers, Namespaces.OrderedItemList.CloudPremiumStickers]
let namespaces: [ItemCollectionId.Namespace] = [Namespaces.ItemCollection.CloudStickerPacks] let namespaces: [ItemCollectionId.Namespace] = [Namespaces.ItemCollection.CloudStickerPacks]
switch position { switch position {
case .initial: case .initial:
@ -1123,8 +1123,21 @@ final class ChatMediaInputNode: ChatInputNode {
let previousView = Atomic<ItemCollectionsView?>(value: nil) let previousView = Atomic<ItemCollectionsView?>(value: nil)
let transitionQueue = Queue() let transitionQueue = Queue()
let transitions = combineLatest(queue: transitionQueue, itemCollectionsView, peerSpecificPack, context.account.viewTracker.featuredStickerPacks(), self.themeAndStringsPromise.get(), reactions, self.panelIsFocusedPromise.get(), ApplicationSpecificNotice.dismissedTrendingStickerPacks(accountManager: context.sharedContext.accountManager), temporaryPackOrder.get(), animatedEmojiStickers, context.account.postbox.peerView(id: context.account.peerId)) let transitions = combineLatest(
|> map { viewAndUpdate, peerSpecificPack, trendingPacks, themeAndStrings, reactions, panelExpanded, dismissedTrendingStickerPacks, temporaryPackOrder, animatedEmojiStickers, peerView -> (ItemCollectionsView, ChatMediaInputPanelTransition, ChatMediaInputPanelTransition, Bool, ChatMediaInputGridTransition, Bool) in queue: transitionQueue,
itemCollectionsView,
peerSpecificPack,
context.account.viewTracker.featuredStickerPacks(),
self.themeAndStringsPromise.get(),
reactions,
self.panelIsFocusedPromise.get(),
ApplicationSpecificNotice.dismissedTrendingStickerPacks(accountManager: context.sharedContext.accountManager),
temporaryPackOrder.get(),
animatedEmojiStickers,
context.engine.data.subscribe(TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId)),
context.engine.data.get(TelegramEngine.EngineData.Item.ItemCache.Item(collectionId: Namespaces.CachedItemCollection.featuredStickersConfiguration, id: ValueBoxKey(length: 0)))
)
|> map { viewAndUpdate, peerSpecificPack, trendingPacks, themeAndStrings, reactions, panelExpanded, dismissedTrendingStickerPacks, temporaryPackOrder, animatedEmojiStickers, accountPeer, featuredStickersConfiguration -> (ItemCollectionsView, ChatMediaInputPanelTransition, ChatMediaInputPanelTransition, Bool, ChatMediaInputGridTransition, Bool) in
let (view, viewUpdate) = viewAndUpdate let (view, viewUpdate) = viewAndUpdate
let previous = previousView.swap(view) let previous = previousView.swap(view)
var update = viewUpdate var update = viewUpdate
@ -1136,6 +1149,7 @@ final class ChatMediaInputNode: ChatInputNode {
var savedStickers: OrderedItemListView? var savedStickers: OrderedItemListView?
var recentStickers: OrderedItemListView? var recentStickers: OrderedItemListView?
var premiumStickers: OrderedItemListView? var premiumStickers: OrderedItemListView?
// var cloudPremiumStickers: OrderedItemListView?
for orderedView in view.orderedItemListsViews { for orderedView in view.orderedItemListsViews {
if orderedView.collectionId == Namespaces.OrderedItemList.CloudRecentStickers { if orderedView.collectionId == Namespaces.OrderedItemList.CloudRecentStickers {
recentStickers = orderedView recentStickers = orderedView
@ -1144,6 +1158,9 @@ final class ChatMediaInputNode: ChatInputNode {
} else if orderedView.collectionId == Namespaces.OrderedItemList.PremiumStickers { } else if orderedView.collectionId == Namespaces.OrderedItemList.PremiumStickers {
premiumStickers = orderedView premiumStickers = orderedView
} }
// else if orderedView.collectionId == Namespaces.OrderedItemList.CloudPremiumStickers {
// cloudPremiumStickers = orderedView
// }
} }
var installedPacks = Set<ItemCollectionId>() var installedPacks = Set<ItemCollectionId>()
@ -1156,12 +1173,12 @@ final class ChatMediaInputNode: ChatInputNode {
trendingIsDismissed = true trendingIsDismissed = true
} }
let accountPeer = peerView.peers[peerView.peerId]
let hasPremium = accountPeer?.isPremium ?? false let hasPremium = accountPeer?.isPremium ?? false
let featuredStickersConfiguration = featuredStickersConfiguration?.get(FeaturedStickersConfiguration.self)
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, temporaryPackOrder: temporaryPackOrder, trendingIsDismissed: trendingIsDismissed, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, theme: theme, strings: strings, premiumStickers: hasPremium ? premiumStickers : nil, expanded: panelExpanded, reorderable: true) let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, temporaryPackOrder: temporaryPackOrder, trendingIsDismissed: trendingIsDismissed, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, theme: theme, strings: strings, premiumStickers: hasPremium ? premiumStickers : nil, expanded: panelExpanded, reorderable: true)
let gifPaneEntries = chatMediaInputPanelGifModeEntries(theme: theme, strings: strings, reactions: reactions, animatedEmojiStickers: animatedEmojiStickers, expanded: panelExpanded) let gifPaneEntries = chatMediaInputPanelGifModeEntries(theme: theme, strings: strings, reactions: reactions, animatedEmojiStickers: animatedEmojiStickers, expanded: panelExpanded)
var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, trendingPacks: trendingPacks, installedPacks: installedPacks, premiumStickers: premiumStickers, trendingIsDismissed: trendingIsDismissed, strings: strings, theme: theme, hasPremium: hasPremium, isPremiumDisabled: premiumConfiguration.isPremiumDisabled) var gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: peerSpecificPack.0, canInstallPeerSpecificPack: peerSpecificPack.1, trendingPacks: trendingPacks, installedPacks: installedPacks, premiumStickers: premiumStickers, trendingIsDismissed: trendingIsDismissed, strings: strings, theme: theme, hasPremium: hasPremium, isPremiumDisabled: premiumConfiguration.isPremiumDisabled, trendingIsPremium: featuredStickersConfiguration?.isPremium ?? false)
if view.higher == nil { if view.higher == nil {
var hasTopSeparator = true var hasTopSeparator = true

View File

@ -594,7 +594,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
} }
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, theme: theme, strings: strings, hasGifs: false, hasSettings: false) let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, theme: theme, strings: strings, hasGifs: false, hasSettings: false)
let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, trendingPacks: [], installedPacks: installedPacks, hasSearch: false, hasAccessories: false, strings: strings, theme: theme, hasPremium: false, isPremiumDisabled: true) let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: savedStickers, recentStickers: recentStickers, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, trendingPacks: [], installedPacks: installedPacks, hasSearch: false, hasAccessories: false, strings: strings, theme: theme, hasPremium: false, isPremiumDisabled: true, trendingIsPremium: false)
let (previousPanelEntries, previousGridEntries) = previousStickerEntries.swap((panelEntries, gridEntries)) let (previousPanelEntries, previousGridEntries) = previousStickerEntries.swap((panelEntries, gridEntries))
return (view, preparedChatMediaInputPanelEntryTransition(context: context, from: previousPanelEntries, to: panelEntries, inputNodeInteraction: stickersInputNodeInteraction, scrollToItem: nil), previousPanelEntries.isEmpty, preparedChatMediaInputGridEntryTransition(account: context.account, view: view, from: previousGridEntries, to: gridEntries, update: update, interfaceInteraction: controllerInteraction, inputNodeInteraction: stickersInputNodeInteraction, trendingInteraction: trendingInteraction), previousGridEntries.isEmpty) return (view, preparedChatMediaInputPanelEntryTransition(context: context, from: previousPanelEntries, to: panelEntries, inputNodeInteraction: stickersInputNodeInteraction, scrollToItem: nil), previousPanelEntries.isEmpty, preparedChatMediaInputGridEntryTransition(account: context.account, view: view, from: previousGridEntries, to: gridEntries, update: update, interfaceInteraction: controllerInteraction, inputNodeInteraction: stickersInputNodeInteraction, trendingInteraction: trendingInteraction), previousGridEntries.isEmpty)
@ -629,7 +629,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode {
} }
let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, theme: theme, strings: strings, hasGifs: false, hasSettings: false) let panelEntries = chatMediaInputPanelEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, theme: theme, strings: strings, hasGifs: false, hasSettings: false)
let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, trendingPacks: [], installedPacks: installedPacks, hasSearch: false, hasAccessories: false, strings: strings, theme: theme, hasPremium: false, isPremiumDisabled: true) let gridEntries = chatMediaInputGridEntries(view: view, savedStickers: nil, recentStickers: nil, peerSpecificPack: nil, canInstallPeerSpecificPack: .none, trendingPacks: [], installedPacks: installedPacks, hasSearch: false, hasAccessories: false, strings: strings, theme: theme, hasPremium: false, isPremiumDisabled: true, trendingIsPremium: false)
let (previousPanelEntries, previousGridEntries) = previousMaskEntries.swap((panelEntries, gridEntries)) let (previousPanelEntries, previousGridEntries) = previousMaskEntries.swap((panelEntries, gridEntries))
return (view, preparedChatMediaInputPanelEntryTransition(context: context, from: previousPanelEntries, to: panelEntries, inputNodeInteraction: masksInputNodeInteraction, scrollToItem: nil), previousPanelEntries.isEmpty, preparedChatMediaInputGridEntryTransition(account: context.account, view: view, from: previousGridEntries, to: gridEntries, update: update, interfaceInteraction: controllerInteraction, inputNodeInteraction: masksInputNodeInteraction, trendingInteraction: trendingInteraction), previousGridEntries.isEmpty) return (view, preparedChatMediaInputPanelEntryTransition(context: context, from: previousPanelEntries, to: panelEntries, inputNodeInteraction: masksInputNodeInteraction, scrollToItem: nil), previousPanelEntries.isEmpty, preparedChatMediaInputGridEntryTransition(account: context.account, view: view, from: previousGridEntries, to: gridEntries, update: update, interfaceInteraction: controllerInteraction, inputNodeInteraction: masksInputNodeInteraction, trendingInteraction: trendingInteraction), previousGridEntries.isEmpty)

View File

@ -376,17 +376,19 @@ final class StickerPaneTrendingListGridItem: GridItem {
let theme: PresentationTheme let theme: PresentationTheme
let strings: PresentationStrings let strings: PresentationStrings
let trendingPacks: [FeaturedStickerPackItem] let trendingPacks: [FeaturedStickerPackItem]
let isPremium: Bool
let inputNodeInteraction: ChatMediaInputNodeInteraction let inputNodeInteraction: ChatMediaInputNodeInteraction
let dismiss: (() -> Void)? let dismiss: (() -> Void)?
let section: GridSection? = nil let section: GridSection? = nil
let fillsRowWithDynamicHeight: ((CGFloat) -> CGFloat)? let fillsRowWithDynamicHeight: ((CGFloat) -> CGFloat)?
init(account: Account, theme: PresentationTheme, strings: PresentationStrings, trendingPacks: [FeaturedStickerPackItem], inputNodeInteraction: ChatMediaInputNodeInteraction, dismiss: (() -> Void)?) { init(account: Account, theme: PresentationTheme, strings: PresentationStrings, trendingPacks: [FeaturedStickerPackItem], isPremium: Bool, inputNodeInteraction: ChatMediaInputNodeInteraction, dismiss: (() -> Void)?) {
self.account = account self.account = account
self.theme = theme self.theme = theme
self.strings = strings self.strings = strings
self.trendingPacks = trendingPacks self.trendingPacks = trendingPacks
self.isPremium = isPremium
self.inputNodeInteraction = inputNodeInteraction self.inputNodeInteraction = inputNodeInteraction
self.dismiss = dismiss self.dismiss = dismiss
self.fillsRowWithDynamicHeight = { _ in self.fillsRowWithDynamicHeight = { _ in
@ -530,7 +532,7 @@ class StickerPaneTrendingListGridItemNode: GridItemNode {
let rightInset: CGFloat = 18.0 + UIScreenPixel let rightInset: CGFloat = 18.0 + UIScreenPixel
let topOffset: CGFloat = 9.0 let topOffset: CGFloat = 9.0
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: item.strings.StickerPacksSettings_FeaturedPacks.uppercased(), font: titleFont, textColor: item.theme.chat.inputMediaPanel.stickersSectionTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets())) let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: (item.isPremium ? item.strings.Stickers_TrendingPremiumStickers : item.strings.StickerPacksSettings_FeaturedPacks).uppercased(), font: titleFont, textColor: item.theme.chat.inputMediaPanel.stickersSectionTextColor), backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - params.leftInset - params.rightInset - leftInset - rightInset - 20.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
self.item = item self.item = item