import {useCallback} from 'react' import {View} from 'react-native' import Animated, { FadeIn, FadeOut, LayoutAnimationConfig, LinearTransition, StretchOutY, } from 'react-native-reanimated' import {type ComAtprotoServerListAppPasswords} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {type NativeStackScreenProps} from '@react-navigation/native-stack' import {type CommonNavigatorParams} from '#/lib/routes/types' import {cleanError} from '#/lib/strings/errors' import {isWeb} from '#/platform/detection' import { useAppPasswordDeleteMutation, useAppPasswordsQuery, } from '#/state/queries/app-passwords' import {EmptyState} from '#/view/com/util/EmptyState' import {ErrorScreen} from '#/view/com/util/error/ErrorScreen' import * as Toast from '#/view/com/util/Toast' import {atoms as a, useTheme} from '#/alf' import {Admonition, colors} from '#/components/Admonition' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {useDialogControl} from '#/components/Dialog' import {PlusLarge_Stroke2_Corner0_Rounded as PlusIcon} from '#/components/icons/Plus' import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash' import {Warning_Stroke2_Corner0_Rounded as WarningIcon} from '#/components/icons/Warning' import * as Layout from '#/components/Layout' import {Loader} from '#/components/Loader' import * as Prompt from '#/components/Prompt' import {Text} from '#/components/Typography' import {AddAppPasswordDialog} from './components/AddAppPasswordDialog' import * as SettingsList from './components/SettingsList' type Props = NativeStackScreenProps export function AppPasswordsScreen({}: Props) { const {_} = useLingui() const {data: appPasswords, error} = useAppPasswordsQuery() const createAppPasswordControl = useDialogControl() return ( App Passwords {error ? ( ) : ( Use app passwords to sign in to other Bluesky clients without giving full access to your account or password. {appPasswords ? ( appPasswords.length > 0 ? ( {appPasswords.map(appPassword => ( ))} ) : ( ) ) : ( )} )} p.name) || []} /> ) } function AppPasswordCard({ appPassword, }: { appPassword: ComAtprotoServerListAppPasswords.AppPassword }) { const t = useTheme() const {i18n, _} = useLingui() const deleteControl = Prompt.usePromptControl() const {mutateAsync: deleteMutation} = useAppPasswordDeleteMutation() const onDelete = useCallback(async () => { await deleteMutation({name: appPassword.name}) Toast.show(_(msg({message: 'App password deleted', context: 'toast'}))) }, [deleteMutation, appPassword.name, _]) return ( {appPassword.name} Created{' '} {i18n.date(appPassword.createdAt, { year: 'numeric', month: 'numeric', day: 'numeric', hour: '2-digit', minute: '2-digit', })} {appPassword.privileged && ( Allows access to direct messages )} ) }