use Dialog.InnerFlatlist
This commit is contained in:
@@ -19,7 +19,6 @@ import {
|
|||||||
useListMembershipAddMutation,
|
useListMembershipAddMutation,
|
||||||
useListMembershipRemoveMutation,
|
useListMembershipRemoveMutation,
|
||||||
} from '#/state/queries/list-memberships'
|
} from '#/state/queries/list-memberships'
|
||||||
import {List} from '#/view/com/util/List'
|
|
||||||
import * as Toast from '#/view/com/util/Toast'
|
import * as Toast from '#/view/com/util/Toast'
|
||||||
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
import {UserAvatar} from '#/view/com/util/UserAvatar'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
@@ -72,38 +71,15 @@ export function StarterPackDialog({
|
|||||||
],
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
const onClose = React.useCallback(() => {
|
|
||||||
control.close()
|
|
||||||
}, [control])
|
|
||||||
|
|
||||||
const t = useTheme()
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog.Outer control={control}>
|
<Dialog.Outer control={control}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<Dialog.Inner label={_(msg`Add to starter packs`)} style={[a.w_full]}>
|
|
||||||
<View>
|
|
||||||
<View
|
|
||||||
style={[
|
|
||||||
{justifyContent: 'space-between', flexDirection: 'row'},
|
|
||||||
a.my_lg,
|
|
||||||
]}>
|
|
||||||
<Text style={[a.text_lg, a.font_bold]}>
|
|
||||||
<Trans>Add to starter packs</Trans>
|
|
||||||
</Text>
|
|
||||||
<TimesLarge_Stroke2_Corner0_Rounded
|
|
||||||
onPress={onClose}
|
|
||||||
fill={t.atoms.text_contrast_medium.color}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
|
|
||||||
<StarterPackList
|
<StarterPackList
|
||||||
|
control={control}
|
||||||
onStartWizard={wrappedNavToWizard}
|
onStartWizard={wrappedNavToWizard}
|
||||||
targetDid={targetDid}
|
targetDid={targetDid}
|
||||||
enabled={enabled}
|
enabled={enabled}
|
||||||
/>
|
/>
|
||||||
</View>
|
|
||||||
</Dialog.Inner>
|
|
||||||
</Dialog.Outer>
|
</Dialog.Outer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -113,8 +89,7 @@ function Empty({onStartWizard}: {onStartWizard: () => void}) {
|
|||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View
|
<View style={[a.gap_2xl, {paddingTop: 64}]}>
|
||||||
style={[a.align_center, a.gap_2xl, {paddingTop: 64, paddingBottom: 64}]}>
|
|
||||||
<View style={[a.gap_xs, a.align_center]}>
|
<View style={[a.gap_xs, a.align_center]}>
|
||||||
<StarterPack
|
<StarterPack
|
||||||
width={48}
|
width={48}
|
||||||
@@ -125,6 +100,7 @@ function Empty({onStartWizard}: {onStartWizard: () => void}) {
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
<View style={[a.align_center]}>
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Create starter pack`)}
|
label={_(msg`Create starter pack`)}
|
||||||
color="secondary_inverted"
|
color="secondary_inverted"
|
||||||
@@ -136,19 +112,23 @@ function Empty({onStartWizard}: {onStartWizard: () => void}) {
|
|||||||
<ButtonIcon icon={PlusLarge_Stroke2_Corner0_Rounded} />
|
<ButtonIcon icon={PlusLarge_Stroke2_Corner0_Rounded} />
|
||||||
</Button>
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function StarterPackList({
|
function StarterPackList({
|
||||||
|
control,
|
||||||
onStartWizard,
|
onStartWizard,
|
||||||
targetDid,
|
targetDid,
|
||||||
enabled,
|
enabled,
|
||||||
}: {
|
}: {
|
||||||
|
control: Dialog.DialogControlProps
|
||||||
onStartWizard: () => void
|
onStartWizard: () => void
|
||||||
targetDid: string
|
targetDid: string
|
||||||
enabled?: boolean
|
enabled?: boolean
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
|
const t = useTheme()
|
||||||
|
|
||||||
const {
|
const {
|
||||||
data,
|
data,
|
||||||
@@ -187,10 +167,30 @@ function StarterPackList({
|
|||||||
[targetDid],
|
[targetDid],
|
||||||
)
|
)
|
||||||
|
|
||||||
const ListHeaderComponent = React.useCallback(
|
const onClose = React.useCallback(() => {
|
||||||
() => (
|
control.close()
|
||||||
|
}, [control])
|
||||||
|
|
||||||
|
const listHeader = (
|
||||||
<>
|
<>
|
||||||
<View style={[a.flex_row, a.justify_between, a.align_center, a.py_md]}>
|
<View
|
||||||
|
style={[
|
||||||
|
{justifyContent: 'space-between', flexDirection: 'row'},
|
||||||
|
a.my_lg,
|
||||||
|
a.align_center,
|
||||||
|
]}>
|
||||||
|
<Text style={[a.text_lg, a.font_bold]}>
|
||||||
|
<Trans>Add to starter packs</Trans>
|
||||||
|
</Text>
|
||||||
|
<TimesLarge_Stroke2_Corner0_Rounded
|
||||||
|
onPress={onClose}
|
||||||
|
fill={t.atoms.text_contrast_medium.color}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
{membershipItems.length > 0 && (
|
||||||
|
<>
|
||||||
|
<View
|
||||||
|
style={[a.flex_row, a.justify_between, a.align_center, a.py_md]}>
|
||||||
<Text style={[a.text_md, a.font_bold]}>
|
<Text style={[a.text_md, a.font_bold]}>
|
||||||
<Trans>New starter pack</Trans>
|
<Trans>New starter pack</Trans>
|
||||||
</Text>
|
</Text>
|
||||||
@@ -207,20 +207,27 @@ function StarterPackList({
|
|||||||
</View>
|
</View>
|
||||||
<Divider />
|
<Divider />
|
||||||
</>
|
</>
|
||||||
),
|
)}
|
||||||
[_, onStartWizard],
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return (
|
return (
|
||||||
<View style={[a.align_center, a.p_xl]}>
|
<>
|
||||||
|
<Dialog.Close />
|
||||||
|
<Dialog.ScrollableInner
|
||||||
|
contentContainerStyle={[a.align_center, a.p_xl]}
|
||||||
|
label={_(msg`Add to starter packs`)}>
|
||||||
<Loader size="xl" />
|
<Loader size="xl" />
|
||||||
</View>
|
</Dialog.ScrollableInner>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List
|
<>
|
||||||
|
<Dialog.Close />
|
||||||
|
<Dialog.InnerFlatList
|
||||||
data={membershipItems}
|
data={membershipItems}
|
||||||
renderItem={renderItem}
|
renderItem={renderItem}
|
||||||
keyExtractor={(item: StarterPackWithMembership, index: number) =>
|
keyExtractor={(item: StarterPackWithMembership, index: number) =>
|
||||||
@@ -230,11 +237,11 @@ function StarterPackList({
|
|||||||
onRefresh={_onRefresh}
|
onRefresh={_onRefresh}
|
||||||
onEndReached={_onEndReached}
|
onEndReached={_onEndReached}
|
||||||
onEndReachedThreshold={0.1}
|
onEndReachedThreshold={0.1}
|
||||||
ListHeaderComponent={
|
ListHeaderComponent={listHeader}
|
||||||
membershipItems.length > 0 ? ListHeaderComponent : null
|
|
||||||
}
|
|
||||||
ListEmptyComponent={<Empty onStartWizard={onStartWizard} />}
|
ListEmptyComponent={<Empty onStartWizard={onStartWizard} />}
|
||||||
|
contentContainerStyle={[a.px_2xl, a.pt_lg]}
|
||||||
/>
|
/>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user