migrate to `expo-clipboard` (#3419)

* replace package

* replace usages
zio/stable
Hailey 2024-04-04 21:19:15 -07:00 committed by GitHub
parent 101d1589bf
commit 0433f8ad68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 69 additions and 68 deletions

View File

@ -65,7 +65,6 @@
"@miblanchard/react-native-slider": "^2.3.1", "@miblanchard/react-native-slider": "^2.3.1",
"@radix-ui/react-dropdown-menu": "^2.0.6", "@radix-ui/react-dropdown-menu": "^2.0.6",
"@react-native-async-storage/async-storage": "1.21.0", "@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-masked-view/masked-view": "0.3.0",
"@react-native-menu/menu": "^0.8.0", "@react-native-menu/menu": "^0.8.0",
"@react-native-picker/picker": "2.6.1", "@react-native-picker/picker": "2.6.1",
@ -110,6 +109,7 @@
"expo-application": "~5.8.3", "expo-application": "~5.8.3",
"expo-build-properties": "^0.11.1", "expo-build-properties": "^0.11.1",
"expo-camera": "~14.0.4", "expo-camera": "~14.0.4",
"expo-clipboard": "^5.0.1",
"expo-constants": "~15.4.5", "expo-constants": "~15.4.5",
"expo-dev-client": "~3.3.8", "expo-dev-client": "~3.3.8",
"expo-device": "~5.9.3", "expo-device": "~5.9.3",

View File

@ -1,6 +1,6 @@
import {Share} from 'react-native' import {Share} from 'react-native'
// import * as Sharing from 'expo-sharing' // import * as Sharing from 'expo-sharing'
import Clipboard from '@react-native-clipboard/clipboard' import {setStringAsync} from 'expo-clipboard'
import {isAndroid, isIOS} from 'platform/detection' import {isAndroid, isIOS} from 'platform/detection'
import * as Toast from '#/view/com/util/Toast' import * as Toast from '#/view/com/util/Toast'
@ -19,7 +19,7 @@ export async function shareUrl(url: string) {
} else { } else {
// React Native Share is not supported by web. Web Share API // React Native Share is not supported by web. Web Share API
// has increasing but not full support, so default to clipboard // has increasing but not full support, so default to clipboard
Clipboard.setString(url) setStringAsync(url)
Toast.show('Copied to clipboard') Toast.show('Copied to clipboard')
} }
} }

View File

