Web app improvements

This commit is contained in:
Ilya Laktyushin 2022-04-06 13:43:57 +04:00
parent e2fc108c03
commit 18b791f1c2
5 changed files with 104 additions and 18 deletions

File diff suppressed because one or more lines are too long

View File

@ -6778,19 +6778,26 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
if let strongSelf = self {
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, {
let (updatedInputMode, updatedClosedButtonKeyboardMessageId) = f($0)
return $0.updatedInputMode({ _ in return updatedInputMode }).updatedInterfaceState({
var updated = $0.updatedInputMode({ _ in return updatedInputMode }).updatedInterfaceState({
$0.withUpdatedMessageActionsState({ value in
var value = value
value.closedButtonKeyboardMessageId = updatedClosedButtonKeyboardMessageId
return value
})
})
if updatedInputMode == .text {
updated = updated.updatedShowWebView(false)
}
return updated
})
}
}, openStickers: { [weak self] in
guard let strongSelf = self else {
return
}
strongSelf.interfaceInteraction?.updateShowWebView { _ in
return false
}
strongSelf.chatDisplayNode.openStickers()
strongSelf.mediaRecordingModeTooltipController?.dismissImmediately()
}, editMessage: { [weak self] in
@ -7071,6 +7078,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
return
}
strongSelf.mediaRecordingModeTooltipController?.dismiss()
strongSelf.interfaceInteraction?.updateShowWebView { _ in
return false
}
let requestId = strongSelf.beginMediaRecordingRequestId
let begin: () -> Void = {
@ -7307,7 +7317,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
var updatedMode: ChatTextInputMediaRecordingButtonMode?
strongSelf.updateChatPresentationInterfaceState(interactive: true, {
return $0.updatedInterfaceState { current in
return $0.updatedInterfaceState({ current in
let mode: ChatTextInputMediaRecordingButtonMode
switch current.mediaRecordingMode {
case .audio:
@ -7317,7 +7327,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
}
updatedMode = mode
return current.withUpdatedMediaRecordingMode(mode)
}
}).updatedShowWebView(false)
})
if let updatedMode = updatedMode, updatedMode == .video {

View File

@ -1294,11 +1294,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
expandedInputDimNode.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
expandedInputDimNode.alpha = 0.0
self.expandedInputDimNode = expandedInputDimNode
if let inputNode = self.inputNode, inputNode.supernode != nil {
self.insertSubnode(expandedInputDimNode, belowSubnode: inputNode)
} else {
self.addSubnode(expandedInputDimNode)
}
self.insertSubnode(expandedInputDimNode, aboveSubnode: self.historyNodeContainer)
transition.updateAlpha(node: expandedInputDimNode, alpha: 1.0)
expandedInputDimNode.frame = exandedFrame
transition.animatePositionAdditive(node: expandedInputDimNode, offset: CGPoint(x: 0.0, y: previousInputPanelOrigin.y - inputPanelOrigin))

View File

@ -21,6 +21,7 @@ import InvisibleInkDustNode
import TextInputMenu
import Pasteboard
import ChatPresentationInterfaceState
import ManagedAnimationNode
private let accessoryButtonFont = Font.medium(14.0)
private let counterFont = Font.with(size: 14.0, design: .regular, traits: [.monospacedNumbers])
@ -255,7 +256,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
let menuButton: HighlightTrackingButtonNode
private let menuButtonBackgroundNode: ASDisplayNode
private let menuButtonClippingNode: ASDisplayNode
private let menuButtonIconNode: AnimationNode
private let menuButtonIconNode: MenuIconNode
private let menuButtonTextNode: ImmediateTextNode
let sendAsAvatarButtonNode: HighlightableButtonNode
@ -483,7 +484,9 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
self.menuButtonClippingNode = ASDisplayNode()
self.menuButtonClippingNode.clipsToBounds = true
self.menuButtonIconNode = AnimationNode(animation: "anim_menuclose", colors: ["1.1.Обводка 1": presentationInterfaceState.theme.chat.inputPanel.actionControlForegroundColor, "2.2.Обводка 1": presentationInterfaceState.theme.chat.inputPanel.actionControlForegroundColor, "3.1.Обводка 1": presentationInterfaceState.theme.chat.inputPanel.actionControlForegroundColor])
self.menuButtonIconNode = MenuIconNode()
self.menuButtonIconNode.enqueueState(presentationInterfaceState.showMenuForWebView ? .app : .menu, animated: false)
self.menuButtonIconNode.customColor = presentationInterfaceState.theme.chat.inputPanel.actionControlForegroundColor
self.menuButtonTextNode = ImmediateTextNode()
self.sendAsAvatarButtonNode = HighlightableButtonNode()
@ -879,24 +882,29 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
let previousState = self.presentationInterfaceState
self.presentationInterfaceState = interfaceState
if interfaceState.showMenuForWebView && self.menuButtonIconNode.iconState == .menu {
self.menuButtonIconNode.enqueueState(.app, animated: false)
} else if !interfaceState.showMenuForWebView && self.menuButtonIconNode.iconState == .app {
self.menuButtonIconNode.enqueueState(.menu, animated: false)
}
let themeUpdated = previousState?.theme !== interfaceState.theme
if themeUpdated {
self.menuButtonIconNode.customColor = interfaceState.theme.chat.inputPanel.actionControlForegroundColor
}
if let sendAsPeers = interfaceState.sendAsPeers, !sendAsPeers.isEmpty {
self.menuButtonIconNode.setAnimation(name: "anim_closemenu", colors: ["1.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "2.2.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "3.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor])
self.menuButtonIconNode.enqueueState(.close, animated: false)
} else if interfaceState.showMenuForWebView, let previousShowWebView = previousState?.showWebView, previousShowWebView != interfaceState.showWebView {
if interfaceState.showWebView {
self.menuButtonIconNode.setAnimation(name: "anim_menuclose", colors: ["1.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "2.2.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "3.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor])
self.menuButtonIconNode.enqueueState(.close, animated: true)
} else {
self.menuButtonIconNode.setAnimation(name: "anim_closemenu", colors: ["1.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "2.2.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "3.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor])
self.menuButtonIconNode.enqueueState(.app, animated: true)
}
self.menuButtonIconNode.playOnce()
} else if let previousShowCommands = previousState?.showCommands, previousShowCommands != interfaceState.showCommands {
if interfaceState.showCommands {
self.menuButtonIconNode.setAnimation(name: "anim_menuclose", colors: ["1.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "2.2.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "3.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor])
self.menuButtonIconNode.enqueueState(.close, animated: true)
} else {
self.menuButtonIconNode.setAnimation(name: "anim_closemenu", colors: ["1.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "2.2.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor, "3.1.Обводка 1": interfaceState.theme.chat.inputPanel.actionControlForegroundColor])
self.menuButtonIconNode.enqueueState(.menu, animated: true)
}
self.menuButtonIconNode.playOnce()
}
var updateSendButtonIcon = false
@ -2734,3 +2742,74 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
}
}
private enum MenuIconNodeState: Equatable {
case menu
case app
case close
}
private final class MenuIconNode: ManagedAnimationNode {
private let duration: Double = 0.33
fileprivate var iconState: MenuIconNodeState = .menu
init() {
super.init(size: CGSize(width: 30.0, height: 30.0))
self.trackTo(item: ManagedAnimationItem(source: .local("anim_menuclose"), frames: .range(startFrame: 0, endFrame: 0), duration: 0.01))
}
func enqueueState(_ state: MenuIconNodeState, animated: Bool) {
guard self.iconState != state else {
return
}
let previousState = self.iconState
self.iconState = state
switch previousState {
case .close:
switch state {
case .menu:
if animated {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_menuclose"), frames: .range(startFrame: 20, endFrame: 0), duration: self.duration))
} else {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_menuclose"), frames: .range(startFrame: 0, endFrame: 0), duration: 0.01))
}
case .app:
if animated {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_webview"), frames: .range(startFrame: 0, endFrame: 22), duration: self.duration))
} else {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_webview"), frames: .range(startFrame: 22, endFrame: 22), duration: 0.01))
}
case .close:
break
}
case .menu:
switch state {
case .close:
if animated {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_menuclose"), frames: .range(startFrame: 0, endFrame: 20), duration: self.duration))
} else {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_menuclose"), frames: .range(startFrame: 20, endFrame: 20), duration: 0.01))
}
case .app:
self.trackTo(item: ManagedAnimationItem(source: .local("anim_webview"), frames: .range(startFrame: 22, endFrame: 22), duration: 0.01))
case .menu:
break
}
case .app:
switch state {
case .close:
if animated {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_webview"), frames: .range(startFrame: 22, endFrame: 0), duration: self.duration))
} else {
self.trackTo(item: ManagedAnimationItem(source: .local("anim_webview"), frames: .range(startFrame: 0, endFrame: 0), duration: 0.01))
}
case .menu:
self.trackTo(item: ManagedAnimationItem(source: .local("anim_menuclose"), frames: .range(startFrame: 0, endFrame: 20), duration: 0.01))
case .app:
break
}
}
}
}