This commit is contained in:
Manav Rathi
2025-02-28 19:04:30 +05:30
parent 61779a6ca7
commit d7587d12ed
3 changed files with 26 additions and 42 deletions

View File

@@ -17,6 +17,7 @@ import { isDesktop } from "@/base/app";
import { type ModalVisibilityProps } from "@/base/components/utils/modal";
import { useBaseContext } from "@/base/context";
import { lowercaseExtension } from "@/base/file-name";
import { pt } from "@/base/i18n";
import type { LocalUser } from "@/base/local-user";
import log from "@/base/log";
import {
@@ -32,7 +33,7 @@ import {
ImageEditorOverlay,
type ImageEditorOverlayProps,
} from "@/new/photos/components/ImageEditorOverlay";
import { Button, Menu, styled } from "@mui/material";
import { Button, Menu, MenuItem, styled } from "@mui/material";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { fileInfoExifForFile } from "./data-source";
import {
@@ -417,7 +418,9 @@ const FileViewer: React.FC<FileViewerProps> = ({
list: { "aria-labelledby": moreButtonID },
}}
>
Test
{activeAnnotatedFile?.annotation.isEditableImage && (
<MenuItem>{/*TODO */ pt("Edit image")}</MenuItem>
)}
</Menu>
<ImageEditorOverlay
open={openImageEditor}

View File

@@ -21,17 +21,12 @@ const paths = {
info: '<path d="M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8" transform="translate(3.5, 3.5)"',
// "@mui/icons-material/ErrorOutline"
error: '<path d="M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2M12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8" transform="translate(7, 5.7) scale(0.85)"',
// "@mui/icons-material/Edit"
edit: '<path d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z" transform="translate(3, 3) scale(0.97)"',
// "@mui/icons-material/FavoriteBorderRounded"
favorite:
'<path d="M19.66 3.99c-2.64-1.8-5.9-.96-7.66 1.1-1.76-2.06-5.02-2.91-7.66-1.1-1.4.96-2.28 2.58-2.34 4.29-.14 3.88 3.3 6.99 8.55 11.76l.1.09c.76.69 1.93.69 2.69-.01l.11-.1c5.25-4.76 8.68-7.87 8.55-11.75-.06-1.7-.94-3.32-2.34-4.28M12.1 18.55l-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05" transform="translate(3, 3)"',
// "@mui/icons-material/FavoriteRounded"
unfavorite:
'<path d="M13.35 20.13c-.76.69-1.93.69-2.69-.01l-.11-.1C5.3 15.27 1.87 12.16 2 8.28c.06-1.7.93-3.33 2.34-4.29 2.64-1.8 5.9-.96 7.66 1.1 1.76-2.06 5.02-2.91 7.66-1.1 1.41.96 2.28 2.59 2.34 4.29.14 3.88-3.3 6.99-8.55 11.76z" transform="translate(3, 3)"',
// TODO(PS): Remove me
// "@mui/icons-material/MoreVert"
moreV: '<path d="M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2m0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2"',
// "@mui/icons-material/MoreHoriz"
more: '<path d="M6 10c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m12 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2m-6 0c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2" transform="translate(3, 4)"',
};

View File

@@ -602,38 +602,23 @@ export class FileViewerPhotoSwipe {
onClick: () => onViewInfo(currentAnnotatedFile()),
});
// TODO(PS):
if (showModifyActions && onEditImage && false) {
pswp.ui.registerElement({
name: "edit",
// TODO(PS):
// title: t("edit_image"),
title: pt("Edit image"),
order: 16,
isButton: true,
html: createPSRegisterElementIconHTML("edit"),
// TODO
// onClick: withCurrentAnnotatedFile(delegate.onEditImage),
// onInit: (buttonElement) =>
// pswp.on("change", () =>
// showIf(
// buttonElement,
// !!currentFileAnnotation().isEditableImage,
// ),
// ),
});
}
if (showModifyActions && onEditImage) {
pswp.ui.registerElement({
name: "more",
// TODO(PS):
title: pt("More"),
order: 17,
order: 16,
isButton: true,
html: createPSRegisterElementIconHTML("more"),
onInit: (buttonElement) => {
buttonElement.setAttribute("id", moreButtonID);
buttonElement.setAttribute("aria-haspopup", "true");
pswp.on("change", () =>
showIf(
buttonElement,
!!currentFileAnnotation().isEditableImage,
),
);
},
onClick: (e) => {
const buttonElement = e.target;
@@ -643,6 +628,7 @@ export class FileViewerPhotoSwipe {
onMore(currentAnnotatedFile(), buttonElement);
},
});
}
});
// Modify the default UI elements.