Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/gallery-so/gallery into jak…
Browse files Browse the repository at this point in the history
…z/gallery-editor-token-draggable
  • Loading branch information
jakzaizzat committed Apr 27, 2024
2 parents 910db8c + 0b6d352 commit b782555
Show file tree
Hide file tree
Showing 46 changed files with 925 additions and 412 deletions.
2 changes: 1 addition & 1 deletion apps/mobile/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default ({ config }: ConfigContext): ExpoConfig => ({
orientation: 'portrait',
icon: './assets/icon.png',
userInterfaceStyle: 'automatic',
version: '1.0.60',
version: '1.0.61',
updates: {
fallbackToCacheTimeout: 0,
},
Expand Down
2 changes: 1 addition & 1 deletion apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"date-fns": "^2.29.3",
"dotenv": "^16.0.3",
"ethers": "6.11.1",
"expo": "^50.0.0",
"expo": "^50.0.17",
"expo-application": "~5.8.3",
"expo-asset": "~9.0.2",
"expo-av": "~13.10.5",
Expand Down
33 changes: 19 additions & 14 deletions apps/mobile/src/components/Feed/Posts/FeedSuggestedProfileRow.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useMemo } from 'react';
import { View } from 'react-native';
import { Dimensions, FlatList, View } from 'react-native';
import { graphql, useFragment } from 'react-relay';
import { removeNullValues } from 'shared/relay/removeNullValues';

Expand All @@ -8,8 +8,8 @@ import { FeedSuggestedProfileRowFragment$key } from '~/generated/FeedSuggestedPr

import { Typography } from '../../Typography';

const CARD_HEIGHT = 180;
const CARD_WIDTH = 180;
const CARD_HEIGHT = 183;
const CARD_ROW_HORIZONTAL_PADDING = 42;

type FeedSuggestedProfileRowProps = {
queryRef: FeedSuggestedProfileRowFragment$key;
Expand All @@ -21,7 +21,7 @@ export function FeedSuggestedProfileRow({ queryRef }: FeedSuggestedProfileRowPro
fragment FeedSuggestedProfileRowFragment on Query {
viewer @required(action: THROW) {
... on Viewer {
suggestedUsers(first: 4) @required(action: THROW) {
suggestedUsers(first: 24) @required(action: THROW) {
__typename
edges {
node {
Expand Down Expand Up @@ -60,11 +60,14 @@ export function FeedSuggestedProfileRow({ queryRef }: FeedSuggestedProfileRowPro
(gallery) => removeNullValues(gallery?.tokenPreviews).length > 0
);
});
return usersWithTokenPreviews?.slice(0, 2);
return usersWithTokenPreviews;
}
return users;
}, [query.viewer?.suggestedUsers]);

const { width: SCREEN_WIDTH } = Dimensions.get('window');
const cardWidth = (SCREEN_WIDTH - CARD_ROW_HORIZONTAL_PADDING) / 2;

return (
<View className="pl-4 mt-2 mb-12 space-y-3">
<Typography
Expand All @@ -73,15 +76,17 @@ export function FeedSuggestedProfileRow({ queryRef }: FeedSuggestedProfileRowPro
>
Suggested creators and collectors
</Typography>
<View className="space-x-1 flex flex-row">
{suggestedUsers?.map((user, idx) => {
return (
<View className="mb-1" style={{ width: CARD_WIDTH, height: CARD_HEIGHT }} key={idx}>
<TrendingUserCard userRef={user} queryRef={query} />
</View>
);
})}
</View>
<FlatList
data={suggestedUsers}
horizontal={true}
renderItem={({ item, index }) => (
<View style={{ width: cardWidth, height: CARD_HEIGHT, marginLeft: index === 0 ? 0 : 4 }}>
<TrendingUserCard userRef={item} queryRef={query} variant="detailed" />
</View>
)}
keyExtractor={(_, index) => index.toString()}
showsHorizontalScrollIndicator={false}
/>
</View>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { removeNullValues } from '~/shared/relay/removeNullValues';
export type FeedItemTypes = 'Post' | 'FeedEvent';
type itemType = FeedItemTypes | null;

const SUGGESTED_PROFILE_ROW_IDX = 5;
const SUGGESTED_PROFILE_ROW_IDX = 8;

export type FeedListItemType = { key: string } & (
| {
Expand Down
55 changes: 27 additions & 28 deletions apps/mobile/src/components/GalleryEditor/GalleryEditorHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,39 @@
import { View } from 'react-native';
import { graphql, useFragment } from 'react-relay';
import { TextInput, View } from 'react-native';

import { GalleryEditorHeaderFragment$key } from '~/generated/GalleryEditorHeaderFragment.graphql';
import { useGalleryEditorActions } from '~/contexts/GalleryEditor/GalleryEditorContext';

import { BaseM } from '../Text';
import { Typography } from '../Typography';

type Props = {
galleryRef: GalleryEditorHeaderFragment$key;
};

export function GalleryEditorHeader({ galleryRef }: Props) {
const gallery = useFragment(
graphql`
fragment GalleryEditorHeaderFragment on Gallery {
name
description
}
`,
galleryRef
);
export function GalleryEditorHeader() {
const { galleryName, setGalleryName, galleryDescription, setGalleryDescription } =
useGalleryEditorActions();

return (
<View className="p-4 flex flex-col gap-4">
<Typography
font={{
family: 'GTAlpina',
weight: 'Light',
}}
className="text-[32px] leading-[36px] text-black-900 dark:text-white"
<TextInput
className="text-[32px] leading-[36px] text-metal dark:text-white"
onChangeText={setGalleryName}
placeholder="My Gallery"
>
<Typography
font={{
family: 'GTAlpina',
weight: 'Light',
}}
className="text-[32px] leading-[36px]text-black-900 dark:text-white"
>
{galleryName}
</Typography>
</TextInput>
<TextInput
onChangeText={setGalleryDescription}
placeholder="Add an optional description...."
className="text-metal"
multiline
>
{gallery.name ?? 'My Gallery'}
</Typography>
<BaseM classNameOverride="text-metal">
{gallery.description || 'Add an optional description....'}
</BaseM>
<BaseM classNameOverride="text-metal leading-1">{galleryDescription}</BaseM>
</TextInput>
</View>
);
}
48 changes: 17 additions & 31 deletions apps/mobile/src/components/GalleryEditor/GalleryEditorRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { graphql, useFragment } from 'react-relay';

import { useGalleryEditorActions } from '~/contexts/GalleryEditor/GalleryEditorContext';
import { StagedSection } from '~/contexts/GalleryEditor/types';
import { GalleryEditorHeaderFragment$key } from '~/generated/GalleryEditorHeaderFragment.graphql';
import { GalleryEditorRendererFragment$key } from '~/generated/GalleryEditorRendererFragment.graphql';
import { GalleryEditorRendererQueryFragment$key } from '~/generated/GalleryEditorRendererQueryFragment.graphql';
import { GalleryEditorSectionFragment$key } from '~/generated/GalleryEditorSectionFragment.graphql';
import { RootStackNavigatorParamList, RootStackNavigatorProp } from '~/navigation/types';
Expand All @@ -20,24 +18,14 @@ import { GalleryEditorSection } from './GalleryEditorSection';

export type ListItemType =
| { kind: 'navigation'; title: string }
| { kind: 'header'; galleryRef: GalleryEditorHeaderFragment$key }
| { kind: 'header' }
| { kind: 'section'; section: StagedSection; queryRef: GalleryEditorSectionFragment$key };

type Props = {
galleryRef: GalleryEditorRendererFragment$key;
queryRef: GalleryEditorRendererQueryFragment$key;
};

export function GalleryEditorRenderer({ galleryRef, queryRef }: Props) {
const gallery = useFragment(
graphql`
fragment GalleryEditorRendererFragment on Gallery {
...GalleryEditorHeaderFragment
}
`,
galleryRef
);

export function GalleryEditorRenderer({ queryRef }: Props) {
const query = useFragment(
graphql`
fragment GalleryEditorRendererQueryFragment on Query {
Expand Down Expand Up @@ -67,13 +55,8 @@ export function GalleryEditorRenderer({ galleryRef, queryRef }: Props) {

const items = useMemo((): ListItemType[] => {
const items: ListItemType[] = [];
items.push({
kind: 'navigation',
title: 'Navigation',
});
items.push({
kind: 'header',
galleryRef: gallery,
});

sections.forEach((section) => {
Expand All @@ -85,31 +68,33 @@ export function GalleryEditorRenderer({ galleryRef, queryRef }: Props) {
});

return items;
}, [gallery, sections, query]);
}, [sections, query]);

const scrollContentOffsetY = useSharedValue(0);
const ref = useAnimatedRef<FlashList<ListItemType>>();

const renderItem = useCallback<ListRenderItem<ListItemType>>(
({ item }) => {
({ item, index }) => {
const isLastItem = index === items.length - 1;

if (item.kind === 'header') {
return <GalleryEditorHeader galleryRef={item.galleryRef} />;
} else if (item.kind === 'navigation') {
return <GalleryEditorNavbar />;
return <GalleryEditorHeader />;
} else if (item.kind === 'section') {
return (
<GalleryEditorSection
section={item.section}
queryRef={item.queryRef}
scrollContentOffsetY={scrollContentOffsetY}
scrollViewRef={ref}
/>
<View className={isLastItem ? 'pb-32' : ''}>
<GalleryEditorSection
section={item.section}
queryRef={item.queryRef}
scrollContentOffsetY={scrollContentOffsetY}
scrollViewRef={ref}
/>
</View>
);
} else {
return null;
}
},
[ref, scrollContentOffsetY]
[items.length, ref, scrollContentOffsetY]
);

const handleScroll = useCallback(
Expand All @@ -126,6 +111,7 @@ export function GalleryEditorRenderer({ galleryRef, queryRef }: Props) {
paddingTop: top,
}}
>
<GalleryEditorNavbar />
<FlashList
ref={ref}
data={items}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,12 @@ export function GalleryEditorSection({
'border-activeBlue': highlightedSection,
})}
>
<BaseM classNameOverride="text-base" weight="Bold">
{section.name}
</BaseM>
<ProcessedText text={section.collectorsNote || ''} />
<View className="space-y-1">
<BaseM classNameOverride="text-base" weight="Bold">
{section.name}
</BaseM>
<ProcessedText text={section.collectorsNote || ''} />
</View>
<SortableRowList
rows={section.rows}
sectionId={section.dbid}
Expand Down
9 changes: 6 additions & 3 deletions apps/mobile/src/components/GalleryEditor/SortableRowList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FlashList } from '@shopify/flash-list';
import { useEffect, useMemo } from 'react';
import { useWindowDimensions, View } from 'react-native';
import { useWindowDimensions, View, ViewProps } from 'react-native';
import { AnimatedRef, SharedValue, useSharedValue } from 'react-native-reanimated';
import { graphql, useFragment } from 'react-relay';

Expand All @@ -22,6 +22,8 @@ type Props = {

scrollContentOffsetY: SharedValue<number>;
scrollViewRef: AnimatedRef<FlashList<ListItemType>>;

style?: ViewProps['style'];
};

type Index = number;
Expand All @@ -38,6 +40,7 @@ export function SortableRowList({
onDragEnd,
scrollContentOffsetY,
scrollViewRef,
style,
}: Props) {
const query = useFragment(
graphql`
Expand Down Expand Up @@ -72,7 +75,7 @@ export function SortableRowList({
return rowOffsets.reduce((totalHeight, row) => totalHeight + row.height, 0);
}, [rowOffsets]);

const style = useMemo(() => {
const rStyle = useMemo(() => {
return {
top: 0,
left: 0,
Expand All @@ -82,7 +85,7 @@ export function SortableRowList({
}, [containerHeight]);

return (
<View className="relative" style={style}>
<View className="relative" style={[rStyle, style]}>
{rows.map((row, index) => {
return (
<SortableRow
Expand Down
Loading

0 comments on commit b782555

Please sign in to comment.