π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Add Space invite friends dialog
Anand Baburajan5669a33f57c9
diff --git a/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx b/web/apps/space/src/components/SpaceInviteFriendsDialog.tsxnew file mode 100644index 0000000000..db6449d088--- /dev/null+++ b/web/apps/space/src/components/SpaceInviteFriendsDialog.tsx@@ -0,0 +1,177 @@+import { Share08Icon } from "@hugeicons/core-free-icons";+import { HugeiconsIcon } from "@hugeicons/react";+import { Box, Dialog, useMediaQuery } from "@mui/material";+import { SpaceBottomSheetTransition } from "components/SpaceBottomSheetTransition";+import React from "react";++const textBase = "#000";+const textSoft = "#777777";+const dangerColor = "#F63A3A";++interface SpaceInviteFriendsDialogProps {+ errorMessage?: string | null;+ open: boolean;+ sharing: boolean;+ onClose: () => void;+ onShare: () => void;+}++export const SpaceInviteFriendsDialog: React.FC<+ SpaceInviteFriendsDialogProps+> = ({ errorMessage, open, sharing, onClose, onShare }) => {+ const titleID = React.useId();+ const isBottomSheet = useMediaQuery("(max-width: 599px)");++ return (+ <Dialog+ open={open}+ onClose={sharing ? undefined : onClose}+ maxWidth={false}+ aria-labelledby={titleID}+ slots={+ isBottomSheet+ ? { transition: SpaceBottomSheetTransition }+ : undefined+ }+ slotProps={{+ backdrop: { sx: { backgroundColor: "rgba(0, 0, 0, 0.48)" } },+ paper: {+ sx: {+ bgcolor: "#FAFAFA",+ borderRadius: "28px 28px 0 0",+ bottom: 0,+ boxShadow: "none",+ boxSizing: "border-box",+ left: 0,+ m: 0,+ maxWidth: "none",+ p: "26px 20px calc(24px + env(safe-area-inset-bottom))",+ position: "fixed",+ width: "100vw",+ "@media (min-width: 600px)": {+ borderRadius: "20px",+ bottom: "auto",+ boxShadow: "0 18px 48px rgba(0, 0, 0, 0.18)",+ left: "50%",+ maxWidth: 342,+ p: "24px 20px 20px",+ top: "50%",+ transform: "translate(-50%, -50%)",+ width: 342,+ },+ },+ },+ }}+ >+ <Box+ sx={{+ maxWidth: 320,+ mx: "auto",+ width: "100%",+ "@media (min-width: 600px)": { maxWidth: "none" },+ }}+ >+ <Box+ component="h2"+ id={titleID}+ sx={{+ color: textBase,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 15,+ fontWeight: 600,+ lineHeight: "20px",+ m: 0,+ px: "20px",+ textAlign: "center",+ }}+ >+ Invite friends+ </Box>+ <Box+ component="p"+ sx={{+ color: textSoft,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 500,+ lineHeight: "20px",+ m: 0,+ mt: "10px",+ textAlign: "center",+ }}+ >+ Invite friends and family to add you as a friend.+ </Box>+ <Box+ sx={{+ display: "flex",+ flexDirection: "column",+ gap: "10px",+ mt: "22px",+ }}+ >+ <Box+ className="green-bg"+ component="button"+ type="button"+ disabled={sharing}+ onClick={onShare}+ sx={{+ alignItems: "center",+ border: 0,+ borderRadius: "20px",+ color: "#FFFFFF",+ cursor: sharing ? "default" : "pointer",+ display: "flex",+ gap: "10px",+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 600,+ height: 48,+ justifyContent: "center",+ lineHeight: "20px",+ px: "24px",+ py: "14px",+ transition: "filter 120ms ease, opacity 120ms ease",+ width: "100%",+ "&:active": sharing+ ? undefined+ : { filter: "brightness(0.96)" },+ "&:disabled": { opacity: 1 },+ "&:focus-visible": {+ outline: "2px solid rgba(0 0 0 / 0.72)",+ outlineOffset: 2,+ },+ "&:hover": sharing+ ? undefined+ : { filter: "brightness(0.98)" },+ }}+ >+ <HugeiconsIcon+ icon={Share08Icon}+ size={18}+ strokeWidth={1.8}+ />+ {sharing ? "Sharing..." : "Share invite"}+ </Box>+ {errorMessage && (+ <Box+ role="alert"+ sx={{+ color: dangerColor,+ fontFamily:+ '"Inter Variable", Inter, sans-serif',+ fontSize: 13,+ fontWeight: 650,+ lineHeight: "18px",+ textAlign: "center",+ }}+ >+ {errorMessage}+ </Box>+ )}+ </Box>+ </Box>+ </Dialog>+ );+};diff --git a/web/apps/space/src/pages/index.tsx b/web/apps/space/src/pages/index.tsxindex 73aed73522..d3cf805f7a 100644--- a/web/apps/space/src/pages/index.tsx+++ b/web/apps/space/src/pages/index.tsx@@ -181,9 +181,8 @@ const PublicFriendRequestScreen: React.FC<PublicFriendRequestScreenProps> = ({maxWidth: 300,}}>- See what @{identity.username} is up to- <br />- on Ente Space.+ Add @{identity.username} as a friend to see what they're up+ to on Ente Space.</Box></Box><Boxdiff --git a/web/apps/space/src/screens/FriendsScreen.tsx b/web/apps/space/src/screens/FriendsScreen.tsxindex af9806c13c..619f0f3a3b 100644--- a/web/apps/space/src/screens/FriendsScreen.tsx+++ b/web/apps/space/src/screens/FriendsScreen.tsx@@ -12,6 +12,7 @@ import {type SpaceActionPhase,} from "components/SpaceActionFeedback";import { SpaceAvatarImage } from "components/SpaceAvatarImage";+import { SpaceInviteFriendsDialog } from "components/SpaceInviteFriendsDialog";import type { FriendProfile } from "data/friends";import React, { useState } from "react";import { ShareIcon } from "screens/ShareProfileLinkScreen";@@ -334,7 +335,11 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({const [loadedAvatarURLsByKey, setLoadedAvatarURLsByKey] = React.useState<Record<string, string>>({});+ const [isInviteDialogOpen, setIsInviteDialogOpen] = React.useState(false);const [isInviteSharing, setIsInviteSharing] = React.useState(false);+ const [inviteShareError, setInviteShareError] = React.useState<+ string | null+ >(null);const avatarLoadsInFlightRef = React.useRef<Map<string, Promise<string | null | undefined>>>(new Map());@@ -420,9 +425,20 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({setUnfriendErrorMessage(null);};+ const openInviteDialog = () => {+ setInviteShareError(null);+ setIsInviteDialogOpen(true);+ };++ const closeInviteDialog = () => {+ if (isInviteSharing) return;+ setIsInviteDialogOpen(false);+ };+const shareInviteLink = async () => {if (!onShareProfileLink || isInviteSharing) return;setIsInviteSharing(true);+ setInviteShareError(null);try {const profileLink = await onShareProfileLink();@@ -430,6 +446,7 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({if (typeof navigator.share == "function") {try {await navigator.share({ url: profileLink });+ setIsInviteDialogOpen(false);return;} catch (error) {if (@@ -441,8 +458,10 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({}await navigator.clipboard.writeText(profileLink);+ setIsInviteDialogOpen(false);} catch (error) {console.error("Failed to share space invite", error);+ setInviteShareError("Couldn't share invite. Please try again.");} finally {setIsInviteSharing(false);}@@ -530,18 +549,15 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({<Boxcomponent="button"type="button"- aria-label="Share invite"- disabled={!onShareProfileLink || isInviteSharing}- onClick={() => void shareInviteLink()}+ aria-label="Invite friends"+ disabled={!onShareProfileLink}+ onClick={openInviteDialog}sx={{alignItems: "center",bgcolor: "transparent",border: 0,color: textBase,- cursor:- onShareProfileLink && !isInviteSharing- ? "pointer"- : "default",+ cursor: onShareProfileLink ? "pointer" : "default",display: "flex",height: spaceTouchTargetSize,justifyContent: "flex-end",@@ -645,8 +661,8 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({},"&:hover":onShareProfileLink && !isInviteSharing- ? { bgcolor: "#DEDEDE" }- : undefined,+ ? { bgcolor: "#DEDEDE" }+ : undefined,}}><ShareIcon />@@ -667,6 +683,13 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({onConfirm={confirmUnfriend}onExited={handleUnfriendSheetExited}/>+ <SpaceInviteFriendsDialog+ errorMessage={inviteShareError}+ open={isInviteDialogOpen}+ sharing={isInviteSharing}+ onClose={closeInviteDialog}+ onShare={() => void shareInviteLink()}+ /></Box>);};