From 071ecf8a60756a383f9fe07847c07fb13219cf68 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Mon, 13 Mar 2023 18:54:01 +0400 Subject: [PATCH] Various fixes --- .../Telegram-iOS/en.lproj/Localizable.strings | 3 ++ .../Sources/AttachmentController.swift | 6 +++ .../Sources/ChatListController.swift | 7 +++ .../Sources/StickerPackScreen.swift | 8 ++++ .../Sources/ChatEntityKeyboardInputNode.swift | 43 ++++++++++++++++--- .../Sources/EmojiPagerContentComponent.swift | 6 ++- .../Sources/DataUsageScreen.swift | 6 +-- ...MessageInstantVideoBubbleContentNode.swift | 4 +- .../ChatTextInputActionButtonsNode.swift | 8 ++++ .../ChatTextInputMediaRecordingButton.swift | 4 -- 10 files changed, 78 insertions(+), 17 deletions(-) diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index a2132ae8c2..efa2fc7a05 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -8854,6 +8854,9 @@ Sorry for the inconvenience."; "DataUsage.TopSectionMobile" = "Mobile"; "DataUsage.TopSectionWifi" = "Wifi"; +"DataUsage.Title" = "Data Usage"; +"DataUsage.NoDataUsed" = "No Data Used"; + "Translation.Language.en" = "English"; "Translation.Language.ar" = "Arabic"; "Translation.Language.zh" = "Chinese"; diff --git a/submodules/AttachmentUI/Sources/AttachmentController.swift b/submodules/AttachmentUI/Sources/AttachmentController.swift index dd710e2c5e..552aefab1c 100644 --- a/submodules/AttachmentUI/Sources/AttachmentController.swift +++ b/submodules/AttachmentUI/Sources/AttachmentController.swift @@ -967,9 +967,15 @@ public class AttachmentController: ViewController { private var validLayout: ContainerViewLayout? override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { + let previousSize = self.validLayout?.size super.containerLayoutUpdated(layout, transition: transition) self.validLayout = layout + if let previousSize, previousSize != layout.size { + Queue.mainQueue().after(0.1) { + self.node.containerLayoutUpdated(layout, transition: transition) + } + } self.node.containerLayoutUpdated(layout, transition: transition) } diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index febbaaa2a5..31209f9e0d 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -771,7 +771,14 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController return componentView.findTitleView() } + private var previousEmojiSetupTimestamp: Double? private func openStatusSetup(sourceView: UIView) { + let currentTimestamp = CACurrentMediaTime() + if let previousTimestamp = self.previousEmojiSetupTimestamp, currentTimestamp < previousTimestamp + 1.0 { + return + } + self.previousEmojiSetupTimestamp = currentTimestamp + self.emojiStatusSelectionController?.dismiss() var selectedItems = Set() var topStatusTitle = self.presentationData.strings.PeerStatusSetup_NoTimerTitle diff --git a/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift b/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift index c116cf3c46..2124e1d528 100644 --- a/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift +++ b/submodules/StickerPackPreviewUI/Sources/StickerPackScreen.swift @@ -2115,9 +2115,17 @@ public final class StickerPackScreenImpl: ViewController { } } + private var validLayout: ContainerViewLayout? override public func containerLayoutUpdated(_ layout: ContainerViewLayout, transition: ContainedViewLayoutTransition) { + let previousSize = self.validLayout?.size super.containerLayoutUpdated(layout, transition: transition) + self.validLayout = layout + if let previousSize, previousSize != layout.size { + Queue.mainQueue().after(0.1) { + self.controllerNode.containerLayoutUpdated(layout, transition: transition) + } + } self.controllerNode.containerLayoutUpdated(layout, transition: transition) } } diff --git a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift index 9ee3acfe7c..c78e371c5b 100644 --- a/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift +++ b/submodules/TelegramUI/Components/ChatEntityKeyboardInputNode/Sources/ChatEntityKeyboardInputNode.swift @@ -570,6 +570,17 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { private weak var currentUndoOverlayController: UndoOverlayController? + private var choosingStickerDisposable: Disposable? + private var scrollingStickersGridPromise = Promise(false) + private var previewingStickersPromise = ValuePromise(false) + private var choosingSticker: Signal { + return combineLatest(self.scrollingStickersGridPromise.get(), self.previewingStickersPromise.get()) + |> map { scrollingStickersGrid, previewingStickers -> Bool in + return scrollingStickersGrid || previewingStickers + } + |> distinctUntilChanged + } + public init(context: AccountContext, currentInputData: InputData, updatedInputData: Signal, defaultToEmojiTab: Bool, opaqueTopPanelBackground: Bool = false, controllerInteraction: ChatControllerInteraction?, interfaceInteraction: ChatPanelInterfaceInteraction?, chatPeerId: PeerId?) { self.context = context self.currentInputData = currentInputData @@ -679,7 +690,10 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { }, presentController: controllerInteraction.presentController, presentGlobalOverlayController: controllerInteraction.presentGlobalOverlayController, - navigationController: controllerInteraction.navigationController + navigationController: controllerInteraction.navigationController, + updateIsPreviewing: { [weak self] value in + self?.previewingStickersPromise.set(value) + } ), chatPeerId: chatPeerId, present: { c, a in @@ -1670,6 +1684,13 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { } }) } + + self.choosingStickerDisposable = (self.choosingSticker + |> deliverOnMainQueue).start(next: { [weak self] value in + if let strongSelf = self { + strongSelf.controllerInteraction?.updateChoosingSticker(value) + } + }) } deinit { @@ -1677,6 +1698,7 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { self.hasRecentGifsDisposable?.dispose() self.emojiSearchDisposable.dispose() self.stickerSearchDisposable.dispose() + self.choosingStickerDisposable?.dispose() } private func reloadGifContext() { @@ -1772,6 +1794,10 @@ public final class ChatEntityKeyboardInputNode: ChatInputNode { stickerContent?.inputInteractionHolder.inputInteraction = self.stickerInputInteraction self.currentInputData.emoji?.inputInteractionHolder.inputInteraction = self.emojiInputInteraction + if let stickerInputInteraction = self.stickerInputInteraction { + self.scrollingStickersGridPromise.set(stickerInputInteraction.scrollingStickersGridPromise.get()) + } + let startTime = CFAbsoluteTimeGetCurrent() var keyboardBottomInset = bottomInset @@ -2466,8 +2492,9 @@ public final class EmojiContentPeekBehaviorImpl: EmojiContentPeekBehavior { public let presentController: (ViewController, Any?) -> Void public let presentGlobalOverlayController: (ViewController, Any?) -> Void public let navigationController: () -> NavigationController? + public let updateIsPreviewing: (Bool) -> Void - public init(sendSticker: @escaping (FileMediaReference, Bool, Bool, String?, Bool, UIView, CGRect, CALayer?, [ItemCollectionId]) -> Bool, sendEmoji: @escaping (TelegramMediaFile) -> Void, setStatus: @escaping (TelegramMediaFile) -> Void, copyEmoji: @escaping (TelegramMediaFile) -> Void, presentController: @escaping (ViewController, Any?) -> Void, presentGlobalOverlayController: @escaping (ViewController, Any?) -> Void, navigationController: @escaping () -> NavigationController?) { + public init(sendSticker: @escaping (FileMediaReference, Bool, Bool, String?, Bool, UIView, CGRect, CALayer?, [ItemCollectionId]) -> Bool, sendEmoji: @escaping (TelegramMediaFile) -> Void, setStatus: @escaping (TelegramMediaFile) -> Void, copyEmoji: @escaping (TelegramMediaFile) -> Void, presentController: @escaping (ViewController, Any?) -> Void, presentGlobalOverlayController: @escaping (ViewController, Any?) -> Void, navigationController: @escaping () -> NavigationController?, updateIsPreviewing: @escaping (Bool) -> Void) { self.sendSticker = sendSticker self.sendEmoji = sendEmoji self.setStatus = setStatus @@ -2475,6 +2502,7 @@ public final class EmojiContentPeekBehaviorImpl: EmojiContentPeekBehavior { self.presentController = presentController self.presentGlobalOverlayController = presentGlobalOverlayController self.navigationController = navigationController + self.updateIsPreviewing = updateIsPreviewing } } @@ -2772,11 +2800,12 @@ public final class EmojiContentPeekBehaviorImpl: EmojiContentPeekBehavior { let controller = PeekController(presentationData: presentationData, content: content, sourceView: { return (sourceView, sourceRect) }) - /*controller.visibilityUpdated = { [weak self] visible in - self?.previewingStickersPromise.set(visible) - self?.requestDisableStickerAnimations?(visible) - self?.simulateUpdateLayout(isVisible: !visible) - }*/ + controller.visibilityUpdated = { [weak self] visible in + guard let strongSelf = self, let interaction = strongSelf.interaction else { + return + } + interaction.updateIsPreviewing(visible) + } strongSelf.peekController = controller strongSelf.present(controller, nil) return controller diff --git a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift index 70156804c7..0b62234a2f 100644 --- a/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift +++ b/submodules/TelegramUI/Components/EntityKeyboard/Sources/EmojiPagerContentComponent.swift @@ -2311,6 +2311,7 @@ public final class EmojiPagerContentComponent: Component { public weak var externalExpansionView: UIView? public let useOpaqueTheme: Bool public let hideBackground: Bool + public let scrollingStickersGridPromise = ValuePromise(false) public init( performItemAction: @escaping (AnyHashable, Item, UIView, CGRect, CALayer, Bool) -> Void, @@ -5168,7 +5169,7 @@ public final class EmojiPagerContentComponent: Component { } private var previousScrollingOffset: ScrollingOffsetState? - + public func scrollViewWillBeginDragging(_ scrollView: UIScrollView) { if self.keepTopPanelVisibleUntilScrollingInput { self.keepTopPanelVisibleUntilScrollingInput = false @@ -5188,6 +5189,7 @@ public final class EmojiPagerContentComponent: Component { self.visibleSearchHeader?.deactivate() } self.component?.inputInteractionHolder.inputInteraction?.onScroll() + self.component?.inputInteractionHolder.inputInteraction?.scrollingStickersGridPromise.set(true) } public func ensureSearchUnfocused() { @@ -5217,11 +5219,13 @@ public final class EmojiPagerContentComponent: Component { public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { if !decelerate { self.snapScrollingOffsetToInsets() + self.component?.inputInteractionHolder.inputInteraction?.scrollingStickersGridPromise.set(false) } } public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { self.snapScrollingOffsetToInsets() + self.component?.inputInteractionHolder.inputInteraction?.scrollingStickersGridPromise.set(false) } private func updateScrollingOffset(isReset: Bool, transition: Transition) { diff --git a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift index 8bd6292eee..4bfcb822d8 100644 --- a/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift +++ b/submodules/TelegramUI/Components/StorageUsageScreen/Sources/DataUsageScreen.swift @@ -783,9 +783,9 @@ final class DataUsageScreenComponent: Component { let headerText: String if totalSize == 0 { - headerText = "No Data Used" + headerText = environment.strings.DataUsage_NoDataUsed } else { - headerText = "Data Usage" + headerText = environment.strings.DataUsage_Title } let headerViewSize = self.headerView.update( transition: .immediate, @@ -1125,7 +1125,7 @@ final class DataUsageScreenComponent: Component { transition: transition, component: AnyComponent(DataButtonComponent( theme: environment.theme, - title: "Reset Statistics", + title: environment.strings.NetworkUsageSettings_ResetStats, action: { [weak self] in self?.requestClear() } diff --git a/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift b/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift index 516b4fd898..3fdc0070e2 100644 --- a/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift +++ b/submodules/TelegramUI/Sources/ChatMessageInstantVideoBubbleContentNode.swift @@ -391,11 +391,11 @@ class ChatMessageInstantVideoBubbleContentNode: ChatMessageBubbleContentNode { } override func willUpdateIsExtractedToContextPreview(_ value: Bool) { -// self.interactiveFileNode.willUpdateIsExtractedToContextPreview(value) + self.interactiveFileNode.willUpdateIsExtractedToContextPreview(value) } override func updateIsExtractedToContextPreview(_ value: Bool) { -// self.interactiveFileNode.updateIsExtractedToContextPreview(value) + self.interactiveFileNode.updateIsExtractedToContextPreview(value) } override func tapActionAtPoint(_ point: CGPoint, gesture: TapLongTapOrDoubleTapGesture, isEstimating: Bool) -> ChatMessageBubbleContentTapAction { diff --git a/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift b/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift index 4166d01f0b..8098585a0f 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputActionButtonsNode.swift @@ -2,6 +2,7 @@ import Foundation import UIKit import AsyncDisplayKit import Display +import SwiftSignalKit import TelegramCore import TelegramPresentationData import ContextUI @@ -133,8 +134,15 @@ final class ChatTextInputActionButtonsNode: ASDisplayNode { private var absoluteRect: (CGRect, CGSize)? func updateAbsoluteRect(_ rect: CGRect, within containerSize: CGSize, transition: ContainedViewLayoutTransition) { + let previousContaierSize = self.absoluteRect?.1 self.absoluteRect = (rect, containerSize) self.backdropNode.update(rect: rect, within: containerSize, transition: transition) + + if let previousContaierSize, previousContaierSize != containerSize { + Queue.mainQueue().after(0.2) { + self.micButton.reset() + } + } } func updateLayout(size: CGSize, isMediaInputExpanded: Bool, transition: ContainedViewLayoutTransition, interfaceState: ChatPresentationInterfaceState) { diff --git a/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift b/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift index ca6a3a7964..4a702819c6 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputMediaRecordingButton.swift @@ -131,10 +131,6 @@ private final class ChatTextInputMediaRecordingButtonPresenter : NSObject, TGMod func present() { let windowIsVisible: (UIWindow) -> Bool = { window in - print(window.alpha) - print(window.isHidden) - print(window.frame) - print(window.subviews) return !window.frame.height.isZero }