Skip to content

Feat/sortable list no scroll #1958

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

Merged
merged 31 commits into from
May 15, 2022
Merged

Feat/sortable list no scroll #1958

merged 31 commits into from
May 15, 2022

Conversation

M-i-k-e-l
Copy link
Collaborator

Description

SortableList - a new component (scroll-while-dragging is not supported in this phase).

Changelog

SortableList - a new component (scroll-while-dragging is not supported in this phase).

Comment on lines 39 to 43
const onLayout = useCallback((event: LayoutChangeEvent) => {
// Round height for Android
const newHeight = Math.round(event.nativeEvent.layout.height);
itemHeight.value = newHeight;
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd consider moving it to the main index file and pass the callback thru the context
It's easier to see the declaration of itemHeight and its initialization in the same file

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

TBH this does not bother me, but ok.
What bothered me more is the logic index === 0 ? onItemLayout : undefined inside the item, but I was not able to move that to the list, let me know if you have a solution for that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

In my case, what I did is pass onLayout to all items.
But save the layout only once and have any callback arriving afterwards do nothing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is much simpler when using ScrollView, here we have a FlatList.
If it is possible to do it, then it's either by:

  1. Changing the renderItem function which will look odd and might affect performance.
  2. Do it in the CellRendererComponent and that's not what you meant.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is it matter if it's FlatList or ScrollView.
The code I suggested is in the on item layout callback

Comment on lines +36 to +37
const tempTranslateY = useSharedValue(0);
const tempItemsOrder = useSharedValue(itemsOrder.value);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Consider moving these to useDragAfterLongPressGesture hook.
I'd move the logic to the hook, any reason onDragStart, onDragUpdate, onDragEnd shouldn't be part of the hook's code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we should look at this hook and the one in the SortableGridList and extract a single one.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, very possible.
But I prefer to do it once the components are stable and we know for sure the logic shared between them is the same.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

So let's keep it as is? Do you want to add a task a TODO or...?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not fix it? Is it a big change?
If we'll decide not to share code, the code we'll just stuck there..

@M-i-k-e-l M-i-k-e-l requested a review from ethanshar May 11, 2022 13:58
@M-i-k-e-l M-i-k-e-l requested a review from ethanshar May 15, 2022 07:07
@ethanshar ethanshar merged commit d0646e7 into master May 15, 2022
@M-i-k-e-l M-i-k-e-l deleted the feat/sortable-list-no-scroll branch May 15, 2022 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants