diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/Contents.json b/submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/Contents.json new file mode 100644 index 0000000000..95e33ed863 --- /dev/null +++ b/submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/Contents.json @@ -0,0 +1,12 @@ +{ + "images" : [ + { + "filename" : "ic_stat.pdf", + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/ic_stat.pdf b/submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/ic_stat.pdf new file mode 100644 index 0000000000..674c810d88 Binary files /dev/null and b/submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/ic_stat.pdf differ diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 316484cb54..d956104adf 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -59,6 +59,7 @@ import SettingsUI import UrlWhitelist import TelegramIntents import TooltipUI +import StatisticsUI public enum ChatControllerPeekActions { case standard @@ -2014,17 +2015,37 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }, synchronousLoad: true) galleryController.setHintWillBePresentedInPreviewingContext(true) - let items: [ContextMenuItem] = [ - .action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, icon: { _ in nil }, action: { _, f in - f(.dismissWithoutContent) - self?.navigationButtonAction(.openChatInfo(expandAvatar: true)) - })), - .action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_Search, icon: { _ in nil }, action: { _, f in + let items: Signal<[ContextMenuItem], NoError> = context.account.postbox.transaction { transaction -> [ContextMenuItem] in + var items: [ContextMenuItem] = [ + .action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_LinkDialogOpen, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Info"), color: theme.actionSheet.primaryTextColor) + }, action: { _, f in + f(.dismissWithoutContent) + self?.navigationButtonAction(.openChatInfo(expandAvatar: true)) + })) + ] + if let cachedData = transaction.getPeerCachedData(peerId: peer.id) as? CachedChannelData, cachedData.flags.contains(.canViewStats) { + items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.ChannelInfo_Stats, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Statistics"), color: theme.actionSheet.primaryTextColor) + }, action: { _, f in + f(.dismissWithoutContent) + guard let strongSelf = self, let peer = strongSelf.presentationInterfaceState.renderedPeer?.chatMainPeer else { + return + } + strongSelf.view.endEditing(true) + strongSelf.push(channelStatsController(context: context, peerId: peer.id, cachedPeerData: cachedData)) + }))) + } + items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.Conversation_Search, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Statistics"), color: theme.actionSheet.primaryTextColor) + }, action: { _, f in f(.dismissWithoutContent) self?.interfaceInteraction?.beginMessageSearch(.everything, "") - })) - ] - let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node)), items: .single(items), reactionItems: [], gesture: gesture) + }))) + return items + } + + let contextController = ContextController(account: strongSelf.context.account, presentationData: strongSelf.presentationData, source: .controller(ContextControllerContentSourceImpl(controller: galleryController, sourceNode: node)), items: items, reactionItems: [], gesture: gesture) strongSelf.presentInGlobalOverlay(contextController) } chatInfoButtonItem = UIBarButtonItem(customDisplayNode: avatarNode)! diff --git a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift index 059942338f..cf7e3b573c 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputNode.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputNode.swift @@ -403,6 +403,7 @@ final class ChatMediaInputNode: ChatInputNode { private let gifPaneIsActiveUpdated: (Bool) -> Void private var inputNodeInteraction: ChatMediaInputNodeInteraction! + private var trendingInteraction: TrendingPaneInteraction? private let collectionListPanel: ASDisplayNode private let collectionListSeparator: ASDisplayNode @@ -764,6 +765,7 @@ final class ChatMediaInputNode: ChatInputNode { return getItemIsPreviewedImpl?(item) ?? false }, openSearch: { }) + self.trendingInteraction = trendingInteraction let previousView = Atomic(value: nil) let transitionQueue = Queue() @@ -1495,6 +1497,7 @@ final class ChatMediaInputNode: ChatInputNode { } self.gifPane.updateLayout(size: CGSize(width: width - leftInset - rightInset, height: panelHeight), topInset: 41.0, bottomInset: bottomInset, isExpanded: isExpanded, isVisible: isVisible, deviceMetrics: deviceMetrics, transition: transition) + self.trendingInteraction?.itemContext.canPlayMedia = isVisible self.stickerPane.updateLayout(size: CGSize(width: width - leftInset - rightInset, height: panelHeight), topInset: 41.0, bottomInset: bottomInset, isExpanded: isExpanded, isVisible: isVisible && visiblePanes.contains(where: { $0.0 == .stickers }), deviceMetrics: deviceMetrics, transition: transition) //self.trendingPane.updateLayout(size: CGSize(width: width - leftInset - rightInset, height: panelHeight), topInset: 41.0, bottomInset: bottomInset, isExpanded: isExpanded, isVisible: isVisible, deviceMetrics: deviceMetrics, transition: transition) diff --git a/submodules/TelegramUI/Sources/ChatMediaInputStickerPane.swift b/submodules/TelegramUI/Sources/ChatMediaInputStickerPane.swift index 8d6ab03042..f1a54e9d67 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputStickerPane.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputStickerPane.swift @@ -171,6 +171,8 @@ final class ChatMediaInputStickerPane: ChatMediaInputPane { self.gridNode.forEachItemNode { itemNode in if let itemNode = itemNode as? ChatMediaInputStickerGridItemNode { itemNode.updateIsPanelVisible(isVisible) + } else if let itemNode = itemNode as? StickerPaneSearchGlobalItemNode { + itemNode.updateCanPlayMedia() } } } diff --git a/submodules/TelegramUI/Sources/ChatMediaInputTrendingPane.swift b/submodules/TelegramUI/Sources/ChatMediaInputTrendingPane.swift index 71fd0b5f13..6e088dfed0 100644 --- a/submodules/TelegramUI/Sources/ChatMediaInputTrendingPane.swift +++ b/submodules/TelegramUI/Sources/ChatMediaInputTrendingPane.swift @@ -19,6 +19,7 @@ final class TrendingPaneInteraction { let openPack: (ItemCollectionInfo) -> Void let getItemIsPreviewed: (StickerPackItem) -> Bool let openSearch: () -> Void + let itemContext = StickerPaneSearchGlobalItemContext() init(installPack: @escaping (ItemCollectionInfo) -> Void, openPack: @escaping (ItemCollectionInfo) -> Void, getItemIsPreviewed: @escaping (StickerPackItem) -> Bool, openSearch: @escaping () -> Void) { self.installPack = installPack @@ -87,15 +88,13 @@ final class TrendingPanePackEntry: Identifiable, Comparable { func item(account: Account, interaction: TrendingPaneInteraction, grid: Bool) -> GridItem { let info = self.info - let itemContext = StickerPaneSearchGlobalItemContext() - itemContext.canPlayMedia = true return StickerPaneSearchGlobalItem(account: account, theme: self.theme, strings: self.strings, listAppearance: false, info: self.info, topItems: self.topItems, grid: grid, topSeparator: self.topSeparator, installed: self.installed, unread: self.unread, open: { interaction.openPack(info) }, install: { interaction.installPack(info) }, getItemIsPreviewed: { item in return interaction.getItemIsPreviewed(item) - }, itemContext: itemContext) + }, itemContext: interaction.itemContext) } } diff --git a/submodules/TelegramUI/Sources/FeaturedStickersScreen.swift b/submodules/TelegramUI/Sources/FeaturedStickersScreen.swift index d00c732a22..f7da842987 100644 --- a/submodules/TelegramUI/Sources/FeaturedStickersScreen.swift +++ b/submodules/TelegramUI/Sources/FeaturedStickersScreen.swift @@ -932,7 +932,7 @@ private final class SearchNavigationContentNode: NavigationBarContentNode { } override func updateLayout(size: CGSize, leftInset: CGFloat, rightInset: CGFloat, transition: ContainedViewLayoutTransition) { - let searchBarFrame = CGRect(origin: CGPoint(x: 0.0, y: size.height - self.nominalHeight), size: CGSize(width: size.width, height: 54.0)) + let searchBarFrame = CGRect(origin: CGPoint(x: 0.0, y: 1.0 + size.height - self.nominalHeight), size: CGSize(width: size.width, height: 54.0)) self.searchBar.frame = searchBarFrame self.searchBar.updateLayout(boundingSize: searchBarFrame.size, leftInset: leftInset, rightInset: rightInset, transition: transition) } diff --git a/submodules/TelegramUI/Sources/PeerInfo/ListItems/PeerInfoScreenMemberItem.swift b/submodules/TelegramUI/Sources/PeerInfo/ListItems/PeerInfoScreenMemberItem.swift index e593df1e4e..237cc6e888 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/ListItems/PeerInfoScreenMemberItem.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/ListItems/PeerInfoScreenMemberItem.swift @@ -194,7 +194,12 @@ private final class PeerInfoScreenMemberItemNode: PeerInfoScreenItemNode { self.selectionNode.update(size: CGSize(width: width, height: height + highlightNodeOffset), theme: presentationData.theme, transition: transition) transition.updateFrame(node: self.selectionNode, frame: CGRect(origin: CGPoint(x: 0.0, y: -highlightNodeOffset), size: CGSize(width: width, height: height + highlightNodeOffset))) - transition.updateFrame(node: self.bottomSeparatorNode, frame: CGRect(origin: CGPoint(x: sideInset, y: height - UIScreenPixel), size: CGSize(width: width - sideInset, height: UIScreenPixel))) + var separatorInset: CGFloat = sideInset + if bottomItem != nil { + separatorInset += 49.0 + } + + transition.updateFrame(node: self.bottomSeparatorNode, frame: CGRect(origin: CGPoint(x: separatorInset, y: height - UIScreenPixel), size: CGSize(width: width - sideInset, height: UIScreenPixel))) transition.updateAlpha(node: self.bottomSeparatorNode, alpha: bottomItem == nil ? 0.0 : 1.0) return height