diff --git a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift index d99c106308..96f41c65bc 100644 --- a/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift +++ b/submodules/TelegramUI/Components/MediaEditorScreen/Sources/MediaEditorScreen.swift @@ -392,6 +392,7 @@ final class MediaEditorScreenComponent: Component { } } + private var nextTransitionUserData: Any? @objc private func deactivateInput() { guard let view = self.inputPanel.view as? MessageInputPanelComponent.View else { return @@ -400,7 +401,12 @@ final class MediaEditorScreenComponent: Component { self.currentInputMode = .text if hasFirstResponder(self) { if let view = self.inputPanel.view as? MessageInputPanelComponent.View { - view.deactivateInput() + self.nextTransitionUserData = TextFieldComponent.AnimationHint(kind: .textFocusChanged) + if view.isActive { + view.deactivateInput() + } else { + self.endEditing(true) + } } } else { self.state?.updated(transition: .spring(duration: 0.4).withUserData(TextFieldComponent.AnimationHint(kind: .textFocusChanged))) @@ -644,6 +650,12 @@ final class MediaEditorScreenComponent: Component { let environment = environment[ViewControllerComponentContainer.Environment.self].value self.environment = environment + var transition = transition + if let nextTransitionUserData = self.nextTransitionUserData { + self.nextTransitionUserData = nil + transition = transition.withUserData(nextTransitionUserData) + } + var isEditingStory = false if let controller = environment.controller() as? MediaEditorScreen { isEditingStory = controller.isEditingStory @@ -1077,8 +1089,6 @@ final class MediaEditorScreenComponent: Component { }) } - keyboardHeight = inputHeight - let nextInputMode: MessageInputPanelComponent.InputMode switch self.currentInputMode { case .text: @@ -1209,6 +1219,7 @@ final class MediaEditorScreenComponent: Component { inputHeight = max(inputHeight, environment.deviceMetrics.standardInputHeight(inLandscape: false)) } } + keyboardHeight = inputHeight let fadeTransition = Transition(animation: .curve(duration: 0.3, curve: .easeInOut)) if self.inputPanelExternalState.isEditing { @@ -2806,7 +2817,7 @@ public final class MediaEditorScreen: ViewController, UIDropInteractionDelegate } self.containerLayoutUpdated(layout: layout, forceUpdate: forceUpdate, hasAppeared: self.hasAppeared, transition: transition) } - + func containerLayoutUpdated(layout: ContainerViewLayout, forceUpdate: Bool = false, hasAppeared: Bool = false, transition: Transition) { guard let controller = self.controller, !self.isDismissed else { return diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift index 96788cedbb..f3562d2e2a 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift @@ -400,6 +400,14 @@ public final class MessageInputPanelComponent: Component { } } + public var isActive: Bool { + if let textFieldView = self.textField.view as? TextFieldComponent.View { + return textFieldView.isActive + } else { + return false + } + } + public func deactivateInput() { if self.canDeactivateInput() { if let textFieldView = self.textField.view as? TextFieldComponent.View { diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index 8274a49433..56ea88065e 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -1944,6 +1944,7 @@ public final class StoryItemSetContainerComponent: Component { containerSize: CGSize(width: inputPanelAvailableWidth, height: 200.0) ) + var inputPanelInset: CGFloat = component.containerInsets.bottom var inputHeight = component.inputHeight if self.inputPanelExternalState.isEditing { if self.sendMessageContext.currentInputMode == .media || (inputHeight.isZero && keyboardWasHidden) { @@ -1954,6 +1955,7 @@ public final class StoryItemSetContainerComponent: Component { let inputMediaNodeHeight = self.sendMessageContext.updateInputMediaNode(inputPanel: self.inputPanel, availableSize: availableSize, bottomInset: component.safeInsets.bottom, bottomContainerInset: component.containerInsets.bottom, inputHeight: component.inputHeight, effectiveInputHeight: inputHeight, metrics: component.metrics, deviceMetrics: component.deviceMetrics, transition: transition) if inputMediaNodeHeight > 0.0 { inputHeight = inputMediaNodeHeight + inputPanelInset = 0.0 } keyboardHeight = inputHeight @@ -1982,11 +1984,12 @@ public final class StoryItemSetContainerComponent: Component { }) } + let inputPanelBackgroundHeight = keyboardHeight + 60.0 - inputPanelInset let inputPanelBackgroundSize = self.inputPanelBackground.update( transition: transition, component: AnyComponent(BlurredGradientComponent(position: .bottom, dark: true, tag: nil)), environment: {}, - containerSize: CGSize(width: availableSize.width, height: max(0.0, keyboardHeight + 100.0 - component.containerInsets.bottom)) + containerSize: CGSize(width: availableSize.width, height: max(0.0, inputPanelBackgroundHeight)) ) if let inputPanelBackgroundView = self.inputPanelBackground.view { if inputPanelBackgroundView.superview == nil { @@ -2012,7 +2015,7 @@ public final class StoryItemSetContainerComponent: Component { inputPanelIsOverlay = false } else { bottomContentInset += 44.0 - inputPanelBottomInset = inputHeight - component.containerInsets.bottom + inputPanelBottomInset = inputHeight - inputPanelInset inputPanelIsOverlay = true } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index 47bbd32d0b..dcb7d9809d 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -2466,7 +2466,7 @@ final class StoryItemSetContainerSendMessage { }) } - func openPeerMention(view: StoryItemSetContainerComponent.View, name: String, navigation: ChatControllerInteractionNavigateToPeer = .default, sourceMessageId: MessageId? = nil) { + func openPeerMention(view: StoryItemSetContainerComponent.View, name: String, sourceMessageId: MessageId? = nil) { guard let component = view.component, let parentController = component.controller() else { return } @@ -2512,11 +2512,11 @@ final class StoryItemSetContainerSendMessage { return } if let peer = peer { - var navigation = navigation - if case .default = navigation { - if let peer = peer as? TelegramUser, peer.botInfo != nil { - navigation = .chat(textInputState: nil, subject: nil, peekData: nil) - } + var navigation: ChatControllerInteractionNavigateToPeer + if let peer = peer as? TelegramUser, peer.botInfo == nil { + navigation = .info + } else { + navigation = .chat(textInputState: nil, subject: nil, peekData: nil) } self.openResolved(view: view, result: .peer(peer, navigation)) } else { diff --git a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift index c953ce79b3..9dfc351541 100644 --- a/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift +++ b/submodules/TelegramUI/Components/TextFieldComponent/Sources/TextFieldComponent.swift @@ -505,6 +505,10 @@ public final class TextFieldComponent: Component { self.textView.resignFirstResponder() } + public var isActive: Bool { + return self.textView.isFirstResponder + } + private var spoilersRevealed = false private var spoilerIsDisappearing = false private func updateSpoilersRevealed(animated: Bool = true) {