Skip to content

Commit

Permalink
Add function to component
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonathan Neuteboom committed Jun 23, 2024
1 parent 72de88d commit d06bbef
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/components/Lightbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,20 @@ type Props = {
index?: number
onClose: () => void
onDelete?: (imageIndex: number) => void
onCrop?: (imageIndex: number) => void
photos: string[]
title?: string
description?: string
content?: JSX.Element
style?: LightboxStyle
}

const Lightbox = ({ index, onClose, onDelete, photos, title, description, content, style }: Props) => {
const Lightbox = ({ index, onClose, onDelete, onCrop, photos, title, description, content, style }: Props) => {
const initialImageIndex = index ?? 0
const [currentImageIndex, setCurrentImageIndex] = useState<number>()

const onPressDelete = onDelete ? () => onDelete(currentImageIndex ?? initialImageIndex) : undefined
const onPressCrop = onCrop ? () => onCrop(currentImageIndex ?? initialImageIndex) : undefined

return (
<ImageView
Expand All @@ -109,7 +111,7 @@ const Lightbox = ({ index, onClose, onDelete, photos, title, description, conten
onImageIndexChange={setCurrentImageIndex}
onRequestClose={onClose}
HeaderComponent={getLightboxHeaderComponent(photos.length, onClose)}
FooterComponent={getLightboxFooterComponent(title, description, content, style, onPressDelete)}
FooterComponent={getLightboxFooterComponent(title, description, content, style, onPressDelete, onPressCrop)}
/>
)
}
Expand Down

0 comments on commit d06bbef

Please sign in to comment.