Skip to content

Commit

Permalink
Make the create gallery button stick at the bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzaizzat committed May 3, 2024
1 parent 69375f1 commit d38f78b
Showing 1 changed file with 16 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@ import { RootStackNavigatorProp } from '~/navigation/types';
import useCreateGallery from '~/shared/hooks/useCreateGallery';
import { removeNullValues } from '~/shared/relay/removeNullValues';

type ListItem =
| {
kind: 'gallery';
isFeatured: boolean;
gallery: GalleryPreviewCardFragment$key;
galleryId: string;
}
| {
kind: 'add-gallery';
};
type ListItem = {
kind: 'gallery';
isFeatured: boolean;
gallery: GalleryPreviewCardFragment$key;
galleryId: string;
};

type ProfileViewGalleriesTabProps = {
queryRef: ProfileViewGalleriesTabFragment$key;
Expand Down Expand Up @@ -92,27 +88,11 @@ export function ProfileViewGalleriesTab({ queryRef }: ProfileViewGalleriesTabPro
});
});

items.push({ kind: 'add-gallery' });

return items;
}, [user?.featuredGallery?.dbid, user?.galleries]);

const renderItem = useCallback<ListRenderItem<ListItem>>(
({ item }) => {
if (item.kind === 'add-gallery') {
return (
<View className="px-4 py-5">
<Button
onPress={handleCreateGallery}
eventElementId={null}
eventName={null}
eventContext={null}
text="Add New Gallery"
/>
</View>
);
}

return (
<View className="px-4 pb-8">
<GalleryPreviewCard
Expand All @@ -123,14 +103,23 @@ export function ProfileViewGalleriesTab({ queryRef }: ProfileViewGalleriesTabPro
</View>
);
},
[handleCreateGallery, query]
[query]
);

const contentContainerStyle = useListContentStyle();

return (
<View style={contentContainerStyle}>
<Tabs.FlashList data={items} estimatedItemSize={300} renderItem={renderItem} />
<View className="px-4 py-5">
<Button
onPress={handleCreateGallery}
eventElementId={null}
eventName={null}
eventContext={null}
text="Add New Gallery"
/>
</View>
</View>
);
}
Expand Down

0 comments on commit d38f78b

Please sign in to comment.