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)
This commit is contained in:
Paul Frazee
2023-03-03 15:13:31 -06:00
committed by GitHub
parent c2bfa111ac
commit a9920d9630
6 changed files with 44 additions and 3 deletions
+7
View File
@@ -1,6 +1,7 @@
import React, {useState, useEffect} from 'react'
import {
ActivityIndicator,
Linking,
StyleProp,
StyleSheet,
View,
@@ -120,6 +121,11 @@ export const Post = observer(function Post({
Clipboard.setString(record.text)
Toast.show('Copied to clipboard')
}
const onOpenTranslate = () => {
Linking.openURL(
encodeURI(`https://translate.google.com/#auto|en|${record?.text || ''}`),
)
}
const onDeletePost = () => {
item.delete().then(
() => {
@@ -214,6 +220,7 @@ export const Post = observer(function Post({
onPressToggleRepost={onPressToggleRepost}
onPressToggleUpvote={onPressToggleUpvote}
onCopyPostText={onCopyPostText}
onOpenTranslate={onOpenTranslate}
onDeletePost={onDeletePost}
/>
</View>