π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
feat: show and onClose
httpjamesm06fcd556cae9
diff --git a/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx b/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsxindex dafe1a39f7..6d03c14132 100644--- a/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx+++ b/apps/photos/src/components/PhotoViewer/ImageEditorOverlay/index.tsx@@ -14,11 +14,14 @@ import Crop32Icon from '@mui/icons-material/Crop32';import MenuSectionTitle from 'components/Menu/MenuSectionTitle';import DownloadIcon from '@mui/icons-material/Download';import mime from 'mime-types';-+import CloseIcon from '@mui/icons-material/Close';import RotateLeftIcon from '@mui/icons-material/RotateLeft';import RotateRightIcon from '@mui/icons-material/RotateRight';+import { HorizontalFlex } from 'components/Container';interface IProps {file: EnteFile;+ show: boolean;+ onClose: () => void;}const PRESET_ASPECT_RATIOS = [@@ -40,7 +43,7 @@ const PRESET_ASPECT_RATIOS = [];const ImageEditorOverlay = (props: IProps) => {- const [originalWidth, originalHeight] = [props.file.w, props.file.h];+ const [originalWidth, originalHeight] = [props.file?.w, props.file?.h];const [scaledWidth, setScaledWidth] = useState(0);const [scaledHeight, setScaledHeight] = useState(0);@@ -109,8 +112,9 @@ const ImageEditorOverlay = (props: IProps) => {};useEffect(() => {+ if (!props.show) return;loadCanvas();- }, []);+ }, [props.show, props.file]);const theme = useTheme();@@ -327,151 +331,171 @@ const ImageEditorOverlay = (props: IProps) => {return (<>- <Backdrop- sx={{- color: '#fff',- zIndex: '999 !important',- display: 'flex',- width: '100%',- justifyContent: 'space-between',- }}- open>- <Box- display="inline-block"- width="100%"- height="100%"- overflow="hidden"- padding="3rem"- boxSizing={'border-box'}>- <Box display="flex" gap="0.5rem" alignItems="center">- <IconButton>- <PhotoSizeSelectLargeIcon />- </IconButton>- </Box>- <Box- height="100%"- width="100%"- ref={parentRef}- display="flex"- alignItems="center"- justifyContent="center"- onMouseDown={handleMouseDown}- onMouseMove={handleMouseMove}- onMouseUp={handleMouseUp}>- <canvas- ref={canvasRef}- // height={originalHeight}- // width={originalWidth}- style={{- maxWidth: '100%',- maxHeight: '1000px',- // transform: `translate(${cropOffsetX}px, ${cropOffsetY}px)`,- }}- />- </Box>- </Box>- <Box- height="100%"- width="30rem"- bgcolor={theme.colors.background.elevated}- padding="1rem"- boxSizing="border-box">- <MenuSectionTitle title={'Aspect Ratio'} />- <MenuItemGroup- style={{- marginBottom: '0.5rem',- }}>- <EnteMenuItem- disabled={cropLoading}- startIcon={<CropOriginalIcon />}- onClick={() => {- loadCanvas();- }}- label={'Original'}- />- <EnteMenuItem- disabled={cropLoading}- startIcon={<CropSquareIcon />}- onClick={() => {- cropCanvas(1, 1);- }}- label={'Square (1:1)'}- />- </MenuItemGroup>- <MenuItemGroup- style={{- marginBottom: '1rem',- }}>- {PRESET_ASPECT_RATIOS.map((ratio, index) => (- <EnteMenuItem- disabled={cropLoading}- key={index}- startIcon={ratio.icon}- onClick={() => {- cropCanvas(ratio.width, ratio.height);- }}- label={`${ratio.width}:${ratio.height}`}- />- ))}- </MenuItemGroup>- <MenuItemGroup- style={{- marginBottom: '1rem',- }}>- {PRESET_ASPECT_RATIOS.map((ratio, index) => (- <EnteMenuItem- disabled={cropLoading}- key={index}- startIcon={ratio.icon}- onClick={() => {- cropCanvas(ratio.height, ratio.width);- }}- label={`${ratio.height}:${ratio.width}`}- />- ))}- </MenuItemGroup>- <MenuSectionTitle title={'Rotation'} />- <MenuItemGroup- style={{- marginBottom: '1rem',- }}>- <EnteMenuItem- disabled={cropLoading}- startIcon={<RotateLeftIcon />}- onClick={() => {- rotateCanvas(-90);- }}- label="Rotate Left 90Λ"- />- <EnteMenuItem- disabled={cropLoading}- startIcon={<RotateRightIcon />}- onClick={() => {- rotateCanvas(90);- }}- label="Rotate Right 90Λ"- />- </MenuItemGroup>-- <MenuSectionTitle title={'Export'} />- <MenuItemGroup>- <EnteMenuItem- startIcon={<DownloadIcon />}- onClick={() => {- exportCanvasToBlob((blob) => {- // create a link- const a = document.createElement('a');- a.href = URL.createObjectURL(blob);- a.download = props.file.metadata.title;- document.body.appendChild(a);- a.click();- });- }}- label={'Download Edited'}- />- </MenuItemGroup>- </Box>- </Backdrop>+ {props.show && (+ <>+ <Backdrop+ sx={{+ color: '#fff',+ zIndex: '999 !important',+ display: 'flex',+ width: '100%',+ justifyContent: 'space-between',+ }}+ open>+ <Box+ display="inline-block"+ width="100%"+ height="100%"+ overflow="hidden"+ padding="3rem"+ boxSizing={'border-box'}>+ <Box+ display="flex"+ gap="0.5rem"+ alignItems="center">+ <IconButton>+ <PhotoSizeSelectLargeIcon />+ </IconButton>+ </Box>+ <Box+ height="100%"+ width="100%"+ ref={parentRef}+ display="flex"+ alignItems="center"+ justifyContent="center"+ onMouseDown={handleMouseDown}+ onMouseMove={handleMouseMove}+ onMouseUp={handleMouseUp}>+ <canvas+ ref={canvasRef}+ // height={originalHeight}+ // width={originalWidth}+ style={{+ maxWidth: '100%',+ maxHeight: '1000px',+ // transform: `translate(${cropOffsetX}px, ${cropOffsetY}px)`,+ }}+ />+ </Box>+ </Box>+ <Box+ height="100%"+ width="30rem"+ bgcolor={theme.colors.background.elevated}+ padding="1rem"+ boxSizing="border-box">+ <HorizontalFlex justifyContent={'flex-end'}>+ <IconButton onClick={props.onClose}>+ <CloseIcon />+ </IconButton>+ </HorizontalFlex>+ <MenuSectionTitle title={'Aspect Ratio'} />+ <MenuItemGroup+ style={{+ marginBottom: '0.5rem',+ }}>+ <EnteMenuItem+ disabled={cropLoading}+ startIcon={<CropOriginalIcon />}+ onClick={() => {+ loadCanvas();+ }}+ label={'Original'}+ />+ <EnteMenuItem+ disabled={cropLoading}+ startIcon={<CropSquareIcon />}+ onClick={() => {+ cropCanvas(1, 1);+ }}+ label={'Square (1:1)'}+ />+ </MenuItemGroup>+ <MenuItemGroup+ style={{+ marginBottom: '1rem',+ }}>+ {PRESET_ASPECT_RATIOS.map((ratio, index) => (+ <EnteMenuItem+ disabled={cropLoading}+ key={index}+ startIcon={ratio.icon}+ onClick={() => {+ cropCanvas(+ ratio.width,+ ratio.height+ );+ }}+ label={`${ratio.width}:${ratio.height}`}+ />+ ))}+ </MenuItemGroup>+ <MenuItemGroup+ style={{+ marginBottom: '1rem',+ }}>+ {PRESET_ASPECT_RATIOS.map((ratio, index) => (+ <EnteMenuItem+ disabled={cropLoading}+ key={index}+ startIcon={ratio.icon}+ onClick={() => {+ cropCanvas(+ ratio.height,+ ratio.width+ );+ }}+ label={`${ratio.height}:${ratio.width}`}+ />+ ))}+ </MenuItemGroup>+ <MenuSectionTitle title={'Rotation'} />+ <MenuItemGroup+ style={{+ marginBottom: '1rem',+ }}>+ <EnteMenuItem+ disabled={cropLoading}+ startIcon={<RotateLeftIcon />}+ onClick={() => {+ rotateCanvas(-90);+ }}+ label="Rotate Left 90Λ"+ />+ <EnteMenuItem+ disabled={cropLoading}+ startIcon={<RotateRightIcon />}+ onClick={() => {+ rotateCanvas(90);+ }}+ label="Rotate Right 90Λ"+ />+ </MenuItemGroup>++ <MenuSectionTitle title={'Export'} />+ <MenuItemGroup>+ <EnteMenuItem+ startIcon={<DownloadIcon />}+ onClick={() => {+ exportCanvasToBlob((blob) => {+ // create a link+ const a =+ document.createElement('a');+ a.href = URL.createObjectURL(blob);+ a.download =+ props.file.metadata.title;+ document.body.appendChild(a);+ a.click();+ });+ }}+ label={'Download Edited'}+ />+ </MenuItemGroup>+ </Box>+ </Backdrop>+ </>+ )}</>);};diff --git a/apps/photos/src/components/PhotoViewer/index.tsx b/apps/photos/src/components/PhotoViewer/index.tsxindex 9fd06dc28e..797d510776 100644--- a/apps/photos/src/components/PhotoViewer/index.tsx+++ b/apps/photos/src/components/PhotoViewer/index.tsx@@ -121,6 +121,8 @@ function PhotoViewer(props: Iprops) {const exifExtractionInProgress = useRef<string>(null);const shouldShowCopyOption = useMemo(() => isClipboardItemPresent(), []);+ const [showImageEditorOverlay, setShowImageEditorOverlay] = useState(false);+const [conversionFailedNotificationOpen,setConversionFailedNotificationOpen,@@ -835,9 +837,13 @@ function PhotoViewer(props: Iprops) {collectionNameMap={props.collectionNameMap}closePhotoViewer={handleClose}/>- {photoSwipe && photoSwipe.currItem && (- <ImageEditorOverlay file={photoSwipe?.currItem as EnteFile} />- )}+ <ImageEditorOverlay+ show={showImageEditorOverlay}+ file={photoSwipe?.currItem as EnteFile}+ onClose={() => {+ setShowImageEditorOverlay(false);+ }}+ /></>);}