π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
[web][photos] Refresh album cast dialog design
AswinAsokb9b0f1bdc828
diff --git a/web/apps/photos/src/components/collections/AlbumCastDialog.tsx b/web/apps/photos/src/components/collections/AlbumCastDialog.tsxindex e94f75dbc7..86a5748098 100644--- a/web/apps/photos/src/components/collections/AlbumCastDialog.tsx+++ b/web/apps/photos/src/components/collections/AlbumCastDialog.tsx@@ -1,9 +1,26 @@import { publishCastPayload, revokeAllCastTokens } from "@/services/cast";import { loadCast } from "@/utils/chromecast-sender";-import { Link, Stack, Typography } from "@mui/material";-import { TitledMiniDialog } from "ente-base/components/MiniDialog";+import ArrowBackIcon from "@mui/icons-material/ArrowBack";+import CastIcon from "@mui/icons-material/Cast";+import ChevronRightIcon from "@mui/icons-material/ChevronRight";+import CloseIcon from "@mui/icons-material/Close";+import KeyboardOutlinedIcon from "@mui/icons-material/KeyboardOutlined";+import {+ Box,+ Dialog,+ IconButton,+ Link,+ Stack,+ Typography,+} from "@mui/material";import { ActivityIndicator } from "ente-base/components/mui/ActivityIndicator";import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";+import {+ v2CloseButtonSx,+ v2HeaderRowSx,+ v2PaperSx,+ v2TitleSx,+} from "ente-base/components/SingleInput.styles";import {SingleInputForm,type SingleInputFormProps,@@ -13,9 +30,10 @@ import { isNamedError } from "ente-base/error";import { ut } from "ente-base/i18n";import log from "ente-base/log";import type { Collection } from "ente-media/collection";+import { FocusVisibleUnstyledButton } from "ente-new/photos/components/UnstyledButton";import { useSettingsSnapshot } from "ente-new/photos/components/utils/use-snapshot";import { t } from "i18next";-import React, { useCallback, useEffect, useState } from "react";+import React, { useCallback, useEffect, useId, useState } from "react";import { Trans } from "react-i18next";import { z } from "zod";@@ -25,11 +43,42 @@ export const AlbumCastDialog: React.FC<AlbumCastDialogProps> = ({open,onClose,collection,-}) => (- <TitledMiniDialog {...{ open, onClose }} title={t("cast_album_to_tv")}>- <AlbumCastDialogContents {...{ open, onClose, collection }} />- </TitledMiniDialog>-);+}) => {+ const titleID = useId();+ return (+ <Dialog+ {...{ open, onClose }}+ maxWidth={false}+ aria-labelledby={titleID}+ slotProps={{ paper: { sx: v2PaperSx } }}+ >+ <Stack sx={{ p: "24px", gap: "24px" }}>+ <Stack sx={{ gap: "16px" }}>+ <Stack direction="row" sx={v2HeaderRowSx}>+ <Typography+ id={titleID}+ component="h2"+ sx={{+ ...v2TitleSx,+ fontFamily: "'Outfit Variable', sans-serif",+ }}+ >+ {t("cast_album_to_tv")}+ </Typography>+ <IconButton+ aria-label={t("close")}+ onClick={onClose}+ sx={v2CloseButtonSx}+ >+ <CloseIcon sx={{ fontSize: 18 }} />+ </IconButton>+ </Stack>+ </Stack>+ <AlbumCastDialogContents {...{ open, onClose, collection }} />+ </Stack>+ </Dialog>+ );+};// MUI preserves a dialog child's state while hidden.// Keep contents separate so each open starts fresh and reruns effects.@@ -119,26 +168,21 @@ const AlbumCastDialogContents: React.FC<AlbumCastDialogProps> = ({return (<>{view == "choose" && (- <Stack sx={{ py: 1, gap: 4 }}>+ <Stack sx={{ gap: "12px" }}>{browserCanCast && (- <Stack sx={{ gap: 2 }}>- <Typography sx={{ color: "text.muted" }}>- {t("cast_auto_pair_description")}- </Typography>-- <FocusVisibleButton onClick={() => setView("auto")}>- {t("cast_auto_pair")}- </FocusVisibleButton>- </Stack>+ <PairingOption+ icon={<CastIcon sx={{ fontSize: 24 }} />}+ title={t("cast_auto_pair")}+ description={t("cast_auto_pair_description")}+ onClick={() => setView("auto")}+ />)}- <Stack sx={{ gap: 2 }}>- <Typography sx={{ color: "text.muted" }}>- {t("pair_with_pin_description")}- </Typography>- <FocusVisibleButton onClick={() => setView("pin")}>- {t("pair_with_pin")}- </FocusVisibleButton>- </Stack>+ <PairingOption+ icon={<KeyboardOutlinedIcon sx={{ fontSize: 24 }} />}+ title={t("pair_with_pin")}+ description={t("pair_with_pin_description")}+ onClick={() => setView("pin")}+ /></Stack>)}{view == "auto" && (@@ -167,13 +211,28 @@ const AlbumCastDialogContents: React.FC<AlbumCastDialogProps> = ({</Stack>)}{view == "pin" && (- <>- <Stack sx={{ gap: 2, mb: 2 }}>+ <Stack sx={{ gap: "20px" }}>+ <FocusVisibleButton+ variant="text"+ color="secondary"+ startIcon={<ArrowBackIcon />}+ onClick={() => setView("choose")}+ sx={{ alignSelf: "flex-start", p: 0 }}+ >+ {t("go_back")}+ </FocusVisibleButton>+ <Stack sx={{ gap: 2 }}><Typography sx={{ color: "text.muted" }}><Transi18nKey="visit_cast_url"components={{- a: <Link target="_blank" href={castURL} />,+ a: (+ <Link+ target="_blank"+ rel="noopener"+ href={castURL}+ />+ ),}}values={{ url: castHost }}/>@@ -188,18 +247,60 @@ const AlbumCastDialogContents: React.FC<AlbumCastDialogProps> = ({submitButtonTitle={t("pair_device_to_tv")}onSubmit={onSubmit}/>- <FocusVisibleButton- variant="text"- fullWidth- onClick={() => setView("choose")}- sx={{ mt: 1 }}- >- {t("go_back")}- </FocusVisibleButton>- </>+ </Stack>)}</>);};const CastPairRequest = z.object({ code: z.string() });++const PairingOption: React.FC<{+ icon: React.ReactNode;+ title: string;+ description: string;+ onClick: () => void;+}> = ({ icon, title, description, onClick }) => (+ <FocusVisibleUnstyledButton+ onClick={onClick}+ sx={(theme) => ({+ display: "flex",+ alignItems: "center",+ gap: "14px",+ width: "100%",+ boxSizing: "border-box",+ p: "18px 14px",+ borderRadius: "16px",+ textAlign: "left",+ color: "text.base",+ backgroundColor: "background.paper",+ "&:hover": { backgroundColor: "fill.faintHover" },+ ...theme.applyStyles("dark", { backgroundColor: "#282828" }),+ })}+ >+ <Box+ sx={{+ width: 36,+ height: 36,+ flexShrink: 0,+ display: "grid",+ placeItems: "center",+ }}+ >+ {icon}+ </Box>+ <Stack sx={{ flex: 1, minWidth: 0, gap: "4px" }}>+ <Typography sx={{ fontSize: 14, fontWeight: 500 }}>+ {title}+ </Typography>+ <Typography+ sx={{ fontSize: 12, lineHeight: "18px", color: "text.muted" }}+ >+ {description}+ </Typography>+ </Stack>+ <ChevronRightIcon+ sx={{ fontSize: 18, color: "text.muted", flexShrink: 0 }}+ />+ </FocusVisibleUnstyledButton>+);