mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-03 21:16:35 +00:00
Add translate
This commit is contained in:
parent
58d6817223
commit
d60441f504
@ -6967,6 +6967,20 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
}
|
||||
|
||||
private func openBioContextMenu(node: ASDisplayNode, gesture: ContextGesture?) {
|
||||
let _ = (self.context.sharedContext.accountManager.sharedData(keys: [ApplicationSpecificSharedDataKeys.translationSettings])
|
||||
|> take(1)
|
||||
|> deliverOnMainQueue).startStandalone(next: { [weak self] sharedData in
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
let translationSettings: TranslationSettings
|
||||
if let current = sharedData.entries[ApplicationSpecificSharedDataKeys.translationSettings]?.get(TranslationSettings.self) {
|
||||
translationSettings = current
|
||||
} else {
|
||||
translationSettings = TranslationSettings.defaultSettings
|
||||
}
|
||||
|
||||
guard let sourceNode = node as? ContextExtractedContentContainingNode else {
|
||||
return
|
||||
}
|
||||
@ -7039,10 +7053,32 @@ final class PeerInfoScreenNode: ViewControllerTracingNode, PeerInfoScreenNodePro
|
||||
}
|
||||
})))
|
||||
|
||||
let (canTranslate, language) = canTranslateText(context: self.context, text: bioText, showTranslate: translationSettings.showTranslate, showTranslateIfTopical: false, ignoredLanguages: translationSettings.ignoredLanguages)
|
||||
if canTranslate {
|
||||
items.append(.action(ContextMenuActionItem(text: self.presentationData.strings.Conversation_ContextMenuTranslate, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Copy"), color: theme.contextMenu.primaryColor) }, action: { [weak self] c, _ in
|
||||
c.dismiss {
|
||||
guard let self else {
|
||||
return
|
||||
}
|
||||
|
||||
let controller = TranslateScreen(context: self.context, text: bioText, canCopy: true, fromLanguage: language, ignoredLanguages: translationSettings.ignoredLanguages)
|
||||
controller.pushController = { [weak self] c in
|
||||
(self?.controller?.navigationController as? NavigationController)?._keepModalDismissProgress = true
|
||||
self?.controller?.push(c)
|
||||
}
|
||||
controller.presentController = { [weak self] c in
|
||||
self?.controller?.present(c, in: .window(.root))
|
||||
}
|
||||
self.controller?.present(controller, in: .window(.root))
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
let actions = ContextController.Items(content: .list(items))
|
||||
|
||||
let contextController = ContextController(presentationData: self.presentationData, source: .extracted(PeerInfoContextExtractedContentSource(sourceNode: sourceNode)), items: .single(actions), gesture: gesture)
|
||||
self.controller?.present(contextController, in: .window(.root))
|
||||
})
|
||||
}
|
||||
|
||||
private func openWorkingHoursContextMenu(node: ASDisplayNode, gesture: ContextGesture?) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user