@ -1,24 +1,25 @@
import React, {useState} from 'react' import React, {useState} from 'react'
import {StyleSheet, TextInput, View, TouchableOpacity} from 'react-native' import {StyleSheet, TextInput, TouchableOpacity, View} from 'react-native'
import {Text} from '../util/text/Text' import {setStringAsync} from 'expo-clipboard'
import {Button} from '../util/forms/Button'
import {s} from 'lib/styles'
import {usePalette} from 'lib/hooks/usePalette'
import {isNative} from 'platform/detection'
import { import {
FontAwesomeIcon, FontAwesomeIcon,
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import Clipboard from '@react-native-clipboard/clipboard' import {msg, Trans} from '@lingui/macro'
import * as Toast from '../util/Toast'
import {logger} from '#/logger'
import {Trans, msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {useModalControls} from '#/state/modals' import {useModalControls} from '#/state/modals'
import { import {
useAppPasswordsQuery,
useAppPasswordCreateMutation, useAppPasswordCreateMutation,
useAppPasswordsQuery,
} from '#/state/queries/app-passwords' } from '#/state/queries/app-passwords'
import {usePalette} from 'lib/hooks/usePalette'
import {s} from 'lib/styles'
import {isNative} from 'platform/detection'
import {Button} from '../util/forms/Button'
import {Text} from '../util/text/Text'
import * as Toast from '../util/Toast'
export const snapPoints = ['70%'] export const snapPoints = ['70%']
@ -72,7 +73,7 @@ export function Component({}: {}) {
const onCopy = React.useCallback(() => { const onCopy = React.useCallback(() => {
if (appPassword) { if (appPassword) {
Clipboard.setString(appPassword) setStringAsync(appPassword)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`))
setWasCopied(true) setWasCopied(true)
} }

View File

@ -1,37 +1,38 @@
import React, {useState} from 'react' import React, {useState} from 'react'
import Clipboard from '@react-native-clipboard/clipboard'
import {ComAtprotoServerDescribeServer} from '@atproto/api'
import * as Toast from '../util/Toast'
import { import {
ActivityIndicator, ActivityIndicator,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
View, View,
} from 'react-native' } from 'react-native'
import {setStringAsync} from 'expo-clipboard'
import {ComAtprotoServerDescribeServer} from '@atproto/api'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {ScrollView, TextInput} from './util' import {msg, Trans} from '@lingui/macro'
import {Text} from '../util/text/Text'
import {Button} from '../util/forms/Button'
import {SelectableBtn} from '../util/forms/SelectableBtn'
import {ErrorMessage} from '../util/error/ErrorMessage'
import {s} from 'lib/styles'
import {createFullHandle, makeValidHandle} from 'lib/strings/handles'
import {usePalette} from 'lib/hooks/usePalette'
import {useTheme} from 'lib/ThemeContext'
import {useAnalytics} from 'lib/analytics/analytics'
import {cleanError} from 'lib/strings/errors'
import {logger} from '#/logger'
import {Trans, msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {logger} from '#/logger'
import {useModalControls} from '#/state/modals' import {useModalControls} from '#/state/modals'
import {useFetchDid, useUpdateHandleMutation} from '#/state/queries/handle'
import {useServiceQuery} from '#/state/queries/service' import {useServiceQuery} from '#/state/queries/service'
import {useUpdateHandleMutation, useFetchDid} from '#/state/queries/handle'
import { import {
getAgent,
SessionAccount,
useSession, useSession,
useSessionApi, useSessionApi,
SessionAccount,
getAgent,
} from '#/state/session' } from '#/state/session'
import {useAnalytics} from 'lib/analytics/analytics'
import {usePalette} from 'lib/hooks/usePalette'
import {cleanError} from 'lib/strings/errors'
import {createFullHandle, makeValidHandle} from 'lib/strings/handles'
import {s} from 'lib/styles'
import {useTheme} from 'lib/ThemeContext'
import {ErrorMessage} from '../util/error/ErrorMessage'
import {Button} from '../util/forms/Button'
import {SelectableBtn} from '../util/forms/SelectableBtn'
import {Text} from '../util/text/Text'
import * as Toast from '../util/Toast'
import {ScrollView, TextInput} from './util'
export const snapPoints = ['100%'] export const snapPoints = ['100%']
@ -321,9 +322,7 @@ function CustomHandleForm({
// events // events
// = // =
const onPressCopy = React.useCallback(() => { const onPressCopy = React.useCallback(() => {
Clipboard.setString( setStringAsync(isDNSForm ? `did=${currentAccount.did}` : currentAccount.did)
isDNSForm ? `did=${currentAccount.did}` : currentAccount.did,
)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`))
}, [currentAccount, isDNSForm, _]) }, [currentAccount, isDNSForm, _])
const onChangeHandle = React.useCallback( const onChangeHandle = React.useCallback(

View File

@ -1,37 +1,38 @@
import React from 'react' import React from 'react'
import { import {
ActivityIndicator,
StyleSheet, StyleSheet,
TouchableOpacity, TouchableOpacity,
View, View,
ActivityIndicator,
} from 'react-native' } from 'react-native'
import {setStringAsync} from 'expo-clipboard'
import {ComAtprotoServerDefs} from '@atproto/api' import {ComAtprotoServerDefs} from '@atproto/api'
import { import {
FontAwesomeIcon, FontAwesomeIcon,
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import Clipboard from '@react-native-clipboard/clipboard' import {msg, Trans} from '@lingui/macro'
import {Text} from '../util/text/Text'
import {Button} from '../util/forms/Button'
import * as Toast from '../util/Toast'
import {ScrollView} from './util'
import {usePalette} from 'lib/hooks/usePalette'
import {isWeb} from 'platform/detection'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {Trans, msg} from '@lingui/macro'
import {cleanError} from 'lib/strings/errors'
import {useModalControls} from '#/state/modals'
import {useInvitesState, useInvitesAPI} from '#/state/invites'
import {UserInfoText} from '../util/UserInfoText'
import {makeProfileLink} from '#/lib/routes/links'
import {Link} from '../util/Link'
import {ErrorMessage} from '../util/error/ErrorMessage'
import {
useInviteCodesQuery,
InviteCodesQueryResponse,
} from '#/state/queries/invites'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import {makeProfileLink} from '#/lib/routes/links'
import {useInvitesAPI, useInvitesState} from '#/state/invites'
import {useModalControls} from '#/state/modals'
import {
InviteCodesQueryResponse,
useInviteCodesQuery,
} from '#/state/queries/invites'
import {usePalette} from 'lib/hooks/usePalette'
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
import {cleanError} from 'lib/strings/errors'
import {isWeb} from 'platform/detection'
import {ErrorMessage} from '../util/error/ErrorMessage'
import {Button} from '../util/forms/Button'
import {Link} from '../util/Link'
import {Text} from '../util/text/Text'
import * as Toast from '../util/Toast'
import {UserInfoText} from '../util/UserInfoText'
import {ScrollView} from './util'
export const snapPoints = ['70%'] export const snapPoints = ['70%']
export function Component() { export function Component() {
@ -148,7 +149,7 @@ function InviteCode({
const uses = invite.uses const uses = invite.uses
const onPress = React.useCallback(() => { const onPress = React.useCallback(() => {
Clipboard.setString(invite.code) setStringAsync(invite.code)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`))
setInviteCopied(invite.code) setInviteCopied(invite.code)
}, [setInviteCopied, invite, _]) }, [setInviteCopied, invite, _])

View File

@ -1,5 +1,6 @@
import React, {memo} from 'react' import React, {memo} from 'react'
import {Pressable, PressableProps, StyleProp, ViewStyle} from 'react-native' import {Pressable, PressableProps, StyleProp, ViewStyle} from 'react-native'
import {setStringAsync} from 'expo-clipboard'
import { import {
AppBskyActorDefs, AppBskyActorDefs,
AppBskyFeedPost, AppBskyFeedPost,
@ -9,7 +10,6 @@ import {
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {msg} from '@lingui/macro' import {msg} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import Clipboard from '@react-native-clipboard/clipboard'
import {useNavigation} from '@react-navigation/native' import {useNavigation} from '@react-navigation/native'
import {makeProfileLink} from '#/lib/routes/links' import {makeProfileLink} from '#/lib/routes/links'
@ -154,7 +154,7 @@ let PostDropdownBtn = ({
const onCopyPostText = React.useCallback(() => { const onCopyPostText = React.useCallback(() => {
const str = richTextToString(richText, true) const str = richTextToString(richText, true)
Clipboard.setString(str) setStringAsync(str)
Toast.show(_(msg`Copied to clipboard`)) Toast.show(_(msg`Copied to clipboard`))
}, [_, richText]) }, [_, richText])

View File

@ -10,13 +10,13 @@ import {
View, View,
ViewStyle, ViewStyle,
} from 'react-native' } from 'react-native'
import {setStringAsync} from 'expo-clipboard'
import { import {
FontAwesomeIcon, FontAwesomeIcon,
FontAwesomeIconStyle, FontAwesomeIconStyle,
} from '@fortawesome/react-native-fontawesome' } from '@fortawesome/react-native-fontawesome'
import {msg, Trans} from '@lingui/macro' import {msg, Trans} from '@lingui/macro'
import {useLingui} from '@lingui/react' import {useLingui} from '@lingui/react'
import Clipboard from '@react-native-clipboard/clipboard'
import {useFocusEffect, useNavigation} from '@react-navigation/native' import {useFocusEffect, useNavigation} from '@react-navigation/native'
import {useQueryClient} from '@tanstack/react-query' import {useQueryClient} from '@tanstack/react-query'
@ -245,7 +245,7 @@ export function SettingsScreen({}: Props) {
}, [onboardingDispatch, _]) }, [onboardingDispatch, _])
const onPressBuildInfo = React.useCallback(() => { const onPressBuildInfo = React.useCallback(() => {
Clipboard.setString( setStringAsync(
`Build version: ${AppInfo.appVersion}; Platform: ${Platform.OS}`, `Build version: ${AppInfo.appVersion}; Platform: ${Platform.OS}`,
) )
Toast.show(_(msg`Copied build version to clipboard`)) Toast.show(_(msg`Copied build version to clipboard`))

View File

@ -4857,11 +4857,6 @@
dependencies: dependencies:
merge-options "^3.0.4" 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/cli-clean@12.3.0": "@react-native-community/cli-clean@12.3.0":
version "12.3.0" version "12.3.0"
resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.0.tgz#667b32daa58b4d11d5b5ab9eb0a2e216d500c90b" resolved "https://registry.yarnpkg.com/@react-native-community/cli-clean/-/cli-clean-12.3.0.tgz#667b32daa58b4d11d5b5ab9eb0a2e216d500c90b"
@ -11777,6 +11772,11 @@ expo-camera@~14.0.4:
dependencies: dependencies:
invariant "^2.2.4" invariant "^2.2.4"
expo-clipboard@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/expo-clipboard/-/expo-clipboard-5.0.1.tgz#a62a021a9444740d180d60f915cca8242a323716"
integrity sha512-JH853QJPr5W3h87If3aDTnMK+ESSIrwzU2TdfZrqZttVDY2pMIf/w37mVHHNYodXM4ATHXadtOkjKbAa0DWwUg==
expo-constants@^13.0.2: expo-constants@^13.0.2:
version "13.2.4" version "13.2.4"
resolved "https://registry.yarnpkg.com/expo-constants/-/expo-constants-13.2.4.tgz#eab4a553f074b2c60ad7a158d3b82e3484a94606" resolved "https://registry.yarnpkg.com/expo-constants/-/expo-constants-13.2.4.tgz#eab4a553f074b2c60ad7a158d3b82e3484a94606"