From e1902192d442529a0aa0ab6dc835bc2b1aa94e40 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Wed, 20 Jul 2022 11:46:57 +0200 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 2 + .../Sources/ContextActionsContainerNode.swift | 2 +- .../PremiumUI/Sources/PremiumDemoScreen.swift | 5 ++- .../Sources/StickerPackEmojisItem.swift | 38 +++++++++++++++---- .../Sources/TextNodeWithEntities.swift | 2 +- .../TelegramUI/Sources/ChatController.swift | 2 + .../Sources/ChatControllerInteraction.swift | 3 ++ .../Sources/ChatControllerNode.swift | 5 +++ .../ChatRecentActionsControllerNode.swift | 1 + .../Sources/DrawingStickersScreen.swift | 1 + .../OverlayAudioPlayerControllerNode.swift | 1 + .../Sources/PeerInfo/PeerInfoScreen.swift | 1 + .../Sources/SharedAccountContext.swift | 1 + 13 files changed, 54 insertions(+), 10 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index e427b5cb88..c58baf8b04 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -7890,3 +7890,5 @@ Sorry for the inconvenience."; "Conversation.VoiceMessagesRestricted" = "%@ doesn't accept voice and video messages"; "Emoji.ClearRecent" = "Clear Recent Emoji"; + +"Premium.AnimatedEmoji.Proceed" = "Unlock Animated Emoji"; diff --git a/submodules/ContextUI/Sources/ContextActionsContainerNode.swift b/submodules/ContextUI/Sources/ContextActionsContainerNode.swift index e366f414f5..c7507f66c9 100644 --- a/submodules/ContextUI/Sources/ContextActionsContainerNode.swift +++ b/submodules/ContextUI/Sources/ContextActionsContainerNode.swift @@ -400,7 +400,7 @@ final class InnerTextSelectionTipContainerNode: ASDisplayNode { self.arguments = arguments self.file = file self.targetSelectionIndex = nil - icon = nil //UIImage(bundleImageName: "Chat/Context Menu/Arrow") + icon = nil isUserInteractionEnabled = text != nil } diff --git a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift index 2c80a1cb54..0095bff066 100644 --- a/submodules/PremiumUI/Sources/PremiumDemoScreen.swift +++ b/submodules/PremiumUI/Sources/PremiumDemoScreen.swift @@ -485,7 +485,7 @@ private final class DemoSheetContent: CombinedComponent { self.context = context self.subject = subject self.source = source - self.order = order ?? [.moreUpload, .fasterDownload, .voiceToText, .noAds, .uniqueReactions, .premiumStickers, .advancedChatManagement, .profileBadge, .animatedUserpics, .appIcons] + self.order = order ?? [.moreUpload, .fasterDownload, .voiceToText, .noAds, .uniqueReactions, .premiumStickers, .animatedEmoji, .advancedChatManagement, .profileBadge, .animatedUserpics, .appIcons] self.action = action self.dismiss = dismiss } @@ -994,6 +994,9 @@ private final class DemoSheetContent: CombinedComponent { buttonAnimationName = "premium_unlock" case .noAds: buttonText = strings.Premium_NoAds_Proceed + case .animatedEmoji: + buttonText = strings.Premium_AnimatedEmoji_Proceed + buttonAnimationName = "premium_unlock" default: buttonText = strings.Common_OK } diff --git a/submodules/StickerPackPreviewUI/Sources/StickerPackEmojisItem.swift b/submodules/StickerPackPreviewUI/Sources/StickerPackEmojisItem.swift index 0b12336a11..2b5a4c4404 100644 --- a/submodules/StickerPackPreviewUI/Sources/StickerPackEmojisItem.swift +++ b/submodules/StickerPackPreviewUI/Sources/StickerPackEmojisItem.swift @@ -172,13 +172,19 @@ final class StickerPackEmojisItemNode: GridItemNode { super.didLoad() let shimmerHostView = PortalSourceView() + shimmerHostView.alpha = 0.0 + shimmerHostView.frame = CGRect(origin: CGPoint(), size: self.frame.size) + self.view.addSubview(shimmerHostView) self.shimmerHostView = shimmerHostView let standaloneShimmerEffect = StandaloneShimmerEffect() self.standaloneShimmerEffect = standaloneShimmerEffect - - shimmerHostView.alpha = 0.0 - self.view.addSubview(shimmerHostView) + if let item = self.item { + let shimmerBackgroundColor = item.theme.chat.inputPanel.primaryTextColor.withMultipliedAlpha(0.08) + let shimmerForegroundColor = item.theme.list.itemBlocksBackgroundColor.withMultipliedAlpha(0.15) + standaloneShimmerEffect.update(background: shimmerBackgroundColor, foreground: shimmerForegroundColor) + self.updateShimmerIfNeeded() + } let boundsChangeTrackerLayer = SimpleLayer() boundsChangeTrackerLayer.opacity = 0.0 @@ -261,7 +267,7 @@ final class StickerPackEmojisItemNode: GridItemNode { placeholderColor: theme.chat.inputPanel.primaryTextColor.withMultipliedAlpha(0.1), blurredBadgeColor: theme.chat.inputPanel.panelBackgroundColor.withMultipliedAlpha(0.5), pointSize: itemNativeFitSize, - onUpdateDisplayPlaceholder: { [weak self] displayPlaceholder, _ in + onUpdateDisplayPlaceholder: { [weak self] displayPlaceholder, duration in guard let strongSelf = self else { return } @@ -275,7 +281,7 @@ final class StickerPackEmojisItemNode: GridItemNode { context: context, file: item.file, shimmerView: strongSelf.shimmerHostView, - color: nil, + color: theme.chat.inputPanel.primaryTextColor.withMultipliedAlpha(0.08), size: itemNativeFitSize ) strongSelf.visibleItemPlaceholderViews[itemId] = placeholderView @@ -289,9 +295,20 @@ final class StickerPackEmojisItemNode: GridItemNode { } else { if let placeholderView = strongSelf.visibleItemPlaceholderViews[itemId] { strongSelf.visibleItemPlaceholderViews.removeValue(forKey: itemId) - placeholderView.removeFromSuperview() - strongSelf.updateShimmerIfNeeded() + if duration > 0.0 { + placeholderView.layer.opacity = 0.0 + placeholderView.layer.animateAlpha(from: 1.0, to: 0.0, duration: duration, completion: { [weak self, weak placeholderView] _ in + guard let strongSelf = self else { + return + } + placeholderView?.removeFromSuperview() + strongSelf.updateShimmerIfNeeded() + }) + } else { + placeholderView.removeFromSuperview() + strongSelf.updateShimmerIfNeeded() + } } } } @@ -324,6 +341,13 @@ final class StickerPackEmojisItemNode: GridItemNode { itemLayer.isVisibleForAnimations = true } + + for id in self.visibleItemLayers.keys { + if !validIds.contains(id) { + self.visibleItemLayers[id]?.removeFromSuperlayer() + self.visibleItemLayers[id] = nil + } + } } private func updateShimmerIfNeeded() { diff --git a/submodules/TelegramUI/Components/TextNodeWithEntities/Sources/TextNodeWithEntities.swift b/submodules/TelegramUI/Components/TextNodeWithEntities/Sources/TextNodeWithEntities.swift index 092277a4e0..9f3b56b741 100644 --- a/submodules/TelegramUI/Components/TextNodeWithEntities/Sources/TextNodeWithEntities.swift +++ b/submodules/TelegramUI/Components/TextNodeWithEntities/Sources/TextNodeWithEntities.swift @@ -78,7 +78,7 @@ public final class TextNodeWithEntities { context: self.context, cache: self.cache, renderer: self.renderer, - placeholderColor: self.placeholderColor, + placeholderColor: color, attemptSynchronous: self.attemptSynchronous ) } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 66e2d188bc..ab34e8964d 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -3702,6 +3702,8 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G }, cancelInteractiveKeyboardGestures: { [weak self] in (self?.view.window as? WindowHost)?.cancelInteractiveKeyboardGestures() self?.chatDisplayNode.cancelInteractiveKeyboardGestures() + }, dismissTextInput: { [weak self] in + self?.chatDisplayNode.dismissTextInput() }, automaticMediaDownloadSettings: self.automaticMediaDownloadSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: self.stickerSettings, presentationContext: ChatPresentationContext(context: context, backgroundNode: self.chatBackgroundNode)) self.controllerInteraction = controllerInteraction diff --git a/submodules/TelegramUI/Sources/ChatControllerInteraction.swift b/submodules/TelegramUI/Sources/ChatControllerInteraction.swift index 36261570fc..95c6a9da12 100644 --- a/submodules/TelegramUI/Sources/ChatControllerInteraction.swift +++ b/submodules/TelegramUI/Sources/ChatControllerInteraction.swift @@ -141,6 +141,7 @@ public final class ChatControllerInteraction { let requestMessageUpdate: (MessageId) -> Void let cancelInteractiveKeyboardGestures: () -> Void + let dismissTextInput: () -> Void var canPlayMedia: Bool = false var hiddenMedia: [MessageId: [Media]] = [:] @@ -243,6 +244,7 @@ public final class ChatControllerInteraction { openWebView: @escaping (String, String, Bool, Bool) -> Void, requestMessageUpdate: @escaping (MessageId) -> Void, cancelInteractiveKeyboardGestures: @escaping () -> Void, + dismissTextInput: @escaping () -> Void, automaticMediaDownloadSettings: MediaAutoDownloadSettings, pollActionState: ChatInterfacePollActionState, stickerSettings: ChatInterfaceStickerSettings, @@ -330,6 +332,7 @@ public final class ChatControllerInteraction { self.openWebView = openWebView self.requestMessageUpdate = requestMessageUpdate self.cancelInteractiveKeyboardGestures = cancelInteractiveKeyboardGestures + self.dismissTextInput = dismissTextInput self.automaticMediaDownloadSettings = automaticMediaDownloadSettings diff --git a/submodules/TelegramUI/Sources/ChatControllerNode.swift b/submodules/TelegramUI/Sources/ChatControllerNode.swift index 230b858fc1..b1ad2afa2d 100644 --- a/submodules/TelegramUI/Sources/ChatControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatControllerNode.swift @@ -2317,6 +2317,10 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { self.view.window?.endEditing(true) } + func dismissTextInput() { + self.view.window?.endEditing(true) + } + func collapseInput() { if self.inputPanelContainerNode.expansionFraction != 0.0 { self.inputPanelContainerNode.collapse() @@ -2866,6 +2870,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate { guard let strongSelf = self else { return } + strongSelf.dismissTextInput() var replaceImpl: ((ViewController) -> Void)? let controller = PremiumDemoScreen(context: strongSelf.context, subject: .premiumStickers, action: { diff --git a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift index 17e7d41d94..5fa9774f2f 100644 --- a/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift +++ b/submodules/TelegramUI/Sources/ChatRecentActionsControllerNode.swift @@ -537,6 +537,7 @@ final class ChatRecentActionsControllerNode: ViewControllerTracingNode { }, openWebView: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { + }, dismissTextInput: { }, automaticMediaDownloadSettings: self.automaticMediaDownloadSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(loopAnimatedStickers: false), presentationContext: ChatPresentationContext(context: context, backgroundNode: self.backgroundNode)) self.controllerInteraction = controllerInteraction diff --git a/submodules/TelegramUI/Sources/DrawingStickersScreen.swift b/submodules/TelegramUI/Sources/DrawingStickersScreen.swift index 0e8743ef92..97ea2d7c5e 100644 --- a/submodules/TelegramUI/Sources/DrawingStickersScreen.swift +++ b/submodules/TelegramUI/Sources/DrawingStickersScreen.swift @@ -163,6 +163,7 @@ private final class DrawingStickersScreenNode: ViewControllerTracingNode { }, openWebView: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { + }, dismissTextInput: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(loopAnimatedStickers: true), presentationContext: ChatPresentationContext(context: context, backgroundNode: nil)) diff --git a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift index 7918d25600..928371d929 100644 --- a/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift +++ b/submodules/TelegramUI/Sources/OverlayAudioPlayerControllerNode.swift @@ -155,6 +155,7 @@ final class OverlayAudioPlayerControllerNode: ViewControllerTracingNode, UIGestu }, openWebView: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { + }, dismissTextInput: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(loopAnimatedStickers: false), presentationContext: ChatPresentationContext(context: context, backgroundNode: nil)) self.dimNode = ASDisplayNode() diff --git a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift index 1f46cd824e..0653983289 100644 --- a/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift +++ b/submodules/TelegramUI/Sources/PeerInfo/PeerInfoScreen.swift @@ -2356,6 +2356,7 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, UIScrollViewDelegate }, openWebView: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { + }, dismissTextInput: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(loopAnimatedStickers: false), presentationContext: ChatPresentationContext(context: context, backgroundNode: nil)) self.hiddenMediaDisposable = context.sharedContext.mediaManager.galleryHiddenMediaManager.hiddenIds().start(next: { [weak self] ids in diff --git a/submodules/TelegramUI/Sources/SharedAccountContext.swift b/submodules/TelegramUI/Sources/SharedAccountContext.swift index 260943c25f..00ae018e33 100644 --- a/submodules/TelegramUI/Sources/SharedAccountContext.swift +++ b/submodules/TelegramUI/Sources/SharedAccountContext.swift @@ -1334,6 +1334,7 @@ public final class SharedAccountContextImpl: SharedAccountContext { }, openWebView: { _, _, _, _ in }, requestMessageUpdate: { _ in }, cancelInteractiveKeyboardGestures: { + }, dismissTextInput: { }, automaticMediaDownloadSettings: MediaAutoDownloadSettings.defaultSettings, pollActionState: ChatInterfacePollActionState(), stickerSettings: ChatInterfaceStickerSettings(loopAnimatedStickers: false), presentationContext: ChatPresentationContext(context: context, backgroundNode: backgroundNode as? WallpaperBackgroundNode))