From 7f99a91a82f122e3379cf75d273ebf7a5b25710d Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 16 Apr 2020 15:28:28 +0400 Subject: [PATCH] Small adjustments --- .../Statistics.imageset/Contents.json | 12 ++++++ .../Statistics.imageset/ic_stat.pdf | Bin 0 -> 4236 bytes .../TelegramUI/Sources/ChatController.swift | 39 ++++++++++++++---- .../Sources/ChatMediaInputNode.swift | 3 ++ .../Sources/ChatMediaInputStickerPane.swift | 2 + .../Sources/ChatMediaInputTrendingPane.swift | 5 +-- .../Sources/FeaturedStickersScreen.swift | 2 +- .../ListItems/PeerInfoScreenMemberItem.swift | 7 +++- 8 files changed, 56 insertions(+), 14 deletions(-) create mode 100644 submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/Contents.json create mode 100644 submodules/TelegramUI/Images.xcassets/Chat/Context Menu/Statistics.imageset/ic_stat.pdf 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 0000000000000000000000000000000000000000..674c810d88731ccaf1f243c80fdebb457e49c62a GIT binary patch literal 4236 zcmai%2{hDg`^N{9Wk@R7QvH%8k(n`z<|+FgWtUwuV}`*PF_y@h<*{XnL?KZ^mZHeM zOL~koNoZn7wn%pMj+Xz^^SL?1^bUpp< zaWgZ|b4!gf1;RyYeS1K&*Kp^CiiYN0J$1f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fdYuY&lm!YVKy;458(DI216s62ma3(0)=LFCjX4VVDikP{I?ido>|m? ziz&$emwf+ChhcU*|6Gee!Tuv30*(A_&r}aA$(7*oy~Q^n`4O1^7l0a5D9noQRF&E4 z>$(vs%<}&jYcLIP28qF(!ojgc~Y6R S{C?1gQz#5XLPFC(3-T{3k4(n^ literal 0 HcmV?d00001 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