From a9920d963041e53be5c454da30f8109c2a145d19 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Fri, 3 Mar 2023 15:13:31 -0600 Subject: Add translate link to post menu (#261) * Add a google translate menu item to posts * Fix: make sure the dropdown menu is always visible (when low on the screen) --- src/view/com/post-thread/PostThreadItem.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/view/com/post-thread/PostThreadItem.tsx') diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index 4e14a84b7..8eda0962a 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -1,6 +1,6 @@ import React from 'react' import {observer} from 'mobx-react-lite' -import {StyleSheet, View} from 'react-native' +import {Linking, StyleSheet, View} from 'react-native' import Clipboard from '@react-native-clipboard/clipboard' import {AtUri} from '../../../third-party/uri' import { @@ -89,6 +89,11 @@ export const PostThreadItem = observer(function PostThreadItem({ Clipboard.setString(record?.text || '') Toast.show('Copied to clipboard') }, [record]) + const onOpenTranslate = React.useCallback(() => { + Linking.openURL( + encodeURI(`https://translate.google.com/#auto|en|${record?.text || ''}`), + ) + }, [record]) const onDeletePost = React.useCallback(() => { item.delete().then( () => { @@ -167,6 +172,7 @@ export const PostThreadItem = observer(function PostThreadItem({ itemTitle={itemTitle} isAuthor={item.post.author.did === store.me.did} onCopyPostText={onCopyPostText} + onOpenTranslate={onOpenTranslate} onDeletePost={onDeletePost}> @@ -353,6 +360,7 @@ export const PostThreadItem = observer(function PostThreadItem({ onPressToggleRepost={onPressToggleRepost} onPressToggleUpvote={onPressToggleUpvote} onCopyPostText={onCopyPostText} + onOpenTranslate={onOpenTranslate} onDeletePost={onDeletePost} /> -- cgit 1.4.1