Skip to content

armgit / ente

Public Imported from GitHub
0

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

update(upload-progress):make-mobile-ui-responsive

Aswin Asok87685380446b
diff --git a/web/packages/gallery/components/UploadCompletion.tsx b/web/packages/gallery/components/UploadCompletion.tsx
index f15c070b22..c29060dcb2 100644
--- a/web/packages/gallery/components/UploadCompletion.tsx
+++ b/web/packages/gallery/components/UploadCompletion.tsx
@@ -10,7 +10,13 @@ import {
type Theme,
} from "@mui/material";
import type { PreUploadSkippedFile } from "ente-base/types/ipc";
+import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
import { t } from "i18next";
+import {
+ uploadSheetMediaQuery,
+ uploadSheetPaperSx,
+ useIsUploadSheet,
+} from "./upload-progress/bottom-sheet";
import {
finishedStatKinds,
uploadCompletionCounts,
@@ -36,9 +42,11 @@ export function UploadCompletion({
preUploadSkippedFiles,
);
const hasReviewableUploads = counts.failed > 0 || counts.skipped > 0;
+ const isSheet = useIsUploadSheet();
const handleClose: DialogProps["onClose"] = (_, reason) => {
- if (reason != "backdropClick") onClose();
+ // On mobile, tapping the scrim also dismisses the sheet.
+ if (reason != "backdropClick" || isSheet) onClose();
};
if (!open) {
@@ -51,7 +59,10 @@ export function UploadCompletion({
onClose={handleClose}
maxWidth={false}
aria-labelledby="upload-completion-title"
- slotProps={{ paper: { sx: completionDialogPaperSx } }}
+ slots={isSheet ? { transition: SlideUpTransition } : undefined}
+ slotProps={{
+ paper: { sx: [completionDialogPaperSx, uploadSheetPaperSx] },
+ }}
>
<Stack sx={completionDialogContentSx}>
<Stack direction="row" sx={{ justifyContent: "flex-end" }}>
@@ -153,7 +164,16 @@ const completionDialogPaperSx = (theme: Theme) => ({
}),
});
-const completionDialogContentSx = { p: "20px", gap: 3, color: "text.base" };
+const completionDialogContentSx = {
+ p: "20px",
+ gap: 3,
+ color: "text.base",
+ [uploadSheetMediaQuery]: {
+ p: "12px 16px",
+ pb: "calc(20px + env(safe-area-inset-bottom, 0px))",
+ overflowY: "auto",
+ },
+};
const completionCloseButtonSx = (theme: Theme) => ({
width: 38,
@@ -184,7 +204,6 @@ const completionStatsGridSx = {
display: "grid",
gridTemplateColumns: "repeat(3, minmax(0, 1fr))",
gap: "10px",
- "@media (max-width: 420px)": { gridTemplateColumns: "1fr" },
};
const completionStatSx = (theme: Theme) => ({
@@ -194,6 +213,7 @@ const completionStatSx = (theme: Theme) => ({
gap: "4px",
borderRadius: "16px",
backgroundColor: "background.paper",
+ [uploadSheetMediaQuery]: { px: 1 },
...theme.applyStyles("dark", { backgroundColor: "#282828" }),
});
diff --git a/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx b/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx
index a954e60183..188c1548e5 100644
--- a/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx
+++ b/web/packages/gallery/components/upload-progress/MinimizedUploadProgress.tsx
@@ -5,6 +5,7 @@ import UnfoldMoreIcon from "@mui/icons-material/UnfoldMore";
import {
Box,
IconButton,
+ keyframes,
Paper,
Snackbar,
Stack,
@@ -14,6 +15,7 @@ import {
import type { SystemStyleObject } from "@mui/system";
import { t } from "i18next";
import { useRef } from "react";
+import { uploadSheetMediaQuery } from "./bottom-sheet";
import type { DragPosition } from "./context";
import { useUploadProgressContext } from "./context";
import {
@@ -41,6 +43,7 @@ export function MinimizedUploadProgress() {
<Snackbar
open
anchorOrigin={{ horizontal: "right", vertical: "bottom" }}
+ sx={minimizedSnackbarSx}
>
<Paper
ref={setDragSurface}
@@ -101,6 +104,17 @@ const ellipsisSx = {
textOverflow: "ellipsis",
whiteSpace: "nowrap",
};
+const minimizedRiseAnimation = keyframes`
+ from { transform: translateY(48px); opacity: 0.6; }
+ to { transform: translateY(0); opacity: 1; }
+`;
+const minimizedSnackbarSx = {
+ [uploadSheetMediaQuery]: {
+ left: "16px",
+ right: "16px",
+ bottom: "calc(16px + env(safe-area-inset-bottom, 0px))",
+ },
+};
const minimizedPaperSx = (theme: Theme): SystemStyleObject<Theme> => ({
width: "min(400px, calc(100svw - 32px))",
p: "16px 16px 16px 12px",
@@ -110,6 +124,11 @@ const minimizedPaperSx = (theme: Theme): SystemStyleObject<Theme> => ({
boxShadow: "0px 4px 4px rgba(0 0 0 / 0.16)",
color: "text.base",
overflow: "hidden",
+ [uploadSheetMediaQuery]: {
+ width: "100%",
+ animation: `${minimizedRiseAnimation} 320ms cubic-bezier(0.2, 0.8, 0.2, 1)`,
+ "@media (prefers-reduced-motion: reduce)": { animation: "none" },
+ },
...theme.applyStyles("dark", { backgroundColor: "#2b2b2b" }),
});
const minimizedDragIconSx = {
diff --git a/web/packages/gallery/components/upload-progress/StopUploadConfirmationDialog.tsx b/web/packages/gallery/components/upload-progress/StopUploadConfirmationDialog.tsx
index d28bd775c2..5085605ec1 100644
--- a/web/packages/gallery/components/upload-progress/StopUploadConfirmationDialog.tsx
+++ b/web/packages/gallery/components/upload-progress/StopUploadConfirmationDialog.tsx
@@ -8,8 +8,14 @@ import {
Typography,
type Theme,
} from "@mui/material";
+import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
import { t } from "i18next";
import { uploadCompletionCounts } from "../uploadProgressStats";
+import {
+ uploadSheetMediaQuery,
+ uploadSheetPaperSx,
+ useIsUploadSheet,
+} from "./bottom-sheet";
import { useUploadProgressContext } from "./context";
import { doneStatConfigs } from "./helpers";
@@ -26,6 +32,7 @@ export function StopUploadConfirmationDialog({
}: StopUploadConfirmationDialogProps) {
const { finishedUploads, preUploadSkippedFiles } =
useUploadProgressContext();
+ const isSheet = useIsUploadSheet();
const counts = uploadCompletionCounts(
finishedUploads,
preUploadSkippedFiles,
@@ -38,7 +45,10 @@ export function StopUploadConfirmationDialog({
maxWidth={false}
aria-labelledby="stop-upload-confirmation-title"
aria-describedby="stop-upload-confirmation-message"
- slotProps={{ paper: { sx: stopConfirmationPaperSx } }}
+ slots={isSheet ? { transition: SlideUpTransition } : undefined}
+ slotProps={{
+ paper: { sx: [stopConfirmationPaperSx, uploadSheetPaperSx] },
+ }}
>
<Stack sx={stopConfirmationContentSx}>
<Stack sx={stopConfirmationMessageSx}>
@@ -141,7 +151,16 @@ const stopConfirmationPaperSx = (theme: Theme) => ({
backgroundColor: "#1b1b1b",
}),
});
-const stopConfirmationContentSx = { p: "20px", gap: 3, color: "text.base" };
+const stopConfirmationContentSx = {
+ p: "20px",
+ gap: 3,
+ color: "text.base",
+ [uploadSheetMediaQuery]: {
+ p: "12px 16px",
+ pb: "calc(20px + env(safe-area-inset-bottom, 0px))",
+ overflowY: "auto",
+ },
+};
const stopConfirmationMessageSx = { alignItems: "center", gap: 1, minWidth: 0 };
const stopConfirmationHeaderSx = {
alignItems: "center",
diff --git a/web/packages/gallery/components/upload-progress/UploadFileList.tsx b/web/packages/gallery/components/upload-progress/UploadFileList.tsx
index 20a5578059..6876c1895c 100644
--- a/web/packages/gallery/components/upload-progress/UploadFileList.tsx
+++ b/web/packages/gallery/components/upload-progress/UploadFileList.tsx
@@ -15,6 +15,7 @@ import { t } from "i18next";
import { useEffect, useRef } from "react";
import { VariableSizeList } from "react-window";
import { uploadStatColors } from "../uploadProgressStats";
+import { uploadSheetMediaQuery } from "./bottom-sheet";
import { useUploadProgressContext } from "./context";
import { uploadStatusText } from "./helpers";
@@ -236,10 +237,14 @@ const uploadRowSx = (theme: Theme) => ({
display: "grid",
gridTemplateColumns: "minmax(160px, 1fr) minmax(180px, 244px)",
gap: "24px",
- "@media (max-width: 620px)": {
+ [uploadSheetMediaQuery]: {
gridTemplateColumns: "1fr",
gap: 1,
- "& > :nth-of-type(2)": { gridColumn: "1 / -1", gridRow: 2 },
+ "& > :nth-of-type(2)": {
+ // Align the progress bar with the file name text (36px icon +
+ // 12px gap) and let it fill the remaining width.
+ pl: "48px",
+ },
},
});
const fileIconSx = {
@@ -285,8 +290,14 @@ const rowProgressSx = {
borderRadius: "35px",
backgroundColor: progressGreen,
},
+ [uploadSheetMediaQuery]: { maxWidth: "none" },
+};
+const rowProgressLabelSx = {
+ width: 46,
+ flexShrink: 0,
+ ...mutedCaptionSx,
+ [uploadSheetMediaQuery]: { width: 40, textAlign: "right" },
};
-const rowProgressLabelSx = { width: 46, flexShrink: 0, ...mutedCaptionSx };
const emptyRowsSx = (theme: Theme) => ({
minHeight: 3 * listedRowHeight,
alignItems: "center",
diff --git a/web/packages/gallery/components/upload-progress/UploadProgressDetails.tsx b/web/packages/gallery/components/upload-progress/UploadProgressDetails.tsx
index 0a55a2cf9c..047ffd3c85 100644
--- a/web/packages/gallery/components/upload-progress/UploadProgressDetails.tsx
+++ b/web/packages/gallery/components/upload-progress/UploadProgressDetails.tsx
@@ -9,6 +9,7 @@ import {
uploadStatColors,
type UploadStatKind,
} from "../uploadProgressStats";
+import { uploadSheetMediaQuery } from "./bottom-sheet";
import { useUploadProgressContext } from "./context";
import {
doneStatConfigs,
@@ -329,8 +330,8 @@ const statsGridSx = (isDone: boolean) => ({
display: "grid",
gridTemplateColumns: `repeat(${isDone ? 3 : 4}, minmax(0, 1fr))`,
gap: "10px",
- "@media (max-width: 620px)": {
- gridTemplateColumns: "repeat(2, minmax(0, 1fr))",
+ [uploadSheetMediaQuery]: {
+ gridTemplateColumns: `repeat(${isDone ? 3 : 2}, minmax(0, 1fr))`,
},
});
const statTileSx = (theme: Theme): SystemStyleObject<Theme> => ({
@@ -346,6 +347,7 @@ const statTileSx = (theme: Theme): SystemStyleObject<Theme> => ({
background: "transparent",
textAlign: "left",
cursor: "pointer",
+ [uploadSheetMediaQuery]: { px: 1 },
"&:hover": { backgroundColor: "rgba(0 0 0 / 0.02)" },
"&:hover .stat-underline": { backgroundColor: "stroke.base" },
...theme.applyStyles("dark", {
diff --git a/web/packages/gallery/components/upload-progress/UploadProgressDialog.tsx b/web/packages/gallery/components/upload-progress/UploadProgressDialog.tsx
index f26f9f27e6..a47ccef869 100644
--- a/web/packages/gallery/components/upload-progress/UploadProgressDialog.tsx
+++ b/web/packages/gallery/components/upload-progress/UploadProgressDialog.tsx
@@ -11,8 +11,14 @@ import {
type DialogProps,
type Theme,
} from "@mui/material";
+import { SlideUpTransition } from "ente-new/photos/components/mui/SlideUpTransition";
import { t } from "i18next";
import { uploadStatColors } from "../uploadProgressStats";
+import {
+ uploadSheetMediaQuery,
+ uploadSheetPaperSx,
+ useIsUploadSheet,
+} from "./bottom-sheet";
import { useUploadProgressContext } from "./context";
import {
normalizePercent,
@@ -22,11 +28,17 @@ import {
import { UploadProgressDetails } from "./UploadProgressDetails";
export function UploadProgressDialog() {
- const { onClose, uploadPhase } = useUploadProgressContext();
+ const { onClose, setExpanded, uploadPhase } = useUploadProgressContext();
const isDone = uploadPhase == "done";
+ const isSheet = useIsUploadSheet();
const handleClose: DialogProps["onClose"] = (_, reason) => {
- if (reason != "backdropClick") onClose();
+ if (reason == "backdropClick") {
+ // On mobile, tapping the scrim minimizes the sheet.
+ if (isSheet) setExpanded(false);
+ return;
+ }
+ onClose();
};
return (
@@ -35,7 +47,12 @@ export function UploadProgressDialog() {
onClose={handleClose}
maxWidth={false}
aria-labelledby="upload-progress-title"
- slotProps={{ paper: { sx: uploadProgressDialogPaperSx } }}
+ slots={isSheet ? { transition: SlideUpTransition } : undefined}
+ slotProps={{
+ paper: {
+ sx: [uploadProgressDialogPaperSx, uploadSheetPaperSx],
+ },
+ }}
>
<Box sx={uploadProgressDialogContentSx(isDone)}>
<UploadProgressHeader />
@@ -211,6 +228,11 @@ const uploadProgressDialogContentSx = (isDone: boolean) => ({
flexDirection: "column",
gap: isDone ? "36px" : "20px",
color: "text.base",
+ [uploadSheetMediaQuery]: {
+ p: "12px 16px",
+ pb: "calc(28px + env(safe-area-inset-bottom, 0px))",
+ overflowY: "auto",
+ },
});
const headerSx = (theme: Theme) => ({
alignItems: "center",
@@ -258,7 +280,7 @@ const summaryLayoutSx = {
gridTemplateColumns: "minmax(0, 440px) minmax(128px, 1fr)",
gap: "32px",
alignItems: "center",
- "@media (max-width: 620px)": { gridTemplateColumns: "1fr", gap: 2 },
+ [uploadSheetMediaQuery]: { pr: "8px", gridTemplateColumns: "1fr", gap: 2 },
};
const mainProgressSx = (theme: Theme) => ({
height: 14,
@@ -276,5 +298,5 @@ const mascotSx = {
width: 128,
maxWidth: "100%",
justifySelf: "center",
- "@media (max-width: 620px)": { display: "none" },
+ [uploadSheetMediaQuery]: { display: "none" },
};
diff --git a/web/packages/gallery/components/upload-progress/bottom-sheet.ts b/web/packages/gallery/components/upload-progress/bottom-sheet.ts
new file mode 100644
index 0000000000..39e925dccc
--- /dev/null
+++ b/web/packages/gallery/components/upload-progress/bottom-sheet.ts
@@ -0,0 +1,49 @@
+import { useMediaQuery } from "@mui/material";
+
+/**
+ * The media query below which the upload progress surfaces switch to their
+ * mobile presentation: dialogs become full width bottom sheets, and the
+ * minimized pill docks above the bottom edge.
+ *
+ * This matches the cutoff at which the upload progress internals (summary
+ * grid, stat grid, in-progress rows) already reflow, so the sheet switch and
+ * those reflows engage together.
+ */
+export const uploadSheetMediaQuery = "@media (max-width: 620px)";
+
+/**
+ * Return `true` if the viewport is narrow enough that the upload progress
+ * dialogs should be presented as bottom sheets.
+ */
+export const useIsUploadSheet = () => useMediaQuery(uploadSheetMediaQuery);
+
+/**
+ * Mobile overrides that convert a dialog's paper into a bottom sheet.
+ *
+ * Layer this on top of the dialog's existing paper sx (which retains the
+ * surface color, border and 20px radius); above {@link uploadSheetMediaQuery}
+ * it has no effect.
+ */
+export const uploadSheetPaperSx = {
+ [uploadSheetMediaQuery]: {
+ position: "fixed",
+ bottom: 0,
+ left: 0,
+ m: 0,
+ width: "100%",
+ maxWidth: "none",
+ maxHeight: "calc(100dvh - 72px)",
+ borderRadius: "20px 20px 0 0",
+ borderBottom: "none",
+ "&::before": {
+ content: '""',
+ width: 36,
+ height: 4,
+ flexShrink: 0,
+ alignSelf: "center",
+ mt: 1,
+ borderRadius: "100px",
+ backgroundColor: "fill.muted",
+ },
+ },
+};