mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Support found sticker preview
This commit is contained in:
parent
69091c606d
commit
48cb7f25ec
@ -1838,7 +1838,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
|||||||
strongSelf.reorderItems(category: category, items: items)
|
strongSelf.reorderItems(category: category, items: items)
|
||||||
},
|
},
|
||||||
makeSearchContainerNode: { [weak self, weak controllerInteraction] content in
|
makeSearchContainerNode: { [weak self, weak controllerInteraction] content in
|
||||||
guard let controllerInteraction = controllerInteraction else {
|
guard let self, let controllerInteraction = controllerInteraction else {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1860,9 +1860,10 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode {
|
|||||||
mode: mappedMode,
|
mode: mappedMode,
|
||||||
trendingGifsPromise: trendingGifsPromise,
|
trendingGifsPromise: trendingGifsPromise,
|
||||||
cancel: {
|
cancel: {
|
||||||
}
|
},
|
||||||
|
peekBehavior: self.emojiInputInteraction?.peekBehavior
|
||||||
)
|
)
|
||||||
searchContainerNode.openGifContextMenu = { item, sourceNode, sourceRect, gesture, isSaved in
|
searchContainerNode.openGifContextMenu = { [weak self] item, sourceNode, sourceRect, gesture, isSaved in
|
||||||
guard let self else {
|
guard let self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -2502,7 +2503,7 @@ public final class EmojiContentPeekBehaviorImpl: EmojiContentPeekBehavior {
|
|||||||
self.present = present
|
self.present = present
|
||||||
}
|
}
|
||||||
|
|
||||||
public func setGestureRecognizerEnabled(view: UIView, isEnabled: Bool, itemAtPoint: @escaping (CGPoint) -> (AnyHashable, EmojiPagerContentComponent.View.ItemLayer, TelegramMediaFile)?) {
|
public func setGestureRecognizerEnabled(view: UIView, isEnabled: Bool, itemAtPoint: @escaping (CGPoint) -> (AnyHashable, CALayer, TelegramMediaFile)?) {
|
||||||
self.viewRecords = self.viewRecords.filter({ $0.view != nil })
|
self.viewRecords = self.viewRecords.filter({ $0.view != nil })
|
||||||
|
|
||||||
let viewRecord = self.viewRecords.first(where: { $0.view === view })
|
let viewRecord = self.viewRecords.first(where: { $0.view === view })
|
||||||
|
@ -12,6 +12,7 @@ import EntityKeyboard
|
|||||||
import ChatControllerInteraction
|
import ChatControllerInteraction
|
||||||
import MultiplexedVideoNode
|
import MultiplexedVideoNode
|
||||||
import FeaturedStickersScreen
|
import FeaturedStickersScreen
|
||||||
|
import StickerPeekUI
|
||||||
|
|
||||||
private let searchBarHeight: CGFloat = 52.0
|
private let searchBarHeight: CGFloat = 52.0
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ public final class PaneSearchContainerNode: ASDisplayNode, EntitySearchContainer
|
|||||||
public private(set) var contentNode: PaneSearchContentNode & ASDisplayNode
|
public private(set) var contentNode: PaneSearchContentNode & ASDisplayNode
|
||||||
private let controllerInteraction: ChatControllerInteraction
|
private let controllerInteraction: ChatControllerInteraction
|
||||||
private let inputNodeInteraction: ChatMediaInputNodeInteraction
|
private let inputNodeInteraction: ChatMediaInputNodeInteraction
|
||||||
|
private let peekBehavior: EmojiContentPeekBehavior?
|
||||||
|
|
||||||
private let backgroundNode: ASDisplayNode
|
private let backgroundNode: ASDisplayNode
|
||||||
private let searchBar: PaneSearchBarNode
|
private let searchBar: PaneSearchBarNode
|
||||||
@ -51,11 +53,12 @@ public final class PaneSearchContainerNode: ASDisplayNode, EntitySearchContainer
|
|||||||
return self.contentNode.ready
|
return self.contentNode.ready
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, controllerInteraction: ChatControllerInteraction, inputNodeInteraction: ChatMediaInputNodeInteraction, mode: ChatMediaInputSearchMode, trendingGifsPromise: Promise<ChatMediaInputGifPaneTrendingState?>, cancel: @escaping () -> Void) {
|
public init(context: AccountContext, theme: PresentationTheme, strings: PresentationStrings, controllerInteraction: ChatControllerInteraction, inputNodeInteraction: ChatMediaInputNodeInteraction, mode: ChatMediaInputSearchMode, trendingGifsPromise: Promise<ChatMediaInputGifPaneTrendingState?>, cancel: @escaping () -> Void, peekBehavior: EmojiContentPeekBehavior?) {
|
||||||
self.context = context
|
self.context = context
|
||||||
self.mode = mode
|
self.mode = mode
|
||||||
self.controllerInteraction = controllerInteraction
|
self.controllerInteraction = controllerInteraction
|
||||||
self.inputNodeInteraction = inputNodeInteraction
|
self.inputNodeInteraction = inputNodeInteraction
|
||||||
|
self.peekBehavior = peekBehavior
|
||||||
switch mode {
|
switch mode {
|
||||||
case .gif:
|
case .gif:
|
||||||
self.contentNode = GifPaneSearchContentNode(context: context, theme: theme, strings: strings, controllerInteraction: controllerInteraction, inputNodeInteraction: inputNodeInteraction, trendingPromise: trendingGifsPromise)
|
self.contentNode = GifPaneSearchContentNode(context: context, theme: theme, strings: strings, controllerInteraction: controllerInteraction, inputNodeInteraction: inputNodeInteraction, trendingPromise: trendingGifsPromise)
|
||||||
@ -103,6 +106,41 @@ public final class PaneSearchContainerNode: ASDisplayNode, EntitySearchContainer
|
|||||||
self?.openGifContextMenu?(file, node, rect, gesture, isSaved)
|
self?.openGifContextMenu?(file, node, rect, gesture, isSaved)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let contentNode = self.contentNode as? StickerPaneSearchContentNode, let peekBehavior = self.peekBehavior {
|
||||||
|
peekBehavior.setGestureRecognizerEnabled(view: self.contentNode.view, isEnabled: true, itemAtPoint: { [weak contentNode] point in
|
||||||
|
guard let contentNode else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
guard let (itemNode, item) = contentNode.itemAt(point: point) else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var maybeFile: TelegramMediaFile?
|
||||||
|
if let item = item as? StickerPreviewPeekItem {
|
||||||
|
switch item {
|
||||||
|
case let .found(foundItem):
|
||||||
|
maybeFile = foundItem.file
|
||||||
|
case let .pack(fileValue):
|
||||||
|
maybeFile = fileValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
guard let file = maybeFile else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var groupId: AnyHashable = AnyHashable("search")
|
||||||
|
for attribute in file.attributes {
|
||||||
|
if case let .Sticker(_, packReference, _) = attribute {
|
||||||
|
if case let .id(id, _) = packReference {
|
||||||
|
groupId = AnyHashable(ItemCollectionId(namespace: Namespaces.ItemCollection.CloudStickerPacks, id: id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (groupId, itemNode.layer, file)
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
|
public func updateThemeAndStrings(theme: PresentationTheme, strings: PresentationStrings) {
|
||||||
|
@ -2222,7 +2222,7 @@ private final class EmptySearchResultsView: UIView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public protocol EmojiContentPeekBehavior: AnyObject {
|
public protocol EmojiContentPeekBehavior: AnyObject {
|
||||||
func setGestureRecognizerEnabled(view: UIView, isEnabled: Bool, itemAtPoint: @escaping (CGPoint) -> (AnyHashable, EmojiPagerContentComponent.View.ItemLayer, TelegramMediaFile)?)
|
func setGestureRecognizerEnabled(view: UIView, isEnabled: Bool, itemAtPoint: @escaping (CGPoint) -> (AnyHashable, CALayer, TelegramMediaFile)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class EmojiPagerContentComponent: Component {
|
public final class EmojiPagerContentComponent: Component {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user