From b8579f2b1609f5d5e30278c9a1e9e3767bd06fe9 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 5 Dec 2025 14:50:53 +0200 Subject: [PATCH] add completed state --- src/screens/Settings/FindContactsSettings.tsx | 196 +++++++++++++++++- 1 file changed, 191 insertions(+), 5 deletions(-) diff --git a/src/screens/Settings/FindContactsSettings.tsx b/src/screens/Settings/FindContactsSettings.tsx index 8146994d68..60fe5df6fd 100644 --- a/src/screens/Settings/FindContactsSettings.tsx +++ b/src/screens/Settings/FindContactsSettings.tsx @@ -1,5 +1,8 @@ +import {useCallback} from 'react' +import {type ListRenderItemInfo, View} from 'react-native' import * as Contacts from 'expo-contacts' -import {msg, Trans} from '@lingui/macro' +import {type ModerationOpts} from '@atproto/api' +import {msg, Plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useQuery} from '@tanstack/react-query' @@ -8,20 +11,31 @@ import { type NativeStackScreenProps, } from '#/lib/routes/types' import {isNative} from '#/platform/detection' +import {useProfileShadow} from '#/state/cache/profile-shadow' +import {useModerationOpts} from '#/state/preferences/moderation-opts' +import {useProfilesQuery} from '#/state/queries/profile' import {ErrorScreen} from '#/view/com/util/error/ErrorScreen' -import {atoms as a, useGutters, useTheme} from '#/alf' +import {List} from '#/view/com/util/List' +import {atoms as a, tokens, useGutters, useTheme} from '#/alf' import {Admonition} from '#/components/Admonition' -import {ButtonText} from '#/components/Button' +import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {ContactsHeroImage} from '#/components/contacts/components/HeroImage' +import {ArrowRotateCounterClockwise_Stroke2_Corner0_Rounded as ResyncIcon} from '#/components/icons/ArrowRotateCounterClockwise' +import {Contacts_Stroke2_Corner2_Rounded as FindContactsIcon} from '#/components/icons/Contacts' +import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times' +import {Trash_Stroke2_Corner0_Rounded as TrashIcon} from '#/components/icons/Trash' import * as Layout from '#/components/Layout' import {InlineLinkText, Link} from '#/components/Link' +import * as ProfileCard from '#/components/ProfileCard' import {Text} from '#/components/Typography' +import type * as bsky from '#/types/bsky' +import * as SettingsList from './components/SettingsList' type Props = NativeStackScreenProps export function FindContactsSettingsScreen({}: Props) { const {_} = useLingui() - const hasInitiated = false + const hasInitiated = true return ( @@ -103,5 +117,177 @@ function Intro() { } function Status() { - return null + const {data: matches} = useProfilesQuery({ + handles: ['hailey.at', 'pfrazee.com', 'esb.lol'], + }) + const moderationOpts = useModerationOpts() + + const numMatches = matches?.profiles.length ?? 0 + + const renderItem = useCallback( + ({item, index}: ListRenderItemInfo) => { + if (!moderationOpts) return null + return ( + + ) + }, + [numMatches, moderationOpts], + ) + return ( + } + ListFooterComponent={} + /> + ) +} + +function MatchItem({ + profile, + isFirst, + isLast, + moderationOpts, +}: { + profile: bsky.profile.AnyProfileView + isFirst: boolean + isLast: boolean + moderationOpts: ModerationOpts +}) { + const t = useTheme() + const {_} = useLingui() + const shadow = useProfileShadow(profile) + + return ( + + + + + + + {!shadow.viewer?.following && ( + + )} + + + + ) +} + +function StatusHeader({numMatches}: {numMatches: number}) { + const t = useTheme() + + return ( + + + {numMatches > 1 ? ( + + + + ) : ( + + + Waiting for your friends to join + + + We will notify you when your contacts sign up. + + + )} + + ) +} + +function StatusFooter() { + const {_, i18n} = useLingui() + const t = useTheme() + + return ( + + + + + + Resync contacts + + + + + Contacts last uploaded on{' '} + {i18n.date(new Date(), { + dateStyle: 'long', + })} + + + + + + + + + Deleting your contact matching data will remove you from future + friend suggestions and immediately delete all non-matching data. + + + + + ) }