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

Video support? #10

Open
usmansbk opened this issue Sep 12, 2024 · 9 comments
Open

Video support? #10

usmansbk opened this issue Sep 12, 2024 · 9 comments

Comments

@usmansbk
Copy link

Does this package support videos?

@chrizuuu
Copy link
Owner

Hi, no it doesn't support, I don't even see any use cases for video galleries.

@ameer-taghavi
Copy link

ameer-taghavi commented Sep 16, 2024

Hi, no it doesn't support, I don't even see any use cases for video galleries.

@chrizuuu
But this is useful for social networking apps. I have make a social networking app where a user can post multiple images and videos in one post.

I changed your code to support any components.

types.ts:
children: React.ReactNode;

GalleryPreview.tsx:

{React.Children.toArray(children).map((child, i) => {
  const visible = isImageVisible(i);
  return (
      <View key={i} style={{ ...dimensions }}>
          {visible && (
              <GalleryItem
                   item={child}
                   index={i}
                   isLast={i === React.Children.count(children) - 1}
                   ... />)}
         .../>

GalleryItem.tsx:

...
<GestureDetector gesture={doubleTap}>
  {item}
</GestureDetector>
...

Example:

<GalleryPreview ...>
  <Image .../>
  <Image .../>
  <Video .../>
</GalleryPreview>

if u agree i can send a pull request

@chrizuuu
Copy link
Owner

Ok, fine but for now I'm more inclined to simply make a separate component for such cas to not spoil the current interface. In the future maybe I'll somehow combine it into one component.

I'll try to figure it out over the weekend

@chrizuuu chrizuuu reopened this Sep 17, 2024
@chrizuuu
Copy link
Owner

chrizuuu commented Oct 4, 2024

Sorry for the slight delay but managed to add a new version with support for any components 1.3.0

To use the new component just add the type='children' parameter to the main gallery component. This will change the interface and required parameters: 'images' to 'children'. Example below.

The API for the main component has not changed.

<GalleryPreview
        isVisible={isVisible}
        onRequestClose={handleCloseImageViewer}
        type="children”
      >
        <ImageItem source={images[0]}. />
        <VideoItem />
        <VideoItem />
        <ImageItem source={images[1]} />
        <ImageItem source={images[2]}. />
        <VideoItem />
      </GalleryPreview>.

This is still a development version so I am open if there are any problems.

@ameer-taghavi
Copy link

Thanks @chrizuuu
I'll test it

@ameer-taghavi
Copy link

Simulator.Screen.Recording.-.iPhone.16.Pro.-.2024-10-29.at.14.15.10.mp4

video controls doesn't works

@chrizuuu
Copy link
Owner

chrizuuu commented Nov 7, 2024

@ameer-taghavi
This is because any clicks are captured by the component responsible for gestures. In this case, it is a single click that hides/shows the header component.

At this point, the only solution I have is to add a props that will block this func but then the header in the preview will be permanently visible or permanently hidden.

@ameer-orange
Copy link

@ameer-taghavi This is because any clicks are captured by the component responsible for gestures. In this case, it is a single click that hides/shows the header component.

At this point, the only solution I have is to add a props that will block this func but then the header in the preview will be permanently visible or permanently hidden.

can we have a prop to disable/enable gestures?
For example, disable gestures when the video is playing
@chrizuuu

@chrizuuu
Copy link
Owner

chrizuuu commented Jan 5, 2025

@ameer-taghavi

I tested the disabled prop, but it didn’t quite work as I initially expected. For now, I don’t have much time to dive deeper into this since I have other higher-priority tasks to focus on. However, I’d be happy to review and accept a PR if someone wants to implement this functionality.

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

No branches or pull requests

4 participants