diff options
author | Paul Frazee <pfrazee@gmail.com> | 2023-03-03 15:13:31 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 15:13:31 -0600 |
commit | a9920d963041e53be5c454da30f8109c2a145d19 (patch) | |
tree | b02b37ffb7ac972f8e34944749fd6cdc6b67b05d /src/view/com/post-thread/PostThreadItem.tsx | |
parent | c2bfa111ac1f2c5fed2dd1caa92106849b14eaec (diff) | |
download | voidsky-a9920d963041e53be5c454da30f8109c2a145d19.tar.zst |
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)
Diffstat (limited to 'src/view/com/post-thread/PostThreadItem.tsx')
-rw-r--r-- | src/view/com/post-thread/PostThreadItem.tsx | 10 |
1 files changed, 9 insertions, 1 deletions
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}> <FontAwesomeIcon icon="ellipsis-h" @@ -259,6 +265,7 @@ export const PostThreadItem = observer(function PostThreadItem({ onPressToggleRepost={onPressToggleRepost} onPressToggleUpvote={onPressToggleUpvote} onCopyPostText={onCopyPostText} + onOpenTranslate={onOpenTranslate} onDeletePost={onDeletePost} /> </View> @@ -353,6 +360,7 @@ export const PostThreadItem = observer(function PostThreadItem({ onPressToggleRepost={onPressToggleRepost} onPressToggleUpvote={onPressToggleUpvote} onCopyPostText={onCopyPostText} + onOpenTranslate={onOpenTranslate} onDeletePost={onDeletePost} /> </View> |