Skip to content

armgit / ente

Public Imported from GitHub
0

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

chore: mobile trip timeline changes

anandbaburajana9d2b4b28971
diff --git a/web/apps/photos/src/components/TripTemplate/MobileTimelineLocation.tsx b/web/apps/photos/src/components/TripTemplate/MobileTimelineLocation.tsx
new file mode 100644
index 0000000000..1244b7059d
--- /dev/null
+++ b/web/apps/photos/src/components/TripTemplate/MobileTimelineLocation.tsx
@@ -0,0 +1,212 @@
+import { Box, Typography, styled } from "@mui/material";
+import { memo } from "react";
+import { PhotoFan } from "./PhotoFan";
+import type { JourneyPoint } from "./types";
+
+interface MobileTimelineLocationProps {
+ cluster: JourneyPoint[];
+ index: number;
+ photoClusters: JourneyPoint[][];
+ scrollProgress: number;
+ journeyData: JourneyPoint[];
+ onRef: (el: HTMLDivElement | null) => void;
+ onPhotoClick?: (cluster: JourneyPoint[], fileId: number) => void;
+}
+
+export const MobileTimelineLocation = memo<MobileTimelineLocationProps>(
+ ({
+ cluster,
+ index,
+ photoClusters,
+ scrollProgress,
+ journeyData,
+ onRef,
+ onPhotoClick,
+ }) => {
+ const firstPhoto = cluster[0];
+ if (!firstPhoto) return null;
+
+ const sortedData = [...journeyData].sort(
+ (a, b) =>
+ new Date(a.timestamp).getTime() -
+ new Date(b.timestamp).getTime(),
+ );
+ const firstData = sortedData[0];
+ if (!firstData) return null;
+ const firstDate = new Date(firstData.timestamp);
+ const photoDate = new Date(firstPhoto.timestamp);
+
+ const firstDateOnly = new Date(
+ firstDate.getFullYear(),
+ firstDate.getMonth(),
+ firstDate.getDate(),
+ );
+ const photoDateOnly = new Date(
+ photoDate.getFullYear(),
+ photoDate.getMonth(),
+ photoDate.getDate(),
+ );
+ const diffTime = photoDateOnly.getTime() - firstDateOnly.getTime();
+ const dayNumber = Math.floor(diffTime / (1000 * 60 * 60 * 24)) + 1;
+
+ // Show green for all covered locations (up to current position)
+ const currentLocationIndex = Math.round(scrollProgress * Math.max(0, photoClusters.length - 1));
+ const isCovered = index <= currentLocationIndex;
+
+ return (
+ <MobileLocationContainer
+ ref={onRef}
+ id={`location-${index}`}
+ className="timeline-location"
+ >
+ {/* Centered Photo Fan Container */}
+ <CenteredPhotoContainer>
+ <PhotoFanWrapper>
+ <PhotoFan
+ cluster={cluster}
+ onPhotoClick={onPhotoClick}
+ />
+
+ {/* Overlay text on top of main photo */}
+ <PhotoOverlay>
+ <DayBadge>
+ DAY {dayNumber} β€’{" "}
+ {new Date(firstPhoto.timestamp)
+ .toLocaleDateString("en-US", {
+ month: "long",
+ day: "numeric",
+ })
+ .toUpperCase()}
+ </DayBadge>
+ <LocationTitle>
+ {firstPhoto.name}
+ </LocationTitle>
+ <LocationCountry>
+ {firstPhoto.country}
+ </LocationCountry>
+ </PhotoOverlay>
+ </PhotoFanWrapper>
+ </CenteredPhotoContainer>
+
+ {/* Dots positioned after the photo fan */}
+ <DotsContainer>
+ <DotBackground />
+ <TimelineDot isReached={isCovered} />
+ </DotsContainer>
+ </MobileLocationContainer>
+ );
+ },
+);
+
+// Styled components
+const MobileLocationContainer = styled(Box)({
+ position: "relative",
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ justifyContent: "center",
+ width: "100%",
+ minHeight: "100vh",
+ scrollSnapAlign: "start",
+ padding: "40px 20px",
+});
+
+const CenteredPhotoContainer = styled(Box)({
+ position: "relative",
+ display: "flex",
+ justifyContent: "center",
+ marginBottom: "16px",
+});
+
+const PhotoFanWrapper = styled(Box)({
+ position: "relative",
+ width: "180px",
+ height: "240px",
+});
+
+const PhotoOverlay = styled(Box)({
+ position: "absolute",
+ bottom: "0",
+ left: "0",
+ right: "0",
+ zIndex: 30,
+ pointerEvents: "none",
+ background: "linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.3), transparent)",
+ borderRadius: "0 0 14px 14px",
+ padding: "24px 16px 16px 16px",
+});
+
+const DotsContainer = styled(Box)({
+ position: "relative",
+ width: "32px",
+ height: "32px",
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ marginTop: "32px",
+});
+
+const DotBackground = styled(Box)(({ theme }) => ({
+ position: "absolute",
+ width: "32px",
+ height: "32px",
+ borderRadius: "50%",
+ zIndex: 10,
+ backgroundColor: theme.palette.background.paper,
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
+}));
+
+const TimelineDot = styled(Box, {
+ shouldForwardProp: (prop) => prop !== 'isReached',
+})<{ isReached: boolean }>(
+ ({ theme, isReached }) => ({
+ position: "absolute",
+ borderRadius: "50%",
+ border: `3px solid ${theme.palette.background.paper}`,
+ zIndex: 20,
+ width: "16px",
+ height: "16px",
+ transition: "all 0.3s",
+ backgroundColor: isReached
+ ? theme.palette.success.main
+ : theme.palette.text.primary,
+ boxShadow: isReached
+ ? `0 0 0 4px ${theme.palette.success.main}30, 0 0 0 8px ${theme.palette.success.main}15`
+ : "0 2px 8px rgba(0, 0, 0, 0.2)",
+ }),
+);
+
+const DayBadge = styled(Box)(({ theme }) => ({
+ display: "inline-flex",
+ alignItems: "center",
+ backgroundColor: "rgba(255, 255, 255, 0.95)",
+ border: `1px solid ${theme.palette.grey[300]}`,
+ borderRadius: "8px",
+ padding: "4px 12px",
+ marginBottom: "8px",
+ fontSize: "10px",
+ fontWeight: "600",
+ color: theme.palette.text.secondary,
+ textTransform: "uppercase",
+ letterSpacing: "0.15em",
+ backdropFilter: "blur(10px)",
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
+}));
+
+const LocationTitle = styled(Typography)(() => ({
+ fontSize: "18px",
+ fontWeight: "600",
+ color: "white",
+ margin: "0 0 4px 0",
+ lineHeight: "1.2",
+ textShadow: "0 2px 8px rgba(0, 0, 0, 0.5)",
+ component: "h3",
+}));
+
+const LocationCountry = styled(Typography)(() => ({
+ fontSize: "13px",
+ color: "rgba(255, 255, 255, 0.9)",
+ margin: "0",
+ textShadow: "0 1px 4px rgba(0, 0, 0, 0.5)",
+ component: "p",
+}));
\ No newline at end of file
diff --git a/web/apps/photos/src/components/TripTemplate/MobileTripStarted.tsx b/web/apps/photos/src/components/TripTemplate/MobileTripStarted.tsx
new file mode 100644
index 0000000000..44b26e6ee6
--- /dev/null
+++ b/web/apps/photos/src/components/TripTemplate/MobileTripStarted.tsx
@@ -0,0 +1,58 @@
+import { Box, styled, Typography } from "@mui/material";
+import { memo } from "react";
+
+interface MobileTripStartedProps {
+ onRef: (el: HTMLDivElement | null) => void;
+}
+
+export const MobileTripStarted = memo<MobileTripStartedProps>(({ onRef }) => {
+ return (
+ <MobileTripStartedContainer ref={onRef}>
+ <MobileTripStartedContent>
+ <MobileTripStartedText>Trip Started</MobileTripStartedText>
+ </MobileTripStartedContent>
+ <MobileTripStartedLine />
+ </MobileTripStartedContainer>
+ );
+});
+
+const MobileTripStartedContainer = styled(Box)({
+ position: "relative",
+ minHeight: "100vh",
+ display: "flex",
+ flexDirection: "column",
+ alignItems: "center",
+ justifyContent: "center",
+ scrollSnapAlign: "start",
+ padding: "40px 20px",
+});
+
+const MobileTripStartedContent = styled(Box)({
+ display: "flex",
+ alignItems: "center",
+ justifyContent: "center",
+ marginBottom: "60px",
+});
+
+const MobileTripStartedText = styled(Typography)(({ theme }) => ({
+ fontSize: "24px",
+ fontWeight: "600",
+ color: theme.palette.success.main,
+ backgroundColor: theme.palette.background.paper,
+ padding: "16px 32px",
+ borderRadius: "30px",
+ border: `3px solid ${theme.palette.success.main}`,
+ boxShadow: "0 4px 20px rgba(0, 0, 0, 0.1)",
+ textAlign: "center",
+}));
+
+const MobileTripStartedLine = styled(Box)(({ theme }) => ({
+ position: "absolute",
+ left: "50%",
+ top: "70%",
+ bottom: "0",
+ width: "4px",
+ backgroundColor: theme.palette.success.main,
+ transform: "translateX(-50%)",
+ borderRadius: "2px",
+}));
\ No newline at end of file
diff --git a/web/apps/photos/src/components/TripTemplate/PhotoFan.tsx b/web/apps/photos/src/components/TripTemplate/PhotoFan.tsx
index 8f5a2fa0c0..2f96e48577 100644
--- a/web/apps/photos/src/components/TripTemplate/PhotoFan.tsx
+++ b/web/apps/photos/src/components/TripTemplate/PhotoFan.tsx
@@ -180,7 +180,7 @@ const ImageWrapper = styled(Box)({
const CountBadge = styled(Box)({
position: "absolute",
- bottom: "6px",
+ top: "6px",
right: "6px",
background: "white",
color: "black",
diff --git a/web/apps/photos/src/components/TripTemplate/TripCover.tsx b/web/apps/photos/src/components/TripTemplate/TripCover.tsx
index fe36255c0d..c4340af384 100644
--- a/web/apps/photos/src/components/TripTemplate/TripCover.tsx
+++ b/web/apps/photos/src/components/TripTemplate/TripCover.tsx
@@ -116,11 +116,11 @@ const GradientOverlay = styled(Box)({
"linear-gradient(to bottom, rgba(0,0,0,0.4), transparent 30%, transparent 70%, rgba(0,0,0,0.7))",
});
-const LogoContainer = styled(Box)(({ theme }) => ({
+const LogoContainer = styled(Box)(() => ({
position: "absolute",
top: "20px",
left: "20px",
- color: theme.palette.success.main,
+ color: "white",
}));
const ContentContainer = styled(Box)({
diff --git a/web/apps/photos/src/components/TripTemplate/TripStarted.tsx b/web/apps/photos/src/components/TripTemplate/TripStarted.tsx
deleted file mode 100644
index 5403c7036a..0000000000
--- a/web/apps/photos/src/components/TripTemplate/TripStarted.tsx
+++ /dev/null
@@ -1,51 +0,0 @@
-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/index.tsx b/web/apps/photos/src/components/TripTemplate/index.tsx
index 48437d33c3..7dd3744587 100644
--- a/web/apps/photos/src/components/TripTemplate/index.tsx
+++ b/web/apps/photos/src/components/TripTemplate/index.tsx
@@ -12,13 +12,14 @@ import { useEffect, useMemo, useRef, useState } from "react";
// Import extracted components
import { MobileCover } from "./MobileCover";
import { MobileNavBar } from "./MobileNavBar";
+import { MobileTimelineLocation } from "./MobileTimelineLocation";
+import { MobileTripStarted } from "./MobileTripStarted";
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";
@@ -298,26 +299,15 @@ export const TripTemplate: React.FC<TripTemplateProps> = ({
</LocationsLoadingContainer>
) : (
<>
- <TripStarted
+ <MobileTripStarted
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
+ <MobileTimelineLocation
key={index}
cluster={cluster}
index={index}
@@ -617,6 +607,7 @@ const MobileTimelineContainer = styled(Box)(({ theme }) => ({
overflow: "auto",
backgroundColor: theme.palette.background.paper,
boxShadow: `0 -4px 20px rgba(0, 0, 0, 0.1)`,
+ scrollSnapType: "y mandatory",
"&::-webkit-scrollbar": { width: "6px" },
"&::-webkit-scrollbar-track": {
background: "transparent",