From fbf7473892575b01e23e48d6e58bb14e0097b92d Mon Sep 17 00:00:00 2001 From: Ilya Laktyushin Date: Sun, 9 Nov 2025 20:16:32 +0400 Subject: [PATCH] Various improvements --- .../CameraScreen/Sources/CameraScreen.swift | 13 ++++--- .../Sources/ChatTextInputPanelComponent.swift | 35 +++++++++++++++++++ .../Sources/ChatTextInputPanelNode.swift | 20 +++++++++-- .../Sources/GiftAuctionInfoScreen.swift | 2 +- .../Sources/MessageInputPanelComponent.swift | 20 +++++++++-- .../StoryItemSetContainerComponent.swift | 5 +-- 6 files changed, 82 insertions(+), 13 deletions(-) diff --git a/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift b/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift index 445e2e8429..7c14762c32 100644 --- a/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift +++ b/submodules/TelegramUI/Components/CameraScreen/Sources/CameraScreen.swift @@ -1582,8 +1582,7 @@ private final class CameraScreenComponent: CombinedComponent { } }, getController: { - return nil - //return controller() + return controller() }, didSetupMediaStream: { [weak state] call in state?.setupLiveStreamCamera(call: call) @@ -1641,8 +1640,8 @@ private final class CameraScreenComponent: CombinedComponent { ) } - if case .none = component.cameraState.recording, !state.isTransitioning && !component.cameraState.isStreaming { - if !state.displayingCollageSelection { + if case .none = component.cameraState.recording, !state.isTransitioning { + if !state.displayingCollageSelection && !component.cameraState.isStreaming { let cancelButton = cancelButton.update( component: CameraButton( content: AnyComponentWithIdentity( @@ -1750,7 +1749,11 @@ private final class CameraScreenComponent: CombinedComponent { let rightMostButtonWidth: CGFloat if component.cameraState.mode == .live { - rightMostButtonWidth = -55.0 + if component.cameraState.isStreaming { + rightMostButtonWidth = -25.0 + } else { + rightMostButtonWidth = -55.0 + } } else if state.displayingCollageSelection { let disableCollageButton = disableCollageButton.update( component: CameraButton( diff --git a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelComponent.swift b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelComponent.swift index ddc161fc45..b07c97b471 100644 --- a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelComponent.swift +++ b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelComponent.swift @@ -60,6 +60,7 @@ public final class ChatTextInputPanelComponent: Component { case empty case attach case toggleExpanded(isVisible: Bool, isExpanded: Bool, hasUnseen: Bool) + case settings } public let kind: Kind @@ -144,6 +145,7 @@ public final class ChatTextInputPanelComponent: Component { let chatPeerId: EnginePeer.Id let inlineActions: [InlineAction] let leftAction: LeftAction? + let secondaryLeftAction: LeftAction? let rightAction: RightAction? let sendAsConfiguration: SendAsConfiguration? let placeholder: String @@ -166,6 +168,7 @@ public final class ChatTextInputPanelComponent: Component { chatPeerId: EnginePeer.Id, inlineActions: [InlineAction], leftAction: LeftAction?, + secondaryLeftAction: LeftAction?, rightAction: RightAction?, sendAsConfiguration: SendAsConfiguration?, placeholder: String, @@ -187,6 +190,7 @@ public final class ChatTextInputPanelComponent: Component { self.chatPeerId = chatPeerId self.inlineActions = inlineActions self.leftAction = leftAction + self.secondaryLeftAction = secondaryLeftAction self.rightAction = rightAction self.sendAsConfiguration = sendAsConfiguration self.placeholder = placeholder @@ -224,6 +228,9 @@ public final class ChatTextInputPanelComponent: Component { if lhs.leftAction != rhs.leftAction { return false } + if lhs.secondaryLeftAction != rhs.secondaryLeftAction { + return false + } if lhs.rightAction != rhs.rightAction { return false } @@ -865,10 +872,38 @@ public final class ChatTextInputPanelComponent: Component { isVisible = false } panelNode.customLeftAction = .toggleExpanded(isVisible: isVisible, isExpanded: isExpanded, hasUnseen: hasUnseen) + case .settings: + var isVisible = true + if component.insets.bottom > 40.0 { + isVisible = false + } + panelNode.customLeftAction = .settings(isVisible: isVisible) } } else { panelNode.customLeftAction = nil } + if let secondaryLeftAction = component.secondaryLeftAction { + switch secondaryLeftAction.kind { + case .empty: + panelNode.customSecondaryLeftAction = .empty + case .attach: + panelNode.customSecondaryLeftAction = nil + case let .toggleExpanded(isVisible, isExpanded, hasUnseen): + var isVisible = isVisible + if component.insets.bottom > 40.0 { + isVisible = false + } + panelNode.customSecondaryLeftAction = .toggleExpanded(isVisible: isVisible, isExpanded: isExpanded, hasUnseen: hasUnseen) + case .settings: + var isVisible = true + if component.insets.bottom > 40.0 { + isVisible = false + } + panelNode.customSecondaryLeftAction = .settings(isVisible: isVisible) + } + } else { + panelNode.customSecondaryLeftAction = nil + } if let rightAction = component.rightAction { switch rightAction.kind { diff --git a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift index db62c26c5b..934142d182 100644 --- a/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Components/Chat/ChatTextInputPanelNode/Sources/ChatTextInputPanelNode.swift @@ -263,6 +263,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg public let attachmentButton: HighlightTrackingButton public let attachmentButtonBackground: GlassBackgroundView public let attachmentButtonIcon: GlassBackgroundView.ContentImageView + public let secondaryLeftButtonBackground: GlassBackgroundView private var commentsButtonIcon: RasterizedCompositionMonochromeLayer? private var commentsButtonCenterIcon: UIImageView? private var commentsButtonContentsLayer: RasterizedCompositionImageLayer? @@ -388,6 +389,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg public enum LeftAction { case empty case toggleExpanded(isVisible: Bool, isExpanded: Bool, hasUnseen: Bool) + case settings(isVisible: Bool) } public enum RightAction { @@ -398,6 +400,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg public var customPlaceholder: String? public var customIsDisabled: Bool = false public var customLeftAction: LeftAction? + public var customSecondaryLeftAction: LeftAction? public var customRightAction: RightAction? public var customSendColor: UIColor? public var customSendIsDisabled: Bool = false @@ -652,6 +655,9 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg self.attachmentButtonIcon.isUserInteractionEnabled = false self.attachmentButtonBackground.contentView.addSubview(self.attachmentButtonIcon) + self.secondaryLeftButtonBackground = GlassBackgroundView(frame: CGRect()) + //self.secondaryLeftButtonBackground.contentView.addSubview(self.attachmentButton) + self.attachmentButtonDisabledNode = HighlightableButtonNode() self.searchLayoutClearButton = HighlightTrackingButton() self.searchLayoutClearButtonIcon = GlassBackgroundView.ContentImageView() @@ -896,6 +902,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg self.glassBackgroundContainer.contentView.addSubview(self.menuButton.view) self.glassBackgroundContainer.contentView.addSubview(self.attachmentButtonBackground) + self.glassBackgroundContainer.contentView.addSubview(self.secondaryLeftButtonBackground) self.glassBackgroundContainer.contentView.addSubview(self.attachmentButtonDisabledNode.view) self.glassBackgroundContainer.contentView.addSubview(self.startButton.view) @@ -1208,6 +1215,8 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg var insets = UIEdgeInsets(top: 0.0, left: 54.0, bottom: 0.0, right: 8.0) if let customLeftAction = self.customLeftAction, case let .toggleExpanded(isVisible, _, _) = customLeftAction, !isVisible { insets.left = 8.0 + } else if let customLeftAction = self.customLeftAction, case .empty = customLeftAction { + insets.left = 8.0 } return insets } @@ -1751,7 +1760,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg if let customLeftAction = self.customLeftAction { switch customLeftAction { - case .empty, .toggleExpanded: + case .empty, .toggleExpanded, .settings: self.attachmentButtonIcon.image = nil self.attachmentButtonIcon.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor } @@ -1791,7 +1800,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg if wasEditingMedia != isEditingMedia || hadMediaDraft != hasMediaDraft || isFirstTime { if let customLeftAction = self.customLeftAction { switch customLeftAction { - case .empty, .toggleExpanded: + case .empty, .toggleExpanded, .settings: self.attachmentButtonIcon.image = nil self.attachmentButtonIcon.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor } @@ -1944,7 +1953,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg if let customLeftAction = self.customLeftAction { switch customLeftAction { - case .empty: + case .empty, .settings: break case let .toggleExpanded(_, isExpanded, hasUnseen): let commentsButtonIcon: RasterizedCompositionMonochromeLayer @@ -2160,6 +2169,8 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg attachmentButtonX = -48.0 } else if let customLeftAction = self.customLeftAction, case let .toggleExpanded(isVisible, _, _) = customLeftAction, !isVisible { attachmentButtonX = -48.0 + } else if let customLeftAction = self.customLeftAction, case .empty = customLeftAction { + attachmentButtonX = -48.0 } self.mediaActionButtons.micButton.updateMode(mode: interfaceState.interfaceState.mediaRecordingMode, animated: transition.isAnimated) @@ -2280,6 +2291,9 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg break } } + if let customSecondaryLeftAction = self.customSecondaryLeftAction, case let .settings(isVisible) = customSecondaryLeftAction, isVisible { + textFieldInsets.left += 46.0 + } var audioRecordingItemsAlpha: CGFloat = 1.0 if interfaceState.interfaceState.mediaDraftState != nil { diff --git a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionInfoScreen.swift b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionInfoScreen.swift index bf1b49ef15..44d814ba56 100644 --- a/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionInfoScreen.swift +++ b/submodules/TelegramUI/Components/Gifts/GiftViewScreen/Sources/GiftAuctionInfoScreen.swift @@ -201,7 +201,7 @@ private final class GiftAuctionInfoSheetContent: CombinedComponent { component: AnyComponent(ParagraphComponent( title: "Top 50 Bidders", titleColor: textColor, - text: "50 gifts are dropped at varying intervals to the top 50 bidders by bid amount.", + text: "50 gifts are dropped in 10 rounds to the top 50 bidders by bid amount.", textColor: secondaryTextColor, accentColor: linkColor, iconName: "Premium/Auction/Drop", diff --git a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift index 21e1c00fcd..bd954c762b 100644 --- a/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift +++ b/submodules/TelegramUI/Components/MessageInputPanelComponent/Sources/MessageInputPanelComponent.swift @@ -289,6 +289,7 @@ public final class MessageInputPanelComponent: Component { public let storyItem: EngineStoryItem? public let chatLocation: ChatLocation? public let liveChatState: LiveChatState? + public let isEmbeddedInCamera: Bool public let toggleLiveChatExpanded: (() -> Void)? public let sendStarsAction: ((UIView, Bool) -> Void)? public let starStars: StarStats? @@ -355,6 +356,7 @@ public final class MessageInputPanelComponent: Component { storyItem: EngineStoryItem?, chatLocation: ChatLocation?, liveChatState: LiveChatState? = nil, + isEmbeddedInCamera: Bool = false, toggleLiveChatExpanded: (() -> Void)? = nil, sendStarsAction: ((UIView, Bool) -> Void)? = nil, starStars: StarStats? = nil, @@ -420,6 +422,7 @@ public final class MessageInputPanelComponent: Component { self.storyItem = storyItem self.chatLocation = chatLocation self.liveChatState = liveChatState + self.isEmbeddedInCamera = isEmbeddedInCamera self.toggleLiveChatExpanded = toggleLiveChatExpanded self.sendStarsAction = sendStarsAction self.starStars = starStars @@ -556,6 +559,9 @@ public final class MessageInputPanelComponent: Component { if lhs.liveChatState != rhs.liveChatState { return false } + if lhs.isEmbeddedInCamera != rhs.isEmbeddedInCamera { + return false + } if lhs.starStars != rhs.starStars { return false } @@ -1033,8 +1039,10 @@ public final class MessageInputPanelComponent: Component { ) } - let rightAction: ChatTextInputPanelComponent.RightAction - if component.sendStarsAction != nil { + let rightAction: ChatTextInputPanelComponent.RightAction? + if component.isEmbeddedInCamera { + rightAction = nil + } else if component.sendStarsAction != nil { rightAction = ChatTextInputPanelComponent.RightAction(kind: .stars(count: Int(component.starStars?.totalStars ?? 0), isFilled: component.starStars?.hasOutgoingStars ?? false), action: { [weak self] sourceView in guard let self, let component = self.component else { return @@ -1050,6 +1058,13 @@ public final class MessageInputPanelComponent: Component { rightAction = ChatTextInputPanelComponent.RightAction(kind: .empty, action: { _ in }) } + var secondaryLeftAction: ChatTextInputPanelComponent.LeftAction? + if !"".isEmpty, component.isEmbeddedInCamera { + secondaryLeftAction = ChatTextInputPanelComponent.LeftAction(kind: .settings, action: { [weak self] in + let _ = self + }) + } + let inputPanelSize = inputPanel.update( transition: transition, component: AnyComponent(ChatTextInputPanelComponent( @@ -1072,6 +1087,7 @@ public final class MessageInputPanelComponent: Component { component.toggleLiveChatExpanded?() } }), + secondaryLeftAction: secondaryLeftAction, rightAction: rightAction, sendAsConfiguration: component.liveChatState?.isEnabled == true ? sendAsConfiguration : nil, //TODO:localize diff --git a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift index c1c0749863..c0405ea8fc 100644 --- a/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift +++ b/submodules/TelegramUI/Components/Stories/StoryContainerScreen/Sources/StoryItemSetContainerComponent.swift @@ -1456,7 +1456,7 @@ public final class StoryItemSetContainerComponent: Component { if self.sendMessageContext.progressPauseContext.hasExternalController { return .pause } - if let navigationController = component.controller()?.navigationController as? NavigationController { + if let controller = component.controller() as? StoryContainerScreen, let navigationController = controller.navigationController as? NavigationController { let topViewController = navigationController.topViewController if !(topViewController is StoryContainerScreen) && !(topViewController is MediaEditorScreen) && !(topViewController is ShareWithPeersScreen) && !(topViewController is AttachmentController) { return .pause @@ -3211,7 +3211,7 @@ public final class StoryItemSetContainerComponent: Component { } self.sendMessageContext.performShareAction(view: self) } : nil, - paidMessageAction: isLiveStream ? { [weak self] in + paidMessageAction: isLiveStream && !component.isEmbeddedInCamera ? { [weak self] in guard let self else { return } @@ -3290,6 +3290,7 @@ public final class StoryItemSetContainerComponent: Component { storyItem: component.slice.item.storyItem, chatLocation: nil, liveChatState: liveChatState, + isEmbeddedInCamera: component.isEmbeddedInCamera, toggleLiveChatExpanded: { [weak self] in guard let self else { return