π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add profile link share step
Anand Baburajan91840a766768
diff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsxindex 1850d52d80..80b7fe4de6 100644--- a/web/apps/social/src/pages/index.tsx+++ b/web/apps/social/src/pages/index.tsx@@ -17,7 +17,12 @@ import {import {SetupProfileScreen,setupProfileBackground,+ type SetupProfile,} from "screens/SetupProfileScreen";+import {+ ShareProfileLinkScreen,+ shareProfileLinkBackground,+} from "screens/ShareProfileLinkScreen";import {VerifyEmailScreen,verifyEmailBackground,@@ -29,13 +34,15 @@ type Screen =| "login"| "verify-email"| "recovery-key"- | "setup-profile";+ | "setup-profile"+ | "share-profile-link";type ProfileBackScreen = "login" | "recovery-key";const Page: React.FC = () => {const [screen, setScreen] = useState<Screen>("onboarding");const [email, setEmail] = useState("[email protected]");+ const [profile, setProfile] = useState<SetupProfile | null>(null);const [profileBackScreen, setProfileBackScreen] =useState<ProfileBackScreen>("recovery-key");@@ -60,7 +67,9 @@ const Page: React.FC = () => {? loginBackground: screen == "setup-profile"? setupProfileBackground- : createAccountBackground+ : screen == "share-profile-link"+ ? shareProfileLinkBackground+ : createAccountBackground}/><meta name="description" content={onboardingDescription} />@@ -115,7 +124,17 @@ const Page: React.FC = () => {{screen == "setup-profile" && (<SetupProfileScreenonBack={() => setScreen(profileBackScreen)}- onContinue={() => undefined}+ onContinue={(nextProfile) => {+ setProfile(nextProfile);+ setScreen("share-profile-link");+ }}+ />+ )}+ {screen == "share-profile-link" && profile && (+ <ShareProfileLinkScreen+ profile={profile}+ onBack={() => setScreen("setup-profile")}+ onDone={() => undefined}/>)}</>diff --git a/web/apps/social/src/screens/SetupProfileScreen.tsx b/web/apps/social/src/screens/SetupProfileScreen.tsxindex fcc7ed5c8f..8bf19c5f90 100644--- a/web/apps/social/src/screens/SetupProfileScreen.tsx+++ b/web/apps/social/src/screens/SetupProfileScreen.tsx@@ -15,9 +15,15 @@ const mockSetupProfileData = {fullName: "Maya Iyer",};+export interface SetupProfile {+ avatarUrl: string | null;+ fullName: string;+ username: string;+}+interface SetupProfileScreenProps {onBack: () => void;- onContinue?: () => void;+ onContinue?: (profile: SetupProfile) => void;}interface TextInputProps {@@ -197,7 +203,13 @@ export const SetupProfileScreen: React.FC<SetupProfileScreenProps> = ({};const submitProfile = () => {- if (canContinue) onContinue?.();+ if (canContinue) {+ onContinue?.({+ avatarUrl,+ fullName: fullName.trim(),+ username: username.trim(),+ });+ }};const handleSubmit: React.FormEventHandler<HTMLFormElement> = (event) => {diff --git a/web/apps/social/src/screens/ShareProfileLinkScreen.tsx b/web/apps/social/src/screens/ShareProfileLinkScreen.tsxnew file mode 100644index 0000000000..60ab4474d1--- /dev/null+++ b/web/apps/social/src/screens/ShareProfileLinkScreen.tsx@@ -0,0 +1,492 @@+import { Box } from "@mui/material";+import React, { useState } from "react";+import type { SetupProfile } from "screens/SetupProfileScreen";++export const shareProfileLinkBackground = "#FAFAFA";++const green = "#08C225";+const textBase = "#000";+const textMuted = "#666";+const textLight = "#969696";+const paleGreen = "#E7F6E9";+const iconFill = "#F0F0F0";+const profileSecret = "5d2a9WhmD2NU";++interface ShareProfileLinkScreenProps {+ onBack: () => void;+ onDone?: () => void;+ profile: SetupProfile;+}++interface ActionRowProps {+ label: string;+ onClick: () => void;+ startIcon: React.ReactNode;+ status?: string;+}++const profileLinkForUsername = (username: string) =>+ `https://ente.gg/${encodeURIComponent(username || "maya")}#${profileSecret}`;++const BackIcon: React.FC = () => (+ <Box+ component="svg"+ viewBox="0 0 24 24"+ aria-hidden+ sx={{ display: "block", height: 24, width: 24 }}+ >+ <path+ d="M15 6L9 12L15 18"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="2"+ />+ </Box>+);++const ShareIcon: React.FC = () => (+ <Box+ component="svg"+ viewBox="0 0 24 24"+ aria-hidden+ sx={{ display: "block", height: 20, width: 20 }}+ >+ <path+ d="M12 15.5V4.75M12 4.75L8.25 8.5M12 4.75L15.75 8.5M6.5 11.5V17.5C6.5 18.6 7.4 19.5 8.5 19.5H15.5C16.6 19.5 17.5 18.6 17.5 17.5V11.5"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.8"+ />+ </Box>+);++const LinkIcon: React.FC = () => (+ <Box+ component="svg"+ viewBox="0 0 24 24"+ aria-hidden+ sx={{ display: "block", height: 20, width: 20 }}+ >+ <path+ d="M9.75 14.25L14.25 9.75M10.75 7.5L11.8 6.45C13.25 5 15.65 5 17.1 6.45C18.55 7.9 18.55 10.3 17.1 11.75L15.75 13.1M13.25 16.5L12.2 17.55C10.75 19 8.35 19 6.9 17.55C5.45 16.1 5.45 13.7 6.9 12.25L8.25 10.9"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.8"+ />+ </Box>+);++const ChevronIcon: React.FC = () => (+ <Box+ component="svg"+ viewBox="0 0 24 24"+ aria-hidden+ sx={{ display: "block", height: 22, width: 22 }}+ >+ <path+ d="M9 6L15 12L9 18"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="2"+ />+ </Box>+);++const ActionRow: React.FC<ActionRowProps> = ({+ label,+ onClick,+ startIcon,+ status,+}) => (+ <Box+ component="button"+ type="button"+ onClick={onClick}+ sx={{+ alignItems: "center",+ bgcolor: "white",+ border: 0,+ borderRadius: "16px",+ color: textBase,+ cursor: "pointer",+ display: "flex",+ gap: "14px",+ height: 56,+ p: "8px 12px",+ textAlign: "left",+ width: "100%",+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ "&:hover": { bgcolor: "#F7F7F7" },+ }}+ >+ <Box+ sx={{+ alignItems: "center",+ bgcolor: iconFill,+ borderRadius: "50%",+ color: textBase,+ display: "flex",+ flexShrink: 0,+ height: 38,+ justifyContent: "center",+ width: 38,+ }}+ >+ {startIcon}+ </Box>+ <Box+ sx={{+ flex: "1 1 0",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ lineHeight: "20px",+ minWidth: 0,+ }}+ >+ {label}+ </Box>+ {status && (+ <Box+ sx={{+ color: green,+ flexShrink: 0,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 12,+ fontWeight: 600,+ lineHeight: "16px",+ }}+ >+ {status}+ </Box>+ )}+ <Box sx={{ color: textBase, display: "flex", flexShrink: 0 }}>+ <ChevronIcon />+ </Box>+ </Box>+);++export const ShareProfileLinkScreen: React.FC<ShareProfileLinkScreenProps> = ({+ onBack,+ onDone,+ profile,+}) => {+ const [copied, setCopied] = useState(false);+ const profileLink = profileLinkForUsername(profile.username.trim());+ const displayName = profile.fullName.trim() || profile.username.trim();+ const initialsSource = displayName || profile.username.trim();+ const initials = initialsSource+ .split(/\s+/)+ .slice(0, 2)+ .map((part) => part[0]?.toUpperCase())+ .join("");++ const copyProfileLink = async () => {+ await navigator.clipboard.writeText(profileLink);+ setCopied(true);+ window.setTimeout(() => setCopied(false), 1200);+ };++ const shareProfileLink = async () => {+ const shareData = {+ title: `Follow ${displayName} on Ente`,+ text: `Follow ${displayName} on Ente to see their private moments.`,+ url: profileLink,+ };++ if (typeof navigator.share == "function") {+ try {+ await navigator.share(shareData);+ return;+ } catch (error) {+ if (error instanceof DOMException && error.name == "AbortError")+ return;+ }+ }++ await copyProfileLink();+ };++ return (+ <Box+ component="main"+ sx={{+ bgcolor: shareProfileLinkBackground,+ color: textBase,+ display: "grid",+ minHeight: "100svh",+ overflow: "hidden",+ placeItems: { xs: "stretch", sm: "start center" },+ }}+ >+ <Box+ sx={{+ bgcolor: shareProfileLinkBackground,+ boxSizing: "border-box",+ display: "flex",+ flexDirection: "column",+ minHeight: "100svh",+ mx: "auto",+ pb: "120px",+ px: 3,+ width: "100%",+ "@media (min-width: 600px)": { maxWidth: 375 },+ }}+ >+ <Box+ component="header"+ sx={{+ display: "grid",+ gridTemplateColumns: "42px 1fr 42px",+ height: 42,+ mt: "32px",+ width: "100%",+ }}+ >+ <Box+ component="button"+ type="button"+ aria-label="Back"+ onClick={onBack}+ sx={{+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ color: textBase,+ cursor: "pointer",+ display: "flex",+ height: 42,+ justifyContent: "flex-start",+ p: 0,+ width: 42,+ "&:focus-visible": {+ borderRadius: "50%",+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <BackIcon />+ </Box>+ <Box+ component="h1"+ sx={{+ alignSelf: "center",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 20,+ fontWeight: 600,+ justifySelf: "center",+ lineHeight: "28px",+ m: 0,+ whiteSpace: "nowrap",+ }}+ >+ Share your Ente link+ </Box>+ <Box />+ </Box>++ <Box+ sx={{+ alignItems: "center",+ display: "flex",+ flexDirection: "column",+ mt: "32px",+ width: "100%",+ }}+ >+ <Box+ sx={{+ alignItems: "center",+ aspectRatio: "1 / 1",+ bgcolor: profile.avatarUrl+ ? "transparent"+ : paleGreen,+ borderRadius: "50%",+ color: green,+ display: "flex",+ height: 112,+ justifyContent: "center",+ overflow: "hidden",+ width: 112,+ }}+ >+ {profile.avatarUrl ? (+ <Box+ component="img"+ alt=""+ src={profile.avatarUrl}+ sx={{+ display: "block",+ height: "100%",+ objectFit: "cover",+ objectPosition: "center",+ width: "100%",+ }}+ />+ ) : (+ <Box+ sx={{+ color: green,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 32,+ fontWeight: 700,+ lineHeight: 1,+ }}+ >+ {initials}+ </Box>+ )}+ </Box>++ <Box+ component="h2"+ sx={{+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 18,+ fontWeight: 600,+ lineHeight: "24px",+ m: 0,+ mt: "18px",+ textAlign: "center",+ }}+ >+ {displayName}+ </Box>+ <Box+ sx={{+ color: textMuted,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ lineHeight: "20px",+ mt: "4px",+ textAlign: "center",+ }}+ >+ @{profile.username}+ </Box>+ <Box+ sx={{+ bgcolor: "white",+ borderRadius: "16px",+ color: textLight,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 13,+ fontWeight: 500,+ lineHeight: "18px",+ mt: "20px",+ overflow: "hidden",+ px: 2,+ py: "13px",+ textAlign: "center",+ textOverflow: "ellipsis",+ whiteSpace: "nowrap",+ width: "100%",+ }}+ >+ {profileLink}+ </Box>+ <Box+ component="p"+ sx={{+ color: textMuted,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ lineHeight: "20px",+ m: 0,+ mt: "12px",+ textAlign: "center",+ width: "100%",+ }}+ >+ Share your end-to-end encrypted profile link with close+ people. Only you and the people you share it with can+ view it.+ </Box>+ </Box>++ <Box+ sx={{+ display: "flex",+ flexDirection: "column",+ gap: "10px",+ mt: "34px",+ width: "100%",+ }}+ >+ <ActionRow+ label="Share"+ onClick={shareProfileLink}+ startIcon={<ShareIcon />}+ />+ <ActionRow+ label="Copy link"+ onClick={copyProfileLink}+ startIcon={<LinkIcon />}+ status={copied ? "Copied" : undefined}+ />+ </Box>++ <Box+ sx={{+ bgcolor: shareProfileLinkBackground,+ bottom: 0,+ boxSizing: "border-box",+ left: "50%",+ maxWidth: 375,+ p: 3,+ position: "fixed",+ transform: "translateX(-50%)",+ width: "100%",+ }}+ >+ <Box+ component="button"+ type="button"+ onClick={onDone}+ sx={{+ alignItems: "center",+ bgcolor: green,+ border: 0,+ borderRadius: "20px",+ color: "white",+ cursor: onDone ? "pointer" : "default",+ display: "flex",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ height: 48,+ justifyContent: "center",+ lineHeight: "20px",+ p: "14px 24px",+ width: "100%",+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 3,+ },+ "&:hover": onDone+ ? { bgcolor: "#07AE22" }+ : undefined,+ }}+ >+ Done+ </Box>+ </Box>+ </Box>+ </Box>+ );+};