π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
refactor(gallery):extract-navbar-contents
Aswin Asok5420e8ed49b6
diff --git a/web/apps/photos/src/components/gallery/NormalNavbarContents.tsx b/web/apps/photos/src/components/gallery/NormalNavbarContents.tsxnew file mode 100644index 0000000000..471a070840--- /dev/null+++ b/web/apps/photos/src/components/gallery/NormalNavbarContents.tsx@@ -0,0 +1,57 @@+import { SearchBar, type SearchBarProps } from "@/components/SearchBar";+import { uploadManager } from "@/services/upload-manager";+import { Upload01Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import MenuIcon from "@mui/icons-material/Menu";+import { IconButton } from "@mui/material";+import type { ButtonishProps } from "ente-base/components/mui";+import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";+import { useIsSmallWidth } from "ente-base/components/utils/hooks";+import { t } from "i18next";++type NormalNavbarContentsProps = SearchBarProps & {+ onSidebar: () => void;+ onUpload: () => void;+};++export const NormalNavbarContents: React.FC<NormalNavbarContentsProps> = ({+ onSidebar,+ onUpload,+ ...props+}) => (+ <>+ {!props.isInSearchMode && <SidebarButton onClick={onSidebar} />}+ <SearchBar {...props} />+ {!props.isInSearchMode && <UploadButton onClick={onUpload} />}+ </>+);++const SidebarButton: React.FC<ButtonishProps> = ({ onClick }) => (+ <IconButton {...{ onClick }}>+ <MenuIcon />+ </IconButton>+);++export const UploadButton: React.FC<ButtonishProps> = ({ onClick }) => {+ const disabled = uploadManager.isUploadInProgress();+ const isSmallWidth = useIsSmallWidth();++ const icon = <HugeiconsIcon icon={Upload01Icon} size={20} />;++ return (+ <>+ {isSmallWidth ? (+ <IconButton {...{ onClick, disabled }}>{icon}</IconButton>+ ) : (+ <FocusVisibleButton+ color="secondary"+ startIcon={icon}+ sx={{ borderRadius: "16px" }}+ {...{ onClick, disabled }}+ >+ {t("upload")}+ </FocusVisibleButton>+ )}+ </>+ );+};diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 61ecf20760..842e134bb3 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -22,7 +22,6 @@ import { FileListWithViewer } from "@/components/FileListWithViewer";import { FixCreationTime } from "@/components/FixCreationTime";import { PlanSelector } from "@/components/PlanSelector";import { QuickLinkCreatedNotification } from "@/components/QuickLinkCreatedNotification";-import { SearchBar, type SearchBarProps } from "@/components/SearchBar";import {SelectedFileOptions,type CollectionOp,@@ -36,6 +35,10 @@ import {SearchResultsHeader,type RemotePullOpts,} from "@/components/gallery";+import {+ NormalNavbarContents,+ UploadButton,+} from "@/components/gallery/NormalNavbarContents";import {findCollectionCreatingIfNeeded,performCollectionOp,@@ -53,11 +56,8 @@ import { useIsOffline } from "@/components/utils/use-is-offline";import { shouldShowWhatsNew } from "@/services/changelog";import exportService from "@/services/export";import { processPendingAlbumJoin } from "@/services/join-album";-import { Upload01Icon } from "@hugeicons/core-free-icons";-import { HugeiconsIcon } from "@hugeicons/react";import ArrowBackIcon from "@mui/icons-material/ArrowBack";import CheckCircleIcon from "@mui/icons-material/CheckCircle";-import MenuIcon from "@mui/icons-material/Menu";import { IconButton, Link, Stack, Typography } from "@mui/material";import { sessionExpiredDialogAttributes } from "ente-accounts/components/utils/dialog";import {@@ -73,10 +73,7 @@ import { NavbarBase } from "ente-base/components/Navbar";import { SingleInputDialog } from "ente-base/components/SingleInputDialog";import { CenteredRow } from "ente-base/components/containers";import { TranslucentLoadingOverlay } from "ente-base/components/loaders";-import type { ButtonishProps } from "ente-base/components/mui";-import { FocusVisibleButton } from "ente-base/components/mui/FocusVisibleButton";import { errorDialogAttributes } from "ente-base/components/utils/dialog";-import { useIsSmallWidth } from "ente-base/components/utils/hooks";import { useModalVisibility } from "ente-base/components/utils/modal";import { useBaseContext } from "ente-base/context";import { subscribeMainWindowFocus } from "ente-base/electron";@@ -2251,53 +2248,6 @@ const preloadImage = (imgBasePath: string) => {new Image().srcset = srcset.join(",");};-type NormalNavbarContentsProps = SearchBarProps & {- onSidebar: () => void;- onUpload: () => void;-};--const NormalNavbarContents: React.FC<NormalNavbarContentsProps> = ({- onSidebar,- onUpload,- ...props-}) => (- <>- {!props.isInSearchMode && <SidebarButton onClick={onSidebar} />}- <SearchBar {...props} />- {!props.isInSearchMode && <UploadButton onClick={onUpload} />}- </>-);--const SidebarButton: React.FC<ButtonishProps> = ({ onClick }) => (- <IconButton {...{ onClick }}>- <MenuIcon />- </IconButton>-);--const UploadButton: React.FC<ButtonishProps> = ({ onClick }) => {- const disabled = uploadManager.isUploadInProgress();- const isSmallWidth = useIsSmallWidth();-- const icon = <HugeiconsIcon icon={Upload01Icon} size={20} />;-- return (- <>- {isSmallWidth ? (- <IconButton {...{ onClick, disabled }}>{icon}</IconButton>- ) : (- <FocusVisibleButton- color="secondary"- startIcon={icon}- sx={{ borderRadius: "16px" }}- {...{ onClick, disabled }}- >- {t("upload")}- </FocusVisibleButton>- )}- </>- );-};-interface SectionNavbarContentsProps {title: string;onBack: () => void;