mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Web app improvements
This commit is contained in:
parent
e2fc108c03
commit
18b791f1c2
File diff suppressed because one or more lines are too long
@ -6778,19 +6778,26 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
if let strongSelf = self {
|
if let strongSelf = self {
|
||||||
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, {
|
strongSelf.updateChatPresentationInterfaceState(animated: true, interactive: true, {
|
||||||
let (updatedInputMode, updatedClosedButtonKeyboardMessageId) = f($0)
|
let (updatedInputMode, updatedClosedButtonKeyboardMessageId) = f($0)
|
||||||
return $0.updatedInputMode({ _ in return updatedInputMode }).updatedInterfaceState({
|
var updated = $0.updatedInputMode({ _ in return updatedInputMode }).updatedInterfaceState({
|
||||||
$0.withUpdatedMessageActionsState({ value in
|
$0.withUpdatedMessageActionsState({ value in
|
||||||
var value = value
|
var value = value
|
||||||
value.closedButtonKeyboardMessageId = updatedClosedButtonKeyboardMessageId
|
value.closedButtonKeyboardMessageId = updatedClosedButtonKeyboardMessageId
|
||||||
return value
|
return value
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
if updatedInputMode == .text {
|
||||||
|
updated = updated.updatedShowWebView(false)
|
||||||
|
}
|
||||||
|
return updated
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}, openStickers: { [weak self] in
|
}, openStickers: { [weak self] in
|
||||||
guard let strongSelf = self else {
|
guard let strongSelf = self else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
strongSelf.interfaceInteraction?.updateShowWebView { _ in
|
||||||
|
return false
|
||||||
|
}
|
||||||
strongSelf.chatDisplayNode.openStickers()
|
strongSelf.chatDisplayNode.openStickers()
|
||||||
strongSelf.mediaRecordingModeTooltipController?.dismissImmediately()
|
strongSelf.mediaRecordingModeTooltipController?.dismissImmediately()
|
||||||
}, editMessage: { [weak self] in
|
}, editMessage: { [weak self] in
|
||||||
@ -7071,6 +7078,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
strongSelf.mediaRecordingModeTooltipController?.dismiss()
|
strongSelf.mediaRecordingModeTooltipController?.dismiss()
|
||||||
|
strongSelf.interfaceInteraction?.updateShowWebView { _ in
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
let requestId = strongSelf.beginMediaRecordingRequestId
|
let requestId = strongSelf.beginMediaRecordingRequestId
|
||||||
let begin: () -> Void = {
|
let begin: () -> Void = {
|
||||||
@ -7307,7 +7317,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
var updatedMode: ChatTextInputMediaRecordingButtonMode?
|
var updatedMode: ChatTextInputMediaRecordingButtonMode?
|
||||||
|
|
||||||
strongSelf.updateChatPresentationInterfaceState(interactive: true, {
|
strongSelf.updateChatPresentationInterfaceState(interactive: true, {
|
||||||
return $0.updatedInterfaceState { current in
|
return $0.updatedInterfaceState({ current in
|
||||||
let mode: ChatTextInputMediaRecordingButtonMode
|
let mode: ChatTextInputMediaRecordingButtonMode
|
||||||
switch current.mediaRecordingMode {
|
switch current.mediaRecordingMode {
|
||||||
case .audio:
|
case .audio:
|
||||||
@ -7317,7 +7327,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
|||||||
}
|
}
|
||||||
updatedMode = mode
|
updatedMode = mode
|
||||||
return current.withUpdatedMediaRecordingMode(mode)
|
return current.withUpdatedMediaRecordingMode(mode)
|
||||||
}
|
}).updatedShowWebView(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
if let updatedMode = updatedMode, updatedMode == .video {
|
if let updatedMode = updatedMode, updatedMode == .video {
|
||||||
|
@ -1294,11 +1294,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
expandedInputDimNode.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
|
expandedInputDimNode.backgroundColor = UIColor(white: 0.0, alpha: 0.5)
|
||||||
expandedInputDimNode.alpha = 0.0
|
expandedInputDimNode.alpha = 0.0
|
||||||
self.expandedInputDimNode = expandedInputDimNode
|
self.expandedInputDimNode = expandedInputDimNode
|
||||||
if let inputNode = self.inputNode, inputNode.supernode != nil {
|
self.insertSubnode(expandedInputDimNode, aboveSubnode: self.historyNodeContainer)
|
||||||
self.insertSubnode(expandedInputDimNode, belowSubnode: inputNode)
|
|
||||||
} else {
|
|
||||||
self.addSubnode(expandedInputDimNode)
|
|
||||||
}
|
|
||||||
transition.updateAlpha(node: expandedInputDimNode, alpha: 1.0)
|
transition.updateAlpha(node: expandedInputDimNode, alpha: 1.0)
|
||||||
expandedInputDimNode.frame = exandedFrame
|
expandedInputDimNode.frame = exandedFrame
|
||||||
transition.animatePositionAdditive(node: expandedInputDimNode, offset: CGPoint(x: 0.0, y: previousInputPanelOrigin.y - inputPanelOrigin))
|
transition.animatePositionAdditive(node: expandedInputDimNode, offset: CGPoint(x: 0.0, y: previousInputPanelOrigin.y - inputPanelOrigin))
|
||||||
|
@ -21,6 +21,7 @@ import InvisibleInkDustNode
|
|||||||
import TextInputMenu
|
import TextInputMenu
|
||||||
import Pasteboard
|
import Pasteboard
|
||||||
import ChatPresentationInterfaceState
|
import ChatPresentationInterfaceState
|
||||||
|
import ManagedAnimationNode
|
||||||
|
|
||||||
private let accessoryButtonFont = Font.medium(14.0)
|
private let accessoryButtonFont = Font.medium(14.0)
|
||||||
private let counterFont = Font.with(size: 14.0, design: .regular, traits: [.monospacedNumbers])
|
private let counterFont = Font.with(size: 14.0, design: .regular, traits: [.monospacedNumbers])
|
||||||
@ -255,7 +256,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
let menuButton: HighlightTrackingButtonNode
|
let menuButton: HighlightTrackingButtonNode
|
||||||
private let menuButtonBackgroundNode: ASDisplayNode
|
private let menuButtonBackgroundNode: ASDisplayNode
|
||||||
private let menuButtonClippingNode: ASDisplayNode
|
private let menuButtonClippingNode: ASDisplayNode
|
||||||
private let menuButtonIconNode: AnimationNode
|
private let menuButtonIconNode: MenuIconNode
|
||||||
private let menuButtonTextNode: ImmediateTextNode
|
private let menuButtonTextNode: ImmediateTextNode
|
||||||
|
|
||||||
let sendAsAvatarButtonNode: HighlightableButtonNode
|
let sendAsAvatarButtonNode: HighlightableButtonNode
|
||||||
@ -483,7 +484,9 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
self.menuButtonClippingNode = ASDisplayNode()
|
self.menuButtonClippingNode = ASDisplayNode()
|
||||||
self.menuButtonClippingNode.clipsToBounds = true
|
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.menuButtonTextNode = ImmediateTextNode()
|
||||||
|
|
||||||
self.sendAsAvatarButtonNode = HighlightableButtonNode()
|
self.sendAsAvatarButtonNode = HighlightableButtonNode()
|
||||||
@ -879,24 +882,29 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
let previousState = self.presentationInterfaceState
|
let previousState = self.presentationInterfaceState
|
||||||
self.presentationInterfaceState = interfaceState
|
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
|
let themeUpdated = previousState?.theme !== interfaceState.theme
|
||||||
|
if themeUpdated {
|
||||||
|
self.menuButtonIconNode.customColor = interfaceState.theme.chat.inputPanel.actionControlForegroundColor
|
||||||
|
}
|
||||||
if let sendAsPeers = interfaceState.sendAsPeers, !sendAsPeers.isEmpty {
|
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 {
|
} else if interfaceState.showMenuForWebView, let previousShowWebView = previousState?.showWebView, previousShowWebView != interfaceState.showWebView {
|
||||||
if 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 {
|
} 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 {
|
} else if let previousShowCommands = previousState?.showCommands, previousShowCommands != interfaceState.showCommands {
|
||||||
if 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 {
|
} 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
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user