Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GAL-3939 WIP start updating collection page scroll behavior #1971

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions apps/mobile/src/components/Community/CommunityCollectors.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { View } from 'react-native';
import { graphql, useFragment } from 'react-relay';

import { CommunityCollectorsFragment$key } from '~/generated/CommunityCollectorsFragment.graphql';
Expand Down Expand Up @@ -30,9 +29,5 @@ export function CommunityCollectors({ communityRef, queryRef }: Props) {
queryRef
);

return (
<View className="flex-1 pt-16">
<CommunityCollectorsList queryRef={query} communityRef={community} />
</View>
);
return <CommunityCollectorsList queryRef={query} communityRef={community} />;
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useNavigation } from '@react-navigation/native';
import { FlashList, ListRenderItem } from '@shopify/flash-list';
import { ListRenderItem } from '@shopify/flash-list';
import { useCallback, useMemo } from 'react';
import { Tabs } from 'react-native-collapsible-tab-view';
import { graphql, useFragment, usePaginationFragment } from 'react-relay';

import { UserFollowCard } from '~/components/UserFollowList/UserFollowCard';
Expand Down Expand Up @@ -87,7 +88,7 @@ export function CommunityCollectorsList({ communityRef, queryRef }: Props) {
);

return (
<FlashList
<Tabs.FlashList
data={holders}
estimatedItemSize={40}
renderItem={renderItem}
Expand Down
9 changes: 8 additions & 1 deletion apps/mobile/src/components/Community/CommunityHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useCallback, useRef } from 'react';
import { useCallback, useEffect, useRef } from 'react';
import { View } from 'react-native';
import { useCurrentTabScrollY } from 'react-native-collapsible-tab-view';
import { graphql, useFragment } from 'react-relay';

import { CommunityHeaderFragment$key } from '~/generated/CommunityHeaderFragment.graphql';
Expand Down Expand Up @@ -27,6 +28,12 @@ export function CommunityHeader({ communityRef }: Props) {
communityRef
);

const scrollY = useCurrentTabScrollY();

useEffect(() => {
console.log({ scrollY });
}, [scrollY]);

const hasCommunityDescription = Boolean(community.description);
const bottomSheetRef = useRef<GalleryBottomSheetModalType | null>(null);
const handlePress = useCallback(() => {
Expand Down
66 changes: 44 additions & 22 deletions apps/mobile/src/components/Community/CommunityView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,36 +76,58 @@ export function CommunityView({ queryRef }: Props) {

const TabBar = useCallback(() => {
return (
<CommunityTabsHeader
communityRef={community}
selectedRoute={selectedRoute}
onRouteChange={setSelectedRoute}
/>
<View>
<View className="px-4">
<CommunityMeta communityRef={community} queryRef={query} />
</View>
<CommunityTabsHeader
communityRef={community}
selectedRoute={selectedRoute}
onRouteChange={setSelectedRoute}
/>
</View>
);
}, [community, setSelectedRoute, selectedRoute]);
}, [community, query, selectedRoute]);

return (
<View className="flex-1">
<View className="flex flex-col px-4 py-4 z-10">
<View className="flex flex-row justify-between">
<BackButton />
const Header = useCallback(() => {
return (
<View>
<View className="flex flex-col px-4 py-4 z-10 bg-white dark:bg-black-900">
<View className="flex flex-row justify-between">
<BackButton />

<IconContainer
eventElementId="Community Share Icon"
eventName="Community Share Icon Clicked"
icon={<ShareIcon />}
onPress={handleShare}
/>
<IconContainer
eventElementId="Community Share Icon"
eventName="Community Share Icon Clicked"
icon={<ShareIcon />}
onPress={handleShare}
/>
</View>
</View>
</View>

<View className="px-4">
<CommunityHeader communityRef={community} />
<CommunityMeta communityRef={community} queryRef={query} />
<View>
<View className="px-4">
<CommunityMeta communityRef={community} queryRef={query} />
</View>
<CommunityTabsHeader
communityRef={community}
selectedRoute={selectedRoute}
onRouteChange={setSelectedRoute}
/>
</View>
</View>
);
}, [community, query, selectedRoute]);

return (
<View className="flex-1">
<View className="flex-grow">
<GalleryTabsContainer TabBar={TabBar} ref={containerRef} initialTabName={selectedRoute}>
<GalleryTabsContainer
// TabBar={TabBar}
Header={Header}
ref={containerRef}
initialTabName={selectedRoute}
>
<Tabs.Tab name="Posts">
<CommunityViewPostsTab communityRef={community} queryRef={query} />
</Tabs.Tab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ export function CommunityViewPostsTab({ communityRef, queryRef }: Props) {
}
}, [hasPrevious, loadPrevious]);

const handleScroll = useCallback(
(e) => console.log('scrolling', e.nativeEvent.contentOffset.y),
[]
);

if (totalPosts === 0) {
return (
<View className="flex-1 pt-16 justify-center">
Expand Down Expand Up @@ -189,6 +194,8 @@ export function CommunityViewPostsTab({ communityRef, queryRef }: Props) {
data={items}
renderItem={renderItem}
onEndReached={loadMore}
showsVerticalScrollIndicator={false}
onScroll={handleScroll}
/>
</View>
);
Expand Down
Loading