add delete btn
This commit is contained in:
@@ -113,7 +113,7 @@ export const ProfileStarterPacks = React.forwardRef<
|
|||||||
testID="listsEmpty"
|
testID="listsEmpty"
|
||||||
style={[{padding: 18, borderTopWidth: 1}, pal.border]}>
|
style={[{padding: 18, borderTopWidth: 1}, pal.border]}>
|
||||||
<Text style={pal.textLight}>
|
<Text style={pal.textLight}>
|
||||||
<Trans>You have no feeds.</Trans>
|
<Trans>You have no starter packs.</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -95,20 +95,7 @@ function reducer(state: State, action: Action): State {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (updatedState.currentStep) {
|
updatedState.canNext = !updatedState.processing
|
||||||
case 'Details':
|
|
||||||
updatedState = {
|
|
||||||
...updatedState,
|
|
||||||
canNext: Boolean(updatedState.description),
|
|
||||||
}
|
|
||||||
break
|
|
||||||
default: {
|
|
||||||
updatedState = {
|
|
||||||
...updatedState,
|
|
||||||
canNext: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return updatedState
|
return updatedState
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
import React from 'react'
|
import React from 'react'
|
||||||
import {Keyboard, TouchableOpacity, View} from 'react-native'
|
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 {useSafeAreaInsets} from 'react-native-safe-area-context'
|
||||||
import {
|
import {
|
||||||
AppBskyActorDefs,
|
AppBskyActorDefs,
|
||||||
@@ -44,6 +47,7 @@ import {Button, ButtonText} from '#/components/Button'
|
|||||||
import {useDialogControl} from '#/components/Dialog'
|
import {useDialogControl} from '#/components/Dialog'
|
||||||
import {ListMaybePlaceholder} from '#/components/Lists'
|
import {ListMaybePlaceholder} from '#/components/Lists'
|
||||||
import {Loader} from '#/components/Loader'
|
import {Loader} from '#/components/Loader'
|
||||||
|
import * as Prompt from '#/components/Prompt'
|
||||||
import {WizardEditListDialog} from '#/components/StarterPack/Wizard/WizardEditListDialog'
|
import {WizardEditListDialog} from '#/components/StarterPack/Wizard/WizardEditListDialog'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {Provider} from './State'
|
import {Provider} from './State'
|
||||||
@@ -52,12 +56,11 @@ export function Wizard({
|
|||||||
route,
|
route,
|
||||||
}: NativeStackScreenProps<CommonNavigatorParams, 'StarterPackWizard'>) {
|
}: NativeStackScreenProps<CommonNavigatorParams, 'StarterPackWizard'>) {
|
||||||
const params = route.params
|
const params = route.params
|
||||||
const {name, rkey} = params ?? {}
|
const {name, rkey} = params
|
||||||
const {currentAccount} = useSession()
|
const {currentAccount} = useSession()
|
||||||
|
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
|
||||||
// TODO load query here
|
|
||||||
const {
|
const {
|
||||||
data: did,
|
data: did,
|
||||||
isLoading: isLoadingDid,
|
isLoading: isLoadingDid,
|
||||||
@@ -147,6 +150,16 @@ function WizardInner({
|
|||||||
did: currentAccount?.did,
|
did: currentAccount?.did,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
})
|
})
|
||||||
|
const {setEnabled} = useKeyboardController()
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
React.useCallback(() => {
|
||||||
|
setEnabled(true)
|
||||||
|
return () => {
|
||||||
|
setEnabled(false)
|
||||||
|
}
|
||||||
|
}, [setEnabled]),
|
||||||
|
)
|
||||||
|
|
||||||
const setMinimalShellMode = useSetMinimalShellMode()
|
const setMinimalShellMode = useSetMinimalShellMode()
|
||||||
|
|
||||||
@@ -347,6 +360,8 @@ function WizardInner({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const deleteStarterPack = async () => {}
|
||||||
|
|
||||||
const onNext = () => {
|
const onNext = () => {
|
||||||
if (state.currentStep === 'Details' && !state.name) {
|
if (state.currentStep === 'Details' && !state.name) {
|
||||||
dispatch({
|
dispatch({
|
||||||
@@ -412,7 +427,9 @@ function WizardInner({
|
|||||||
<View style={[{width: 65}]} />
|
<View style={[{width: 65}]} />
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Container>
|
<Container
|
||||||
|
showDeleteBtn={Boolean(did && rkey)}
|
||||||
|
deleteStarterPack={deleteStarterPack}>
|
||||||
<StepView />
|
<StepView />
|
||||||
</Container>
|
</Container>
|
||||||
|
|
||||||
@@ -423,9 +440,18 @@ function WizardInner({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function Container({children}: {children: React.ReactNode}) {
|
function Container({
|
||||||
|
showDeleteBtn,
|
||||||
|
deleteStarterPack,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
showDeleteBtn: boolean
|
||||||
|
deleteStarterPack: () => Promise<void>
|
||||||
|
children: React.ReactNode
|
||||||
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const [state, dispatch] = useWizardState()
|
const [state, dispatch] = useWizardState()
|
||||||
|
const control = useDialogControl()
|
||||||
|
|
||||||
if (state.currentStep === 'Profiles' || state.currentStep === 'Feeds') {
|
if (state.currentStep === 'Profiles' || state.currentStep === 'Feeds') {
|
||||||
return <View style={[a.flex_1]}>{children}</View>
|
return <View style={[a.flex_1]}>{children}</View>
|
||||||
@@ -437,37 +463,55 @@ function Container({children}: {children: React.ReactNode}) {
|
|||||||
keyboardShouldPersistTaps="handled">
|
keyboardShouldPersistTaps="handled">
|
||||||
{children}
|
{children}
|
||||||
{state.currentStep === 'Details' && (
|
{state.currentStep === 'Details' && (
|
||||||
|
<>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Next`)}
|
label={_(msg`Next`)}
|
||||||
variant="solid"
|
variant="solid"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="medium"
|
size="medium"
|
||||||
style={[a.mx_xl, a.mb_lg, {marginTop: 60}]}
|
style={[a.mx_xl, a.mb_lg, {marginTop: 35}]}
|
||||||
onPress={() => dispatch({type: 'Next'})}
|
onPress={() => dispatch({type: 'Next'})}
|
||||||
disabled={!state.canNext}>
|
disabled={!state.canNext}>
|
||||||
<ButtonText>
|
<ButtonText>
|
||||||
<Trans>Next</Trans>
|
<Trans>Next</Trans>
|
||||||
</ButtonText>
|
</ButtonText>
|
||||||
</Button>
|
</Button>
|
||||||
|
{showDeleteBtn && (
|
||||||
|
<Button
|
||||||
|
label={_(msg`Next`)}
|
||||||
|
variant="outline"
|
||||||
|
color="negative"
|
||||||
|
size="medium"
|
||||||
|
style={[a.mx_xl, a.mb_lg]}
|
||||||
|
onPress={control.open}
|
||||||
|
disabled={!state.canNext}>
|
||||||
|
<ButtonText>
|
||||||
|
<Trans>Delete</Trans>
|
||||||
|
</ButtonText>
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
<Prompt.Outer control={control}>
|
||||||
|
<Prompt.TitleText>
|
||||||
|
<Trans>Delete starter pack?</Trans>
|
||||||
|
</Prompt.TitleText>
|
||||||
|
<Prompt.DescriptionText>
|
||||||
|
<Trans>Are you sure you want delete this starter pack?</Trans>
|
||||||
|
</Prompt.DescriptionText>
|
||||||
|
<Prompt.Actions>
|
||||||
|
<Prompt.Action
|
||||||
|
onPress={deleteStarterPack}
|
||||||
|
color="negative"
|
||||||
|
cta={_(msg`Delete`)}
|
||||||
|
/>
|
||||||
|
<Prompt.Cancel />
|
||||||
|
</Prompt.Actions>
|
||||||
|
</Prompt.Outer>
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
</KeyboardAwareScrollView>
|
</KeyboardAwareScrollView>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function StepView() {
|
|
||||||
const [state] = useWizardState()
|
|
||||||
|
|
||||||
if (state.currentStep === 'Details') {
|
|
||||||
return <StepDetails />
|
|
||||||
}
|
|
||||||
if (state.currentStep === 'Profiles') {
|
|
||||||
return <StepProfiles />
|
|
||||||
}
|
|
||||||
if (state.currentStep === 'Feeds') {
|
|
||||||
return <StepFeeds />
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function Footer({
|
function Footer({
|
||||||
onNext,
|
onNext,
|
||||||
nextBtnText,
|
nextBtnText,
|
||||||
@@ -522,7 +566,6 @@ function Footer({
|
|||||||
)}
|
)}
|
||||||
|
|
||||||
<View style={[a.flex_row, a.gap_xs]}>
|
<View style={[a.flex_row, a.gap_xs]}>
|
||||||
<View style={[a.flex_row]}>
|
|
||||||
{items.slice(0, 6).map((p, index) => (
|
{items.slice(0, 6).map((p, index) => (
|
||||||
<UserAvatar
|
<UserAvatar
|
||||||
key={index}
|
key={index}
|
||||||
@@ -532,7 +575,6 @@ function Footer({
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
|
||||||
|
|
||||||
{items.length === 0 ? (
|
{items.length === 0 ? (
|
||||||
<View style={[a.gap_sm]}>
|
<View style={[a.gap_sm]}>
|
||||||
@@ -596,7 +638,7 @@ function Footer({
|
|||||||
color="primary"
|
color="primary"
|
||||||
size="small"
|
size="small"
|
||||||
onPress={onNext}
|
onPress={onNext}
|
||||||
disabled={!state.canNext || state.processing}>
|
disabled={!state.canNext}>
|
||||||
<ButtonText>{nextBtnText}</ButtonText>
|
<ButtonText>{nextBtnText}</ButtonText>
|
||||||
{state.processing && <Loader size="xs" style={{color: 'white'}} />}
|
{state.processing && <Loader size="xs" style={{color: 'white'}} />}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -619,3 +661,17 @@ function getName(item: AppBskyActorDefs.ProfileViewBasic | GeneratorView) {
|
|||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function StepView() {
|
||||||
|
const [state] = useWizardState()
|
||||||
|
|
||||||
|
if (state.currentStep === 'Details') {
|
||||||
|
return <StepDetails />
|
||||||
|
}
|
||||||
|
if (state.currentStep === 'Profiles') {
|
||||||
|
return <StepProfiles />
|
||||||
|
}
|
||||||
|
if (state.currentStep === 'Feeds') {
|
||||||
|
return <StepFeeds />
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user