From aa6aad652e8091ea6039af82f41d4de3669a5944 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 31 Oct 2024 20:45:34 +0000 Subject: [Settings] Thread prefs revamp (#5772) * thread preferences screen * minor tweaks * more spacing * replace gate with IS_INTERNAL * [Settings] Following feed prefs revamp (#5773) * gated new settings screen * Following feed prefs * Update src/screens/Settings/FollowingFeedPreferences.tsx Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * Update src/screens/Settings/FollowingFeedPreferences.tsx Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * replace pref following feed gate * Update src/screens/Settings/FollowingFeedPreferences.tsx Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * use "Experimental" as the header --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * [Settings] External media prefs revamp (#5774) * gated new settings screen * external media prefs revamp * replace gate ext media embeds * Update src/screens/Settings/ExternalMediaPreferences.tsx Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * add imports for translation * alternate list style on native --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * [Settings] Languages revamp (partial) (#5775) * language settings (lazy restyle) * replace gate * fix text determining flex space * [Settings] App passwords revamp (#5777) * rework app passwords screen * Apply surfdude's copy changes Thanks @surfdude29! Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * format * replace gate * use admonition for input error and animate --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * [Settings] Change handle dialog (#5781) * new change handle dialog * animations native only * overflow hidden on togglebutton animation * add a low-contrast border * extract out copybutton * finish change handle dialog * invalidate query on success * web fixes * error message for rate limit exceeded * typo * em dash! Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * another em dash Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * set maxwidth of suffixtext * Copy tweak Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> * [Settings] Notifs settings revamp (#5884) * rename, move, and restyle notif settings * bold "experimental:" --------- Co-authored-by: surfdude29 <149612116+surfdude29@users.noreply.github.com> --- src/screens/Settings/AppPasswords.tsx | 209 ++++++++++++++++++++++++++++++++++ 1 file changed, 209 insertions(+) create mode 100644 src/screens/Settings/AppPasswords.tsx (limited to 'src/screens/Settings/AppPasswords.tsx') diff --git a/src/screens/Settings/AppPasswords.tsx b/src/screens/Settings/AppPasswords.tsx new file mode 100644 index 000000000..8cebf97ce --- /dev/null +++ b/src/screens/Settings/AppPasswords.tsx @@ -0,0 +1,209 @@ +import React, {useCallback} from 'react' +import {View} from 'react-native' +import Animated, { + FadeIn, + FadeOut, + LayoutAnimationConfig, + LinearTransition, + StretchOutY, +} from 'react-native-reanimated' +import {ComAtprotoServerListAppPasswords} from '@atproto/api' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' +import {NativeStackScreenProps} from '@react-navigation/native-stack' + +import {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 ( + + + + {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`App password deleted`)) + }, [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 + + + )} + + + + ) +} -- cgit 1.4.1