1
0
mirror of https://github.com/tooot-app/app synced 2025-06-05 22:19:13 +02:00

Update image viewer index seraching

This commit is contained in:
Zhiyuan Zheng
2021-03-06 23:42:29 +01:00
parent 4cf7b79f83
commit 960634ec0b
5 changed files with 13 additions and 15 deletions

View File

@ -34,7 +34,6 @@ const HeaderComponent = React.memo(
height?: number | undefined
preview_url: string
remote_url?: string | undefined
imageIndex: number
}[]
}) => {
const insets = useSafeAreaInsets()
@ -134,7 +133,7 @@ export type ScreenImagesViewerProp = StackScreenProps<
const ScreenImagesViewer = ({
route: {
params: { imageUrls, imageIndex }
params: { imageUrls, id }
},
navigation
}: ScreenImagesViewerProp) => {
@ -142,16 +141,15 @@ const ScreenImagesViewer = ({
return null
}
const [currentIndex, setCurrentIndex] = useState(
findIndex(imageUrls, ['imageIndex', imageIndex])
)
const initialIndex = findIndex(imageUrls, ['id', id])
const [currentIndex, setCurrentIndex] = useState(initialIndex)
return (
<SafeAreaProvider>
<StatusBar backgroundColor='rgb(0,0,0)' />
<ImageView
images={imageUrls}
imageIndex={imageIndex}
imageIndex={initialIndex}
onImageIndexChange={index => setCurrentIndex(index)}
onRequestClose={() => navigation.goBack()}
HeaderComponent={() => (