diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index 96f41c65bc..d8b4439149 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -2690,7 +2690,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } } - func updateEditProgress(_ progress: Float) { + func updateEditProgress(_ progress: Float, cancel: @escaping () -> Void) { guard let controller = self.controller else { return } @@ -2708,6 +2708,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } else { let tooltipController = SaveProgressScreen(context: self.context, content: .progress(text, 0.0)) tooltipController.cancelled = { [weak self] in + cancel() if let self, let controller = self.controller { controller.cancelVideoExport() } @@ -4134,8 +4135,8 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } } - public func updateEditProgress(_ progress: Float) { - self.node.updateEditProgress(progress) + public func updateEditProgress(_ progress: Float, cancel: @escaping () -> Void) { + self.node.updateEditProgress(progress, cancel: cancel) } fileprivate func dismissAllTooltips() { diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift index a6440e81d4..f60d1f6655 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryAuthorInfoComponent.swift @@ -76,6 +76,7 @@ final class StoryAuthorInfoComponent: Component { let size = availableSize let spacing: CGFloat = 0.0 + let leftInset: CGFloat = 54.0 let presentationData = component.context.sharedContext.currentPresentationData.with({ $0 }) @@ -83,7 +84,11 @@ final class StoryAuthorInfoComponent: Component { if component.peer?.id == component.context.account.peerId { title = component.strings.Story_HeaderYourStory } else { - title = component.peer?.debugDisplayTitle ?? "" + if let _ = component.counters { + title = component.peer?.compactDisplayTitle ?? "" + } else { + title = component.peer?.debugDisplayTitle ?? "" + } } let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970) @@ -102,7 +107,7 @@ final class StoryAuthorInfoComponent: Component { maximumNumberOfLines: 1 )), environment: {}, - containerSize: availableSize + containerSize: CGSize(width: availableSize.width - leftInset, height: availableSize.height) ) let subtitleSize = self.subtitle.update( transition: .immediate, @@ -112,12 +117,12 @@ final class StoryAuthorInfoComponent: Component { maximumNumberOfLines: 1 )), environment: {}, - containerSize: availableSize + containerSize: CGSize(width: availableSize.width - leftInset, height: availableSize.height) ) let contentHeight: CGFloat = titleSize.height + spacing + subtitleSize.height - let titleFrame = CGRect(origin: CGPoint(x: 54.0, y: 2.0 + floor((availableSize.height - contentHeight) * 0.5)), size: titleSize) - let subtitleFrame = CGRect(origin: CGPoint(x: 54.0, y: titleFrame.maxY + spacing + UIScreenPixel), size: subtitleSize) + let titleFrame = CGRect(origin: CGPoint(x: leftInset, y: 2.0 + floor((availableSize.height - contentHeight) * 0.5)), size: titleSize) + let subtitleFrame = CGRect(origin: CGPoint(x: leftInset, y: titleFrame.maxY + spacing + UIScreenPixel), size: subtitleSize) if let titleView = self.title.view { if titleView.superview == nil { diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift index ea8b389c05..6cadc3a186 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryContainerScreen.swift @@ -613,6 +613,8 @@ private final class StoryContainerScreenComponent: Component { } private func beginHorizontalPan(translation: CGPoint) { + self.dismissAllTooltips() + if self.layer.animation(forKey: "panState") != nil { self.layer.removeAnimation(forKey: "panState") } @@ -876,6 +878,8 @@ private final class StoryContainerScreenComponent: Component { controller.forEachController { controller in if let controller = controller as? UndoOverlayController { controller.dismissWithCommitAction() + } else if let controller = controller as? TooltipScreen { + controller.dismiss() } return true } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 756fbd375f..44e59272a7 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -2611,7 +2611,7 @@ public final class StoryItemSetContainerComponent: Component { } })), environment: {}, - containerSize: CGSize(width: max(10.0, headerRightOffset), height: 44.0) + containerSize: CGSize(width: headerRightOffset - 10.0, height: 44.0) ) if let view = currentCenterInfoItem.view.view { var animateIn = false @@ -3203,13 +3203,15 @@ public final class StoryItemSetContainerComponent: Component { } let presentationData = component.context.sharedContext.currentPresentationData.with { $0 } - self.component?.presentController(UndoOverlayController( + let controller = UndoOverlayController( presentationData: presentationData, content: .info(title: nil, text: text, timeout: nil), elevatedLayout: false, animateInAsReplacement: false, action: { _ in return false } - ), nil) + ) + self.sendMessageContext.tooltipScreen = controller + self.component?.presentController(controller, nil) } private func openItemPrivacySettings(initialPrivacy: EngineStoryPrivacy? = nil) { @@ -3460,7 +3462,8 @@ public final class StoryItemSetContainerComponent: Component { ) } } - + + let updateDisposable = MetaDisposable() var updateProgressImpl: ((Float) -> Void)? let controller = MediaEditorScreen( context: context, @@ -3493,7 +3496,7 @@ public final class StoryItemSetContainerComponent: Component { updateProgressImpl?(0.0) if let imageData = compressImageToJPEG(image, quality: 0.7) { - let _ = (context.engine.messages.editStory(id: id, media: .image(dimensions: dimensions, data: imageData, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: updatedPrivacy) + updateDisposable.set((context.engine.messages.editStory(id: id, media: .image(dimensions: dimensions, data: imageData, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: updatedPrivacy) |> deliverOnMainQueue).start(next: { [weak self] result in guard let self else { return @@ -3511,7 +3514,7 @@ public final class StoryItemSetContainerComponent: Component { commit({}) } } - }) + })) } case let .video(content, firstFrameImage, values, duration, dimensions): updateProgressImpl?(0.0) @@ -3541,7 +3544,7 @@ public final class StoryItemSetContainerComponent: Component { } } - let _ = (context.engine.messages.editStory(id: id, media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: updatedPrivacy) + updateDisposable.set((context.engine.messages.editStory(id: id, media: .video(dimensions: dimensions, duration: duration, resource: resource, firstFrameFile: firstFrameFile, stickers: stickers), text: updatedText, entities: updatedEntities, privacy: updatedPrivacy) |> deliverOnMainQueue).start(next: { [weak self] result in guard let self else { return @@ -3559,7 +3562,7 @@ public final class StoryItemSetContainerComponent: Component { commit({}) } } - }) + })) } } } else if updatedText != nil || updatedPrivacy != nil { @@ -3599,7 +3602,9 @@ public final class StoryItemSetContainerComponent: Component { } self.component?.controller()?.push(controller) updateProgressImpl = { [weak controller] progress in - controller?.updateEditProgress(progress) + controller?.updateEditProgress(progress, cancel: { + updateDisposable.dispose() + }) } } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index beed7ae61d..877381838c 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -94,10 +94,6 @@ final class StoryItemSetContainerSendMessage { self.navigationActionDisposable.dispose() self.resolvePeerByNameDisposable.dispose() self.inputMediaNodeDataDisposable?.dispose() - - if let tooltipScreen = self.tooltipScreen { - tooltipScreen.dismiss() - } } func setup(context: AccountContext, view: StoryItemSetContainerComponent.View, inputPanelExternalState: MessageInputPanelComponent.ExternalState, keyboardInputData: Signal) {