![Screenshot 2024-05-23 at 1 02 03โฏPM](https://private-user-images.githubusercontent.com/13172299/333156687-d43f4d04-3510-47fa-8c1d-93cb01644d38.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjMzNTM5NjYsIm5iZiI6MTcyMzM1MzY2NiwicGF0aCI6Ii8xMzE3MjI5OS8zMzMxNTY2ODctZDQzZjRkMDQtMzUxMC00N2ZhLThjMWQtOTNjYjAxNjQ0ZDM4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODExVDA1MjEwNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTlmODkxMTk1M2RkNDczOGZkMGQwMzc5ZWEzOWJlMjBlMTA2MzE2NjdjOWQzZjk4YjI4YzNjODlkYmM2OTAyOTYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0._IeKR1yxVpnRJ69fcwhzt3k5hFfQiOlipYeSvcaubAo)
The React (Native) Image viewer. The API is simple, and it runs natively.
RPReplay_Final1716158876.2.MP4
- Shared element transitions
- Pinch to zoom
- Double tap to zoom
- Pan to close
- Multi-image support
- Modal support
- FlashList support
- Clean API
- Web support (coming soon!)
- Remote URLs & local images
Galeria is in beta...๐ง A true release is coming soon.
import { Galeria } from '@nandorojo/galeria'
import { Image } from 'react-native' // works with ANY image component!
const url = 'https://my-image.com/image.jpg'
export const SingleImage = ({ style }) => (
<Galeria urls={[url]}>
<Galeria.Image>
<Image source={{ uri: url }} style={style} />
</Galeria.Image>
</Galeria>
)
Simply pass an array to urls
.
import { Galeria } from '@nandorojo/galeria'
import { Image } from 'react-native' // works with ANY image component!
import localImage from './assets/local-image.png'
const urls = ['https://my-image.com/image.jpg', localImage]
export const MutliImage = ({ style }) => (
<Galeria urls={urls}>
{urls.map((url, index) => (
<Galeria.Image index={index} key={...}>
<Image source={typeof url === 'string' ? { uri: url } : url} style={style} />
</Galeria.Image>
)}
</Galeria>
)
import { Galeria } from '@nandorojo/galeria'
export const DarkMode = () => (
<Galeria urls={urls} theme='dark'>
...
</Galeria>
)
import { Galeria } from '@nandorojo/galeria'
import { Image, type ImageAssetSource } from 'react-native' // works with ANY image component!
import { FlashList } from "@shopify/flash-list"
import localImage from './assets/local-image.png'
const urls = ['https://my-image.com/image.jpg', localImage]
export const FlashListSupport = () => {
return (
<Galeria urls={urls}>
<FlashList
data={urls}
renderItem={({ item, index }) => {
// you should put this in a memoized component
return (
<Galeria.Image index={index}>
<Image
style={styles.image}
source={src(item)}
recyclingKey={item + index}
/>
</Galeria.Image>
)
}}
numColumns={3}
estimatedItemSize={size}
keyExtractor={(item, i) => item + i}
/>
</Galeria>
)
}
const src = (s) => (typeof s === 'string' ? { uri: s } : s) // ๐คทโโ๏ธ
- Under the hood, Galeria uses native libraries on iOS and Android.
- On Web, Galeria uses Framer Motion.
- Thanks to Michael Henry for the iOS Image Viewer
- Thanks to iielse for the Android Image Viewer
- Thanks to Alan for building the Android integration.
This software is free to use for apps or libraries of any size. However, I ask that you don't re-sell it or represent it as yours. If you fork it and make it public, please give credit back to the original GitHub repository.
Consider this the MIT license โ just be considerate.