π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add social notifications screen
Anand Baburajan07fbffc39c11
diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsxindex 97652d43af..c3402d9221 100644--- a/web/apps/social/src/pages/index.tsx+++ b/web/apps/social/src/pages/index.tsx@@ -9,6 +9,10 @@ import {import { FriendsScreen, friendsBackground } from "screens/FriendsScreen";import { HomeScreen, homeBackground } from "screens/HomeScreen";import { LoginScreen, loginBackground } from "screens/LoginScreen";+import {+ NotificationsScreen,+ notificationsBackground,+} from "screens/NotificationsScreen";import {OnboardingScreen,addFriendOnboardingDescription,@@ -43,11 +47,12 @@ type Screen =| "home"| "profile"| "friends"+ | "notifications"| "friend-profile"| "settings";type ProfileBackScreen = "login" | "verify-email";-type FriendProfileBackScreen = "friends" | "home";+type FriendProfileBackScreen = "friends" | "home" | "notifications";type OnboardingEntrySource = "direct" | "add-friend-link";const onboardingSourceSearchParam = "onboardingSource";@@ -181,9 +186,11 @@ const Page: React.FC = () => {? profileBackground: screen == "friends" || screen == "friend-profile"? friendsBackground- : screen == "settings"- ? settingsBackground- : createAccountBackground;+ : screen == "notifications"+ ? notificationsBackground+ : screen == "settings"+ ? settingsBackground+ : createAccountBackground;return (<>@@ -285,6 +292,9 @@ const Page: React.FC = () => {onOpenFriend={(friendID) =>openFriendProfile(friendID, "home")}+ onOpenNotifications={() =>+ setScreen("notifications")+ }onOpenProfile={() => setScreen("profile")}/>)}@@ -313,6 +323,14 @@ const Page: React.FC = () => {}/>)}+ {screen == "notifications" && (+ <NotificationsScreen+ onBack={() => setScreen("home")}+ onOpenFriend={(friendID) =>+ openFriendProfile(friendID, "notifications")+ }+ />+ )}{screen == "friend-profile" && selectedFriend && (<ProfileScreenfriendsCount={selectedFriend.friendsCount}diff --git a/web/apps/social/src/screens/FriendsScreen.tsx b/web/apps/social/src/screens/FriendsScreen.tsxindex ab037c0a7f..f64440c359 100644--- a/web/apps/social/src/screens/FriendsScreen.tsx+++ b/web/apps/social/src/screens/FriendsScreen.tsx@@ -374,6 +374,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({display: "flex",height: 24,justifyContent: "flex-start",+ ml: "-2px",p: 0,width: 24,"&:focus-visible": {diff --git a/web/apps/social/src/screens/HomeScreen.tsx b/web/apps/social/src/screens/HomeScreen.tsxindex 2255dfabe9..7671c5dbf0 100644--- a/web/apps/social/src/screens/HomeScreen.tsx+++ b/web/apps/social/src/screens/HomeScreen.tsx@@ -32,6 +32,12 @@ const feedCardBackground = "#F5F5F5";const textBase = "#000";const textSecondary = "#6B6B6B";const feedAvatarSize = 26;+const headerActionSize = 32;+const headerActionGap = 8;+const headerAddIconSize = 24;+const headerAvatarSize = 23;+const headerIconSize = 25;+const headerSideWidth = headerActionSize * 2 + headerActionGap;const minutesAgo = (minutes: number) => Date.now() - minutes * 60 * 1000;const hoursAgo = (hours: number) => minutesAgo(hours * 60);@@ -178,6 +184,7 @@ const sampleFeedItems = [interface HomeScreenProps {friendsCount: number;onOpenFriend?: (friendID: string) => void;+ onOpenNotifications?: () => void;onOpenProfile?: () => void;profile: SetupProfile;}@@ -559,6 +566,7 @@ const FeedItem: React.FC<FeedItemProps> = ({export const HomeScreen: React.FC<HomeScreenProps> = ({friendsCount,onOpenFriend,+ onOpenNotifications,onOpenProfile,profile,}) => {@@ -670,8 +678,12 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({sx={{alignItems: "center",display: "grid",- gridTemplateColumns: "32px 1fr 32px",- p: 2,+ gap: "12px",+ gridTemplateColumns: `${headerSideWidth}px minmax(0, 1fr) ${headerSideWidth}px`,+ boxSizing: "border-box",+ pb: 2,+ pt: 1.5,+ px: 1.25,width: "100%",}}>@@ -706,21 +718,18 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({postActionPhase == null ? "pointer" : "default",display: "flex",fontSize: 0,- height: 32,+ height: headerActionSize,justifyContent: "center",- justifySelf: "flex-start",lineHeight: 0,+ ml: 0,opacity: 1,p: 0,placeSelf: "center start",- width: 28,+ width: headerActionSize,transition: `color ${socialActionTransition}`,- "& svg": {- display: "block",- transform: "translateX(-2px)",- },+ "& svg": { display: "block" },"&:focus-visible": {- borderRadius: "6px",+ borderRadius: "50%",outline: `2px solid ${green}`,outlineOffset: 2,},@@ -730,12 +739,12 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({idleIcon={<HugeiconsIconicon={AddSquareIcon}- size={28}+ size={headerAddIconSize}strokeWidth={1.8}/>}phase={postActionFeedbackPhase}- size={28}+ size={headerAddIconSize}/></Box><Box@@ -744,6 +753,7 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({color: textBase,justifySelf: "center",lineHeight: 0,+ minWidth: 0,overflow: "visible",placeSelf: "center",width: 58,@@ -753,64 +763,125 @@ export const HomeScreen: React.FC<HomeScreenProps> = ({<EnteLogo height={18} /></Box><Box- component="button"- type="button"- aria-label="Open profile"- onClick={onOpenProfile}sx={{- appearance: "none",alignItems: "center",- bgcolor: profile.avatarUrl- ? "transparent"- : paleGreen,- border: 0,- borderRadius: "50%",- boxSizing: "border-box",- color: green,- cursor: onOpenProfile ? "pointer" : "default",display: "flex",- height: feedAvatarSize,- justifyContent: "center",+ gap: `${headerActionGap}px`,+ justifyContent: "flex-end",justifySelf: "flex-end",- lineHeight: 0,- placeSelf: "center end",- overflow: "hidden",- p: 0,- width: feedAvatarSize,- "&:focus-visible": {- outline: `2px solid ${green}`,- outlineOffset: 2,- },+ minWidth: 0,+ width: "100%",}}>- {profile.avatarUrl ? (- <Box- component="img"- alt=""- src={profile.avatarUrl}- sx={{- display: "block",- height: "100%",+ <Box+ component="button"+ type="button"+ aria-label="Open notifications"+ onClick={onOpenNotifications}+ sx={{+ appearance: "none",+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ boxSizing: "border-box",+ color: textBase,+ cursor: onOpenNotifications+ ? "pointer"+ : "default",+ display: "flex",+ fontSize: 0,+ height: headerActionSize,+ justifyContent: "center",+ lineHeight: 0,+ p: 0,+ width: headerActionSize,+ "& svg": { display: "block" },+ "&:focus-visible": {borderRadius: "50%",- objectFit: "cover",- objectPosition: "center",- width: "100%",- }}+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <HugeiconsIcon+ icon={FavouriteIcon}+ size={headerIconSize}+ strokeWidth={1.8}/>- ) : (+ </Box>+ <Box+ component="button"+ type="button"+ aria-label="Open profile"+ onClick={onOpenProfile}+ sx={{+ appearance: "none",+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ borderRadius: "50%",+ boxSizing: "border-box",+ color: green,+ cursor: onOpenProfile ? "pointer" : "default",+ display: "flex",+ height: headerActionSize,+ justifyContent: "center",+ lineHeight: 0,+ overflow: "visible",+ p: 0,+ pr: "2.5px",+ width: headerActionSize,+ "&:focus-visible": {+ borderRadius: "50%",+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ ><Boxsx={{- color: green,- fontFamily:- '"Inter Variable", Inter, sans-serif',- fontSize: 10,- fontWeight: 700,- lineHeight: 1,+ alignItems: "center",+ bgcolor: profile.avatarUrl+ ? "transparent"+ : paleGreen,+ borderRadius: "50%",+ display: "flex",+ height: headerAvatarSize,+ justifyContent: "center",+ overflow: "hidden",+ width: headerAvatarSize,}}>- {initials}+ {profile.avatarUrl ? (+ <Box+ component="img"+ alt=""+ src={profile.avatarUrl}+ sx={{+ display: "block",+ height: "100%",+ borderRadius: "50%",+ objectFit: "cover",+ objectPosition: "center",+ width: "100%",+ }}+ />+ ) : (+ <Box+ sx={{+ color: green,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 9,+ fontWeight: 700,+ lineHeight: 1,+ }}+ >+ {initials}+ </Box>+ )}</Box>- )}+ </Box></Box></Box><Boxdiff --git a/web/apps/social/src/screens/NotificationsScreen.tsx b/web/apps/social/src/screens/NotificationsScreen.tsxnew file mode 100644index 0000000000..ac77115b04--- /dev/null+++ b/web/apps/social/src/screens/NotificationsScreen.tsx@@ -0,0 +1,482 @@+import {+ ArrowLeft02Icon,+ Comment01Icon,+ FavouriteIcon,+ MailReply01Icon,+ UserAdd01Icon,+} from "@hugeicons/core-free-icons";+import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";+import { Box } from "@mui/material";+import type { FriendProfile } from "data/friends";+import React from "react";+import { formatSocialDate, initialsFor } from "utils/socialDisplay";++export const notificationsBackground = "#FFFFFF";++const green = "#08C225";+const paleGreen = "#E7F6E9";+const textBase = "#000";+const textSoft = "#777777";+const timelineLine = "#E6E6E6";++type NotificationType =+ | "liked-post"+ | "commented-post"+ | "liked-comment"+ | "replied-comment"+ | "added-friend";++interface SocialNotification {+ actor: Pick<FriendProfile, "avatarUrl" | "fullName" | "id" | "username">;+ id: string;+ postThumbnailUrl?: string;+ timestampMs: number;+ type: NotificationType;+}++interface NotificationsScreenProps {+ onBack?: () => void;+ onOpenFriend?: (friendID: string) => void;+}++interface NotificationRowProps {+ notification: SocialNotification;+ onOpenFriend?: (friendID: string) => void;+}++const minutesAgo = (minutes: number) => Date.now() - minutes * 60 * 1000;+const hoursAgo = (hours: number) => minutesAgo(hours * 60);+const daysAgo = (days: number) => hoursAgo(days * 24);++const sampleActors = {+ aparna: {+ avatarUrl: "/images/sample-feed-4.jpg",+ fullName: "Aparna Bhatnagar",+ id: "aparna-bhatnagar",+ username: "aparnab",+ },+ dev: {+ avatarUrl: "/images/sample-feed-1.jpg",+ fullName: "Dev Shah",+ id: "dev-shah",+ username: "devshah",+ },+ isha: {+ avatarUrl: "/images/sample-feed-2.jpg",+ fullName: "Isha Mehta",+ id: "isha-mehta",+ username: "ishamehta",+ },+ kabir: {+ avatarUrl: "/images/sample-avatar.jpg",+ fullName: "Kabir Menon",+ id: "kabir-menon",+ username: "kabirmenon",+ },+ mira: {+ avatarUrl: "/images/sample-feed-3.jpg",+ fullName: "Mira Sen",+ id: "mira-sen",+ username: "mirasen",+ },+ nikhil: {+ avatarUrl: "/images/sample-feed-5.jpg",+ fullName: "Nikhil Rao",+ id: "nikhil-rao",+ username: "nikhilrao",+ },+ riya: {+ avatarUrl: "/images/sample-feed-6.jpg",+ fullName: "Riya Kapoor",+ id: "riya-kapoor",+ username: "riyakapoor",+ },+} satisfies Record<string, SocialNotification["actor"]>;++const sampleNotifications: SocialNotification[] = [+ {+ actor: sampleActors.mira,+ id: "mira-liked-post",+ postThumbnailUrl: "/images/sample-feed-1.jpg",+ timestampMs: minutesAgo(12),+ type: "liked-post",+ },+ {+ actor: sampleActors.aparna,+ id: "aparna-commented-post",+ postThumbnailUrl: "/images/sample-feed-portrait-2.jpg",+ timestampMs: minutesAgo(38),+ type: "commented-post",+ },+ {+ actor: sampleActors.nikhil,+ id: "nikhil-liked-comment",+ postThumbnailUrl: "/images/sample-feed-3.jpg",+ timestampMs: hoursAgo(2),+ type: "liked-comment",+ },+ {+ actor: sampleActors.riya,+ id: "riya-replied-comment",+ postThumbnailUrl: "/images/sample-feed-portrait-4.jpg",+ timestampMs: hoursAgo(5),+ type: "replied-comment",+ },+ {+ actor: sampleActors.dev,+ id: "dev-added-friend",+ timestampMs: hoursAgo(8),+ type: "added-friend",+ },+ {+ actor: sampleActors.isha,+ id: "isha-commented-post",+ postThumbnailUrl: "/images/sample-feed-6.jpg",+ timestampMs: daysAgo(1),+ type: "commented-post",+ },+ {+ actor: sampleActors.kabir,+ id: "kabir-liked-post",+ postThumbnailUrl: "/images/sample-feed-portrait-1.jpg",+ timestampMs: daysAgo(2),+ type: "liked-post",+ },+ {+ actor: sampleActors.aparna,+ id: "aparna-replied-comment",+ postThumbnailUrl: "/images/sample-feed-5.jpg",+ timestampMs: daysAgo(4),+ type: "replied-comment",+ },+ {+ actor: sampleActors.mira,+ id: "mira-added-friend",+ timestampMs: daysAgo(8),+ type: "added-friend",+ },+];++const actionForNotification = (+ type: NotificationType,+): { icon: IconSvgElement; label: string } => {+ switch (type) {+ case "liked-post":+ return { icon: FavouriteIcon, label: "liked your post" };+ case "commented-post":+ return { icon: Comment01Icon, label: "commented on your post" };+ case "liked-comment":+ return { icon: FavouriteIcon, label: "liked a comment" };+ case "replied-comment":+ return { icon: MailReply01Icon, label: "replied to a comment" };+ case "added-friend":+ return { icon: UserAdd01Icon, label: "added you as a friend" };+ }+};++const NotificationRow: React.FC<NotificationRowProps> = ({+ notification,+ onOpenFriend,+}) => {+ const { icon, label } = actionForNotification(notification.type);+ const actorName =+ notification.actor.fullName.trim() || notification.actor.username;+ const actorInitials = initialsFor(actorName || notification.actor.username);++ return (+ <Box+ component="li"+ sx={{+ alignItems: "flex-start",+ display: "flex",+ gap: "12px",+ listStyle: "none",+ mb: "40px",+ position: "relative",+ width: "100%",+ "&:last-of-type": { mb: 0 },+ "&:not(:last-of-type)::before": {+ backgroundImage: `repeating-linear-gradient(to bottom, ${timelineLine} 0px, ${timelineLine} 8px, transparent 8px, transparent 16px)`,+ borderRadius: "1px",+ bottom: "-40px",+ content: '""',+ left: "16px",+ position: "absolute",+ top: "33px",+ width: "2px",+ },+ }}+ >+ <Box+ component="button"+ type="button"+ onClick={() => onOpenFriend?.(notification.actor.id)}+ sx={{+ alignItems: "flex-start",+ appearance: "none",+ bgcolor: "transparent",+ border: 0,+ cursor: onOpenFriend ? "pointer" : "default",+ display: "flex",+ flex: 1,+ gap: "12px",+ minWidth: 0,+ p: 0,+ textAlign: "left",+ width: "100%",+ "&:focus-visible": {+ borderRadius: "12px",+ outline: `2px solid ${green}`,+ outlineOffset: -4,+ },+ }}+ >+ <Box+ sx={{+ alignItems: "center",+ bgcolor: notificationsBackground,+ borderRadius: "50%",+ color: green,+ display: "flex",+ flexShrink: 0,+ height: 33,+ justifyContent: "center",+ position: "relative",+ zIndex: 1,+ width: 33,+ }}+ >+ <HugeiconsIcon icon={icon} size={20} strokeWidth={1.8} />+ </Box>+ <Box+ sx={{+ display: "flex",+ flex: 1,+ flexDirection: "column",+ gap: "4px",+ minWidth: 0,+ }}+ >+ <Box+ sx={{+ alignItems: "center",+ display: "flex",+ flexDirection: "row",+ }}+ >+ <Box+ sx={{+ alignItems: "center",+ bgcolor: notification.actor.avatarUrl+ ? "transparent"+ : paleGreen,+ border: `2px solid ${notificationsBackground}`,+ borderRadius: "50%",+ color: green,+ boxSizing: "border-box",+ display: "flex",+ flexShrink: 0,+ height: 32,+ justifyContent: "center",+ overflow: "hidden",+ width: 32,+ }}+ >+ {notification.actor.avatarUrl ? (+ <Box+ component="img"+ alt=""+ src={notification.actor.avatarUrl}+ sx={{+ display: "block",+ height: "100%",+ objectFit: "cover",+ objectPosition: "center",+ width: "100%",+ }}+ />+ ) : (+ <Box+ sx={{+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 11,+ fontWeight: 800,+ lineHeight: 1,+ }}+ >+ {actorInitials}+ </Box>+ )}+ </Box>+ </Box>+ <Box+ sx={{+ color: textBase,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 600,+ lineHeight: "19px",+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ {actorName}+ </Box>+ <Box+ sx={{+ color: textSoft,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 13,+ fontWeight: 500,+ lineHeight: "18px",+ minWidth: 0,+ overflow: "hidden",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ }}+ >+ {label}+ <Box component="span" aria-hidden sx={{ px: "5px" }}>+ Β·+ </Box>+ <Box+ component="time"+ dateTime={new Date(+ notification.timestampMs,+ ).toISOString()}+ sx={{ display: "inline" }}+ >+ {formatSocialDate(notification.timestampMs)}+ </Box>+ </Box>+ </Box>+ {notification.postThumbnailUrl && (+ <Box+ component="img"+ alt=""+ src={notification.postThumbnailUrl}+ sx={{+ borderRadius: "8px",+ display: "block",+ flexShrink: 0,+ height: 76,+ objectFit: "cover",+ objectPosition: "center",+ width: 76,+ }}+ />+ )}+ </Box>+ </Box>+ );+};++export const NotificationsScreen: React.FC<NotificationsScreenProps> = ({+ onBack,+ onOpenFriend,+}) => (+ <Box+ component="main"+ sx={{+ bgcolor: notificationsBackground,+ boxSizing: "border-box",+ color: textBase,+ display: "grid",+ minHeight: "100svh",+ overflowX: "hidden",+ placeItems: { xs: "stretch", sm: "start center" },+ }}+ >+ <Box+ sx={{+ bgcolor: notificationsBackground,+ boxSizing: "border-box",+ minHeight: "100svh",+ mx: "auto",+ width: "100%",+ "@media (min-width: 600px)": { maxWidth: 390 },+ }}+ >+ <Box+ component="header"+ sx={{+ alignItems: "center",+ display: "grid",+ gridTemplateColumns: "24px 1fr 24px",+ height: 56,+ px: 2,+ width: "100%",+ }}+ >+ <Box+ component="button"+ type="button"+ aria-label="Back to home"+ onClick={onBack}+ sx={{+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ color: textBase,+ cursor: onBack ? "pointer" : "default",+ display: "flex",+ height: 24,+ justifyContent: "flex-start",+ ml: "-2px",+ p: 0,+ width: 24,+ "&:focus-visible": {+ borderRadius: "50%",+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <HugeiconsIcon+ icon={ArrowLeft02Icon}+ size={24}+ strokeWidth={1.8}+ />+ </Box>+ <Box+ component="h1"+ sx={{+ color: textBase,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 18,+ fontWeight: 700,+ justifySelf: "center",+ lineHeight: "24px",+ m: 0,+ }}+ >+ Notifications+ </Box>+ </Box>++ <Box+ component="ul"+ sx={{+ display: "flex",+ flexDirection: "column",+ m: 0,+ mt: "40px",+ px: "24px",+ py: 0,+ width: "100%",+ }}+ >+ {sampleNotifications.map((notification) => (+ <NotificationRow+ key={notification.id}+ notification={notification}+ onOpenFriend={onOpenFriend}+ />+ ))}+ </Box>+ </Box>+ </Box>+);diff --git a/web/apps/social/src/screens/ProfileScreen.tsx b/web/apps/social/src/screens/ProfileScreen.tsxindex 7691d594f7..1fd5161fac 100644--- a/web/apps/social/src/screens/ProfileScreen.tsx+++ b/web/apps/social/src/screens/ProfileScreen.tsx@@ -453,6 +453,7 @@ export const ProfileScreen: React.FC<ProfileScreenProps> = ({display: "flex",height: 24,justifyContent: "flex-start",+ ml: "-2px",p: 0,width: 24,"&:focus-visible": {diff --git a/web/apps/social/src/screens/SettingsScreen.tsx b/web/apps/social/src/screens/SettingsScreen.tsxindex 7df079fbbb..600a29d670 100644--- a/web/apps/social/src/screens/SettingsScreen.tsx+++ b/web/apps/social/src/screens/SettingsScreen.tsx@@ -209,6 +209,7 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({display: "flex",height: 24,justifyContent: "flex-start",+ ml: "-2px",p: 0,width: 24,"&:focus-visible": {