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

Make the token draggable #2441

Merged
merged 71 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
3f5594c
nft selector components
jakzaizzat Mar 19, 2024
4735d26
Post flow using new component
jakzaizzat Mar 19, 2024
fbc3376
set pfp use new component
jakzaizzat Mar 19, 2024
ae087b9
Community flow use new component
jakzaizzat Mar 19, 2024
0c6dd81
onboarding with new component
jakzaizzat Mar 19, 2024
d94276d
depreciate old component
jakzaizzat Mar 19, 2024
f17b171
Clean up messed up logic
jakzaizzat Mar 19, 2024
3cc2026
Remove unused component
jakzaizzat Mar 19, 2024
caefb0c
lint
jakzaizzat Mar 19, 2024
b4cf07d
Added sync state on single contract screen
jakzaizzat Mar 19, 2024
2cbbf9b
wip
jakzaizzat Mar 20, 2024
5c92470
Render gallery editor
jakzaizzat Mar 27, 2024
15ec0a0
Able to move between row
jakzaizzat Mar 27, 2024
234d373
move gallery editor screen to root stack
jakzaizzat Mar 27, 2024
c870151
Add gallery bottom sheet
jakzaizzat Mar 27, 2024
bd280a9
Fix row change order
jakzaizzat Apr 3, 2024
575229b
Able to sort section
jakzaizzat Apr 3, 2024
fe3f3a4
Add feature flag
jakzaizzat Apr 3, 2024
fd44771
Merge branch 'main' of https://github.com/gallery-so/gallery into jak…
jakzaizzat Apr 3, 2024
ee544e5
prettier
jakzaizzat Apr 4, 2024
bf50fbd
Refactor naming
jakzaizzat Apr 4, 2024
7397abb
prettier
jakzaizzat Apr 4, 2024
26d8322
Merge branch 'jakz/gallery-editor' of https://github.com/gallery-so/g…
jakzaizzat Apr 4, 2024
c1a03c8
Fix different between row <> section
jakzaizzat Apr 4, 2024
c625898
comment unused func
jakzaizzat Apr 4, 2024
3985f74
Rename collection to section
jakzaizzat Apr 4, 2024
8d6691c
Rename component
jakzaizzat Apr 4, 2024
f8fb95f
Able to clear activeRow
jakzaizzat Apr 4, 2024
dd57fc9
Merge branch 'main' of https://github.com/gallery-so/gallery into jak…
jakzaizzat Apr 4, 2024
66e1f9c
Set limit to increment/decrement column
jakzaizzat Apr 4, 2024
31ac556
simplify
jakzaizzat Apr 4, 2024
ad8836d
render whitespace
jakzaizzat Apr 4, 2024
82ed341
lint
jakzaizzat Apr 4, 2024
7ea323d
Add gallery editor actions
jakzaizzat Apr 5, 2024
31a6f70
Able to add nft
jakzaizzat Apr 5, 2024
2858523
fix missing error
jakzaizzat Apr 8, 2024
e66865f
Add GalleryDraggable
jakzaizzat Apr 8, 2024
e0d92fb
Remove previous dnd
jakzaizzat Apr 8, 2024
0c7ce5f
Able to move section and row
jakzaizzat Apr 9, 2024
162b85a
virtualize edtior
jakzaizzat Apr 15, 2024
bc00d8c
Able to move section up and down
jakzaizzat Apr 16, 2024
ce04073
Make row draggableeeee
jakzaizzat Apr 19, 2024
027dae4
fix container height
jakzaizzat Apr 19, 2024
03c2a67
Fix undraggable
jakzaizzat Apr 19, 2024
51c6652
update row height & position when column changed
jakzaizzat Apr 19, 2024
d53059a
Save new row position to mutation
jakzaizzat Apr 19, 2024
0d71c66
Remove unnecessary code
jakzaizzat Apr 19, 2024
ec51204
Add haptic feedback
jakzaizzat Apr 19, 2024
e891c54
Merge branch 'main' of https://github.com/gallery-so/gallery into jak…
jakzaizzat Apr 19, 2024
a0533e0
Strict feature flag
jakzaizzat Apr 19, 2024
ea7bf71
Remove unused library
jakzaizzat Apr 19, 2024
22d1022
Clean up
jakzaizzat Apr 19, 2024
edd9cea
Move web editor logic to shared
jakzaizzat Apr 19, 2024
d4a019d
restrict ff
jakzaizzat Apr 19, 2024
8bbae3a
prettier
jakzaizzat Apr 19, 2024
4cb85fb
remove unused code
jakzaizzat Apr 19, 2024
4804304
sync with scroll
jakzaizzat Apr 22, 2024
e23bb7d
Merge branch 'main' of https://github.com/gallery-so/gallery into jak…
jakzaizzat Apr 25, 2024
d2121e7
Make the token draggable
jakzaizzat Apr 25, 2024
5bf155d
Merge branch 'main' of https://github.com/gallery-so/gallery into jak…
jakzaizzat Apr 25, 2024
321ff0f
Remove conflict file
jakzaizzat Apr 25, 2024
7764b72
Able to add new token into row
jakzaizzat Apr 26, 2024
89e1ffe
update debugger data
jakzaizzat Apr 26, 2024
45636f0
remove drag icon in the section
jakzaizzat Apr 26, 2024
8da69d7
fix active border on row
jakzaizzat Apr 26, 2024
fe4d68c
Able to save new token order to db
jakzaizzat Apr 26, 2024
0b10690
fix border on row
jakzaizzat Apr 26, 2024
910db8c
remove comment
jakzaizzat Apr 26, 2024
b782555
Merge branch 'main' of https://github.com/gallery-so/gallery into jak…
jakzaizzat Apr 27, 2024
7e8fbda
Added comment
jakzaizzat Apr 27, 2024
65f3df3
memoize
jakzaizzat Apr 27, 2024
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
1 change: 1 addition & 0 deletions apps/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"react-native-tab-view": "^3.4.0",
"react-native-url-polyfill": "^1.3.0",
"react-native-webview": "13.6.4",
"rfdc": "^1.3.1",
"sentry-expo": "~7.2.0",
"siwe": "^2.1.4",
"swr": "^2.1.1",
Expand Down
39 changes: 28 additions & 11 deletions apps/mobile/src/components/GalleryEditor/GalleryEditorNavbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,34 @@ function DebuggerBottomSheet({ activeRowId, activeSectionId, sections }: Debugge
{section.name || 'Empty'} -
<BaseM classNameOverride="text-gray-500">{section.dbid}</BaseM>
</BaseM>
{section.rows.map((row, index) => {
return (
<View key={row.id}>
<BaseM
classNameOverride={clsx(row.id === activeRowId ? 'text-activeBlue' : null)}
>
{index + 1}. {row.id} - columns ({row.columns})
</BaseM>
</View>
);
})}
<View className="gap-2">
{section.rows.map((row, index) => {
return (
<View key={row.id}>
<BaseM
classNameOverride={clsx(
'mb-1',
row.id === activeRowId ? 'text-activeBlue' : null
)}
>
{index + 1}. {row.id} - columns ({row.columns})
</BaseM>
<View className="gap-1">
{row.items.map((item) => {
return (
<BaseM
key={item.id}
classNameOverride="text-xs font-mono text-gray-600"
>
{item.id}
</BaseM>
);
})}
</View>
</View>
);
})}
</View>
</View>
);
})}
Expand Down
84 changes: 45 additions & 39 deletions apps/mobile/src/components/GalleryEditor/GalleryEditorRow.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { FlashList } from '@shopify/flash-list';
import clsx from 'clsx';
import React, { useCallback } from 'react';
import { GestureResponderEvent, View, ViewProps } from 'react-native';
import Animated from 'react-native-reanimated';
import { GestureResponderEvent, View } from 'react-native';
import Animated, { AnimatedRef, SharedValue } from 'react-native-reanimated';
import { graphql, useFragment } from 'react-relay';

