From 695099d4d237dc8dad4759aade047cf196ed622b Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 5 Jun 2024 23:33:43 -0700 Subject: [PATCH] start reworking ui --- .../StarterPack/Wizard/WizardListEmpty.tsx | 3 +- .../StarterPack/Wizard/StepProfiles.tsx | 45 +++- src/screens/StarterPack/Wizard/index.tsx | 199 ++++++++++++++---- 3 files changed, 194 insertions(+), 53 deletions(-) diff --git a/src/components/StarterPack/Wizard/WizardListEmpty.tsx b/src/components/StarterPack/Wizard/WizardListEmpty.tsx index 51cd3150ef..c48b718046 100644 --- a/src/components/StarterPack/Wizard/WizardListEmpty.tsx +++ b/src/components/StarterPack/Wizard/WizardListEmpty.tsx @@ -29,8 +29,7 @@ export function WizardListEmpty({type}: {type: 'profiles' | 'feeds'}) { {type === 'profiles' ? ( - Add people to your starter pack that you think others will enjoy - following + Search for people that you want to suggest others to follow ) : ( Add some cool feeds! diff --git a/src/screens/StarterPack/Wizard/StepProfiles.tsx b/src/screens/StarterPack/Wizard/StepProfiles.tsx index 003a5fb512..4156007b91 100644 --- a/src/screens/StarterPack/Wizard/StepProfiles.tsx +++ b/src/screens/StarterPack/Wizard/StepProfiles.tsx @@ -1,10 +1,14 @@ -import React from 'react' -import {ListRenderItemInfo} from 'react-native' +import React, {useState} from 'react' +import {ListRenderItemInfo, View} from 'react-native' import {AppBskyActorDefs} from '@atproto/api' +import {useActorAutocompleteQuery} from 'state/queries/actor-autocomplete' +import {useProfileFollowsQuery} from 'state/queries/profile-follows' +import {useSession} from 'state/session' +import {SearchInput} from 'view/com/util/forms/SearchInput' import {List} from 'view/com/util/List' import {useWizardState} from '#/screens/StarterPack/Wizard/State' -import {WizardListEmpty} from '#/components/StarterPack/Wizard/WizardListEmpty' +import {atoms as a} from '#/alf' import {WizardProfileCard} from '#/components/StarterPack/Wizard/WizardProfileCard' function keyExtractor(item: AppBskyActorDefs.ProfileViewBasic) { @@ -13,6 +17,19 @@ function keyExtractor(item: AppBskyActorDefs.ProfileViewBasic) { export function StepProfiles() { const [state, dispatch] = useWizardState() + const [query, setQuery] = useState('') + + const {currentAccount} = useSession() + const {data: followsPages, fetchNextPage} = useProfileFollowsQuery( + currentAccount?.did, + ) + const follows = followsPages?.pages.flatMap(page => page.follows) || [] + + const {data: results} = useActorAutocompleteQuery( + query || encodeURIComponent('*'), + true, + 12, + ) const renderItem = ({ item, @@ -23,11 +40,21 @@ export function StepProfiles() { } return ( - } - /> + <> + + setQuery('')} + onSubmitQuery={() => {}} + /> + + fetchNextPage() : undefined} + /> + ) } diff --git a/src/screens/StarterPack/Wizard/index.tsx b/src/screens/StarterPack/Wizard/index.tsx index 4cd490432d..ec504aed58 100644 --- a/src/screens/StarterPack/Wizard/index.tsx +++ b/src/screens/StarterPack/Wizard/index.tsx @@ -1,16 +1,20 @@ import React from 'react' import {Keyboard, View} from 'react-native' import {KeyboardAwareScrollView} from 'react-native-keyboard-controller' -import {msg, Trans} from '@lingui/macro' +import {AppBskyActorDefs, AppBskyFeedDefs} from '@atproto/api' +import {GeneratorView} from '@atproto/api/dist/client/types/app/bsky/feed/defs' +import {msg, Plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useNavigation} from '@react-navigation/native' +import {useFocusEffect, useNavigation} from '@react-navigation/native' import {NativeStackScreenProps} from '@react-navigation/native-stack' -import {useBottomBarOffset} from 'lib/hooks/useBottomBarOffset' import {CommonNavigatorParams, NavigationProp} from 'lib/routes/types' +import {enforceLen} from 'lib/strings/helpers' import {isAndroid, isWeb} from 'platform/detection' import {useProfileQuery} from 'state/queries/profile' import {useSession} from 'state/session' +import {useSetMinimalShellMode} from 'state/shell' +import {UserAvatar} from 'view/com/util/UserAvatar' import {CenteredView} from 'view/com/util/Views' import {useWizardState, WizardStep} from '#/screens/StarterPack/Wizard/State' import {StepDetails} from '#/screens/StarterPack/Wizard/StepDetails' @@ -71,7 +75,6 @@ function WizardInner() { const navigation = useNavigation() const {_} = useLingui() const t = useTheme() - const bottomOffset = useBottomBarOffset() const [state, dispatch] = useWizardState() const {currentAccount} = useSession() const {data: currentProfile} = useProfileQuery({ @@ -80,22 +83,20 @@ function WizardInner() { }) const addDialogControl = useDialogControl() + const setMinimalShellMode = useSetMinimalShellMode() + React.useEffect(() => { navigation.setOptions({ gestureEnabled: false, }) }, [navigation]) - // TODO move to state if we keep this - const continueIsCta = () => { - if (state.currentStep === 'Details') { - return true - } else if (state.currentStep === 'Profiles') { - return state.profiles.length > 0 - } else if (state.currentStep === 'Feeds') { - return state.feeds.length > 0 - } - } + useFocusEffect( + React.useCallback(() => { + setMinimalShellMode(true) + return () => setMinimalShellMode(false) + }, [setMinimalShellMode]), + ) const wizardUiStrings: Record< WizardStep, @@ -145,9 +146,7 @@ function WizardInner() { } return ( - + - - {state.currentStep !== 'Details' && ( - - )} - + {state.currentStep === 'Details' && ( - + )} + +