From 6016ae3b98603f4dc38484149267a9972ffa98c1 Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 3 Aug 2023 23:09:25 +0300 Subject: [PATCH] Stories --- .../Sources/MessageInputPanelComponent.swift | 29 +++++++++++++++---- ...StoryItemSetContainerViewSendMessage.swift | 2 +- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift index 0cf5e09875..f15878e994 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift @@ -648,7 +648,7 @@ public final class MessageInputPanelComponent: Component { fieldBackgroundFrame = fieldFrame } else { fieldBackgroundFrame = CGRect(origin: CGPoint(x: mediaInsets.left, y: insets.top), size: CGSize(width: availableSize.width - mediaInsets.left - insets.right, height: textFieldSize.height)) - if let _ = component.likeAction { + if component.likeAction != nil && component.forwardAction != nil { fieldBackgroundFrame.size.width -= 49.0 } } @@ -1019,7 +1019,22 @@ public final class MessageInputPanelComponent: Component { containerSize: CGSize(width: 33.0, height: 33.0) ) - let hasLikeAction = !(isEditing || component.likeAction == nil) + let hasLikeAction: Bool + let displayLikeAction: Bool + let likeActionReplacesInputAction: Bool + if component.likeAction == nil { + hasLikeAction = false + displayLikeAction = false + likeActionReplacesInputAction = false + } else if isEditing { + hasLikeAction = false + displayLikeAction = false + likeActionReplacesInputAction = false + } else { + hasLikeAction = component.forwardAction != nil + likeActionReplacesInputAction = component.forwardAction == nil + displayLikeAction = true + } var inputActionButtonOriginX: CGFloat if component.setMediaRecordingActive != nil || isEditing { @@ -1039,7 +1054,11 @@ public final class MessageInputPanelComponent: Component { let inputActionButtonFrame = CGRect(origin: CGPoint(x: inputActionButtonOriginX, y: size.height - insets.bottom - baseFieldHeight + floor((baseFieldHeight - inputActionButtonSize.height) * 0.5)), size: inputActionButtonSize) transition.setPosition(view: inputActionButtonView, position: inputActionButtonFrame.center) transition.setBounds(view: inputActionButtonView, bounds: CGRect(origin: CGPoint(), size: inputActionButtonFrame.size)) - inputActionButtonOriginX += 41.0 + transition.setAlpha(view: inputActionButtonView, alpha: likeActionReplacesInputAction ? 0.0 : 1.0) + + if hasLikeAction { + inputActionButtonOriginX += 41.0 + } } let likeButtonSize = self.likeButton.update( @@ -1082,14 +1101,14 @@ public final class MessageInputPanelComponent: Component { let likeButtonFrame = CGRect(origin: CGPoint(x: inputActionButtonOriginX, y: size.height - insets.bottom - baseFieldHeight + floor((baseFieldHeight - likeButtonSize.height) * 0.5)), size: likeButtonSize) transition.setPosition(view: likeButtonView, position: likeButtonFrame.center) transition.setBounds(view: likeButtonView, bounds: CGRect(origin: CGPoint(), size: likeButtonFrame.size)) - transition.setAlpha(view: likeButtonView, alpha: hasLikeAction ? 1.0 : 0.0) + transition.setAlpha(view: likeButtonView, alpha: displayLikeAction ? 1.0 : 0.0) inputActionButtonOriginX += 41.0 } var fieldIconNextX = fieldBackgroundFrame.maxX - 4.0 var inputModeVisible = false - if component.style == .story || isEditing { + if isEditing { inputModeVisible = true } diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift index fe27e8ca94..19190a9b39 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerViewSendMessage.swift @@ -2989,7 +2989,7 @@ final class StoryItemSetContainerSendMessage { } let timestamp = Int32(Date().timeIntervalSince1970) - if let activeUntilTimestamp = config.stealthModeState.actualizedNow().activeUntilTimestamp, activeUntilTimestamp > timestamp, !"".isEmpty { + if let activeUntilTimestamp = config.stealthModeState.actualizedNow().activeUntilTimestamp, activeUntilTimestamp > timestamp { let remainingActiveSeconds = activeUntilTimestamp - timestamp let presentationData = component.context.sharedContext.currentPresentationData.with { $0 }.withUpdated(theme: defaultDarkPresentationTheme)