diff --git a/src/components/StarterPack/ProfileStarterPacks.tsx b/src/components/StarterPack/ProfileStarterPacks.tsx index 44fc64c1d6..74d22f409c 100644 --- a/src/components/StarterPack/ProfileStarterPacks.tsx +++ b/src/components/StarterPack/ProfileStarterPacks.tsx @@ -113,7 +113,7 @@ export const ProfileStarterPacks = React.forwardRef< testID="listsEmpty" style={[{padding: 18, borderTopWidth: 1}, pal.border]}> - You have no feeds. + You have no starter packs. ) diff --git a/src/screens/StarterPack/Wizard/State.tsx b/src/screens/StarterPack/Wizard/State.tsx index 5ce6c93ef9..fc56b68b71 100644 --- a/src/screens/StarterPack/Wizard/State.tsx +++ b/src/screens/StarterPack/Wizard/State.tsx @@ -95,20 +95,7 @@ function reducer(state: State, action: Action): State { break } - switch (updatedState.currentStep) { - case 'Details': - updatedState = { - ...updatedState, - canNext: Boolean(updatedState.description), - } - break - default: { - updatedState = { - ...updatedState, - canNext: true, - } - } - } + updatedState.canNext = !updatedState.processing return updatedState } diff --git a/src/screens/StarterPack/Wizard/index.tsx b/src/screens/StarterPack/Wizard/index.tsx index 66dc8b9246..d29f47df48 100644 --- a/src/screens/StarterPack/Wizard/index.tsx +++ b/src/screens/StarterPack/Wizard/index.tsx @@ -1,6 +1,9 @@ import React from 'react' import {Keyboard, TouchableOpacity, View} from 'react-native' -import {KeyboardAwareScrollView} from 'react-native-keyboard-controller' +import { + KeyboardAwareScrollView, + useKeyboardController, +} from 'react-native-keyboard-controller' import {useSafeAreaInsets} from 'react-native-safe-area-context' import { AppBskyActorDefs, @@ -44,6 +47,7 @@ import {Button, ButtonText} from '#/components/Button' import {useDialogControl} from '#/components/Dialog' import {ListMaybePlaceholder} from '#/components/Lists' import {Loader} from '#/components/Loader' +import * as Prompt from '#/components/Prompt' import {WizardEditListDialog} from '#/components/StarterPack/Wizard/WizardEditListDialog' import {Text} from '#/components/Typography' import {Provider} from './State' @@ -52,12 +56,11 @@ export function Wizard({ route, }: NativeStackScreenProps) { const params = route.params - const {name, rkey} = params ?? {} + const {name, rkey} = params const {currentAccount} = useSession() const {_} = useLingui() - // TODO load query here const { data: did, isLoading: isLoadingDid, @@ -147,6 +150,16 @@ function WizardInner({ did: currentAccount?.did, staleTime: 0, }) + const {setEnabled} = useKeyboardController() + + useFocusEffect( + React.useCallback(() => { + setEnabled(true) + return () => { + setEnabled(false) + } + }, [setEnabled]), + ) const setMinimalShellMode = useSetMinimalShellMode() @@ -347,6 +360,8 @@ function WizardInner({ } } + const deleteStarterPack = async () => {} + const onNext = () => { if (state.currentStep === 'Details' && !state.name) { dispatch({ @@ -412,7 +427,9 @@ function WizardInner({ - + @@ -423,9 +440,18 @@ function WizardInner({ ) } -function Container({children}: {children: React.ReactNode}) { +function Container({ + showDeleteBtn, + deleteStarterPack, + children, +}: { + showDeleteBtn: boolean + deleteStarterPack: () => Promise + children: React.ReactNode +}) { const {_} = useLingui() const [state, dispatch] = useWizardState() + const control = useDialogControl() if (state.currentStep === 'Profiles' || state.currentStep === 'Feeds') { return {children} @@ -437,37 +463,55 @@ function Container({children}: {children: React.ReactNode}) { keyboardShouldPersistTaps="handled"> {children} {state.currentStep === 'Details' && ( - + <> + + {showDeleteBtn && ( + + )} + + + Delete starter pack? + + + Are you sure you want delete this starter pack? + + + + + + + )} ) } -function StepView() { - const [state] = useWizardState() - - if (state.currentStep === 'Details') { - return - } - if (state.currentStep === 'Profiles') { - return - } - if (state.currentStep === 'Feeds') { - return - } -} - function Footer({ onNext, nextBtnText, @@ -522,16 +566,14 @@ function Footer({ )} - - {items.slice(0, 6).map((p, index) => ( - - ))} - + {items.slice(0, 6).map((p, index) => ( + + ))} {items.length === 0 ? ( @@ -596,7 +638,7 @@ function Footer({ color="primary" size="small" onPress={onNext} - disabled={!state.canNext || state.processing}> + disabled={!state.canNext}> {nextBtnText} {state.processing && } @@ -619,3 +661,17 @@ function getName(item: AppBskyActorDefs.ProfileViewBasic | GeneratorView) { } return '' } + +function StepView() { + const [state] = useWizardState() + + if (state.currentStep === 'Details') { + return + } + if (state.currentStep === 'Profiles') { + return + } + if (state.currentStep === 'Feeds') { + return + } +}