Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Refine public album mobile header and download dialogs

Anand Baburajanab7b23cfa484
diff --git a/web/apps/photos/src/components/DownloadStatusNotifications.tsx b/web/apps/photos/src/components/DownloadStatusNotifications.tsx
index 64d8dd6cd3..513f48e06b 100644
--- a/web/apps/photos/src/components/DownloadStatusNotifications.tsx
+++ b/web/apps/photos/src/components/DownloadStatusNotifications.tsx
@@ -6,7 +6,7 @@ import {
import { HugeiconsIcon } from "@hugeicons/react";
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
import ReplayIcon from "@mui/icons-material/Replay";
-import { keyframes, styled, Typography } from "@mui/material";
+import { Box, Button, Dialog, keyframes, styled, Typography } from "@mui/material";
import { useBaseContext } from "ente-base/context";
import {
isSaveComplete,
@@ -15,6 +15,7 @@ import {
} from "ente-gallery/components/utils/save-groups";
import { Notification } from "ente-new/photos/components/Notification";
import { t } from "i18next";
+import { useState } from "react";
/** Maximum characters for album name before truncation */
const MAX_ALBUM_NAME_LENGTH = 25;
@@ -56,6 +57,11 @@ interface DownloadStatusNotificationsProps {
collectionSummaryID: number | undefined,
isHiddenCollectionSummary: boolean | undefined,
) => void;
+ /**
+ * If true, make each notification full width on mobile phones (MUI "sm"
+ * and below). Tablet and desktop widths remain unchanged.
+ */
+ fullWidthOnMobile?: boolean;
}
/**
@@ -64,11 +70,25 @@ interface DownloadStatusNotificationsProps {
*/
export const DownloadStatusNotifications: React.FC<
DownloadStatusNotificationsProps
-> = ({ saveGroups, onRemoveSaveGroup, onShowCollectionSummary }) => {
+> = ({
+ saveGroups,
+ onRemoveSaveGroup,
+ onShowCollectionSummary,
+ fullWidthOnMobile,
+}) => {
const { showMiniDialog } = useBaseContext();
const fileLabel = t("file").toLowerCase();
+ const [cancelDownloadGroup, setCancelDownloadGroup] =
+ useState<SaveGroup | null>(null);
+
+ const closeCancelDownloadDialog = () => setCancelDownloadGroup(null);
+
+ const confirmCancelDownload = (group: SaveGroup) => {
+ if (fullWidthOnMobile) {
+ setCancelDownloadGroup(group);
+ return;
+ }
- const confirmCancelDownload = (group: SaveGroup) =>
showMiniDialog({
title: t("stop_downloads_title"),
message: t("stop_downloads_message"),
@@ -82,6 +102,14 @@ export const DownloadStatusNotifications: React.FC<
},
cancel: t("no"),
});
+ };
+
+ const handleConfirmCancelDownload = () => {
+ if (!cancelDownloadGroup) return;
+ cancelDownloadGroup.canceller.abort();
+ onRemoveSaveGroup(cancelDownloadGroup);
+ closeCancelDownloadDialog();
+ };
const createOnClose = (group: SaveGroup) => () => {
if (isSaveComplete(group)) {
@@ -105,161 +133,296 @@ export const DownloadStatusNotifications: React.FC<
}
};
- return saveGroups.map((group, index) => {
- const hasErrors = isSaveCompleteWithErrors(group);
- const isComplete = isSaveComplete(group);
- const canRetry = hasErrors && !!group.retry;
-
- // Determine if this is a ZIP download (web with multiple files or live photo)
- const isZipDownload = !group.downloadDirPath && group.total > 1;
- const shouldShowZipPart =
- isZipDownload &&
- (group.includeZipNumber || (group.currentPart ?? 1) > 1);
- const isDesktopOrSingleFile =
- !!group.downloadDirPath || group.total === 1;
-
- // Build the status text for the caption
- let statusText: React.ReactNode;
- if (hasErrors) {
- // Show specific error message based on failure reason
- if (group.failureReason === "network_offline") {
- statusText = t("download_failed_network_offline");
- } else if (group.failureReason === "file_error") {
- statusText = t("download_failed_file_error");
- } else {
- statusText = t("download_failed");
- }
- } else if (isComplete) {
- statusText = t("download_complete");
- } else if (shouldShowZipPart) {
- const part = group.currentPart ?? 1;
- statusText = group.isDownloadingZip
- ? t("downloading_part", { part })
- : t("preparing_part", { part });
- } else if (isZipDownload) {
- statusText = group.isDownloadingZip
- ? t("downloading")
- : t("preparing");
- } else if (isDesktopOrSingleFile) {
- statusText =
- group.total === 1
- ? t("downloading_file")
- : t("downloading_files");
- } else {
- statusText = t("downloading");
- }
+ return (
+ <>
+ {saveGroups.map((group, index) => {
+ const hasErrors = isSaveCompleteWithErrors(group);
+ const isComplete = isSaveComplete(group);
+ const canRetry = hasErrors && !!group.retry;
- // Build caption: "Status β€’ X / Y files"
- const completedCount = group.success + group.failed;
- const progress =
- group.total === 1
- ? `${t("processed_counts", {
- count: completedCount,
- total: group.total,
- })} ${fileLabel}`
- : t("download_progress", {
- count: completedCount,
- total: group.total,
- });
- const caption = (
- <Typography
- variant="small"
- sx={{
- color: hasErrors ? "white" : "text.muted",
- fontVariantNumeric: "tabular-nums",
- }}
- >
- {statusText}
- {!isComplete && <> &bull; {progress}</>}
- </Typography>
- );
-
- // Determine the start icon based on state
- let startIcon: React.ReactNode;
- if (hasErrors) {
- startIcon = <ErrorOutlineIcon />;
- } else if (isComplete) {
- startIcon = (
- <GlowingIconWrapper>
- <HugeiconsIcon icon={Tick02Icon} size={28} />
- </GlowingIconWrapper>
- );
- } else if (isZipDownload && !group.isDownloadingZip) {
- // Preparing state - use loading icon
- startIcon = <SpinningIcon />;
- } else {
- // Downloading state
- startIcon = (
- <DroppingIconWrapper>
- <HugeiconsIcon icon={Download01Icon} size={28} />
- </DroppingIconWrapper>
- );
- }
+ // Determine if this is a ZIP download (web with multiple files or live photo)
+ const isZipDownload = !group.downloadDirPath && group.total > 1;
+ const shouldShowZipPart =
+ isZipDownload &&
+ (group.includeZipNumber || (group.currentPart ?? 1) > 1);
+ const isDesktopOrSingleFile =
+ !!group.downloadDirPath || group.total === 1;
+
+ // Build the status text for the caption
+ let statusText: React.ReactNode;
+ if (hasErrors) {
+ // Show specific error message based on failure reason
+ if (group.failureReason === "network_offline") {
+ statusText = t("download_failed_network_offline");
+ } else if (group.failureReason === "file_error") {
+ statusText = t("download_failed_file_error");
+ } else {
+ statusText = t("download_failed");
+ }
+ } else if (isComplete) {
+ statusText = t("download_complete");
+ } else if (shouldShowZipPart) {
+ const part = group.currentPart ?? 1;
+ statusText = group.isDownloadingZip
+ ? t("downloading_part", { part })
+ : t("preparing_part", { part });
+ } else if (isZipDownload) {
+ statusText = group.isDownloadingZip
+ ? t("downloading")
+ : t("preparing");
+ } else if (isDesktopOrSingleFile) {
+ statusText =
+ group.total === 1
+ ? t("downloading_file")
+ : t("downloading_files");
+ } else {
+ statusText = t("downloading");
+ }
+
+ // Build caption: "Status β€’ X / Y files"
+ const completedCount = group.success + group.failed;
+ const progress =
+ group.total === 1
+ ? `${t("processed_counts", {
+ count: completedCount,
+ total: group.total,
+ })} ${fileLabel}`
+ : t("download_progress", {
+ count: completedCount,
+ total: group.total,
+ });
+ const caption = (
+ <Typography
+ variant="small"
+ sx={{
+ color: hasErrors ? "white" : "text.muted",
+ fontVariantNumeric: "tabular-nums",
+ }}
+ >
+ {statusText}
+ {!isComplete && <> &bull; {progress}</>}
+ </Typography>
+ );
+
+ // Determine the start icon based on state
+ let startIcon: React.ReactNode;
+ if (hasErrors) {
+ startIcon = <ErrorOutlineIcon />;
+ } else if (isComplete) {
+ startIcon = (
+ <GlowingIconWrapper>
+ <HugeiconsIcon icon={Tick02Icon} size={28} />
+ </GlowingIconWrapper>
+ );
+ } else if (isZipDownload && !group.isDownloadingZip) {
+ // Preparing state - use loading icon
+ startIcon = <SpinningIcon />;
+ } else {
+ // Downloading state
+ startIcon = (
+ <DroppingIconWrapper>
+ <HugeiconsIcon icon={Download01Icon} size={28} />
+ </DroppingIconWrapper>
+ );
+ }
- // Title is always the album name (truncated)
- const filesCountTitle = t("files_count", { count: group.total });
- const title =
- group.total === 1 && group.title === filesCountTitle
- ? `${group.total} ${fileLabel}`
- : group.title;
- const truncatedName = truncateAlbumName(title);
-
- return (
- <Notification
- key={group.id}
- horizontal="left"
- sx={(theme) => ({
- "&&": { bottom: `${index * 80 + 20}px` },
- width: "min(400px, 100vw)",
- borderRadius: "20px",
- "& .MuiButton-root": {
- borderRadius: "20px",
- padding: "16px 16px 16px 20px",
- },
- "& .MuiIconButton-root": {
- width: "40px",
- height: "40px",
- "& svg": { fontSize: "22px" },
- },
- [theme.breakpoints.down("sm")]: {
- "&&": { bottom: `${index * 70 + 16}px` },
- width: "min(340px, calc(100vw - 16px))",
- borderRadius: "16px",
- "& .MuiButton-root": {
- borderRadius: "16px",
- padding: "12px 12px 12px 16px",
- },
- "& .MuiIconButton-root": {
- width: "36px",
- height: "36px",
- "& svg": { fontSize: "20px" },
- },
- },
- })}
- open={true}
- onClose={createOnClose(group)}
- keepOpenOnClick
- attributes={{
- color: hasErrors ? "critical" : "secondary",
- startIcon,
- title: truncatedName,
- caption,
- onClick: createOnClick(group),
- endIcon: canRetry ? (
- <ReplayIcon
- titleAccess={t("retry")}
- sx={{ color: "white" }}
- />
- ) : undefined,
- onEndIconClick: canRetry
- ? () => group.retry?.()
- : undefined,
- }}
- />
- );
- });
+ // Title is always the album name (truncated)
+ const filesCountTitle = t("files_count", { count: group.total });
+ const title =
+ group.total === 1 && group.title === filesCountTitle
+ ? `${group.total} ${fileLabel}`
+ : group.title;
+ const truncatedName = truncateAlbumName(title);
+
+ return (
+ <Notification
+ key={group.id}
+ horizontal="left"
+ sx={(theme) => ({
+ "&&": { bottom: `${index * 80 + 20}px` },
+ width: "min(400px, 100vw)",
+ borderRadius: "20px",
+ "& .MuiButton-root": {
+ borderRadius: "20px",
+ padding: "16px 16px 16px 20px",
+ },
+ "& .MuiIconButton-root": {
+ width: "40px",
+ height: "40px",
+ "& svg": { fontSize: "22px" },
+ },
+ [theme.breakpoints.down("sm")]: {
+ "&&": {
+ bottom: `${index * 70 + 16}px`,
+ ...(fullWidthOnMobile ? { left: "8px" } : {}),
+ },
+ width: fullWidthOnMobile
+ ? "calc(100vw - 16px)"
+ : "min(340px, calc(100vw - 16px))",
+ borderRadius: "16px",
+ "& .MuiButton-root": {
+ borderRadius: "16px",
+ padding: "12px 12px 12px 16px",
+ },
+ "& .MuiIconButton-root": {
+ width: "36px",
+ height: "36px",
+ "& svg": { fontSize: "20px" },
+ },
+ },
+ })}
+ open={true}
+ onClose={createOnClose(group)}
+ keepOpenOnClick
+ attributes={{
+ color: hasErrors ? "critical" : "secondary",
+ startIcon,
+ title: truncatedName,
+ caption,
+ onClick: createOnClick(group),
+ endIcon: canRetry ? (
+ <ReplayIcon
+ titleAccess={t("retry")}
+ sx={{ color: "white" }}
+ />
+ ) : undefined,
+ onEndIconClick: canRetry
+ ? () => group.retry?.()
+ : undefined,
+ }}
+ />
+ );
+ })}
+
+ {fullWidthOnMobile && (
+ <StyledStopDownloadDialog
+ open={!!cancelDownloadGroup}
+ onClose={closeCancelDownloadDialog}
+ >
+ <StopDownloadDialogWrapper>
+ <StopDownloadTitleSection>
+ <Typography
+ sx={{
+ fontWeight: 600,
+ fontSize: 24,
+ lineHeight: "28px",
+ letterSpacing: "-0.48px",
+ textAlign: "center",
+ }}
+ >
+ {t("stop_downloads_title")}
+ </Typography>
+ <StopDownloadSubtitle>
+ {t("stop_downloads_message")}
+ </StopDownloadSubtitle>
+ </StopDownloadTitleSection>
+ <StopDownloadButtonsSection>
+ <StopDownloadSecondaryButton
+ fullWidth
+ onClick={closeCancelDownloadDialog}
+ >
+ {t("no")}
+ </StopDownloadSecondaryButton>
+ <StopDownloadPrimaryButton
+ fullWidth
+ onClick={handleConfirmCancelDownload}
+ >
+ {t("yes_stop_downloads")}
+ </StopDownloadPrimaryButton>
+ </StopDownloadButtonsSection>
+ </StopDownloadDialogWrapper>
+ </StyledStopDownloadDialog>
+ )}
+ </>
+ );
};
+const StyledStopDownloadDialog = styled(Dialog)(({ theme }) => ({
+ "& .MuiDialog-paper": {
+ width: 381,
+ maxWidth: "calc(100% - 32px)",
+ borderRadius: 28,
+ backgroundColor: "#fff",
+ padding: 0,
+ margin: 16,
+ boxShadow: "none",
+ border: "1px solid #E0E0E0",
+ ...theme.applyStyles("dark", {
+ backgroundColor: "#1b1b1b",
+ border: "1px solid rgba(255, 255, 255, 0.18)",
+ }),
+ },
+ "& .MuiBackdrop-root": { backgroundColor: "rgba(0, 0, 0, 0.5)" },
+}));
+
+const StopDownloadDialogWrapper = styled(Box)(() => ({
+ padding: "40px 16px 16px 16px",
+}));
+
+const StopDownloadTitleSection = styled(Box)(() => ({
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ justifyContent: "center",
+ gap: 9,
+ textAlign: "center",
+ marginBottom: 36,
+}));
+
+const StopDownloadButtonsSection = styled(Box)(() => ({
+ width: "100%",
+ display: "flex",
+ flexDirection: "column",
+ gap: 12,
+}));
+
+const StopDownloadSubtitle = styled(Typography)(({ theme }) => ({
+ fontWeight: 500,
+ fontSize: 14,
+ lineHeight: "20px",
+ color: "#666666",
+ maxWidth: 295,
+ textAlign: "center",
+ marginInline: "auto",
+ ...theme.applyStyles("dark", { color: "rgba(255, 255, 255, 0.7)" }),
+}));
+
+const StopDownloadSecondaryButton = styled(Button)(({ theme }) => ({
+ display: "flex",
+ padding: "20px 16px",
+ justifyContent: "center",
+ alignItems: "center",
+ gap: 8,
+ borderRadius: 20,
+ backgroundColor: "rgba(0, 0, 0, 0.04)",
+ border: "none",
+ fontSize: 16,
+ fontWeight: 500,
+ textTransform: "none",
+ color: "#000",
+ "&:hover": { backgroundColor: "rgba(0, 0, 0, 0.08)", border: "none" },
+ ...theme.applyStyles("dark", {
+ backgroundColor: "rgba(255, 255, 255, 0.08)",
+ color: "#fff",
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 0.12)" },
+ }),
+}));
+
+const StopDownloadPrimaryButton = styled(Button)(({ theme }) => ({
+ display: "flex",
+ padding: "20px 16px",
+ justifyContent: "center",
+ alignItems: "center",
+ gap: 8,
+ borderRadius: 20,
+ backgroundColor: theme.vars.palette.critical.main,
+ fontSize: 16,
+ fontWeight: 500,
+ textTransform: "none",
+ color: theme.vars.palette.critical.contrastText,
+ "&:hover": { backgroundColor: theme.vars.palette.critical.dark },
+}));
+
/** CSS keyframes for spinning animation */
const spinAnimation = keyframes`
from { transform: rotate(0deg); }
diff --git a/web/apps/photos/src/components/TripLayout/index.tsx b/web/apps/photos/src/components/TripLayout/index.tsx
index edc225aeac..461a803680 100644
--- a/web/apps/photos/src/components/TripLayout/index.tsx
+++ b/web/apps/photos/src/components/TripLayout/index.tsx
@@ -608,6 +608,7 @@ export const TripLayout: React.FC<TripLayoutProps> = ({
<DownloadStatusNotifications
saveGroups={saveGroups}
onRemoveSaveGroup={onRemoveSaveGroup}
+ fullWidthOnMobile
/>
{/* Public feed sidebar */}
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index e00279b70e..11d606f8d5 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -3,7 +3,15 @@
import { Download01Icon, ImageAdd02Icon } from "@hugeicons/core-free-icons";
import { HugeiconsIcon } from "@hugeicons/react";
import CloseIcon from "@mui/icons-material/Close";
-import { Box, Button, IconButton, Stack, styled, Tooltip } from "@mui/material";
+import {
+ Box,
+ Button,
+ IconButton,
+ Stack,
+ styled,
+ Tooltip,
+ useMediaQuery,
+} from "@mui/material";
import Typography from "@mui/material/Typography";
import { FeedIcon } from "components/Collections/CollectionHeader";
import { DownloadStatusNotifications } from "components/DownloadStatusNotifications";
@@ -87,7 +95,13 @@ import { usePhotosAppContext } from "ente-new/photos/types/context";
import { useJoinAlbum } from "hooks/useJoinAlbum";
import { t } from "i18next";
import { useRouter } from "next/router";
-import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import {
+ useCallback,
+ useEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
import { type FileWithPath } from "react-dropzone";
import { uploadManager } from "services/upload-manager";
import { getSelectedFiles, type SelectedState } from "utils/file";
@@ -479,6 +493,10 @@ export default function PublicCollectionGallery() {
const addPhotosEnabled = !!onAddPhotos;
const hasSelection = selected.count > 0;
+ const isMobileHeaderLayout = useMediaQuery("(width < 720px)");
+ const fileListHeaderHeightForViewport = isMobileHeaderLayout
+ ? fileListHeaderHeightMobile
+ : fileListHeaderHeight;
const fileListHeader = useMemo<FileListHeaderOrFooter | undefined>(
() =>
@@ -498,7 +516,7 @@ export default function PublicCollectionGallery() {
}}
/>
),
- height: fileListHeaderHeight,
+ height: fileListHeaderHeightForViewport,
}
: undefined,
[
@@ -509,6 +527,7 @@ export default function PublicCollectionGallery() {
showPublicFeed,
commentsEnabled,
hasSelection,
+ fileListHeaderHeightForViewport,
],
);
@@ -676,6 +695,7 @@ export default function PublicCollectionGallery() {
/>
<DownloadStatusNotifications
{...{ saveGroups, onRemoveSaveGroup }}
+ fullWidthOnMobile
/>
{publicCollection && collectionKey.current && (
<PublicFeedSidebar
@@ -873,6 +893,13 @@ interface FileListHeaderProps {
*/
const fileListHeaderHeight = 84;
+/**
+ * The height (in px) of {@link FileListHeader} on mobile.
+ *
+ * Keep this fixed so the virtualized list has a stable header row height.
+ */
+const fileListHeaderHeightMobile = 132;
+
/**
* A header shown before the listing of files.
*
@@ -887,6 +914,8 @@ const FileListHeader: React.FC<FileListHeaderProps> = ({
onShowFeed,
hasSelection,
}) => {
+ const showHeaderActions = !hasSelection && !!(onShowFeed || downloadEnabled);
+
const memoriesDateRange = useMemo(() => {
if (!publicFiles.length) return undefined;
@@ -913,7 +942,15 @@ const FileListHeader: React.FC<FileListHeaderProps> = ({
return (
<GalleryItemsHeaderAdapter sx={{ pt: "16px" }}>
- <SpacedRow>
+ <SpacedRow
+ sx={{
+ "@media (width < 720px)": {
+ flexDirection: "column",
+ alignItems: "flex-start",
+ gap: 1,
+ },
+ }}
+ >
<Box sx={{ minWidth: 0 }}>
<GalleryItemsSummary
name={publicCollection.name}
@@ -931,41 +968,47 @@ const FileListHeader: React.FC<FileListHeaderProps> = ({
</Typography>
) : undefined
}
- nameProps={{ noWrap: true }}
+ nameProps={{
+ noWrap: true,
+ sx: { maxWidth: "100%" },
+ }}
/>
</Box>
- <Stack
- direction="row"
- spacing={1}
- sx={{
- alignItems: "center",
- "@media (width > 720px)": { mr: -1.5 },
- }}
- >
- {onShowFeed && !hasSelection && (
- <IconButton onClick={onShowFeed}>
- <Box
- sx={{
- width: 24,
- height: 24,
- display: "flex",
- alignItems: "center",
- justifyContent: "center",
- }}
- >
- <FeedIcon />
- </Box>
- </IconButton>
- )}
- {downloadEnabled && !hasSelection && (
- <IconButton onClick={downloadAllFiles}>
- <HugeiconsIcon
- icon={Download01Icon}
- strokeWidth={1.6}
- />
- </IconButton>
- )}
- </Stack>
+ {showHeaderActions && (
+ <Stack
+ direction="row"
+ spacing={0}
+ sx={{
+ alignItems: "center",
+ "@media (width > 720px)": { mr: -1.5 },
+ "@media (width < 720px)": { ml: -1.5 },
+ }}
+ >
+ {onShowFeed && (
+ <IconButton onClick={onShowFeed}>
+ <Box
+ sx={{
+ width: 24,
+ height: 24,
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ }}
+ >
+ <FeedIcon />
+ </Box>
+ </IconButton>
+ )}
+ {downloadEnabled && (
+ <IconButton onClick={downloadAllFiles}>
+ <HugeiconsIcon
+ icon={Download01Icon}
+ strokeWidth={1.6}
+ />
+ </IconButton>
+ )}
+ </Stack>
+ )}
</SpacedRow>
</GalleryItemsHeaderAdapter>
);