Skip to content

armgit / ente

Public Imported from GitHub
0

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

chore: mobile version first version

anandbaburajandf941c7c9197
diff --git a/web/apps/photos/src/components/TripTemplate/MobileCover.tsx b/web/apps/photos/src/components/TripTemplate/MobileCover.tsx
new file mode 100644
index 0000000000..e6bbe78d01
--- /dev/null
+++ b/web/apps/photos/src/components/TripTemplate/MobileCover.tsx
@@ -0,0 +1,125 @@
+import { Box, Skeleton, styled, Typography } from "@mui/material";
+import Image from "next/image";
+import { memo } from "react";
+import type { JourneyPoint } from "./types";
+
+interface MobileCoverProps {
+ journeyData: JourneyPoint[];
+ photoClusters: JourneyPoint[][];
+ albumTitle?: string;
+ coverImageUrl?: string | null;
+}
+
+export const MobileCover = memo<MobileCoverProps>(
+ ({ journeyData, photoClusters, albumTitle, coverImageUrl }) => {
+ const sortedData = [...journeyData].sort(
+ (a, b) =>
+ new Date(a.timestamp).getTime() -
+ new Date(b.timestamp).getTime(),
+ );
+ const firstData = sortedData[0];
+ const lastData = sortedData[sortedData.length - 1];
+ if (!firstData || !lastData) {
+ return null;
+ }
+ const firstDate = new Date(firstData.timestamp);
+ const lastDate = new Date(lastData.timestamp);
+ const diffTime = Math.abs(lastDate.getTime() - firstDate.getTime());
+ const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
+ const monthYear = firstDate.toLocaleDateString("en-US", {
+ month: "long",
+ year: "numeric",
+ });
+
+ return (
+ <MobileCoverContainer>
+ {coverImageUrl ? (
+ <>
+ <Image
+ src={coverImageUrl}
+ alt="Trip Cover"
+ fill
+ style={{ objectFit: "cover" }}
+ sizes="100vw"
+ />
+ <GradientOverlay />
+ </>
+ ) : (
+ <Skeleton
+ variant="rectangular"
+ width="100%"
+ height="100%"
+ sx={{ bgcolor: "#f5f5f5" }}
+ />
+ )}
+
+
+ <ContentContainer>
+ {coverImageUrl ? (
+ <>
+ <TripTitle>{albumTitle || "Trip"}</TripTitle>
+ <TripSubtitle>
+ {monthYear} β€’ {diffDays} days β€’{" "}
+ {photoClusters.length} locations
+ </TripSubtitle>
+ </>
+ ) : (
+ <>
+ <Skeleton
+ variant="text"
+ width="200px"
+ height="40px"
+ sx={{
+ mb: "5px",
+ bgcolor: "rgba(255,255,255,0.95)",
+ }}
+ />
+ <Skeleton
+ variant="text"
+ width="270px"
+ height="24px"
+ sx={{ bgcolor: "rgba(255,255,255,0.7)" }}
+ />
+ </>
+ )}
+ </ContentContainer>
+ </MobileCoverContainer>
+ );
+ },
+);
+
+const MobileCoverContainer = styled(Box)({
+ position: "relative",
+ width: "100%",
+ height: "100%",
+ backgroundColor: "#e0e0e0",
+});
+
+const GradientOverlay = styled(Box)({
+ position: "absolute",
+ inset: 0,
+ background:
+ "linear-gradient(to bottom, rgba(0,0,0,0.3), transparent 30%, transparent 60%, rgba(0,0,0,0.8))",
+});
+
+
+const ContentContainer = styled(Box)({
+ position: "absolute",
+ bottom: "20px",
+ left: "20px",
+ right: "20px",
+ color: "white",
+});
+
+const TripTitle = styled(Typography)({
+ fontSize: "28px",
+ fontWeight: "bold",
+ marginBottom: "8px",
+ component: "h1",
+});
+
+const TripSubtitle = styled(Typography)({
+ color: "rgba(255, 255, 255, 0.9)",
+ fontSize: "15px",
+ fontWeight: "600",
+});
\ No newline at end of file
diff --git a/web/apps/photos/src/components/TripTemplate/MobileNavBar.tsx b/web/apps/photos/src/components/TripTemplate/MobileNavBar.tsx
new file mode 100644
index 0000000000..afb446b171
--- /dev/null
+++ b/web/apps/photos/src/components/TripTemplate/MobileNavBar.tsx
@@ -0,0 +1,139 @@
+import AddPhotoAlternateOutlinedIcon from "@mui/icons-material/AddPhotoAlternateOutlined";
+import CheckIcon from "@mui/icons-material/Check";
+import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
+import ShareIcon from "@mui/icons-material/Share";
+import { Box, Button, IconButton, styled } from "@mui/material";
+import { EnteLogo } from "ente-base/components/EnteLogo";
+import { useIsTouchscreen } from "ente-base/components/utils/hooks";
+import { Notification } from "ente-new/photos/components/Notification";
+import { t } from "i18next";
+import { useState } from "react";
+
+interface MobileNavBarProps {
+ onAddPhotos?: () => void;
+ downloadAllFiles: () => void;
+ enableDownload?: boolean;
+}
+
+export const MobileNavBar: React.FC<MobileNavBarProps> = ({
+ onAddPhotos,
+ downloadAllFiles,
+ enableDownload,
+}) => {
+ const [showCopiedMessage, setShowCopiedMessage] = useState(false);
+ const isTouchscreen = useIsTouchscreen();
+
+ const handleShare = () => {
+ if (typeof window !== "undefined") {
+ void navigator.clipboard.writeText(window.location.href);
+ setShowCopiedMessage(true);
+ setTimeout(() => setShowCopiedMessage(false), 2000);
+ }
+ };
+
+ const handleSignUp = () => {
+ if (typeof window !== "undefined") {
+ window.open("https://ente.io", "_blank", "noopener,noreferrer");
+ }
+ };
+
+ return (
+ <>
+ <MobileNavContainer>
+ <LogoContainer>
+ <EnteLogo />
+ </LogoContainer>
+
+ <ButtonGroup>
+ <MobileNavButton onClick={handleShare}>
+ <ShareIcon sx={{ fontSize: "15px" }} />
+ </MobileNavButton>
+
+ {onAddPhotos && (
+ <MobileNavButton onClick={onAddPhotos}>
+ <AddPhotoAlternateOutlinedIcon
+ sx={{ fontSize: "16px" }}
+ />
+ </MobileNavButton>
+ )}
+
+ {enableDownload && (
+ <MobileNavButton onClick={downloadAllFiles}>
+ <FileDownloadOutlinedIcon
+ sx={{ fontSize: "18px" }}
+ />
+ </MobileNavButton>
+ )}
+
+ <MobileSignUpButton onClick={handleSignUp}>
+ {isTouchscreen ? t("install") : t("sign_up")}
+ </MobileSignUpButton>
+ </ButtonGroup>
+ </MobileNavContainer>
+
+ <Notification
+ open={showCopiedMessage}
+ onClose={() => setShowCopiedMessage(false)}
+ horizontal="left"
+ attributes={{
+ color: "secondary",
+ startIcon: <CheckIcon />,
+ title: "Copied!",
+ }}
+ />
+ </>
+ );
+};
+
+const MobileNavContainer = styled(Box)({
+ position: "fixed",
+ top: 0,
+ left: 0,
+ right: 0,
+ height: "60px",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "space-between",
+ padding: "0 16px",
+ backgroundColor: "transparent",
+ zIndex: 2000,
+});
+
+const LogoContainer = styled(Box)({
+ display: "flex",
+ alignItems: "center",
+ "& svg": { height: "20px", width: "auto" },
+});
+
+const ButtonGroup = styled(Box)({
+ display: "flex",
+ alignItems: "center",
+ gap: "8px",
+});
+
+const MobileNavButton = styled(IconButton)({
+ padding: "6px",
+ backgroundColor: "rgba(255, 255, 255, 0.9)",
+ borderRadius: "6px",
+ color: "#000000",
+ transition: "background-color 0.2s",
+ backdropFilter: "blur(10px)",
+ width: "32px",
+ height: "32px",
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 1)" },
+});
+
+const MobileSignUpButton = styled(Button)({
+ padding: "6px 10px",
+ fontSize: "13px",
+ fontWeight: "600",
+ whiteSpace: "nowrap",
+ backgroundColor: "rgba(255, 255, 255, 0.9)",
+ borderRadius: "6px",
+ color: "#000000",
+ transition: "background-color 0.2s",
+ backdropFilter: "blur(10px)",
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
+ "&:hover": { backgroundColor: "rgba(255, 255, 255, 1)" },
+});
diff --git a/web/apps/photos/src/components/TripTemplate/TripMap.tsx b/web/apps/photos/src/components/TripTemplate/TripMap.tsx
index 72f6f4c9be..91306e9f28 100644
--- a/web/apps/photos/src/components/TripTemplate/TripMap.tsx
+++ b/web/apps/photos/src/components/TripTemplate/TripMap.tsx
@@ -1,4 +1,5 @@
import { Box, styled } from "@mui/material";
+import { useIsSmallWidth } from "ente-base/components/utils/hooks";
import L from "leaflet";
import dynamic from "next/dynamic";
import { MapEvents } from "./MapEvents";
@@ -57,6 +58,8 @@ export const TripMap: React.FC<TripMapProps> = ({
setTargetZoom,
onMarkerClick,
}) => {
+ const isMobile = useIsSmallWidth();
+
// Calculate super-clusters based on screen collisions
const { superClusters, visibleClusters } = detectScreenCollisions(
photoClusters,
@@ -71,9 +74,10 @@ export const TripMap: React.FC<TripMapProps> = ({
{hasPhotoData ? (
<StyledMapContainer
center={getMapCenter(photoClusters, journeyData)}
- zoom={optimalZoom}
+ zoom={isMobile ? Math.max(1, optimalZoom - 2) : optimalZoom}
scrollWheelZoom={true}
zoomControl={false}
+ attributionControl={!isMobile}
>
<MapEvents
setMapRef={setMapRef}
@@ -82,7 +86,7 @@ export const TripMap: React.FC<TripMapProps> = ({
/>
{/* Stadia Alidade Satellite - includes both imagery and labels */}
<TileLayer
- attribution='&copy; <a href="https://stadiamaps.com/">Stadia Maps</a>, &copy; <a href="https://openmaptiles.org/">OpenMapTiles</a> &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'
+ attribution={isMobile ? '' : '&copy; <a href="https://stadiamaps.com/">Stadia Maps</a>, &copy; <a href="https://openmaptiles.org/">OpenMapTiles</a> &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors'}
url="https://tiles.stadiamaps.com/tiles/alidade_satellite/{z}/{x}/{y}{r}.jpg"
maxZoom={20}
/>
@@ -100,7 +104,7 @@ export const TripMap: React.FC<TripMapProps> = ({
icon={createSuperClusterIcon(
superCluster.image, // Use representative photo (first photo of first cluster)
superCluster.clusterCount,
- 55,
+ isMobile ? 40 : 55,
isCovered,
)}
eventHandlers={{
@@ -147,7 +151,7 @@ export const TripMap: React.FC<TripMapProps> = ({
position={[avgLat, avgLng]}
icon={createIcon(
firstPhoto.image,
- 55,
+ isMobile ? 40 : 55,
"#ffffff",
cluster.length,
isCovered,
diff --git a/web/apps/photos/src/components/TripTemplate/TripStarted.tsx b/web/apps/photos/src/components/TripTemplate/TripStarted.tsx
new file mode 100644
index 0000000000..5403c7036a
--- /dev/null
+++ b/web/apps/photos/src/components/TripTemplate/TripStarted.tsx
@@ -0,0 +1,51 @@
+import { Box, styled, Typography } from "@mui/material";
+import { memo } from "react";
+
+interface TripStartedProps {
+ onRef: (el: HTMLDivElement | null) => void;
+}
+
+export const TripStarted = memo<TripStartedProps>(({ onRef }) => {
+ return (
+ <TripStartedContainer ref={onRef}>
+ <TripStartedContent>
+ <TripStartedText>Trip Started</TripStartedText>
+ </TripStartedContent>
+ <TripStartedLine />
+ </TripStartedContainer>
+ );
+});
+
+const TripStartedContainer = styled(Box)({
+ position: "relative",
+ marginBottom: "32px",
+ paddingTop: "24px",
+});
+
+const TripStartedContent = styled(Box)({
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ paddingLeft: "32px",
+ paddingRight: "32px",
+});
+
+const TripStartedText = styled(Typography)(({ theme }) => ({
+ fontSize: "18px",
+ fontWeight: "600",
+ color: theme.palette.success.main,
+ backgroundColor: theme.palette.background.paper,
+ padding: "8px 16px",
+ borderRadius: "20px",
+ border: `2px solid ${theme.palette.divider}`,
+}));
+
+const TripStartedLine = styled(Box)(({ theme }) => ({
+ position: "absolute",
+ left: "50%",
+ top: "60px",
+ bottom: "-32px",
+ width: "2px",
+ backgroundColor: theme.palette.divider,
+ transform: "translateX(-50%)",
+}));
\ No newline at end of file
diff --git a/web/apps/photos/src/components/TripTemplate/hooks/useScrollHandling.ts b/web/apps/photos/src/components/TripTemplate/hooks/useScrollHandling.ts
index ddb1d98f07..15fa13faeb 100644
--- a/web/apps/photos/src/components/TripTemplate/hooks/useScrollHandling.ts
+++ b/web/apps/photos/src/components/TripTemplate/hooks/useScrollHandling.ts
@@ -1,4 +1,5 @@
import { useCallback, useEffect, useMemo } from "react";
+import { useIsSmallWidth } from "ente-base/components/utils/hooks";
import type { JourneyPoint } from "../types";
import { throttle } from "../utils/geocoding";
@@ -37,6 +38,7 @@ export const useScrollHandling = ({
setHasUserScrolled,
setScrollProgress,
}: UseScrollHandlingParams) => {
+ const isMobile = useIsSmallWidth();
// Update location positions callback
const updatePositions = useCallback(() => {
updateLocationPositions({
@@ -56,6 +58,7 @@ export const useScrollHandling = ({
setHasUserScrolled,
setScrollProgress,
previousActiveLocationRef,
+ isMobile,
});
}, [
timelineRef,
@@ -66,6 +69,7 @@ export const useScrollHandling = ({
setHasUserScrolled,
setScrollProgress,
previousActiveLocationRef,
+ isMobile,
]);
// Throttled scroll handler
@@ -101,6 +105,7 @@ export const useScrollHandling = ({
setScrollProgress,
setHasUserScrolled,
scrollTimelineToLocation: scrollToLocation,
+ isMobile,
});
},
[
@@ -111,6 +116,7 @@ export const useScrollHandling = ({
setScrollProgress,
setHasUserScrolled,
scrollToLocation,
+ isMobile,
],
);
diff --git a/web/apps/photos/src/components/TripTemplate/index.tsx b/web/apps/photos/src/components/TripTemplate/index.tsx
index e8f0dfb94b..48437d33c3 100644
--- a/web/apps/photos/src/components/TripTemplate/index.tsx
+++ b/web/apps/photos/src/components/TripTemplate/index.tsx
@@ -1,5 +1,6 @@
import { Box, styled } from "@mui/material";
import { DownloadStatusNotifications } from "components/DownloadStatusNotifications";
+import { useIsSmallWidth } from "ente-base/components/utils/hooks";
import { useSaveGroups } from "ente-gallery/components/utils/save-groups";
import { FileViewer } from "ente-gallery/components/viewer/FileViewer";
import { downloadAndSaveCollectionFiles } from "ente-gallery/services/save";
@@ -9,12 +10,15 @@ import L from "leaflet";
import { useEffect, useMemo, useRef, useState } from "react";
// Import extracted components
+import { MobileCover } from "./MobileCover";
+import { MobileNavBar } from "./MobileNavBar";
import { TimelineBaseLine } from "./TimelineBaseLine";
import { TimelineLocation } from "./TimelineLocation";
import { TimelineProgressLine } from "./TimelineProgressLine";
import { TopNavButtons } from "./TopNavButtons";
import { TripCover } from "./TripCover";
import { TripMap } from "./TripMap";
+import { TripStarted } from "./TripStarted";
// Import hooks
import { useDataProcessing } from "./hooks/useDataProcessing";
@@ -53,6 +57,9 @@ export const TripTemplate: React.FC<TripTemplateProps> = ({
// Extract collection info if available
const collectionTitle = collection?.name || albumTitle || "Trip";
+ // Check if mobile screen
+ const isMobile = useIsSmallWidth();
+
// Save groups hook for download progress tracking
const { saveGroups, onAddSaveGroup, onRemoveSaveGroup } = useSaveGroups();
@@ -88,11 +95,13 @@ export const TripTemplate: React.FC<TripTemplateProps> = ({
const [targetZoom, setTargetZoom] = useState<number | null>(null);
const [scrollProgress, setScrollProgress] = useState(0); // 0 to 1 representing scroll progress
const [hasUserScrolled, setHasUserScrolled] = useState(false); // Track if user has actually scrolled
+ const [showMobileCover, setShowMobileCover] = useState(true); // Track mobile cover state
const [locationPositions, setLocationPositions] = useState<PositionInfo[]>(
[],
);
const timelineRef = useRef<HTMLDivElement>(null);
const locationRefs = useRef<(HTMLDivElement | null)[]>([]);
+ const tripStartedRef = useRef<HTMLDivElement | null>(null);
const isClusterClickScrollingRef = useRef(false); // Use ref for immediate updates
const clusterClickTimeoutRef = useRef<NodeJS.Timeout | null>(null); // Timeout for cluster clicks
const thumbnailsGeneratedRef = useRef(false); // Track if thumbnails have been generated
@@ -175,7 +184,23 @@ export const TripTemplate: React.FC<TripTemplateProps> = ({
clusterClickTimeoutRef,
previousActiveLocationRef,
setLocationPositions,
- setHasUserScrolled,
+ setHasUserScrolled: (scrolled: boolean) => {
+ setHasUserScrolled(scrolled);
+ if (isMobile && tripStartedRef.current && timelineRef.current) {
+ const timelineContainer = timelineRef.current;
+ const tripStartedElement = tripStartedRef.current;
+ const tripStartedRect = tripStartedElement.getBoundingClientRect();
+ const timelineRect = timelineContainer.getBoundingClientRect();
+
+ // Show/hide cover based on trip started position
+ const threshold = timelineRect.top + timelineRect.height * 0.3;
+ if (tripStartedRect.bottom < threshold) {
+ setShowMobileCover(false);
+ } else {
+ setShowMobileCover(true);
+ }
+ }
+ },
setScrollProgress,
});
@@ -191,14 +216,136 @@ export const TripTemplate: React.FC<TripTemplateProps> = ({
return (
<TripTemplateContainer>
{!openFileViewer && (
- <TopNavButtons
- onAddPhotos={onAddPhotos}
- downloadAllFiles={downloadAllFiles}
- enableDownload={enableDownload}
- />
+ isMobile ? (
+ <MobileNavBar
+ onAddPhotos={onAddPhotos}
+ downloadAllFiles={downloadAllFiles}
+ enableDownload={enableDownload}
+ />
+ ) : (
+ <TopNavButtons
+ onAddPhotos={onAddPhotos}
+ downloadAllFiles={downloadAllFiles}
+ enableDownload={enableDownload}
+ />
+ )
)}
- {/* Left Sidebar - Floating Timeline */}
- <TimelineSidebar ref={timelineRef}>
+ {/* Mobile Layout */}
+ {isMobile ? (
+ <MobileContainer>
+ {/* Map takes 60% of height */}
+ <MobileMapContainer>
+ <TripMap
+ journeyData={journeyData}
+ photoClusters={photoClusters}
+ hasPhotoData={hasPhotoData}
+ optimalZoom={optimalZoom}
+ currentZoom={currentZoom}
+ targetZoom={targetZoom}
+ mapRef={mapRef}
+ scrollProgress={scrollProgress}
+ setMapRef={setMapRef}
+ setCurrentZoom={setCurrentZoom}
+ setTargetZoom={setTargetZoom}
+ onMarkerClick={markerClickHandler}
+ />
+ {/* Cover overlay */}
+ {!isInitialLoad && journeyData.length > 0 && (
+ <MobileCoverOverlay show={showMobileCover}>
+ <MobileCover
+ journeyData={journeyData}
+ photoClusters={photoClusters}
+ albumTitle={collectionTitle}
+ coverImageUrl={coverImageUrl}
+ />
+ </MobileCoverOverlay>
+ )}
+ </MobileMapContainer>
+
+ {/* Timeline takes 40% of height */}
+ <MobileTimelineContainer ref={timelineRef}>
+ <TimelineContent>
+ {isInitialLoad ? (
+ <LoadingCoverPlaceholder>
+ <LoadingCoverImage>
+ <CoverGradientOverlay />
+ <CoverPlaceholderContent>
+ <PlaceholderTextBox
+ sx={{
+ height: "30px",
+ width: "200px",
+ mb: "2px",
+ }}
+ />
+ <PlaceholderTextBox
+ sx={{
+ height: "16px",
+ width: "120px",
+ margin: 0,
+ }}
+ />
+ </CoverPlaceholderContent>
+ </LoadingCoverImage>
+ <LoadingSpinnerContainer>
+ <LoadingSpinner />
+ </LoadingSpinnerContainer>
+ </LoadingCoverPlaceholder>
+ ) : journeyData.length > 0 ? (
+ <div>
+ {isLoadingLocations ? (
+ <LocationsLoadingContainer>
+ <LoadingSpinner />
+ </LocationsLoadingContainer>
+ ) : (
+ <>
+ <TripStarted
+ onRef={(el) => {
+ tripStartedRef.current = el;
+ }}
+ />
+
+ <TimelineContainer id="timeline-container">
+ <TimelineBaseLine
+ locationPositions={locationPositions}
+ />
+
+ <TimelineProgressLine
+ locationPositions={locationPositions}
+ scrollProgress={scrollProgress}
+ hasUserScrolled={hasUserScrolled}
+ photoClusters={photoClusters}
+ />
+
+ {photoClusters.map((cluster, index) => (
+ <TimelineLocation
+ key={index}
+ cluster={cluster}
+ index={index}
+ photoClusters={photoClusters}
+ scrollProgress={scrollProgress}
+ journeyData={journeyData}
+ onRef={(el) => {
+ locationRefs.current[index] = el;
+ }}
+ onPhotoClick={handleOpenFileViewer}
+ />
+ ))}
+ </TimelineContainer>
+ </>
+ )}
+ </div>
+ ) : (
+ <NoPhotosContainer>
+ No photos found with location information.
+ </NoPhotosContainer>
+ )}
+ </TimelineContent>
+ </MobileTimelineContainer>
+ </MobileContainer>
+ ) : (
+ <>
+ {/* Desktop Layout - Left Sidebar - Floating Timeline */}
+ <TimelineSidebar ref={timelineRef}>
<TimelineContent>
{isInitialLoad ? (
<LoadingCoverPlaceholder>
@@ -283,24 +430,26 @@ export const TripTemplate: React.FC<TripTemplateProps> = ({
No photos found with location information.
</NoPhotosContainer>
)}
- </TimelineContent>
- </TimelineSidebar>
-
- {/* Map Container */}
- <TripMap
- journeyData={journeyData}
- photoClusters={photoClusters}
- hasPhotoData={hasPhotoData}
- optimalZoom={optimalZoom}
- currentZoom={currentZoom}
- targetZoom={targetZoom}
- mapRef={mapRef}
- scrollProgress={scrollProgress}
- setMapRef={setMapRef}
- setCurrentZoom={setCurrentZoom}
- setTargetZoom={setTargetZoom}
- onMarkerClick={markerClickHandler}
- />
+ </TimelineContent>
+ </TimelineSidebar>
+
+ {/* Desktop Map Container */}
+ <TripMap
+ journeyData={journeyData}
+ photoClusters={photoClusters}
+ hasPhotoData={hasPhotoData}
+ optimalZoom={optimalZoom}
+ currentZoom={currentZoom}
+ targetZoom={targetZoom}
+ mapRef={mapRef}
+ scrollProgress={scrollProgress}
+ setMapRef={setMapRef}
+ setCurrentZoom={setCurrentZoom}
+ setTargetZoom={setTargetZoom}
+ onMarkerClick={markerClickHandler}
+ />
+ </>
+ )}
{/* FileViewer for photo gallery */}
<FileViewer
@@ -448,3 +597,47 @@ const NoPhotosContainer = styled(Box)(({ theme }) => ({
color: theme.palette.text.secondary,
fontSize: "16px",
}));
+
+// Mobile specific styled components
+const MobileContainer = styled(Box)({
+ display: "flex",
+ flexDirection: "column",
+ height: "100vh",
+ width: "100%",
+});
+
+const MobileMapContainer = styled(Box)({
+ height: "60%",
+ position: "relative",
+ overflow: "hidden",
+});
+
+const MobileTimelineContainer = styled(Box)(({ theme }) => ({
+ height: "40%",
+ overflow: "auto",
+ backgroundColor: theme.palette.background.paper,
+ boxShadow: `0 -4px 20px rgba(0, 0, 0, 0.1)`,
+ "&::-webkit-scrollbar": { width: "6px" },
+ "&::-webkit-scrollbar-track": {
+ background: "transparent",
+ },
+ "&::-webkit-scrollbar-thumb": {
+ background: theme.palette.divider,
+ borderRadius: "20px",
+ "&:hover": { background: theme.palette.text.disabled },
+ },
+ scrollbarWidth: "thin",
+ scrollbarColor: `${theme.palette.divider} transparent`,
+}));
+
+const MobileCoverOverlay = styled(Box)<{ show: boolean }>(({ show }) => ({
+ position: "absolute",
+ top: 0,
+ left: 0,
+ right: 0,
+ bottom: 0,
+ zIndex: 1000,
+ opacity: show ? 1 : 0,
+ transition: "opacity 0.5s ease-in-out",
+ pointerEvents: show ? "auto" : "none",
+}));
diff --git a/web/apps/photos/src/components/TripTemplate/utils/scrollUtils.ts b/web/apps/photos/src/components/TripTemplate/utils/scrollUtils.ts
index a7d5c691e4..989da2b414 100644
--- a/web/apps/photos/src/components/TripTemplate/utils/scrollUtils.ts
+++ b/web/apps/photos/src/components/TripTemplate/utils/scrollUtils.ts
@@ -42,6 +42,7 @@ export interface HandleTimelineScrollParams {
setHasUserScrolled: (scrolled: boolean) => void;
setScrollProgress: (progress: number) => void;
previousActiveLocationRef: React.RefObject<number>;
+ isMobile: boolean;
}
export const handleTimelineScroll = ({
@@ -53,6 +54,7 @@ export const handleTimelineScroll = ({
setHasUserScrolled,
setScrollProgress,
previousActiveLocationRef,
+ isMobile,
}: HandleTimelineScrollParams) => {
if (
!timelineRef.current ||
@@ -95,7 +97,7 @@ export const handleTimelineScroll = ({
const previousActiveLocationIndex = previousActiveLocationRef.current;
// Only pan map when active location changes (discrete panning)
- if (mapRef && currentActiveLocationIndex !== previousActiveLocationIndex) {
+ if (mapRef && mapRef.getContainer() && mapRef._loaded && currentActiveLocationIndex !== previousActiveLocationIndex) {
previousActiveLocationRef.current = currentActiveLocationIndex;
const clusterCenters = photoClusters.map((cluster) => {
@@ -125,16 +127,17 @@ export const handleTimelineScroll = ({
}
}
- const targetZoom = 10; // Fixed zoom level
+ const targetZoom = isMobile ? 8 : 10; // Mobile-aware zoom level
if (isDistantLocation) {
// For distant locations: zoom out β†’ pan β†’ zoom in
- mapRef.flyTo([positionedLat, positionedLng], 4, {
+ const intermediateZoom = isMobile ? 2 : 4;
+ mapRef.flyTo([positionedLat, positionedLng], intermediateZoom, {
animate: true,
duration: 1.5,
easeLinearity: 0.25,
});
-
+
setTimeout(() => {
mapRef.flyTo([positionedLat, positionedLng], targetZoom, {
animate: true,
@@ -209,6 +212,7 @@ export interface HandleMarkerClickParams {
setScrollProgress: (progress: number) => void;
setHasUserScrolled: (scrolled: boolean) => void;
scrollTimelineToLocation: (locationIndex: number) => void;
+ isMobile: boolean;
}
export const handleMarkerClick = ({
@@ -222,6 +226,7 @@ export const handleMarkerClick = ({
setScrollProgress,
setHasUserScrolled,
scrollTimelineToLocation,
+ isMobile,
}: HandleMarkerClickParams) => {
const targetProgress = clusterIndex / Math.max(1, photoClusters.length - 1);
@@ -236,8 +241,8 @@ export const handleMarkerClick = ({
// Position clicked location at 20% from right edge
const [positionedLat, positionedLng] = getLocationPosition(clusterLat, clusterLng);
- if (mapRef) {
- const targetZoom = 10; // Fixed zoom level
+ if (mapRef && mapRef.getContainer() && mapRef._loaded) {
+ const targetZoom = isMobile ? 8 : 10; // Mobile-aware zoom level
mapRef.flyTo([positionedLat, positionedLng], targetZoom, {
animate: true,
duration: 1.0,