mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-08 08:31:13 +00:00
Support input language restoration
This commit is contained in:
parent
9906f56507
commit
2a75b5fc61
@ -3251,6 +3251,7 @@ public final class ChatController: TelegramController, KeyShortcutResponder, Gal
|
|||||||
let scrollState = self.chatDisplayNode.historyNode.immediateScrollState()
|
let scrollState = self.chatDisplayNode.historyNode.immediateScrollState()
|
||||||
interfaceState = interfaceState.withUpdatedHistoryScrollState(scrollState)
|
interfaceState = interfaceState.withUpdatedHistoryScrollState(scrollState)
|
||||||
}
|
}
|
||||||
|
interfaceState = interfaceState.withUpdatedInputLanguage(self.chatDisplayNode.currentTextInputLanguage)
|
||||||
let _ = updatePeerChatInterfaceState(account: account, peerId: peerId, state: interfaceState).start()
|
let _ = updatePeerChatInterfaceState(account: account, peerId: peerId, state: interfaceState).start()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,6 +258,7 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
self.textInputPanelNode = ChatTextInputPanelNode(theme: chatPresentationInterfaceState.theme, presentController: { [weak self] controller in
|
self.textInputPanelNode = ChatTextInputPanelNode(theme: chatPresentationInterfaceState.theme, presentController: { [weak self] controller in
|
||||||
self?.interfaceInteraction?.presentController(controller, nil)
|
self?.interfaceInteraction?.presentController(controller, nil)
|
||||||
})
|
})
|
||||||
|
self.textInputPanelNode?.storedInputLanguage = chatPresentationInterfaceState.interfaceState.inputLanguage
|
||||||
self.textInputPanelNode?.updateHeight = { [weak self] in
|
self.textInputPanelNode?.updateHeight = { [weak self] in
|
||||||
if let strongSelf = self, let _ = strongSelf.inputPanelNode as? ChatTextInputPanelNode, !strongSelf.ignoreUpdateHeight {
|
if let strongSelf = self, let _ = strongSelf.inputPanelNode as? ChatTextInputPanelNode, !strongSelf.ignoreUpdateHeight {
|
||||||
strongSelf.requestLayout(.animated(duration: 0.1, curve: .easeInOut))
|
strongSelf.requestLayout(.animated(duration: 0.1, curve: .easeInOut))
|
||||||
@ -1547,6 +1548,10 @@ class ChatControllerNode: ASDisplayNode, UIScrollViewDelegate {
|
|||||||
return self.inputPanelNode is ChatTextInputPanelNode
|
return self.inputPanelNode is ChatTextInputPanelNode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var currentTextInputLanguage: String? {
|
||||||
|
return self.textInputPanelNode?.effectiveInputLanguage
|
||||||
|
}
|
||||||
|
|
||||||
func getWindowInputAccessoryHeight() -> CGFloat {
|
func getWindowInputAccessoryHeight() -> CGFloat {
|
||||||
var height = self.inputPanelBackgroundNode.bounds.size.height
|
var height = self.inputPanelBackgroundNode.bounds.size.height
|
||||||
if case .overlay = self.chatPresentationInterfaceState.mode {
|
if case .overlay = self.chatPresentationInterfaceState.mode {
|
||||||
|
@ -441,6 +441,7 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
let historyScrollState: ChatInterfaceHistoryScrollState?
|
let historyScrollState: ChatInterfaceHistoryScrollState?
|
||||||
let mediaRecordingMode: ChatTextInputMediaRecordingButtonMode
|
let mediaRecordingMode: ChatTextInputMediaRecordingButtonMode
|
||||||
let silentPosting: Bool
|
let silentPosting: Bool
|
||||||
|
let inputLanguage: String?
|
||||||
|
|
||||||
public var associatedMessageIds: [MessageId] {
|
public var associatedMessageIds: [MessageId] {
|
||||||
var ids: [MessageId] = []
|
var ids: [MessageId] = []
|
||||||
@ -498,9 +499,10 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
self.historyScrollState = nil
|
self.historyScrollState = nil
|
||||||
self.mediaRecordingMode = .audio
|
self.mediaRecordingMode = .audio
|
||||||
self.silentPosting = false
|
self.silentPosting = false
|
||||||
|
self.inputLanguage = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
init(timestamp: Int32, composeInputState: ChatTextInputState, composeDisableUrlPreview: String?, replyMessageId: MessageId?, forwardMessageIds: [MessageId]?, editMessage: ChatEditMessageState?, selectionState: ChatInterfaceSelectionState?, messageActionsState: ChatInterfaceMessageActionsState, historyScrollState: ChatInterfaceHistoryScrollState?, mediaRecordingMode: ChatTextInputMediaRecordingButtonMode, silentPosting: Bool) {
|
init(timestamp: Int32, composeInputState: ChatTextInputState, composeDisableUrlPreview: String?, replyMessageId: MessageId?, forwardMessageIds: [MessageId]?, editMessage: ChatEditMessageState?, selectionState: ChatInterfaceSelectionState?, messageActionsState: ChatInterfaceMessageActionsState, historyScrollState: ChatInterfaceHistoryScrollState?, mediaRecordingMode: ChatTextInputMediaRecordingButtonMode, silentPosting: Bool, inputLanguage: String?) {
|
||||||
self.timestamp = timestamp
|
self.timestamp = timestamp
|
||||||
self.composeInputState = composeInputState
|
self.composeInputState = composeInputState
|
||||||
self.composeDisableUrlPreview = composeDisableUrlPreview
|
self.composeDisableUrlPreview = composeDisableUrlPreview
|
||||||
@ -512,6 +514,7 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
self.historyScrollState = historyScrollState
|
self.historyScrollState = historyScrollState
|
||||||
self.mediaRecordingMode = mediaRecordingMode
|
self.mediaRecordingMode = mediaRecordingMode
|
||||||
self.silentPosting = silentPosting
|
self.silentPosting = silentPosting
|
||||||
|
self.inputLanguage = inputLanguage
|
||||||
}
|
}
|
||||||
|
|
||||||
public init(decoder: PostboxDecoder) {
|
public init(decoder: PostboxDecoder) {
|
||||||
@ -561,6 +564,7 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
self.mediaRecordingMode = ChatTextInputMediaRecordingButtonMode(rawValue: decoder.decodeInt32ForKey("mrm", orElse: 0))!
|
self.mediaRecordingMode = ChatTextInputMediaRecordingButtonMode(rawValue: decoder.decodeInt32ForKey("mrm", orElse: 0))!
|
||||||
|
|
||||||
self.silentPosting = decoder.decodeInt32ForKey("sip", orElse: 0) != 0
|
self.silentPosting = decoder.decodeInt32ForKey("sip", orElse: 0) != 0
|
||||||
|
self.inputLanguage = decoder.decodeOptionalStringForKey("inputLanguage")
|
||||||
}
|
}
|
||||||
|
|
||||||
public func encode(_ encoder: PostboxEncoder) {
|
public func encode(_ encoder: PostboxEncoder) {
|
||||||
@ -609,6 +613,11 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
}
|
}
|
||||||
encoder.encodeInt32(self.mediaRecordingMode.rawValue, forKey: "mrm")
|
encoder.encodeInt32(self.mediaRecordingMode.rawValue, forKey: "mrm")
|
||||||
encoder.encodeInt32(self.silentPosting ? 1 : 0, forKey: "sip")
|
encoder.encodeInt32(self.silentPosting ? 1 : 0, forKey: "sip")
|
||||||
|
if let inputLanguage = self.inputLanguage {
|
||||||
|
encoder.encodeString(inputLanguage, forKey: "inputLanguage")
|
||||||
|
} else {
|
||||||
|
encoder.encodeNil(forKey: "inputLanguage")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func isEqual(to: PeerChatInterfaceState) -> Bool {
|
public func isEqual(to: PeerChatInterfaceState) -> Bool {
|
||||||
@ -642,17 +651,20 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
if lhs.silentPosting != rhs.silentPosting {
|
if lhs.silentPosting != rhs.silentPosting {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if lhs.inputLanguage != rhs.inputLanguage {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return lhs.composeInputState == rhs.composeInputState && lhs.replyMessageId == rhs.replyMessageId && lhs.selectionState == rhs.selectionState && lhs.editMessage == rhs.editMessage
|
return lhs.composeInputState == rhs.composeInputState && lhs.replyMessageId == rhs.replyMessageId && lhs.selectionState == rhs.selectionState && lhs.editMessage == rhs.editMessage
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedComposeInputState(_ inputState: ChatTextInputState) -> ChatInterfaceState {
|
func withUpdatedComposeInputState(_ inputState: ChatTextInputState) -> ChatInterfaceState {
|
||||||
let updatedComposeInputState = inputState
|
let updatedComposeInputState = inputState
|
||||||
|
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: updatedComposeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: updatedComposeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedComposeDisableUrlPreview(_ disableUrlPreview: String?) -> ChatInterfaceState {
|
func withUpdatedComposeDisableUrlPreview(_ disableUrlPreview: String?) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: disableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: disableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedEffectiveInputState(_ inputState: ChatTextInputState) -> ChatInterfaceState {
|
func withUpdatedEffectiveInputState(_ inputState: ChatTextInputState) -> ChatInterfaceState {
|
||||||
@ -664,15 +676,15 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
updatedComposeInputState = inputState
|
updatedComposeInputState = inputState
|
||||||
}
|
}
|
||||||
|
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: updatedComposeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: updatedEditMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: updatedComposeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: updatedEditMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedReplyMessageId(_ replyMessageId: MessageId?) -> ChatInterfaceState {
|
func withUpdatedReplyMessageId(_ replyMessageId: MessageId?) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedForwardMessageIds(_ forwardMessageIds: [MessageId]?) -> ChatInterfaceState {
|
func withUpdatedForwardMessageIds(_ forwardMessageIds: [MessageId]?) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedSelectedMessages(_ messageIds: [MessageId]) -> ChatInterfaceState {
|
func withUpdatedSelectedMessages(_ messageIds: [MessageId]) -> ChatInterfaceState {
|
||||||
@ -683,7 +695,7 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
for messageId in messageIds {
|
for messageId in messageIds {
|
||||||
selectedIds.insert(messageId)
|
selectedIds.insert(messageId)
|
||||||
}
|
}
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: ChatInterfaceSelectionState(selectedIds: selectedIds), messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: ChatInterfaceSelectionState(selectedIds: selectedIds), messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withToggledSelectedMessages(_ messageIds: [MessageId], value: Bool) -> ChatInterfaceState {
|
func withToggledSelectedMessages(_ messageIds: [MessageId], value: Bool) -> ChatInterfaceState {
|
||||||
@ -698,34 +710,38 @@ public final class ChatInterfaceState: SynchronizeableChatInterfaceState, Equata
|
|||||||
selectedIds.remove(messageId)
|
selectedIds.remove(messageId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: ChatInterfaceSelectionState(selectedIds: selectedIds), messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: ChatInterfaceSelectionState(selectedIds: selectedIds), messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withoutSelectionState() -> ChatInterfaceState {
|
func withoutSelectionState() -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: nil, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: nil, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedTimestamp(_ timestamp: Int32) -> ChatInterfaceState {
|
func withUpdatedTimestamp(_ timestamp: Int32) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedEditMessage(_ editMessage: ChatEditMessageState?) -> ChatInterfaceState {
|
func withUpdatedEditMessage(_ editMessage: ChatEditMessageState?) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMessageActionsState(_ f: (ChatInterfaceMessageActionsState) -> ChatInterfaceMessageActionsState) -> ChatInterfaceState {
|
func withUpdatedMessageActionsState(_ f: (ChatInterfaceMessageActionsState) -> ChatInterfaceMessageActionsState) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: f(self.messageActionsState), historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: f(self.messageActionsState), historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedHistoryScrollState(_ historyScrollState: ChatInterfaceHistoryScrollState?) -> ChatInterfaceState {
|
func withUpdatedHistoryScrollState(_ historyScrollState: ChatInterfaceHistoryScrollState?) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
func withUpdatedMediaRecordingMode(_ mediaRecordingMode: ChatTextInputMediaRecordingButtonMode) -> ChatInterfaceState {
|
func withUpdatedMediaRecordingMode(_ mediaRecordingMode: ChatTextInputMediaRecordingButtonMode) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: mediaRecordingMode, silentPosting: self.silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: self.inputLanguage)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func withUpdatedSilentPosting(_ silentPosting: Bool) -> ChatInterfaceState {
|
public func withUpdatedSilentPosting(_ silentPosting: Bool) -> ChatInterfaceState {
|
||||||
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: silentPosting)
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: silentPosting, inputLanguage: self.inputLanguage)
|
||||||
|
}
|
||||||
|
|
||||||
|
public func withUpdatedInputLanguage(_ inputLanguage: String?) -> ChatInterfaceState {
|
||||||
|
return ChatInterfaceState(timestamp: self.timestamp, composeInputState: self.composeInputState, composeDisableUrlPreview: self.composeDisableUrlPreview, replyMessageId: self.replyMessageId, forwardMessageIds: self.forwardMessageIds, editMessage: self.editMessage, selectionState: self.selectionState, messageActionsState: self.messageActionsState, historyScrollState: self.historyScrollState, mediaRecordingMode: self.mediaRecordingMode, silentPosting: self.silentPosting, inputLanguage: inputLanguage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,6 +220,15 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var storedInputLanguage: String?
|
||||||
|
var effectiveInputLanguage: String? {
|
||||||
|
if let textInputNode = textInputNode, textInputNode.isFirstResponder() {
|
||||||
|
return textInputNode.textInputMode.primaryLanguage
|
||||||
|
} else {
|
||||||
|
return self.storedInputLanguage
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override var account: Account? {
|
override var account: Account? {
|
||||||
didSet {
|
didSet {
|
||||||
self.actionButtons.micButton.account = self.account
|
self.actionButtons.micButton.account = self.account
|
||||||
@ -389,6 +398,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
|
|
||||||
private func loadTextInputNode() {
|
private func loadTextInputNode() {
|
||||||
let textInputNode = EditableTextNode()
|
let textInputNode = EditableTextNode()
|
||||||
|
textInputNode.initialPrimaryLanguage = self.presentationInterfaceState?.interfaceState.inputLanguage
|
||||||
var textColor: UIColor = .black
|
var textColor: UIColor = .black
|
||||||
var tintColor: UIColor = .blue
|
var tintColor: UIColor = .blue
|
||||||
var baseFontSize: CGFloat = 17.0
|
var baseFontSize: CGFloat = 17.0
|
||||||
@ -1243,6 +1253,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func editableTextNodeDidFinishEditing(_ editableTextNode: ASEditableTextNode) {
|
func editableTextNodeDidFinishEditing(_ editableTextNode: ASEditableTextNode) {
|
||||||
|
self.storedInputLanguage = editableTextNode.textInputMode.primaryLanguage
|
||||||
self.inputMenu.deactivate()
|
self.inputMenu.deactivate()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user