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

Feat/image viewer #2665

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 4 additions & 0 deletions example/storybook-nativewind/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ module.exports = function (api) {
__dirname,
'../../packages/unstyled/input/src'
),
'@gluestack-ui/image-viewer': path.resolve(
__dirname,
'../../packages/unstyled/image-viewer/src'
),
'@gluestack-ui/tooltip': path.resolve(
__dirname,
'../../packages/unstyled/tooltip/src'
Expand Down
3 changes: 1 addition & 2 deletions example/storybook-nativewind/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
"@react-native-community/slider": "4.2.4",
"@react-stately/collections": "^3.6.0",
"@react-stately/tree": "^3.5.0",
"@unitools/link": "^0.0.4",
"@unitools/image": "^0.0.5",
"@unitools/link": "^0.0.4",
"expo": "^47.0.0",
"expo-linear-gradient": "^12.3.0",
"expo-status-bar": "~1.4.2",
Expand All @@ -66,7 +66,6 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-native": "0.72.4",
"react-native-gesture-handler": "~2.14.0",
"react-native-reanimated": "~3.6.2",
"react-native-safe-area-context": "^4.4.1",
"react-native-svg": "13.4.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import type { ComponentMeta } from '@storybook/react-native';
import ImageViewer from './ImageViewer';

const ImageViewerMeta: ComponentMeta<typeof ImageViewer> = {
title: 'stories/ImageViewer',
component: ImageViewer,
// metaInfo is required for figma generation
// @ts-ignore
metaInfo: {
componentDescription: `The ImageViewer component provides a modal view for displaying and interacting with images, supporting features like pinch-to-zoom, double-tap zoom, and swipe-to-dismiss.`,
},
argTypes: {},
args: {
images: [{ id: 1, url: 'https://picsum.photos/1000/1000' }],
},
};

export default ImageViewerMeta;

export { ImageViewer };
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
'use client';
import React, { useState } from 'react';
import { Image, Pressable } from 'react-native';
import {
ImageViewer,
ImageViewerBackdrop,
ImageViewerCloseButton,
ImageViewerContent,
ImageViewerImage,
} from '@/components/ui/image-viewer';
import { Icon } from '@/components/ui/icon';
import { CloseIcon } from '@/components/ui/icon';

const ImageViewerBasic = ({ ...props }: any) => {
const Images = [{ id: 1, url: 'https://picsum.photos/1000/1000' }];
const [visible, setVisible] = useState(false);
return (
<>
<Pressable onPress={() => setVisible(true)}>
<Image
source={{ uri: Images[0].url }}
className="w-[200px] h-[200px]"
resizeMode="contain"
/>
</Pressable>

<ImageViewer
isOpen={visible}
onClose={() => setVisible(false)}
{...props}
>
<ImageViewerBackdrop>
<ImageViewerContent
images={Images}
renderImages={(item: any) => (
<ImageViewerImage key={item.id} source={{ uri: item.url }} />
)}
>
<ImageViewerCloseButton>
<Icon as={CloseIcon} size="md" />
</ImageViewerCloseButton>
</ImageViewerContent>
</ImageViewerBackdrop>
</ImageViewer>
</>
);
};

ImageViewerBasic.description = 'This is a basic ImageViewer component example.';

export default ImageViewerBasic;

export { ImageViewer };
Loading
Loading