Дизайн звонков
This commit is contained in:
42
app/components/ActiveCall/ActiveCall.module.css
Normal file
42
app/components/ActiveCall/ActiveCall.module.css
Normal file
@@ -0,0 +1,42 @@
|
||||
.active {
|
||||
background: linear-gradient(90deg,rgba(0, 186, 59, 1) 0%, rgba(0, 194, 81, 1) 50%);
|
||||
background-size: 200% 200%;
|
||||
animation: activeFlow 5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes activeFlow {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
filter: saturate(1);
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
filter: saturate(1.15);
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
filter: saturate(1);
|
||||
}
|
||||
}
|
||||
|
||||
.connecting {
|
||||
background: linear-gradient(120deg, #ff2d2d, #ff7a00, #ff2d2d);
|
||||
background-size: 220% 220%;
|
||||
animation: connectingFlow 5s ease-in-out infinite;
|
||||
}
|
||||
|
||||
@keyframes connectingFlow {
|
||||
0% {
|
||||
background-position: 0% 50%;
|
||||
filter: saturate(1);
|
||||
}
|
||||
50% {
|
||||
background-position: 100% 50%;
|
||||
filter: saturate(1.15);
|
||||
}
|
||||
100% {
|
||||
background-position: 0% 50%;
|
||||
filter: saturate(1);
|
||||
}
|
||||
}
|
||||
/* ...existing code... */
|
||||
95
app/components/ActiveCall/ActiveCall.tsx
Normal file
95
app/components/ActiveCall/ActiveCall.tsx
Normal file
@@ -0,0 +1,95 @@
|
||||
import { useCalls } from "@/app/providers/CallProvider/useCalls";
|
||||
import { useUserInformation } from "@/app/providers/InformationProvider/useUserInformation";
|
||||
import { Box, Flex, Loader, Text } from "@mantine/core";
|
||||
import classes from "./ActiveCall.module.css";
|
||||
import { CallState } from "@/app/providers/CallProvider/CallProvider";
|
||||
import { IconMicrophone, IconMicrophoneOff, IconPhoneX, IconVolume, IconVolumeOff } from "@tabler/icons-react";
|
||||
import { translateDurationToTime } from "@/app/providers/CallProvider/translateDurationTime";
|
||||
|
||||
export function ActiveCall() {
|
||||
const {activeCall, callState, duration, muted, sound, close, setMuted, setSound, setShowCallView} = useCalls();
|
||||
const [userInfo] = useUserInformation(activeCall);
|
||||
//const colors = useRosettaColors();
|
||||
|
||||
if(activeCall == ""){
|
||||
return <></>
|
||||
}
|
||||
|
||||
const getConnectingClass = () => {
|
||||
if(callState === CallState.CONNECTING){
|
||||
return classes.connecting;
|
||||
}
|
||||
if(callState === CallState.ACTIVE){
|
||||
return classes.active;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Box py={4} style={{
|
||||
cursor: 'pointer'
|
||||
}} px={10} className={getConnectingClass()} onClick={() => setShowCallView(true)}>
|
||||
<Flex align={'center'} justify={'row'} gap={10}>
|
||||
<Flex w={'100%'} justify={'space-between'} align={'center'}>
|
||||
<Flex>
|
||||
{!muted && (
|
||||
<IconMicrophoneOff style={{
|
||||
cursor: 'pointer'
|
||||
}} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setMuted(true);
|
||||
}} size={16} color={'#fff'}></IconMicrophoneOff>
|
||||
)}
|
||||
{muted && (
|
||||
<IconMicrophone style={{
|
||||
cursor: 'pointer'
|
||||
}} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setMuted(false);
|
||||
}} size={16} color={'#fff'}></IconMicrophone>
|
||||
)}
|
||||
</Flex>
|
||||
<Flex justify={'center'} align={'center'} gap={'xs'}>
|
||||
<Text fw={500} c={'#fff'} style={{
|
||||
userSelect: 'none'
|
||||
}} fz={13}>{userInfo?.title || activeCall}</Text>
|
||||
{callState === CallState.CONNECTING && (
|
||||
<Loader type={'dots'} size={12} color="white"></Loader>
|
||||
)}
|
||||
{callState == CallState.ACTIVE && (
|
||||
<Text fw={500} c={'#ffffff'} style={{
|
||||
userSelect: 'none'
|
||||
}} fz={12}>{translateDurationToTime(duration)}</Text>
|
||||
)}
|
||||
</Flex>
|
||||
<Flex gap={'xs'} align={'center'} justify={'center'}>
|
||||
{sound && (
|
||||
<IconVolumeOff style={{
|
||||
cursor: 'pointer'
|
||||
}} size={16} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setSound(false)
|
||||
}} color={'#fff'}></IconVolumeOff>
|
||||
)}
|
||||
{!sound && (
|
||||
<IconVolume style={{
|
||||
cursor: 'pointer'
|
||||
}} size={16} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
setSound(true)
|
||||
}} color={'#fff'}></IconVolume>
|
||||
)}
|
||||
<IconPhoneX style={{
|
||||
cursor: 'pointer'
|
||||
}} onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
close();
|
||||
}} size={16} color={'#fff'}></IconPhoneX>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Box>
|
||||
</>
|
||||
);
|
||||
}
|
||||
111
app/components/Call/Call.tsx
Normal file
111
app/components/Call/Call.tsx
Normal file
@@ -0,0 +1,111 @@
|
||||
import { useRosettaColors } from "@/app/hooks/useRosettaColors";
|
||||
import { useAvatars } from "@/app/providers/AvatarProvider/useAvatars";
|
||||
import { CallContextValue, CallState } from "@/app/providers/CallProvider/CallProvider";
|
||||
import { translateDurationToTime } from "@/app/providers/CallProvider/translateDurationTime";
|
||||
import { useUserInformation } from "@/app/providers/InformationProvider/useUserInformation";
|
||||
import { Avatar, Box, Flex, Text } from "@mantine/core";
|
||||
import { IconChevronLeft, IconMicrophone, IconMicrophoneOff, IconPhone, IconPhoneX, IconQrcode, IconVolume, IconVolumeOff, IconX } from "@tabler/icons-react";
|
||||
|
||||
export interface CallProps {
|
||||
context: CallContextValue;
|
||||
}
|
||||
|
||||
export function Call(props: CallProps) {
|
||||
const {
|
||||
activeCall,
|
||||
duration,
|
||||
callState,
|
||||
close,
|
||||
sound,
|
||||
setSound,
|
||||
setMuted,
|
||||
setShowCallView,
|
||||
muted} = props.context;
|
||||
const [userInfo] = useUserInformation(activeCall);
|
||||
const avatars = useAvatars(activeCall);
|
||||
const colors = useRosettaColors();
|
||||
|
||||
return (
|
||||
<Box pos={'absolute'} top={0} left={0} w={'100%'} h={'100vh'} style={{
|
||||
zIndex: 11,
|
||||
background: 'linear-gradient(120deg,#141414 0%, #000000 100%)',
|
||||
}}>
|
||||
<Flex h={'100%'} w={'100vw'} direction={'column'} gap={'lg'} pt={'xl'}>
|
||||
<Flex direction={'row'} w={'100%'} gap={'sm'} align={'center'} justify={'space-between'} p={'sm'}>
|
||||
<Flex style={{
|
||||
cursor: 'pointer'
|
||||
}} onClick={() => setShowCallView(false)} justify={'center'} align={'center'}>
|
||||
<IconChevronLeft size={20}></IconChevronLeft>
|
||||
<Text fw={500}>Back</Text>
|
||||
</Flex>
|
||||
<Flex>
|
||||
<IconQrcode size={24}></IconQrcode>
|
||||
</Flex>
|
||||
</Flex>
|
||||
<Flex direction={'column'} mt={'xl'} style={{
|
||||
userSelect: 'none'
|
||||
}} w={'100vw'} gap={'sm'} align={'center'} justify={'center'}>
|
||||
<Avatar size={128} bg={avatars.length > 0 ? '#fff' : undefined} src={avatars.length > 0 ? avatars[0].avatar : undefined} color={'initials'} name={userInfo.title}></Avatar>
|
||||
<Text fz={20} fw={'bold'} c={'#FFF'}>{userInfo.title}</Text>
|
||||
{callState == CallState.ACTIVE && (<Text fz={14} c={'#FFF'}>{translateDurationToTime(duration)}</Text>)}
|
||||
{callState == CallState.CONNECTING && (<Text fz={14} c={'#FFF'}>Connecting...</Text>)}
|
||||
{callState == CallState.INCOMING && (<Text fz={14} c={'#FFF'}>Incoming call...</Text>)}
|
||||
<Flex gap={'xl'} align={'center'} justify={'center'} mt={'xl'}>
|
||||
{callState == CallState.ACTIVE || callState == CallState.CONNECTING && (
|
||||
<>
|
||||
<Box w={50} onClick={() => setSound(!sound)} style={{
|
||||
borderRadius: 25,
|
||||
cursor: 'pointer'
|
||||
}} h={50} bg={sound ? colors.chevrons.active : colors.chevrons.disabled}>
|
||||
<Flex w={'100%'} h={'100%'} justify={'center'} align={'center'}>
|
||||
{!sound && <IconVolume size={24} color={'#fff'}></IconVolume>}
|
||||
{sound && <IconVolumeOff size={24} color={'#fff'}></IconVolumeOff>}
|
||||
</Flex>
|
||||
</Box>
|
||||
<Box w={50} onClick={() => setMuted(!muted)} style={{
|
||||
borderRadius: 25,
|
||||
cursor: 'pointer'
|
||||
}} h={50} bg={!muted ? colors.chevrons.active : colors.chevrons.disabled}>
|
||||
<Flex w={'100%'} h={'100%'} justify={'center'} align={'center'}>
|
||||
{muted && <IconMicrophone size={24} color={'#fff'}></IconMicrophone>}
|
||||
{!muted && <IconMicrophoneOff size={24} color={'#fff'}></IconMicrophoneOff>}
|
||||
</Flex>
|
||||
</Box>
|
||||
<Box w={50} onClick={close} style={{
|
||||
borderRadius: 25,
|
||||
cursor: 'pointer'
|
||||
}} h={50} bg={colors.error}>
|
||||
<Flex w={'100%'} h={'100%'} justify={'center'} align={'center'}>
|
||||
<IconPhoneX size={24} color={'#fff'}></IconPhoneX>
|
||||
</Flex>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
{callState == CallState.INCOMING && (
|
||||
<>
|
||||
{userInfo.title != "Rosetta" && (
|
||||
<Box w={50} onClick={close} style={{
|
||||
borderRadius: 25,
|
||||
cursor: 'pointer'
|
||||
}} h={50} bg={colors.error}>
|
||||
<Flex w={'100%'} h={'100%'} justify={'center'} align={'center'}>
|
||||
<IconX size={24} color={'#fff'}></IconX>
|
||||
</Flex>
|
||||
</Box>
|
||||
)}
|
||||
<Box w={userInfo.title != "Rosetta" ? 50 : 100} onClick={close} style={{
|
||||
borderRadius: '50%',
|
||||
cursor: 'pointer'
|
||||
}} h={userInfo.title != "Rosetta" ? 50 : 100} bg={colors.success}>
|
||||
<Flex w={'100%'} h={'100%'} justify={'center'} align={'center'}>
|
||||
<IconPhone size={24} color={'#fff'}></IconPhone>
|
||||
</Flex>
|
||||
</Box>
|
||||
</>
|
||||
)}
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Box>
|
||||
)
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
import { useRosettaColors } from "@/app/hooks/useRosettaColors";
|
||||
import { OnlineState } from "@/app/providers/ProtocolProvider/protocol/packets/packet.onlinestate";
|
||||
import { usePublicKey } from "@/app/providers/AccountProvider/usePublicKey";
|
||||
import { useBlacklist } from "@/app/providers/BlacklistProvider/useBlacklist";
|
||||
import { useDialog } from "@/app/providers/DialogProvider/useDialog";
|
||||
import { useUserInformation } from "@/app/providers/InformationProvider/useUserInformation";
|
||||
import { ProtocolState } from "@/app/providers/ProtocolProvider/ProtocolProvider";
|
||||
import { useProtocolState } from "@/app/providers/ProtocolProvider/useProtocolState";
|
||||
import { Avatar, Box, Divider, Flex, Loader, Text, Tooltip, useComputedColorScheme, useMantineTheme } from "@mantine/core";
|
||||
import { Avatar, Box, Divider, Flex, Loader, Text, useComputedColorScheme, useMantineTheme } from "@mantine/core";
|
||||
import { modals } from "@mantine/modals";
|
||||
import { IconBookmark, IconLockAccess, IconLockCancel, IconTrashX } from "@tabler/icons-react";
|
||||
import { IconBookmark, IconPhone, IconTrashX } from "@tabler/icons-react";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { VerifiedBadge } from "../VerifiedBadge/VerifiedBadge";
|
||||
@@ -20,6 +19,7 @@ import { ReplyHeader } from "../ReplyHeader/ReplyHeader";
|
||||
import { useRosettaBreakpoints } from "@/app/hooks/useRosettaBreakpoints";
|
||||
import { BackToDialogs } from "../BackToDialogs/BackToDialogs";
|
||||
import { useSystemAccounts } from "@/app/providers/SystemAccountsProvider/useSystemAccounts";
|
||||
import { useCalls } from "@/app/providers/CallProvider/useCalls";
|
||||
|
||||
|
||||
export function ChatHeader() {
|
||||
@@ -29,7 +29,6 @@ export function ChatHeader() {
|
||||
const publicKey = usePublicKey();
|
||||
const {deleteMessages, dialog} = useDialog();
|
||||
const theme = useMantineTheme();
|
||||
const [blocked, blockUser, unblockUser] = useBlacklist(dialog);
|
||||
const [opponent, ___, forceUpdateUserInformation] = useUserInformation(dialog);
|
||||
const [protocolState] = useProtocolState();
|
||||
const [userTypeing, setUserTypeing] = useState(false);
|
||||
@@ -39,6 +38,7 @@ export function ChatHeader() {
|
||||
const {lg} = useRosettaBreakpoints();
|
||||
const systemAccounts = useSystemAccounts();
|
||||
const isSystemAccount = systemAccounts.find((acc) => acc.publicKey == dialog) != undefined;
|
||||
const {call} = useCalls();
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
@@ -78,20 +78,6 @@ export function ChatHeader() {
|
||||
});
|
||||
}
|
||||
|
||||
const onClickBlockUser = () => {
|
||||
if(opponent.publicKey != "DELETED"
|
||||
&& opponent.publicKey != publicKey){
|
||||
blockUser();
|
||||
}
|
||||
}
|
||||
|
||||
const onClickUnblockUser = () => {
|
||||
if(opponent.publicKey != "DELETED"
|
||||
&& opponent.publicKey != publicKey){
|
||||
unblockUser();
|
||||
}
|
||||
}
|
||||
|
||||
const onClickProfile = () => {
|
||||
if(opponent.publicKey != "DELETED" && opponent.publicKey != publicKey){
|
||||
navigate("/main/profile/" + opponent.publicKey);
|
||||
@@ -149,32 +135,16 @@ export function ChatHeader() {
|
||||
</Flex>
|
||||
</Flex>
|
||||
<Flex h={'100%'} align={'center'} gap={'sm'}>
|
||||
<Tooltip onClick={onClickClearMessages} withArrow position={'bottom'} label={"Clear all messages"}>
|
||||
<IconTrashX
|
||||
style={{
|
||||
cursor: 'pointer'
|
||||
}} stroke={1.5} color={theme.colors.blue[7]} size={24}></IconTrashX>
|
||||
</Tooltip>
|
||||
{publicKey != opponent.publicKey && !blocked && !isSystemAccount && (
|
||||
<Tooltip onClick={onClickBlockUser} withArrow position={'bottom'} label={"Block user"}>
|
||||
<IconLockCancel
|
||||
style={{
|
||||
cursor: 'pointer'
|
||||
}} stroke={1.5} color={theme.colors.red[7]} size={24}
|
||||
>
|
||||
</IconLockCancel>
|
||||
</Tooltip>
|
||||
)}
|
||||
{blocked && !isSystemAccount && (
|
||||
<Tooltip onClick={onClickUnblockUser} withArrow position={'bottom'} label={"Unblock user"}>
|
||||
<IconLockAccess
|
||||
style={{
|
||||
cursor: 'pointer'
|
||||
}} stroke={1.5} color={theme.colors.green[7]} size={24}
|
||||
>
|
||||
</IconLockAccess>
|
||||
</Tooltip>
|
||||
)}
|
||||
<IconPhone
|
||||
onClick={() => call(dialog)}
|
||||
style={{
|
||||
cursor: 'pointer'
|
||||
}} stroke={1.5} color={theme.colors.blue[7]} size={24}></IconPhone>
|
||||
<IconTrashX
|
||||
onClick={onClickClearMessages}
|
||||
style={{
|
||||
cursor: 'pointer'
|
||||
}} stroke={1.5} color={theme.colors.blue[7]} size={24}></IconTrashX>
|
||||
</Flex>
|
||||
</Flex>}
|
||||
{replyMessages.messages.length > 0 && !replyMessages.inDialogInput && <ReplyHeader></ReplyHeader>}
|
||||
|
||||
@@ -10,6 +10,8 @@ import { DialogsPanelHeader } from '../DialogsPanelHeader/DialogsPanelHeader';
|
||||
import { useDialogsList } from '@/app/providers/DialogListProvider/useDialogsList';
|
||||
import { useVerifyRequest } from '@/app/providers/DeviceProvider/useVerifyRequest';
|
||||
import { DeviceVerify } from '../DeviceVerify/DeviceVerify';
|
||||
import { ActiveCall } from '../ActiveCall/ActiveCall';
|
||||
import { useViewPanelsState, ViewPanelsState } from '@/app/hooks/useViewPanelsState';
|
||||
|
||||
export function DialogsPanel() {
|
||||
const [dialogsMode, setDialogsMode] = useState<'all' | 'requests'>('all');
|
||||
@@ -18,6 +20,7 @@ export function DialogsPanel() {
|
||||
const colors = useRosettaColors();
|
||||
const navigate = useNavigate();
|
||||
const device = useVerifyRequest();
|
||||
const [viewState] = useViewPanelsState();
|
||||
|
||||
useEffect(() => {
|
||||
((async () => {
|
||||
@@ -52,6 +55,9 @@ export function DialogsPanel() {
|
||||
direction={'column'}
|
||||
justify={'space-between'}
|
||||
>
|
||||
{viewState == ViewPanelsState.DIALOGS_PANEL_ONLY && (
|
||||
<ActiveCall></ActiveCall>
|
||||
)}
|
||||
<Box>
|
||||
<DialogsPanelHeader></DialogsPanelHeader>
|
||||
{device && (
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
left: 12px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
z-index: 10;
|
||||
z-index: 15;
|
||||
app-region: no-drag;
|
||||
}
|
||||
.close_btn, .minimize_btn, .maximize_btn {
|
||||
|
||||
Reference in New Issue
Block a user