Various improvements

This commit is contained in:
Ilya Laktyushin 2025-11-09 20:16:32 +04:00
parent b76c6c9b3c
commit fbf7473892
6 changed files with 82 additions and 13 deletions

View File

@ -1582,8 +1582,7 @@ private final class CameraScreenComponent: CombinedComponent {
} }
}, },
getController: { getController: {
return nil return controller()
//return controller()
}, },
didSetupMediaStream: { [weak state] call in didSetupMediaStream: { [weak state] call in
state?.setupLiveStreamCamera(call: call) 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 case .none = component.cameraState.recording, !state.isTransitioning {
if !state.displayingCollageSelection { if !state.displayingCollageSelection && !component.cameraState.isStreaming {
let cancelButton = cancelButton.update( let cancelButton = cancelButton.update(
component: CameraButton( component: CameraButton(
content: AnyComponentWithIdentity( content: AnyComponentWithIdentity(
@ -1750,7 +1749,11 @@ private final class CameraScreenComponent: CombinedComponent {
let rightMostButtonWidth: CGFloat let rightMostButtonWidth: CGFloat
if component.cameraState.mode == .live { if component.cameraState.mode == .live {
if component.cameraState.isStreaming {
rightMostButtonWidth = -25.0
} else {
rightMostButtonWidth = -55.0 rightMostButtonWidth = -55.0
}
} else if state.displayingCollageSelection { } else if state.displayingCollageSelection {
let disableCollageButton = disableCollageButton.update( let disableCollageButton = disableCollageButton.update(
component: CameraButton( component: CameraButton(

View File

@ -60,6 +60,7 @@ public final class ChatTextInputPanelComponent: Component {
case empty case empty
case attach case attach
case toggleExpanded(isVisible: Bool, isExpanded: Bool, hasUnseen: Bool) case toggleExpanded(isVisible: Bool, isExpanded: Bool, hasUnseen: Bool)
case settings
} }
public let kind: Kind public let kind: Kind
@ -144,6 +145,7 @@ public final class ChatTextInputPanelComponent: Component {
let chatPeerId: EnginePeer.Id let chatPeerId: EnginePeer.Id
let inlineActions: [InlineAction] let inlineActions: [InlineAction]
let leftAction: LeftAction? let leftAction: LeftAction?
let secondaryLeftAction: LeftAction?
let rightAction: RightAction? let rightAction: RightAction?
let sendAsConfiguration: SendAsConfiguration? let sendAsConfiguration: SendAsConfiguration?
let placeholder: String let placeholder: String
@ -166,6 +168,7 @@ public final class ChatTextInputPanelComponent: Component {
chatPeerId: EnginePeer.Id, chatPeerId: EnginePeer.Id,
inlineActions: [InlineAction], inlineActions: [InlineAction],
leftAction: LeftAction?, leftAction: LeftAction?,
secondaryLeftAction: LeftAction?,
rightAction: RightAction?, rightAction: RightAction?,
sendAsConfiguration: SendAsConfiguration?, sendAsConfiguration: SendAsConfiguration?,
placeholder: String, placeholder: String,
@ -187,6 +190,7 @@ public final class ChatTextInputPanelComponent: Component {
self.chatPeerId = chatPeerId self.chatPeerId = chatPeerId
self.inlineActions = inlineActions self.inlineActions = inlineActions
self.leftAction = leftAction self.leftAction = leftAction
self.secondaryLeftAction = secondaryLeftAction
self.rightAction = rightAction self.rightAction = rightAction
self.sendAsConfiguration = sendAsConfiguration self.sendAsConfiguration = sendAsConfiguration
self.placeholder = placeholder self.placeholder = placeholder
@ -224,6 +228,9 @@ public final class ChatTextInputPanelComponent: Component {
if lhs.leftAction != rhs.leftAction { if lhs.leftAction != rhs.leftAction {
return false return false
} }
if lhs.secondaryLeftAction != rhs.secondaryLeftAction {
return false
}
if lhs.rightAction != rhs.rightAction { if lhs.rightAction != rhs.rightAction {
return false return false
} }
@ -865,10 +872,38 @@ public final class ChatTextInputPanelComponent: Component {
isVisible = false isVisible = false
} }
panelNode.customLeftAction = .toggleExpanded(isVisible: isVisible, isExpanded: isExpanded, hasUnseen: hasUnseen) 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 { } else {
panelNode.customLeftAction = nil 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 { if let rightAction = component.rightAction {
switch rightAction.kind { switch rightAction.kind {

View File

@ -263,6 +263,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
public let attachmentButton: HighlightTrackingButton public let attachmentButton: HighlightTrackingButton
public let attachmentButtonBackground: GlassBackgroundView public let attachmentButtonBackground: GlassBackgroundView
public let attachmentButtonIcon: GlassBackgroundView.ContentImageView public let attachmentButtonIcon: GlassBackgroundView.ContentImageView
public let secondaryLeftButtonBackground: GlassBackgroundView
private var commentsButtonIcon: RasterizedCompositionMonochromeLayer? private var commentsButtonIcon: RasterizedCompositionMonochromeLayer?
private var commentsButtonCenterIcon: UIImageView? private var commentsButtonCenterIcon: UIImageView?
private var commentsButtonContentsLayer: RasterizedCompositionImageLayer? private var commentsButtonContentsLayer: RasterizedCompositionImageLayer?
@ -388,6 +389,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
public enum LeftAction { public enum LeftAction {
case empty case empty
case toggleExpanded(isVisible: Bool, isExpanded: Bool, hasUnseen: Bool) case toggleExpanded(isVisible: Bool, isExpanded: Bool, hasUnseen: Bool)
case settings(isVisible: Bool)
} }
public enum RightAction { public enum RightAction {
@ -398,6 +400,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
public var customPlaceholder: String? public var customPlaceholder: String?
public var customIsDisabled: Bool = false public var customIsDisabled: Bool = false
public var customLeftAction: LeftAction? public var customLeftAction: LeftAction?
public var customSecondaryLeftAction: LeftAction?
public var customRightAction: RightAction? public var customRightAction: RightAction?
public var customSendColor: UIColor? public var customSendColor: UIColor?
public var customSendIsDisabled: Bool = false public var customSendIsDisabled: Bool = false
@ -652,6 +655,9 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
self.attachmentButtonIcon.isUserInteractionEnabled = false self.attachmentButtonIcon.isUserInteractionEnabled = false
self.attachmentButtonBackground.contentView.addSubview(self.attachmentButtonIcon) self.attachmentButtonBackground.contentView.addSubview(self.attachmentButtonIcon)
self.secondaryLeftButtonBackground = GlassBackgroundView(frame: CGRect())
//self.secondaryLeftButtonBackground.contentView.addSubview(self.attachmentButton)
self.attachmentButtonDisabledNode = HighlightableButtonNode() self.attachmentButtonDisabledNode = HighlightableButtonNode()
self.searchLayoutClearButton = HighlightTrackingButton() self.searchLayoutClearButton = HighlightTrackingButton()
self.searchLayoutClearButtonIcon = GlassBackgroundView.ContentImageView() 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.menuButton.view)
self.glassBackgroundContainer.contentView.addSubview(self.attachmentButtonBackground) self.glassBackgroundContainer.contentView.addSubview(self.attachmentButtonBackground)
self.glassBackgroundContainer.contentView.addSubview(self.secondaryLeftButtonBackground)
self.glassBackgroundContainer.contentView.addSubview(self.attachmentButtonDisabledNode.view) self.glassBackgroundContainer.contentView.addSubview(self.attachmentButtonDisabledNode.view)
self.glassBackgroundContainer.contentView.addSubview(self.startButton.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) 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 { if let customLeftAction = self.customLeftAction, case let .toggleExpanded(isVisible, _, _) = customLeftAction, !isVisible {
insets.left = 8.0 insets.left = 8.0
} else if let customLeftAction = self.customLeftAction, case .empty = customLeftAction {
insets.left = 8.0
} }
return insets return insets
} }
@ -1751,7 +1760,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
if let customLeftAction = self.customLeftAction { if let customLeftAction = self.customLeftAction {
switch customLeftAction { switch customLeftAction {
case .empty, .toggleExpanded: case .empty, .toggleExpanded, .settings:
self.attachmentButtonIcon.image = nil self.attachmentButtonIcon.image = nil
self.attachmentButtonIcon.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor self.attachmentButtonIcon.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor
} }
@ -1791,7 +1800,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
if wasEditingMedia != isEditingMedia || hadMediaDraft != hasMediaDraft || isFirstTime { if wasEditingMedia != isEditingMedia || hadMediaDraft != hasMediaDraft || isFirstTime {
if let customLeftAction = self.customLeftAction { if let customLeftAction = self.customLeftAction {
switch customLeftAction { switch customLeftAction {
case .empty, .toggleExpanded: case .empty, .toggleExpanded, .settings:
self.attachmentButtonIcon.image = nil self.attachmentButtonIcon.image = nil
self.attachmentButtonIcon.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor self.attachmentButtonIcon.tintColor = interfaceState.theme.chat.inputPanel.panelControlColor
} }
@ -1944,7 +1953,7 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
if let customLeftAction = self.customLeftAction { if let customLeftAction = self.customLeftAction {
switch customLeftAction { switch customLeftAction {
case .empty: case .empty, .settings:
break break
case let .toggleExpanded(_, isExpanded, hasUnseen): case let .toggleExpanded(_, isExpanded, hasUnseen):
let commentsButtonIcon: RasterizedCompositionMonochromeLayer let commentsButtonIcon: RasterizedCompositionMonochromeLayer
@ -2160,6 +2169,8 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
attachmentButtonX = -48.0 attachmentButtonX = -48.0
} else if let customLeftAction = self.customLeftAction, case let .toggleExpanded(isVisible, _, _) = customLeftAction, !isVisible { } else if let customLeftAction = self.customLeftAction, case let .toggleExpanded(isVisible, _, _) = customLeftAction, !isVisible {
attachmentButtonX = -48.0 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) self.mediaActionButtons.micButton.updateMode(mode: interfaceState.interfaceState.mediaRecordingMode, animated: transition.isAnimated)
@ -2280,6 +2291,9 @@ public class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDeleg
break break
} }
} }
if let customSecondaryLeftAction = self.customSecondaryLeftAction, case let .settings(isVisible) = customSecondaryLeftAction, isVisible {
textFieldInsets.left += 46.0
}
var audioRecordingItemsAlpha: CGFloat = 1.0 var audioRecordingItemsAlpha: CGFloat = 1.0
if interfaceState.interfaceState.mediaDraftState != nil { if interfaceState.interfaceState.mediaDraftState != nil {

View File

@ -201,7 +201,7 @@ private final class GiftAuctionInfoSheetContent: CombinedComponent {
component: AnyComponent(ParagraphComponent( component: AnyComponent(ParagraphComponent(
title: "Top 50 Bidders", title: "Top 50 Bidders",
titleColor: textColor, 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, textColor: secondaryTextColor,
accentColor: linkColor, accentColor: linkColor,
iconName: "Premium/Auction/Drop", iconName: "Premium/Auction/Drop",

View File

@ -289,6 +289,7 @@ public final class MessageInputPanelComponent: Component {
public let storyItem: EngineStoryItem? public let storyItem: EngineStoryItem?
public let chatLocation: ChatLocation? public let chatLocation: ChatLocation?
public let liveChatState: LiveChatState? public let liveChatState: LiveChatState?
public let isEmbeddedInCamera: Bool
public let toggleLiveChatExpanded: (() -> Void)? public let toggleLiveChatExpanded: (() -> Void)?
public let sendStarsAction: ((UIView, Bool) -> Void)? public let sendStarsAction: ((UIView, Bool) -> Void)?
public let starStars: StarStats? public let starStars: StarStats?
@ -355,6 +356,7 @@ public final class MessageInputPanelComponent: Component {
storyItem: EngineStoryItem?, storyItem: EngineStoryItem?,
chatLocation: ChatLocation?, chatLocation: ChatLocation?,
liveChatState: LiveChatState? = nil, liveChatState: LiveChatState? = nil,
isEmbeddedInCamera: Bool = false,
toggleLiveChatExpanded: (() -> Void)? = nil, toggleLiveChatExpanded: (() -> Void)? = nil,
sendStarsAction: ((UIView, Bool) -> Void)? = nil, sendStarsAction: ((UIView, Bool) -> Void)? = nil,
starStars: StarStats? = nil, starStars: StarStats? = nil,
@ -420,6 +422,7 @@ public final class MessageInputPanelComponent: Component {
self.storyItem = storyItem self.storyItem = storyItem
self.chatLocation = chatLocation self.chatLocation = chatLocation
self.liveChatState = liveChatState self.liveChatState = liveChatState
self.isEmbeddedInCamera = isEmbeddedInCamera
self.toggleLiveChatExpanded = toggleLiveChatExpanded self.toggleLiveChatExpanded = toggleLiveChatExpanded
self.sendStarsAction = sendStarsAction self.sendStarsAction = sendStarsAction
self.starStars = starStars self.starStars = starStars
@ -556,6 +559,9 @@ public final class MessageInputPanelComponent: Component {
if lhs.liveChatState != rhs.liveChatState { if lhs.liveChatState != rhs.liveChatState {
return false return false
} }
if lhs.isEmbeddedInCamera != rhs.isEmbeddedInCamera {
return false
}
if lhs.starStars != rhs.starStars { if lhs.starStars != rhs.starStars {
return false return false
} }
@ -1033,8 +1039,10 @@ public final class MessageInputPanelComponent: Component {
) )
} }
let rightAction: ChatTextInputPanelComponent.RightAction let rightAction: ChatTextInputPanelComponent.RightAction?
if component.sendStarsAction != nil { 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 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 { guard let self, let component = self.component else {
return return
@ -1050,6 +1058,13 @@ public final class MessageInputPanelComponent: Component {
rightAction = ChatTextInputPanelComponent.RightAction(kind: .empty, action: { _ in }) 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( let inputPanelSize = inputPanel.update(
transition: transition, transition: transition,
component: AnyComponent(ChatTextInputPanelComponent( component: AnyComponent(ChatTextInputPanelComponent(
@ -1072,6 +1087,7 @@ public final class MessageInputPanelComponent: Component {
component.toggleLiveChatExpanded?() component.toggleLiveChatExpanded?()
} }
}), }),
secondaryLeftAction: secondaryLeftAction,
rightAction: rightAction, rightAction: rightAction,
sendAsConfiguration: component.liveChatState?.isEnabled == true ? sendAsConfiguration : nil, sendAsConfiguration: component.liveChatState?.isEnabled == true ? sendAsConfiguration : nil,
//TODO:localize //TODO:localize

View File

@ -1456,7 +1456,7 @@ public final class StoryItemSetContainerComponent: Component {
if self.sendMessageContext.progressPauseContext.hasExternalController { if self.sendMessageContext.progressPauseContext.hasExternalController {
return .pause 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 let topViewController = navigationController.topViewController
if !(topViewController is StoryContainerScreen) && !(topViewController is MediaEditorScreen) && !(topViewController is ShareWithPeersScreen) && !(topViewController is AttachmentController) { if !(topViewController is StoryContainerScreen) && !(topViewController is MediaEditorScreen) && !(topViewController is ShareWithPeersScreen) && !(topViewController is AttachmentController) {
return .pause return .pause
@ -3211,7 +3211,7 @@ public final class StoryItemSetContainerComponent: Component {
} }
self.sendMessageContext.performShareAction(view: self) self.sendMessageContext.performShareAction(view: self)
} : nil, } : nil,
paidMessageAction: isLiveStream ? { [weak self] in paidMessageAction: isLiveStream && !component.isEmbeddedInCamera ? { [weak self] in
guard let self else { guard let self else {
return return
} }
@ -3290,6 +3290,7 @@ public final class StoryItemSetContainerComponent: Component {
storyItem: component.slice.item.storyItem, storyItem: component.slice.item.storyItem,
chatLocation: nil, chatLocation: nil,
liveChatState: liveChatState, liveChatState: liveChatState,
isEmbeddedInCamera: component.isEmbeddedInCamera,
toggleLiveChatExpanded: { [weak self] in toggleLiveChatExpanded: { [weak self] in
guard let self else { guard let self else {
return return