From b9ba7336bb3ec58382c7bbc76aa09b01c8c75092 Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Fri, 27 Feb 2026 15:24:38 +0400 Subject: [PATCH] Various fixes --- .../AccountContext/Sources/AccountContext.swift | 1 + .../Sources/Items/ChatImageGalleryItem.swift | 1 + .../Sources/MediaEditorScreen.swift | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/submodules/AccountContext/Sources/AccountContext.swift b/submodules/AccountContext/Sources/AccountContext.swift index 4bf66ba784..0851c30af7 100644 --- a/submodules/AccountContext/Sources/AccountContext.swift +++ b/submodules/AccountContext/Sources/AccountContext.swift @@ -1008,6 +1008,7 @@ public protocol CameraScreen: ViewController { } public protocol MediaEditorScreen: ViewController { + var customNavigationController: UINavigationController? { get set } } public protocol MediaPickerScreen: ViewController { diff --git a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift index 8cb2d0b1a6..51a087ab2e 100644 --- a/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift +++ b/submodules/GalleryUI/Sources/Items/ChatImageGalleryItem.swift @@ -743,6 +743,7 @@ final class ChatImageGalleryItemNode: ZoomableContentGalleryItemNode { } galleryController.willDismiss() (navigationController.topViewController as? ViewController)?.present(controller, in: .window(.root)) + (controller as? MediaEditorScreen)?.customNavigationController = navigationController self.imageNode.isHidden = true Queue.mainQueue().after(0.5, { galleryController.dismiss() diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index 9848ee07a7..c70994a019 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -6742,6 +6742,16 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID fileprivate let customTarget: EnginePeer.Id? let forwardSource: (EnginePeer, EngineStoryItem)? + public weak var customNavigationController: UINavigationController? + + var effectiveNavigationController: UINavigationController? { + if let navigationController = self.navigationController { + return navigationController + } else { + return self.customNavigationController + } + } + let initialCaption: NSAttributedString? let initialPrivacy: EngineStoryPrivacy? let initialMediaAreas: [MediaArea]? @@ -8145,7 +8155,7 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID self?.stickerUploadDisposable.set(nil) }) case let .complete(resource, _): - let navigationController = self.navigationController as? NavigationController + let navigationController = self.effectiveNavigationController as? NavigationController let result: MediaEditorScreenImpl.Result switch action { @@ -8174,7 +8184,7 @@ public final class MediaEditorScreenImpl: ViewController, MediaEditorScreen, UID parentController.present(UndoOverlayController(presentationData: presentationData, content: .sticker(context: self.context, file: file, loop: true, title: nil, text: presentationData.strings.Conversation_StickerAddedToFavorites, undoText: nil, customAction: nil), elevatedLayout: false, action: { _ in return false }), in: .current) } case .addToStickerPack, .createStickerPack: - if let (packReference, packTitle) = packReferenceAndTitle, let navigationController = self.navigationController as? NavigationController { + if let (packReference, packTitle) = packReferenceAndTitle, let navigationController { Queue.mainQueue().after(0.2) { let controller = self.context.sharedContext.makeStickerPackScreen(context: self.context, updatedPresentationData: nil, mainStickerPack: packReference, stickerPacks: [packReference], loadedStickerPacks: [], actionTitle: nil, isEditing: false, expandIfNeeded: true, parentNavigationController: navigationController, sendSticker: self.sendSticker, actionPerformed: nil) (navigationController.viewControllers.last as? ViewController)?.present(controller, in: .window(.root))