optimize for the web
This commit is contained in:
@@ -11,6 +11,7 @@ import {useQueryClient} from '@tanstack/react-query'
|
|||||||
|
|
||||||
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
|
import {useRequireEmailVerification} from '#/lib/hooks/useRequireEmailVerification'
|
||||||
import {type NavigationProp} from '#/lib/routes/types'
|
import {type NavigationProp} from '#/lib/routes/types'
|
||||||
|
import {isWeb} from '#/platform/detection'
|
||||||
import {
|
import {
|
||||||
invalidateActorStarterPacksWithMembershipQuery,
|
invalidateActorStarterPacksWithMembershipQuery,
|
||||||
useActorStarterPacksWithMembershipsQuery,
|
useActorStarterPacksWithMembershipsQuery,
|
||||||
@@ -30,7 +31,7 @@ import * as bsky from '#/types/bsky'
|
|||||||
import {AvatarStack} from '../AvatarStack'
|
import {AvatarStack} from '../AvatarStack'
|
||||||
import {PlusLarge_Stroke2_Corner0_Rounded} from '../icons/Plus'
|
import {PlusLarge_Stroke2_Corner0_Rounded} from '../icons/Plus'
|
||||||
import {StarterPack} from '../icons/StarterPack'
|
import {StarterPack} from '../icons/StarterPack'
|
||||||
import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '../icons/Times'
|
import {TimesLarge_Stroke2_Corner0_Rounded} from '../icons/Times'
|
||||||
|
|
||||||
type StarterPackWithMembership =
|
type StarterPackWithMembership =
|
||||||
AppBskyGraphGetStarterPacksWithMembership.StarterPackWithMembership
|
AppBskyGraphGetStarterPacksWithMembership.StarterPackWithMembership
|
||||||
@@ -56,9 +57,11 @@ export function StarterPackDialog({
|
|||||||
fromDialog: true,
|
fromDialog: true,
|
||||||
targetDid: targetDid,
|
targetDid: targetDid,
|
||||||
onSuccess: () => {
|
onSuccess: () => {
|
||||||
|
setTimeout(() => {
|
||||||
if (!control.isOpen) {
|
if (!control.isOpen) {
|
||||||
control.open()
|
control.open()
|
||||||
}
|
}
|
||||||
|
}, 0)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}, [navigation, control, targetDid])
|
}, [navigation, control, targetDid])
|
||||||
@@ -88,8 +91,9 @@ function Empty({onStartWizard}: {onStartWizard: () => void}) {
|
|||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
|
isWeb
|
||||||
return (
|
return (
|
||||||
<View style={[a.gap_2xl, {paddingTop: 64}]}>
|
<View style={[a.gap_2xl, {paddingTop: isWeb ? 100 : 64}]}>
|
||||||
<View style={[a.gap_xs, a.align_center]}>
|
<View style={[a.gap_xs, a.align_center]}>
|
||||||
<StarterPack
|
<StarterPack
|
||||||
width={48}
|
width={48}
|
||||||
@@ -130,6 +134,8 @@ function StarterPackList({
|
|||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const t = useTheme()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
refetch,
|
refetch,
|
||||||
@@ -171,19 +177,27 @@ function StarterPackList({
|
|||||||
control.close()
|
control.close()
|
||||||
}, [control])
|
}, [control])
|
||||||
|
|
||||||
|
const XIcon = React.useMemo(() => {
|
||||||
|
return (
|
||||||
|
<TimesLarge_Stroke2_Corner0_Rounded
|
||||||
|
fill={t.atoms.text_contrast_medium.color}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}, [t])
|
||||||
|
|
||||||
const listHeader = (
|
const listHeader = (
|
||||||
<>
|
<>
|
||||||
<View
|
<View
|
||||||
style={[
|
style={[
|
||||||
{justifyContent: 'space-between', flexDirection: 'row'},
|
{justifyContent: 'space-between', flexDirection: 'row'},
|
||||||
a.my_lg,
|
isWeb ? a.mb_2xl : a.my_lg,
|
||||||
a.align_center,
|
a.align_center,
|
||||||
]}>
|
]}>
|
||||||
<Text style={[a.text_lg, a.font_bold]}>
|
<Text style={[a.text_lg, a.font_bold]}>
|
||||||
<Trans>Add to starter packs</Trans>
|
<Trans>Add to starter packs</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
<Button label={_(msg`Close`)} onPress={onClose}>
|
<Button label={_(msg`Close`)} onPress={onClose}>
|
||||||
<ButtonIcon icon={XIcon} />
|
<ButtonIcon icon={() => XIcon} />
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
{membershipItems.length > 0 && (
|
{membershipItems.length > 0 && (
|
||||||
@@ -213,7 +227,6 @@ function StarterPackList({
|
|||||||
)
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
|
||||||
<Dialog.InnerFlatList
|
<Dialog.InnerFlatList
|
||||||
data={isLoading ? [{}] : membershipItems}
|
data={isLoading ? [{}] : membershipItems}
|
||||||
renderItem={
|
renderItem={
|
||||||
@@ -236,9 +249,8 @@ function StarterPackList({
|
|||||||
onEndReachedThreshold={0.1}
|
onEndReachedThreshold={0.1}
|
||||||
ListHeaderComponent={listHeader}
|
ListHeaderComponent={listHeader}
|
||||||
ListEmptyComponent={<Empty onStartWizard={onStartWizard} />}
|
ListEmptyComponent={<Empty onStartWizard={onStartWizard} />}
|
||||||
contentContainerStyle={[a.px_2xl, a.pt_lg]}
|
style={isWeb ? [a.px_md, {minHeight: 500}] : [a.px_2xl, a.pt_lg]}
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -283,7 +283,6 @@ function WizardInner({
|
|||||||
currentListItems: currentListItems,
|
currentListItems: currentListItems,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
console.log('Creating new starter pack: ', state.profiles)
|
|
||||||
createStarterPack({
|
createStarterPack({
|
||||||
name: state.name?.trim() || getDefaultName(),
|
name: state.name?.trim() || getDefaultName(),
|
||||||
description: state.description?.trim(),
|
description: state.description?.trim(),
|
||||||
|
|||||||
Reference in New Issue
Block a user