import React from 'react'; import {useDialogContext} from './dialog-context'; import {Dialog} from './dialog'; import {DialogBody} from './dialog-body'; import {IconButton} from '@common/ui/buttons/icon-button'; import {CloseIcon} from '@common/icons/material/Close'; import {KeyboardArrowLeftIcon} from '@common/icons/material/KeyboardArrowLeft'; import {KeyboardArrowRightIcon} from '@common/icons/material/KeyboardArrowRight'; import {useControlledState} from '@react-stately/utils'; interface Props { image?: string; images?: string[]; activeIndex?: number; onActiveIndexChange?: (index: number) => void; defaultActiveIndex?: number; } export function ImageZoomDialog(props: Props) { const {close} = useDialogContext(); const {image, images} = props; const [activeIndex, setActiveIndex] = useControlledState( props.activeIndex, props.defaultActiveIndex, props.onActiveIndexChange ); const src = image || images?.[activeIndex]; return ( { close(); }} >
{images?.length ? ( { setActiveIndex(activeIndex - 1); }} > ) : null} {images?.length ? ( { setActiveIndex(activeIndex + 1); }} > ) : null}
); }