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

Release/image [email protected] #2678

Merged
merged 5 commits into from
Jan 8, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ import {
CloseIcon,
Icon,
Center,
Pressable,
Image
} from '../../core-components/nativewind';
import {
Pressable,
Expand Down Expand Up @@ -277,7 +275,7 @@ The `ImageViewerContent` component is responsible for rendering the images withi
</Table.TText>
</Table.TD>
<Table.TD>
<Table.TText>Array&lt;{`{id: number, url: string}`}&gt;</Table.TText>
<Table.TText>Array&lt;{`any`}&gt;</Table.TText>
</Table.TD>
<Table.TD>
<Table.TText>-</Table.TText>
Expand Down Expand Up @@ -325,6 +323,74 @@ The `ImageViewerBackdrop` component serves as the background layer of the `Image

The `ImageViewerImage` component is used to display individual images within the `ImageViewerContent`. It supports all the properties of React Native's [Image](https://reactnative.dev/docs/image) component, making it easy to customize the appearance and behavior of the images.

### Example

The Example section offers visual previews of the component, letting you quickly identify the best fit for your needs. Just copy the code and use it in your project.

```jsx
import { ImageViewer, ImageViewerBackdrop, ImageViewerContent, ImageViewerCloseButton, ImageViewerImage } from '@/components/ui/image-viewer';
import { CloseIcon, Icon } from '@/components/ui/icon';
import React, { useState } from 'react';
import { Pressable, Image } from 'react-native';
import { Center } from '@/components/ui/center';
```

<Wrapper>
<CodePreview
_rendererWrapper={{
py: '$8',
px: '$8',
}}
showComponentRenderer={true}
showArgsController={true}
metaData={{
code: `
function App() {
const [visible, setVisible] = React.useState(false);
const Images = [{ id: 1, url: 'https://picsum.photos/1000/1000' }];
return (
<Center>
<Pressable onPress={() => setVisible(true)}>
<Image
source={{ uri: Images[0].url }}
className="w-[200px] h-[200px]"
resizeMode="contain"
/>
</Pressable>
<ImageViewer isOpen={visible} onClose={() => setVisible(false)}>
<ImageViewerBackdrop>
<ImageViewerContent images={Images} renderImages={(item) => (<ImageViewerImage key={item.id} source={{ uri: item.url }} />)} >
<ImageViewerCloseButton>
<Icon as={CloseIcon}/>
</ImageViewerCloseButton>
</ImageViewerContent>
</ImageViewerBackdrop>
</ImageViewer>
</Center>
);
}
`,
transformCode: (code) => {
return transformedCode(code, 'function', 'App');
},
scope: {
Wrapper,
ImageViewer,
ImageViewerBackdrop,
ImageViewerContent,
ImageViewerCloseButton,
ImageViewerImage,
CloseIcon,
Icon,
useState,
Pressable,
Image,
Center,
},
argsType: {},
}}
/>
</Wrapper>

> Note: Currently, the ImageViewer component is limited to only single image, multiple image support will be added in the future.

Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
"@gluestack-ui/image": "latest"
}
},
"image-viewer": {
"dependencies": {
"@gluestack-ui/image-viewer": "latest",
"react-native-gesture-handler": "^2.21.2"
}
},
"image-background": {
"dependencies": {}
},
Expand Down
6 changes: 6 additions & 0 deletions packages/unstyled/image-viewer/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @gluestack-ui/image-viewer

## 0.0.4

### Patch Changes

- fix: updated dependencies.json

## 0.0.3

### Patch Changes
Expand Down
8 changes: 4 additions & 4 deletions packages/unstyled/image-viewer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ export default () => (

### ImageViewerContent

| Prop | Type | Default | Description |
| ------------ | -------------------------------- | ------- | ---------------------------------- |
| images | Array<{id: number, url: string}> | - | Array of image objects to display |
| renderImages | (item: any) => ReactNode | - | Function to render each image item |
| Prop | Type | Default | Description |
| ------------ | ------------------------ | ------- | ---------------------------------- |
| images | Array<any> | - | Array of image objects to display |
| renderImages | (item: any) => ReactNode | - | Function to render each image item |

More guides on how to get started are available [here](https://ui.gluestack.io/docs/components/media-and-icons/image-viewer).

Expand Down
2 changes: 1 addition & 1 deletion packages/unstyled/image-viewer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gluestack-ui/image-viewer",
"version": "0.0.3",
"version": "0.0.4",
"main": "lib/index",
"module": "lib/index",
"types": "lib/index.d.ts",
Expand Down
Loading