π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add social setup profile screen
Anand Baburajand9655364c45e
diff --git a/web/apps/social/public/images/mock-profile-picture.jpg b/web/apps/social/public/images/mock-profile-picture.jpgnew file mode 100644index 0000000000..032884885aBinary files /dev/null and b/web/apps/social/public/images/mock-profile-picture.jpg differdiff --git a/web/apps/social/src/pages/index.tsx b/web/apps/social/src/pages/index.tsxindex f2f1b0f985..1850d52d80 100644--- a/web/apps/social/src/pages/index.tsx+++ b/web/apps/social/src/pages/index.tsx@@ -14,6 +14,10 @@ import {RecoveryKeyScreen,recoveryKeyBackground,} from "screens/RecoveryKeyScreen";+import {+ SetupProfileScreen,+ setupProfileBackground,+} from "screens/SetupProfileScreen";import {VerifyEmailScreen,verifyEmailBackground,@@ -24,11 +28,21 @@ type Screen =| "create-account"| "login"| "verify-email"- | "recovery-key";+ | "recovery-key"+ | "setup-profile";++type ProfileBackScreen = "login" | "recovery-key";const Page: React.FC = () => {const [screen, setScreen] = useState<Screen>("onboarding");const [email, setEmail] = useState("[email protected]");+ const [profileBackScreen, setProfileBackScreen] =+ useState<ProfileBackScreen>("recovery-key");++ const openSetupProfile = (backScreen: ProfileBackScreen) => {+ setProfileBackScreen(backScreen);+ setScreen("setup-profile");+ };return (<>@@ -40,11 +54,13 @@ const Page: React.FC = () => {? onboardingGreen: screen == "verify-email"? verifyEmailBackground- : screen == "recovery-key"+ : screen == "recovery-key"? recoveryKeyBackground: screen == "login"? loginBackground- : createAccountBackground+ : screen == "setup-profile"+ ? setupProfileBackground+ : createAccountBackground}/><meta name="description" content={onboardingDescription} />@@ -78,7 +94,7 @@ const Page: React.FC = () => {{screen == "login" && (<LoginScreenonBack={() => setScreen("onboarding")}- onContinue={() => undefined}+ onContinue={() => openSetupProfile("login")}onSignup={() => setScreen("create-account")}/>)}@@ -93,7 +109,13 @@ const Page: React.FC = () => {{screen == "recovery-key" && (<RecoveryKeyScreenonBack={() => setScreen("verify-email")}- onNext={() => undefined}+ onNext={() => openSetupProfile("recovery-key")}+ />+ )}+ {screen == "setup-profile" && (+ <SetupProfileScreen+ onBack={() => setScreen(profileBackScreen)}+ onContinue={() => undefined}/>)}</>diff --git a/web/apps/social/src/screens/SetupProfileScreen.tsx b/web/apps/social/src/screens/SetupProfileScreen.tsxnew file mode 100644index 0000000000..35c34451c8--- /dev/null+++ b/web/apps/social/src/screens/SetupProfileScreen.tsx@@ -0,0 +1,469 @@+import { Box } from "@mui/material";+import React, { useEffect, useRef, useState } from "react";++export const setupProfileBackground = "#FAFAFA";++const green = "#08C225";+const textBase = "#000";+const textLight = "#969696";+const warning = "#F63A3A";+const paleGreen = "#E7F6E9";++const mockSetupProfileData = {+ avatarUrl: "/images/mock-profile-picture.jpg",+ username: "maya",+ fullName: "Maya Iyer",+};++interface SetupProfileScreenProps {+ onBack: () => void;+ onContinue?: () => void;+}++interface TextInputProps {+ label: string;+ onChange?: (value: string) => void;+ placeholder?: string;+ required?: boolean;+ value?: string;+}++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 UploadIcon: React.FC = () => (+ <Box+ component="svg"+ viewBox="0 0 24 24"+ aria-hidden+ sx={{ display: "block", height: 20, width: 20 }}+ >+ <path+ d="M8.5 7.5L9.75 5.75H14.25L15.5 7.5H18C19.1 7.5 20 8.4 20 9.5V17C20 18.1 19.1 19 18 19H6C4.9 19 4 18.1 4 17V9.5C4 8.4 4.9 7.5 6 7.5H8.5Z"+ fill="none"+ stroke="currentColor"+ strokeLinejoin="round"+ strokeWidth="1.8"+ />+ <circle+ cx="12"+ cy="13"+ fill="none"+ r="3"+ stroke="currentColor"+ strokeWidth="1.8"+ />+ </Box>+);++const PencilIcon: React.FC = () => (+ <Box+ component="svg"+ viewBox="0 0 24 24"+ aria-hidden+ sx={{ display: "block", height: 14, width: 14 }}+ >+ <path+ d="M14.25 5.25L18.75 9.75M4.75 19.25L8.9 18.45L19.35 8C20.25 7.1 20.25 5.65 19.35 4.75C18.45 3.85 17 3.85 16.1 4.75L5.65 15.2L4.75 19.25Z"+ fill="none"+ stroke="currentColor"+ strokeLinecap="round"+ strokeLinejoin="round"+ strokeWidth="1.8"+ />+ </Box>+);++const TextInput: React.FC<TextInputProps> = ({+ label,+ onChange,+ placeholder,+ required,+ value,+}) => (+ <Box sx={{ width: "100%" }}>+ <Box+ component="label"+ sx={{+ color: textBase,+ display: "flex",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ gap: "2px",+ lineHeight: "20px",+ mb: "9px",+ }}+ >+ {label}+ {required && <Box sx={{ color: warning }}>*</Box>}+ </Box>+ <Box+ sx={{+ alignItems: "center",+ bgcolor: "white",+ borderRadius: "16px",+ display: "flex",+ height: 52,+ px: 2,+ width: "100%",+ "&:focus-within": {+ outline: `2px solid ${green}`,+ outlineOffset: 1,+ },+ }}+ >+ <Box+ component="input"+ onChange={(event) => onChange?.(event.target.value)}+ placeholder={placeholder}+ type="text"+ value={value}+ sx={{+ bgcolor: "transparent",+ border: 0,+ color: textBase,+ flex: 1,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ lineHeight: "20px",+ minWidth: 0,+ outline: 0,+ p: 0,+ "&::placeholder": { color: textLight, opacity: 1 },+ }}+ />+ </Box>+ </Box>+);++export const SetupProfileScreen: React.FC<SetupProfileScreenProps> = ({+ onBack,+ onContinue,+}) => {+ const [avatarUrl, setAvatarUrl] = useState<string | null>(+ mockSetupProfileData.avatarUrl,+ );+ const [username, setUsername] = useState(mockSetupProfileData.username);+ const [fullName, setFullName] = useState(mockSetupProfileData.fullName);+ const avatarUrlRef = useRef<string | null>(null);+ const fileInputRef = useRef<HTMLInputElement | null>(null);++ const canContinue =+ Boolean(avatarUrl) &&+ username.trim().length > 0 &&+ fullName.trim().length > 0;+ const initialsSource = fullName.trim() || username.trim();+ const initials = initialsSource+ .split(/\s+/)+ .slice(0, 2)+ .map((part) => part[0]?.toUpperCase())+ .join("");++ useEffect(+ () => () => {+ if (avatarUrlRef.current) URL.revokeObjectURL(avatarUrlRef.current);+ },+ [],+ );++ const handleAvatarChange: React.ChangeEventHandler<HTMLInputElement> = (+ event,+ ) => {+ const file = event.target.files?.[0];+ if (!file) return;++ if (avatarUrlRef.current) URL.revokeObjectURL(avatarUrlRef.current);+ const nextUrl = URL.createObjectURL(file);+ avatarUrlRef.current = nextUrl;+ setAvatarUrl(nextUrl);+ event.target.value = "";+ };++ const submitProfile = () => {+ if (canContinue) onContinue?.();+ };++ const handleSubmit: React.FormEventHandler<HTMLFormElement> = (event) => {+ event.preventDefault();+ submitProfile();+ };++ return (+ <Box+ component="main"+ sx={{+ bgcolor: setupProfileBackground,+ color: textBase,+ display: "grid",+ minHeight: "100svh",+ overflow: "hidden",+ placeItems: { xs: "stretch", sm: "start center" },+ }}+ >+ <Box+ sx={{+ bgcolor: setupProfileBackground,+ 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",+ }}+ >+ Setup your profile+ </Box>+ <Box />+ </Box>++ <Box+ component="form"+ onSubmit={handleSubmit}+ sx={{+ alignItems: "center",+ display: "flex",+ flexDirection: "column",+ mt: "32px",+ width: "100%",+ }}+ >+ <Box+ component="input"+ ref={fileInputRef}+ accept="image/*"+ onChange={handleAvatarChange}+ type="file"+ sx={{ display: "none" }}+ />++ <Box sx={{ position: "relative" }}>+ <Box+ component="button"+ type="button"+ aria-label="Upload profile picture"+ onClick={() => fileInputRef.current?.click()}+ sx={{+ alignItems: "center",+ aspectRatio: "1 / 1",+ bgcolor: avatarUrl ? "transparent" : paleGreen,+ border: 0,+ borderRadius: "50%",+ color: green,+ cursor: "pointer",+ display: "flex",+ height: 112,+ justifyContent: "center",+ overflow: "hidden",+ p: 0,+ position: "relative",+ width: 112,+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 3,+ },+ }}+ >+ {avatarUrl ? (+ <Box+ component="img"+ alt=""+ src={avatarUrl}+ sx={{+ display: "block",+ height: "100%",+ objectFit: "cover",+ objectPosition: "center",+ width: "100%",+ }}+ />+ ) : initials ? (+ <Box+ sx={{+ color: green,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 32,+ fontWeight: 700,+ lineHeight: 1,+ }}+ >+ {initials}+ </Box>+ ) : (+ <UploadIcon />+ )}+ </Box>+ <Box+ component="button"+ type="button"+ aria-label="Edit profile picture"+ onClick={() => fileInputRef.current?.click()}+ sx={{+ alignItems: "center",+ bgcolor: "white",+ border: "1px solid #E6E6E6",+ borderRadius: "50%",+ bottom: 6,+ boxShadow: "0 4px 10px rgba(0, 0, 0, 0.12)",+ color: textBase,+ cursor: "pointer",+ display: "flex",+ height: 30,+ justifyContent: "center",+ position: "absolute",+ right: -2,+ width: 30,+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 3,+ },+ }}+ >+ <PencilIcon />+ </Box>+ </Box>++ <Box+ sx={{+ display: "flex",+ flexDirection: "column",+ gap: "24px",+ mt: "52px",+ width: "100%",+ }}+ >+ <TextInput+ label="Username"+ onChange={setUsername}+ placeholder="Choose a username"+ required+ value={username}+ />+ <TextInput+ label="Full name"+ onChange={setFullName}+ placeholder="Enter your full name"+ required+ value={fullName}+ />+ </Box>+ </Box>++ <Box+ sx={{+ bgcolor: setupProfileBackground,+ bottom: 0,+ boxSizing: "border-box",+ left: "50%",+ maxWidth: 375,+ p: 3,+ position: "fixed",+ transform: "translateX(-50%)",+ width: "100%",+ }}+ >+ <Box+ component="button"+ type="button"+ disabled={!canContinue}+ onClick={submitProfile}+ sx={{+ alignItems: "center",+ bgcolor: canContinue ? green : "#F5F5F5",+ border: 0,+ borderRadius: "20px",+ color: canContinue ? "white" : textLight,+ cursor: canContinue ? "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": canContinue+ ? { bgcolor: "#07AE22" }+ : undefined,+ }}+ >+ Continue+ </Box>+ </Box>+ </Box>+ </Box>+ );+};