Files
bsky-social-app/src/view/com/lightbox/Lightbox.tsx
T
Paul Frazee 065d7ef629 Improve lightbox... and update to React Native 0.71.0 (#49)
* Switch to a better lightbox implementation (close #42)

* Upgrade to react-native 0.71.0

* Update (or remove low-value) tests
2023-01-17 20:40:02 -06:00

44 lines
1.1 KiB
TypeScript

import React from 'react'
import {View} from 'react-native'
import {observer} from 'mobx-react-lite'
import ImageView from 'react-native-image-viewing'
import {useStores} from '../../../state'
import * as models from '../../../state/models/shell-ui'
export const Lightbox = observer(function Lightbox() {
const store = useStores()
const onClose = () => {
console.log('hit')
store.shell.closeLightbox()
}
if (!store.shell.isLightboxActive) {
return <View />
}
if (store.shell.activeLightbox?.name === 'profile-image') {
const opts = store.shell.activeLightbox as models.ProfileImageLightbox
return (
<ImageView
images={[{uri: opts.profileView.avatar}]}
imageIndex={0}
visible
onRequestClose={onClose}
/>
)
} else if (store.shell.activeLightbox?.name === 'images') {
const opts = store.shell.activeLightbox as models.ImagesLightbox
return (
<ImageView
images={opts.uris.map(uri => ({uri}))}
imageIndex={opts.index}
visible
onRequestClose={onClose}
/>
)
} else {
return <View />
}
})