diff --git a/src/view/com/post-thread/PostThreadItem.tsx b/src/view/com/post-thread/PostThreadItem.tsx index fcfaba9d..93cf4be3 100644 --- a/src/view/com/post-thread/PostThreadItem.tsx +++ b/src/view/com/post-thread/PostThreadItem.tsx @@ -1,6 +1,7 @@ import React, {useMemo, useState} from 'react' import {observer} from 'mobx-react-lite' import {StyleSheet, Text, View} from 'react-native' +import Clipboard from '@react-native-clipboard/clipboard' import {AtUri} from '../../../third-party/uri' import * as PostType from '../../../third-party/api/src/client/types/app/bsky/feed/post' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' @@ -75,6 +76,10 @@ export const PostThreadItem = observer(function PostThreadItem({ .toggleUpvote() .catch(e => console.error('Failed to toggle upvote', record, e)) } + const onCopyPostText = () => { + Clipboard.setString(record.text) + Toast.show('Copied to clipboard') + } const onDeletePost = () => { item.delete().then( () => { @@ -130,6 +135,7 @@ export const PostThreadItem = observer(function PostThreadItem({ itemHref={itemHref} itemTitle={itemTitle} isAuthor={item.author.did === store.me.did} + onCopyPostText={onCopyPostText} onDeletePost={onDeletePost}> diff --git a/src/view/com/post/Post.tsx b/src/view/com/post/Post.tsx index 2996991e..23ec44c6 100644 --- a/src/view/com/post/Post.tsx +++ b/src/view/com/post/Post.tsx @@ -8,6 +8,7 @@ import { ViewStyle, } from 'react-native' import {observer} from 'mobx-react-lite' +import Clipboard from '@react-native-clipboard/clipboard' import {AtUri} from '../../../third-party/uri' import * as PostType from '../../../third-party/api/src/client/types/app/bsky/feed/post' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' @@ -110,6 +111,10 @@ export const Post = observer(function Post({ .toggleUpvote() .catch(e => console.error('Failed to toggle upvote', record, e)) } + const onCopyPostText = () => { + Clipboard.setString(record.text) + Toast.show('Copied to clipboard') + } const onDeletePost = () => { item.delete().then( () => { @@ -144,6 +149,7 @@ export const Post = observer(function Post({ authorDisplayName={item.author.displayName} timestamp={item.indexedAt} isAuthor={item.author.did === store.me.did} + onCopyPostText={onCopyPostText} onDeletePost={onDeletePost} /> {replyHref !== '' && ( diff --git a/src/view/com/posts/FeedItem.tsx b/src/view/com/posts/FeedItem.tsx index 19df5a74..b34fe239 100644 --- a/src/view/com/posts/FeedItem.tsx +++ b/src/view/com/posts/FeedItem.tsx @@ -1,6 +1,7 @@ import React, {useMemo, useState} from 'react' import {observer} from 'mobx-react-lite' import {StyleSheet, Text, View} from 'react-native' +import Clipboard from '@react-native-clipboard/clipboard' import {AtUri} from '../../../third-party/uri' import * as PostType from '../../../third-party/api/src/client/types/app/bsky/feed/post' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' @@ -66,6 +67,10 @@ export const FeedItem = observer(function FeedItem({ .toggleUpvote() .catch(e => console.error('Failed to toggle upvote', record, e)) } + const onCopyPostText = () => { + Clipboard.setString(record.text) + Toast.show('Copied to clipboard') + } const onDeletePost = () => { item.delete().then( () => { @@ -147,6 +152,7 @@ export const FeedItem = observer(function FeedItem({ authorDisplayName={item.author.displayName} timestamp={item.indexedAt} isAuthor={item.author.did === store.me.did} + onCopyPostText={onCopyPostText} onDeletePost={onDeletePost} /> ) : undefined} diff --git a/src/view/com/util/DropdownBtn.tsx b/src/view/com/util/DropdownBtn.tsx index 98e2f3f2..b38a6ed9 100644 --- a/src/view/com/util/DropdownBtn.tsx +++ b/src/view/com/util/DropdownBtn.tsx @@ -79,6 +79,7 @@ export function PostDropdownBtn({ itemHref, itemTitle, isAuthor, + onCopyPostText, onDeletePost, }: { style?: StyleProp @@ -86,6 +87,7 @@ export function PostDropdownBtn({ itemHref: string itemTitle: string isAuthor: boolean + onCopyPostText: () => void onDeletePost: () => void }) { const store = useStores() @@ -100,6 +102,13 @@ export function PostDropdownBtn({ }, } : undefined, + { + icon: ['far', 'paste'], + label: 'Copy post text', + onPress() { + onCopyPostText() + }, + }, { icon: 'share', label: 'Share...', diff --git a/src/view/com/util/PostMeta.tsx b/src/view/com/util/PostMeta.tsx index 80dde0e0..1994580c 100644 --- a/src/view/com/util/PostMeta.tsx +++ b/src/view/com/util/PostMeta.tsx @@ -14,6 +14,7 @@ interface PostMetaOpts { authorDisplayName: string | undefined timestamp: string isAuthor: boolean + onCopyPostText: () => void onDeletePost: () => void } @@ -40,6 +41,7 @@ export function PostMeta(opts: PostMetaOpts) { itemHref={opts.itemHref} itemTitle={opts.itemTitle} isAuthor={opts.isAuthor} + onCopyPostText={opts.onCopyPostText} onDeletePost={opts.onDeletePost}> diff --git a/src/view/index.ts b/src/view/index.ts index 65779bf9..71769471 100644 --- a/src/view/index.ts +++ b/src/view/index.ts @@ -38,6 +38,7 @@ import {faLock} from '@fortawesome/free-solid-svg-icons/faLock' import {faMagnifyingGlass} from '@fortawesome/free-solid-svg-icons/faMagnifyingGlass' import {faMessage} from '@fortawesome/free-regular-svg-icons/faMessage' import {faNoteSticky} from '@fortawesome/free-solid-svg-icons/faNoteSticky' +import {faPaste} from '@fortawesome/free-regular-svg-icons/faPaste' import {faPen} from '@fortawesome/free-solid-svg-icons/faPen' import {faPenNib} from '@fortawesome/free-solid-svg-icons/faPenNib' import {faPenToSquare} from '@fortawesome/free-solid-svg-icons/faPenToSquare' @@ -101,6 +102,7 @@ export function setup() { faMagnifyingGlass, faMessage, faNoteSticky, + faPaste, faPen, faPenNib, faPenToSquare,