mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-15 21:45:19 +00:00
Improve chat text input speak feature
This commit is contained in:
parent
458f1ca584
commit
34a29f6dec
@ -679,7 +679,7 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
if let previousAdditionalSideInsets = previousAdditionalSideInsets, previousAdditionalSideInsets.right != additionalSideInsets.right {
|
||||
additionalOffset = (previousAdditionalSideInsets.right - additionalSideInsets.right) / 3.0
|
||||
|
||||
if case let .animated(duration, _) = transition {
|
||||
if case .animated = transition {
|
||||
transition = .animated(duration: 0.2, curve: .easeInOut)
|
||||
}
|
||||
}
|
||||
@ -1777,17 +1777,25 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
|
||||
func editableTextNodeTarget(forAction action: Selector) -> ASEditableTextNodeTargetForAction? {
|
||||
if action == Selector(("_accessibilitySpeak:")) {
|
||||
if let textInputNode = self.textInputNode, textInputNode.selectedRange.length > 0 {
|
||||
if case .format = self.inputMenu.state {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
} else if let textInputNode = self.textInputNode, textInputNode.selectedRange.length > 0 {
|
||||
return ASEditableTextNodeTargetForAction(target: self)
|
||||
} else {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
}
|
||||
} else if action == Selector("_accessibilitySpeakLanguageSelection:") {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
} else if action == Selector("_accessibilityPauseSpeaking:") {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
} else if action == Selector(("_accessibilitySpeakSpellOut:")) {
|
||||
if case .format = self.inputMenu.state {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
} else if let textInputNode = self.textInputNode, textInputNode.selectedRange.length > 0 {
|
||||
return nil
|
||||
} else {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
}
|
||||
}
|
||||
else if action == Selector(("_showTextStyleOptions:")) {
|
||||
else if action == Selector("_accessibilitySpeakLanguageSelection:") || action == Selector("_accessibilityPauseSpeaking:") || action == Selector("_accessibilitySpeakSentence:") {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
} else if action == Selector(("_showTextStyleOptions:")) {
|
||||
if case .general = self.inputMenu.state {
|
||||
if let textInputNode = self.textInputNode, textInputNode.attributedText == nil || textInputNode.attributedText!.length == 0 || textInputNode.selectedRange.length == 0 {
|
||||
return ASEditableTextNodeTargetForAction(target: nil)
|
||||
@ -1816,6 +1824,13 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate {
|
||||
return (current, inputMode)
|
||||
}
|
||||
speakText(text)
|
||||
|
||||
if #available(iOS 13.0, *) {
|
||||
UIMenuController.shared.hideMenu()
|
||||
} else {
|
||||
UIMenuController.shared.isMenuVisible = false
|
||||
UIMenuController.shared.update()
|
||||
}
|
||||
}
|
||||
|
||||
@objc func _showTextStyleOptions(_ sender: Any) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user