import { useGalleryEditorActions } from '~/contexts/GalleryEditor/GalleryEditorContext';
Expand All @@ -10,17 +11,26 @@ import { GalleryEditorRowFragment$key } from '~/generated/GalleryEditorRowFragme

import { GalleryTouchableOpacity } from '../GalleryTouchableOpacity';
import { GalleryEditorActiveActions } from './GalleryEditorActiveActions';
import { GalleryEditorTokenPreview } from './GalleryEditorTokenPreview';
import { ListItemType } from './GalleryEditorRenderer';
import { SortableTokenGrid } from './SortableTokenGrid/SortableTokenGrid';
import { useWidthPerToken } from './useWidthPerToken';

type Props = {
sectionId: string;
row: StagedRow;
style?: ViewProps['style'];
queryRef: GalleryEditorRowFragment$key;

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

export function GalleryEditorRow({ sectionId, row, style, queryRef }: Props) {
export function GalleryEditorRow({
sectionId,
row,
queryRef,
scrollContentOffsetY,
scrollViewRef,
}: Props) {
const query = useFragment(
graphql`
fragment GalleryEditorRowFragment on Query {
Expand All @@ -30,7 +40,7 @@ export function GalleryEditorRow({ sectionId, row, style, queryRef }: Props) {
queryRef
);

const { activateRow, activeRowId } = useGalleryEditorActions();
const { activateRow, activeRowId, moveItem } = useGalleryEditorActions();

const widthPerToken = useWidthPerToken(row.columns);

Expand All @@ -42,50 +52,46 @@ export function GalleryEditorRow({ sectionId, row, style, queryRef }: Props) {
[activateRow, sectionId, row.id]
);

const handleDragStart = useCallback(() => {
activateRow(sectionId, row.id);
}, [activateRow, sectionId, row.id]);

const handleDragEnd = useCallback(
(newPositionsById: string[]) => {
moveItem(row.id, newPositionsById);
},
[moveItem, row.id]
);

return (
<Animated.View className={clsx('border border-transparent gap-4')}>
<Animated.View className={clsx('border border-transparent')}>
<GalleryTouchableOpacity
eventElementId={null}
eventName={null}
eventContext={null}
onPress={handleSectionPress}
className={clsx('border border-transparent relative', {
'border-activeBlue': activeRowId === row.id,
})}
style={style}
withoutFeedback
>
<View>
<View className="flex-row flex-wrap gap-2">
{row.items.map((item) => {
if (item.kind === 'whitespace') {
return <WhiteSpace key={item.id} size={widthPerToken - 8} />;
} else {
return (
<View
key={item.id}
className="aspect-square"
style={{
width: widthPerToken - 8,
}}
>
<GalleryEditorTokenPreview tokenRef={item.tokenRef} />
</View>
);
}
})}
<View
className={clsx('border border-transparent relative', {
'border-activeBlue': activeRowId === row.id,
})}
>
<View className="relative">
{/* this component is responsible for rendering the grid of tokens. */}
<SortableTokenGrid
columns={row.columns}
items={row.items}
size={widthPerToken}
scrollContentOffsetY={scrollContentOffsetY}
scrollViewRef={scrollViewRef}
onDragStart={handleDragStart}
onDragEnd={handleDragEnd}
/>
Comment on lines +82 to +90
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This component responsible to render the item in grid view

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add this as a comment?

</View>
{activeRowId === row.id && <GalleryEditorActiveActions row={row} queryRef={query} />}
</View>
</GalleryTouchableOpacity>
</Animated.View>
);
}

type WhiteSpaceProps = {
size: number;
style?: ViewProps['style'];
};

function WhiteSpace({ size, style }: WhiteSpaceProps) {
return <View style={[{ width: size, height: size }, style]} />;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { useCallback, useMemo } from 'react';
import { View } from 'react-native';
import { AnimatedRef, SharedValue } from 'react-native-reanimated';
import { graphql, useFragment } from 'react-relay';
import { DragIcon } from 'src/icons/DragIcon';

import { useGalleryEditorActions } from '~/contexts/GalleryEditor/GalleryEditorContext';
import { StagedSection } from '~/contexts/GalleryEditor/types';
Expand Down Expand Up @@ -71,13 +70,6 @@ export function GalleryEditorSection({
'border-activeBlue': highlightedSection,
})}
>
{highlightedSection && (
<View className="absolute right-2 top-2 flex-row gap-1 z-10">
<View className="h-6 w-7 rounded-sm bg-activeBlue px-1 py-0.5">
<DragIcon />
</View>
</View>
)}
<View className="space-y-1">
<BaseM classNameOverride="text-base" weight="Bold">
{section.name}
Expand Down
8 changes: 1 addition & 7 deletions apps/mobile/src/components/GalleryEditor/SortableRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import Animated, {
useAnimatedStyle,
useDerivedValue,
useSharedValue,
withSpring,
withTiming,
} from 'react-native-reanimated';
import { useSafeAreaInsets } from 'react-native-safe-area-context';
Expand Down Expand Up @@ -247,12 +246,7 @@ export function SortableRow({
left: 0,
right: 0,
zIndex: zIndex,
transform: [
{ translateY: translateY.value ?? 0 },
{
scale: withSpring(isGestureActive.value ? 1.05 : 1),
},
],
Comment on lines -250 to -255
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the scale for the row here. Kind of weird when hovering the token to drag but the **row ** as triggered too

transform: [{ translateY: translateY.value ?? 0 }],
};
}, []);

Expand Down
8 changes: 7 additions & 1 deletion apps/mobile/src/components/GalleryEditor/SortableRowList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ export function SortableRowList({
scrollViewRef={scrollViewRef}
onDragEnd={onDragEnd}
>
<GalleryEditorRow sectionId={sectionId} row={row} queryRef={query} />
<GalleryEditorRow
sectionId={sectionId}
row={row}
queryRef={query}
scrollContentOffsetY={scrollContentOffsetY}
scrollViewRef={scrollViewRef}
/>
</SortableRow>
);
})}
Expand Down
Loading
Loading