π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Confirm before unfriending in social app
Anand Baburajan8a525090b077
diff --git a/web/apps/social/src/components/ConfirmationActionSheet.tsx b/web/apps/social/src/components/ConfirmationActionSheet.tsxnew file mode 100644index 0000000000..ff60e08bd6--- /dev/null+++ b/web/apps/social/src/components/ConfirmationActionSheet.tsx@@ -0,0 +1,143 @@+import { Box, Dialog } from "@mui/material";+import React from "react";++const green = "#08C225";+const dangerColor = "#F63A3A";+const textBase = "#000";++interface ConfirmationActionSheetProps {+ open: boolean;+ title: string;+ confirmLabel: string;+ cancelLabel?: string;+ onCancel: () => void;+ onConfirm: () => void;+}++export const ConfirmationActionSheet: React.FC<+ ConfirmationActionSheetProps+> = ({+ open,+ title,+ confirmLabel,+ cancelLabel = "Cancel",+ onCancel,+ onConfirm,+}) => {+ const titleID = React.useId();++ return (+ <Dialog+ open={open}+ onClose={onCancel}+ maxWidth={false}+ aria-labelledby={titleID}+ slotProps={{+ backdrop: {+ sx: { backgroundColor: "rgba(0, 0, 0, 0.48)" },+ },+ paper: {+ sx: {+ bgcolor: "#FAFAFA",+ borderRadius: "20px 20px 0 0",+ bottom: 0,+ boxShadow: "none",+ boxSizing: "border-box",+ left: "50%",+ m: 0,+ p: "26px 20px 24px",+ position: "fixed",+ transform: "translateX(-50%)",+ width: "calc(100vw - 12px)",+ maxWidth: 363,+ },+ },+ }}+ >+ <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",+ }}+ >+ {title}+ </Box>+ <Box+ sx={{+ display: "flex",+ flexDirection: "column",+ gap: "12px",+ mt: "28px",+ }}+ >+ <SheetButton+ label={confirmLabel}+ backgroundColor={dangerColor}+ color="#FFFFFF"+ onClick={onConfirm}+ />+ <SheetButton+ label={cancelLabel}+ backgroundColor="#F2F2F2"+ color="#666666"+ onClick={onCancel}+ />+ </Box>+ </Dialog>+ );+};++interface SheetButtonProps {+ backgroundColor: string;+ color: string;+ label: string;+ onClick: () => void;+}++const SheetButton: React.FC<SheetButtonProps> = ({+ backgroundColor,+ color,+ label,+ onClick,+}) => (+ <Box+ component="button"+ type="button"+ onClick={onClick}+ sx={{+ alignItems: "center",+ bgcolor: backgroundColor,+ border: 0,+ borderRadius: "20px",+ color,+ cursor: "pointer",+ display: "flex",+ 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": { filter: "brightness(0.96)" },+ "&:focus-visible": {+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ "&:hover": { filter: "brightness(0.98)" },+ }}+ >+ {label}+ </Box>+);diff --git a/web/apps/social/src/screens/FriendsScreen.tsx b/web/apps/social/src/screens/FriendsScreen.tsxindex eb6ef94fde..502ecb9c43 100644--- a/web/apps/social/src/screens/FriendsScreen.tsx+++ b/web/apps/social/src/screens/FriendsScreen.tsx@@ -5,6 +5,7 @@ import {} from "@hugeicons/core-free-icons";import { HugeiconsIcon } from "@hugeicons/react";import { Box, Menu, MenuItem } from "@mui/material";+import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";import type { FriendProfile } from "data/friends";import React, { useState } from "react";@@ -277,122 +278,142 @@ export const FriendsScreen: React.FC<FriendsScreenProps> = ({onBack,onOpenFriend,onUnfriend,-}) => (- <Box- component="main"- sx={{- bgcolor: friendsBackground,- color: textBase,- display: "grid",- minHeight: "100svh",- overflowX: "hidden",- placeItems: { xs: "stretch", sm: "start center" },- }}- >+}) => {+ const [friendToUnfriend, setFriendToUnfriend] =+ React.useState<FriendProfile | null>(null);++ const cancelUnfriend = () => setFriendToUnfriend(null);++ const confirmUnfriend = () => {+ if (friendToUnfriend) onUnfriend?.(friendToUnfriend.id);+ setFriendToUnfriend(null);+ };++ return (<Box+ component="main"sx={{bgcolor: friendsBackground,+ color: textBase,+ display: "grid",boxSizing: "border-box",minHeight: "100svh",- mx: "auto",- width: "100%",- "@media (min-width: 600px)": { maxWidth: 375 },+ overflowX: "hidden",+ placeItems: { xs: "stretch", sm: "start center" },}}><Box- component="header"sx={{- alignItems: "center",- display: "grid",- gridTemplateColumns: "24px 1fr 24px",- height: 56,- px: 2,+ bgcolor: friendsBackground,+ boxSizing: "border-box",+ minHeight: "100svh",+ mx: "auto",width: "100%",+ "@media (min-width: 600px)": { maxWidth: 375 },}}><Box- component="button"- type="button"- aria-label="Back to profile"- onClick={onBack}+ component="header"sx={{alignItems: "center",- bgcolor: "transparent",- border: 0,- color: textBase,- cursor: onBack ? "pointer" : "default",- display: "flex",- height: 24,- justifyContent: "flex-start",- 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,- }}- >- Friends- </Box>- </Box>-- {friends.length > 0 ? (- <Box- component="ul"- sx={{- display: "flex",- flexDirection: "column",- gap: "4px",- m: 0,- mt: "8px",- p: 0,+ display: "grid",+ gridTemplateColumns: "24px 1fr 24px",+ height: 56,+ px: 2,width: "100%",}}>- {friends.map((friend) => (- <FriendRow- key={friend.id}- friend={friend}- onOpenFriend={onOpenFriend}- onUnfriend={onUnfriend}+ <Box+ component="button"+ type="button"+ aria-label="Back to profile"+ onClick={onBack}+ sx={{+ alignItems: "center",+ bgcolor: "transparent",+ border: 0,+ color: textBase,+ cursor: onBack ? "pointer" : "default",+ display: "flex",+ height: 24,+ justifyContent: "flex-start",+ p: 0,+ width: 24,+ "&:focus-visible": {+ borderRadius: "50%",+ outline: `2px solid ${green}`,+ outlineOffset: 2,+ },+ }}+ >+ <HugeiconsIcon+ icon={ArrowLeft02Icon}+ size={24}+ strokeWidth={1.8}/>- ))}- </Box>- ) : (- <Box- sx={{- color: textSoft,- fontFamily: '"Inter Variable", Inter, sans-serif',- fontSize: 14,- fontWeight: 600,- lineHeight: "20px",- px: "24px",- py: "44px",- textAlign: "center",- }}- >- No friends yet+ </Box>+ <Box+ component="h1"+ sx={{+ color: textBase,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 18,+ fontWeight: 700,+ justifySelf: "center",+ lineHeight: "24px",+ m: 0,+ }}+ >+ Friends+ </Box></Box>- )}++ {friends.length > 0 ? (+ <Box+ component="ul"+ sx={{+ display: "flex",+ flexDirection: "column",+ gap: "4px",+ m: 0,+ mt: "8px",+ p: 0,+ width: "100%",+ }}+ >+ {friends.map((friend) => (+ <FriendRow+ key={friend.id}+ friend={friend}+ onOpenFriend={onOpenFriend}+ onUnfriend={() => setFriendToUnfriend(friend)}+ />+ ))}+ </Box>+ ) : (+ <Box+ sx={{+ color: textSoft,+ fontFamily: '"Inter Variable", Inter, sans-serif',+ fontSize: 14,+ fontWeight: 600,+ lineHeight: "20px",+ px: "24px",+ py: "44px",+ textAlign: "center",+ }}+ >+ No friends yet+ </Box>+ )}+ </Box>+ <ConfirmationActionSheet+ open={Boolean(friendToUnfriend)}+ title="Are you sure you want to unfriend?"+ confirmLabel="Yes, unfriend"+ onCancel={cancelUnfriend}+ onConfirm={confirmUnfriend}+ /></Box>- </Box>-);+ );+};diff --git a/web/apps/social/src/screens/SettingsScreen.tsx b/web/apps/social/src/screens/SettingsScreen.tsxindex c8b955dc94..cba195c4b2 100644--- a/web/apps/social/src/screens/SettingsScreen.tsx+++ b/web/apps/social/src/screens/SettingsScreen.tsx@@ -6,7 +6,8 @@ import {Logout05Icon,} from "@hugeicons/core-free-icons";import { HugeiconsIcon, type IconSvgElement } from "@hugeicons/react";-import { Box, Dialog } from "@mui/material";+import { Box } from "@mui/material";+import { ConfirmationActionSheet } from "components/ConfirmationActionSheet";import React from "react";export const settingsBackground = "#FAFAFA";@@ -113,129 +114,6 @@ const SettingsRow: React.FC<SettingsRowProps> = ({</Box>);-interface LogoutConfirmationSheetProps {- open: boolean;- onCancel: () => void;- onConfirm: () => void;-}--const LogoutConfirmationSheet: React.FC<LogoutConfirmationSheetProps> = ({- open,- onCancel,- onConfirm,-}) => (- <Dialog- open={open}- onClose={onCancel}- maxWidth={false}- aria-labelledby="logout-confirmation-title"- slotProps={{- backdrop: { sx: { backgroundColor: "rgba(0, 0, 0, 0.48)" } },- paper: {- sx: {- bgcolor: settingsBackground,- borderRadius: "20px 20px 0 0",- bottom: 0,- boxShadow: "none",- boxSizing: "border-box",- left: "50%",- m: 0,- p: "26px 20px 24px",- position: "fixed",- transform: "translateX(-50%)",- width: "calc(100vw - 12px)",- maxWidth: 363,- },- },- }}- >- <Box- component="h2"- id="logout-confirmation-title"- sx={{- color: textBase,- fontFamily: '"Inter Variable", Inter, sans-serif',- fontSize: 15,- fontWeight: 600,- lineHeight: "20px",- m: 0,- px: "20px",- textAlign: "center",- }}- >- Are you sure you want to logout?- </Box>- <Box- sx={{- display: "flex",- flexDirection: "column",- gap: "12px",- mt: "28px",- }}- >- <SheetButton- label="Yes, logout"- backgroundColor={dangerColor}- color="#FFFFFF"- onClick={onConfirm}- />- <SheetButton- label="Cancel"- backgroundColor="#F2F2F2"- color="#666666"- onClick={onCancel}- />- </Box>- </Dialog>-);--interface SheetButtonProps {- backgroundColor: string;- color: string;- label: string;- onClick: () => void;-}--const SheetButton: React.FC<SheetButtonProps> = ({- backgroundColor,- color,- label,- onClick,-}) => (- <Box- component="button"- type="button"- onClick={onClick}- sx={{- alignItems: "center",- bgcolor: backgroundColor,- border: 0,- borderRadius: "20px",- color,- cursor: "pointer",- display: "flex",- 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": { filter: "brightness(0.96)" },- "&:focus-visible": {- outline: `2px solid ${green}`,- outlineOffset: 2,- },- "&:hover": { filter: "brightness(0.98)" },- }}- >- {label}- </Box>-);-const SocialIcon: React.FC<SocialIconProps> = ({ label, src }) => (<Boxaria-label={label}@@ -402,8 +280,10 @@ export const SettingsScreen: React.FC<SettingsScreenProps> = ({<SocialIcon label="Reddit" src="/images/reddit.svg" /></Box></Box>- <LogoutConfirmationSheet+ <ConfirmationActionSheetopen={logoutSheetOpen}+ title="Are you sure you want to logout?"+ confirmLabel="Yes, logout"onCancel={() => setLogoutSheetOpen(false)}onConfirm={handleConfirmLogout}/>