Input node improvements

This commit is contained in:
Ali
2022-06-28 22:54:05 +02:00
parent 575605f4d0
commit 131be5aaab
51 changed files with 2586 additions and 1363 deletions

View File

@@ -20,7 +20,7 @@ private struct StickersChatInputContextPanelEntryStableId: Hashable {
}
final class StickersChatInputContextPanelInteraction {
var previewedStickerItem: StickerPackItem?
var previewedStickerItem: TelegramMediaFile?
}
private struct StickersChatInputContextPanelEntry: Identifiable, Comparable {
@@ -129,7 +129,7 @@ final class StickersChatInputContextPanelNode: ChatInputContextPanelNode {
if let (item, itemNode) = stickersNode.stickerItem(at: point) {
return strongSelf.context.engine.stickers.isStickerSaved(id: item.file.fileId)
|> deliverOnMainQueue
|> map { isStarred -> (ASDisplayNode, PeekControllerContent)? in
|> map { isStarred -> (UIView, CGRect, PeekControllerContent)? in
if let strongSelf = self, let controllerInteraction = strongSelf.controllerInteraction {
var menuItems: [ContextMenuItem] = []
menuItems = [
@@ -197,7 +197,7 @@ final class StickersChatInputContextPanelNode: ChatInputContextPanelNode {
}
}))
]
return (itemNode, StickerPreviewPeekContent(account: strongSelf.context.account, theme: strongSelf.theme, strings: strongSelf.strings, item: .pack(item), menu: menuItems, openPremiumIntro: { [weak self] in
return (itemNode.view, itemNode.bounds, StickerPreviewPeekContent(account: strongSelf.context.account, theme: strongSelf.theme, strings: strongSelf.strings, item: .pack(item.file), menu: menuItems, openPremiumIntro: { [weak self] in
guard let strongSelf = self else {
return
}
@@ -212,11 +212,11 @@ final class StickersChatInputContextPanelNode: ChatInputContextPanelNode {
}
}
return nil
}, present: { [weak self] content, sourceNode in
}, present: { [weak self] content, sourceView, sourceRect in
if let strongSelf = self {
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
let controller = PeekController(presentationData: presentationData, content: content, sourceNode: {
return sourceNode
let controller = PeekController(presentationData: presentationData, content: content, sourceView: {
return (sourceView, sourceRect)
})
strongSelf.interfaceInteraction?.presentGlobalOverlayController(controller, nil)
return controller
@@ -224,18 +224,18 @@ final class StickersChatInputContextPanelNode: ChatInputContextPanelNode {
return nil
}, updateContent: { [weak self] content in
if let strongSelf = self {
var item: StickerPackItem?
var item: TelegramMediaFile?
if let content = content as? StickerPreviewPeekContent, case let .pack(contentItem) = content.item {
item = contentItem
}
strongSelf.updatePreviewingItem(item: item, animated: true)
strongSelf.updatePreviewingItem(file: item, animated: true)
}
}))
}
private func updatePreviewingItem(item: StickerPackItem?, animated: Bool) {
if self.stickersInteraction.previewedStickerItem != item {
self.stickersInteraction.previewedStickerItem = item
private func updatePreviewingItem(file: TelegramMediaFile?, animated: Bool) {
if self.stickersInteraction.previewedStickerItem?.fileId != file?.fileId {
self.stickersInteraction.previewedStickerItem = file
self.listView.forEachItemNode { itemNode in
if let itemNode = itemNode as? StickersChatInputContextPanelItemNode {