Skip to content

Commit

Permalink
Fabric migration - @react-native-clipboard/clipboard -> `expo-clipb…
Browse files Browse the repository at this point in the history
…oard` (#3101)
  • Loading branch information
haileyok authored Mar 6, 2024
1 parent 7ec3c46 commit dc0447f
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 21 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@
"@mattermost/react-native-paste-input": "^0.6.4",
"@miblanchard/react-native-slider": "^2.3.1",
"@react-native-async-storage/async-storage": "1.21.0",
"@react-native-clipboard/clipboard": "^1.10.0",
"@react-native-masked-view/masked-view": "0.3.0",
"@react-native-menu/menu": "^0.8.0",
"@react-native-picker/picker": "2.6.1",
Expand Down
6 changes: 3 additions & 3 deletions src/lib/sharing.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {isIOS, isAndroid} from 'platform/detection'
import {Share} from 'react-native'
import {setStringAsync} from 'expo-clipboard'
// import * as Sharing from 'expo-sharing'
import Clipboard from '@react-native-clipboard/clipboard'
import * as Toast from '../view/com/util/Toast'
import {Share} from 'react-native'

/**
* This function shares a URL using the native Share API if available, or copies it to the clipboard
Expand All @@ -18,7 +18,7 @@ export async function shareUrl(url: string) {
} else {
// React Native Share is not supported by web. Web Share API
// has increasing but not full support, so default to clipboard
Clipboard.setString(url)
setStringAsync(url)
Toast.show('Copied to clipboard')
}
}
4 changes: 2 additions & 2 deletions src/view/com/modals/AddAppPasswords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
FontAwesomeIcon,
FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome'
import Clipboard from '@react-native-clipboard/clipboard'
import {setStringAsync} from 'expo-clipboard'
import * as Toast from '../util/Toast'
import {logger} from '#/logger'
import {Trans, msg} from '@lingui/macro'
Expand Down Expand Up @@ -72,7 +72,7 @@ export function Component({}: {}) {

const onCopy = React.useCallback(() => {
if (appPassword) {
Clipboard.setString(appPassword)
setStringAsync(appPassword)
Toast.show(_(msg`Copied to clipboard`))
setWasCopied(true)
}
Expand Down
6 changes: 2 additions & 4 deletions src/view/com/modals/ChangeHandle.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, {useState} from 'react'
import Clipboard from '@react-native-clipboard/clipboard'
import {setStringAsync} from 'expo-clipboard'
import {ComAtprotoServerDescribeServer} from '@atproto/api'
import * as Toast from '../util/Toast'
import {
Expand Down Expand Up @@ -321,9 +321,7 @@ function CustomHandleForm({
// events
// =
const onPressCopy = React.useCallback(() => {
Clipboard.setString(
isDNSForm ? `did=${currentAccount.did}` : currentAccount.did,
)
setStringAsync(isDNSForm ? `did=${currentAccount.did}` : currentAccount.did)
Toast.show('Copied to clipboard')
}, [currentAccount, isDNSForm])
const onChangeHandle = React.useCallback(
Expand Down
4 changes: 2 additions & 2 deletions src/view/com/modals/InviteCodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
FontAwesomeIcon,
FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome'
import Clipboard from '@react-native-clipboard/clipboard'
import {setStringAsync} from 'expo-clipboard'
import {Text} from '../util/text/Text'
import {Button} from '../util/forms/Button'
import * as Toast from '../util/Toast'
Expand Down Expand Up @@ -148,7 +148,7 @@ function InviteCode({
const uses = invite.uses

const onPress = React.useCallback(() => {
Clipboard.setString(invite.code)
setStringAsync(invite.code)
Toast.show(_(msg`Copied to clipboard`))
setInviteCopied(invite.code)
}, [setInviteCopied, invite, _])
Expand Down
4 changes: 2 additions & 2 deletions src/view/com/util/forms/PostDropdownBtn.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {memo} from 'react'
import {StyleProp, View, ViewStyle} from 'react-native'
import Clipboard from '@react-native-clipboard/clipboard'
import {setStringAsync} from 'expo-clipboard'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {useNavigation} from '@react-navigation/native'
import {
Expand Down Expand Up @@ -139,7 +139,7 @@ let PostDropdownBtn = ({
const onCopyPostText = React.useCallback(() => {
const str = richTextToString(richText, true)

Clipboard.setString(str)
setStringAsync(str)
Toast.show(_(msg`Copied to clipboard`))
}, [_, richText])

Expand Down
4 changes: 2 additions & 2 deletions src/view/screens/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {useAccountSwitcher} from 'lib/hooks/useAccountSwitcher'
import {useAnalytics} from 'lib/analytics/analytics'
import {NavigationProp} from 'lib/routes/types'
import {HandIcon, HashtagIcon} from 'lib/icons'
import Clipboard from '@react-native-clipboard/clipboard'
import {setStringAsync} from 'expo-clipboard'
import {makeProfileLink} from 'lib/routes/links'
import {RQKEY as RQKEY_PROFILE} from '#/state/queries/profile'
import {useModalControls} from '#/state/modals'
Expand Down Expand Up @@ -235,7 +235,7 @@ export function SettingsScreen({}: Props) {
}, [onboardingDispatch, _])

const onPressBuildInfo = React.useCallback(() => {
Clipboard.setString(
setStringAsync(
`Build version: ${AppInfo.appVersion}; Platform: ${Platform.OS}`,
)
Toast.show(_(msg`Copied build version to clipboard`))
Expand Down
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4682,11 +4682,6 @@
dependencies:
merge-options "^3.0.4"

"@react-native-clipboard/clipboard@^1.10.0":
version "1.11.2"
resolved "https://registry.yarnpkg.com/@react-native-clipboard/clipboard/-/clipboard-1.11.2.tgz#e826d0336b34e67294aaffa6878308900bc7d197"
integrity sha512-bHyZVW62TuleiZsXNHS1Pv16fWc0fh8O9WvBzl4h2fykqZRW9a+Pv/RGTH56E3X2PqzHP38K5go8zmCZUoIsoQ==

"@react-native-community/[email protected]":
version "12.3.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.0.tgz#667b32daa58b4d11d5b5ab9eb0a2e216d500c90b"
Expand Down

0 comments on commit dc0447f

Please sign in to comment.