mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 14:38:45 +00:00
Feat(Call): useCall hook
This commit is contained in:
1 parent
efbdff0849
commit
fd09a2df14
11 files changed
+117
-72
No files matched your search
Binary file not shown.
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 76 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 47 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
+59
-50
@@ -4,7 +4,7 @@ import "./i18n";
|
||||
import { Route } from "react-router-dom";
|
||||
import { useSettings } from "./apps/settings/hooks/useSettings";
|
||||
import MessageIcon from "@material-ui/icons/Email";
|
||||
|
||||
import { CallModal } from "./modal/components/CallModal";
|
||||
import { HomeApp } from "./apps/home/components/Home";
|
||||
import { ThemeProvider } from "@material-ui/core";
|
||||
import { useInitKeyboard } from "./os/keyboard/hooks/useKeyboard";
|
||||
@@ -18,53 +18,53 @@ import { useApps } from "./os/apps/hooks/useApps";
|
||||
|
||||
import { useContactsService } from "./apps/contacts/hooks/useContactsService";
|
||||
|
||||
// These events are just for testing. Comment it out before building.
|
||||
//setTimeout(() => {
|
||||
// window.dispatchEvent(
|
||||
// new MessageEvent("message", {
|
||||
// data: {
|
||||
// app: "SIMCARD",
|
||||
// method: "setNumber",
|
||||
// data: "111-1134",
|
||||
// },
|
||||
// })
|
||||
// );
|
||||
//}, 1000);
|
||||
//These events are just for testing. Comment it out before building.
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
data: {
|
||||
app: "SIMCARD",
|
||||
method: "setNumber",
|
||||
data: "111-1134",
|
||||
},
|
||||
})
|
||||
);
|
||||
}, 1000);
|
||||
|
||||
//setTimeout(() => {
|
||||
// window.dispatchEvent(
|
||||
// new MessageEvent("message", {
|
||||
// data: {
|
||||
// app: "BANK",
|
||||
// method: "setContacts",
|
||||
// data: [
|
||||
// {
|
||||
// id: 1,
|
||||
// number: "345-4366",
|
||||
// display: "Kevin",
|
||||
// },
|
||||
// {
|
||||
// id: 2,
|
||||
// number: "345-4366",
|
||||
// display: "Kevin",
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// })
|
||||
// );
|
||||
//}, 1000);
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
data: {
|
||||
app: "BANK",
|
||||
method: "setContacts",
|
||||
data: [
|
||||
{
|
||||
id: 1,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
number: "345-4366",
|
||||
display: "Kevin",
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
);
|
||||
}, 1000);
|
||||
|
||||
//setTimeout(() => {
|
||||
// window.dispatchEvent(
|
||||
// new MessageEvent("message", {
|
||||
// data: {
|
||||
// app: "PHONE",
|
||||
// method: "setVisibility",
|
||||
// data: true,
|
||||
// },
|
||||
// })
|
||||
// );
|
||||
//}, 1000);
|
||||
setTimeout(() => {
|
||||
window.dispatchEvent(
|
||||
new MessageEvent("message", {
|
||||
data: {
|
||||
app: "PHONE",
|
||||
method: "setVisibility",
|
||||
data: true,
|
||||
},
|
||||
})
|
||||
);
|
||||
}, 1000);
|
||||
|
||||
function Phone() {
|
||||
useNuiService();
|
||||
@@ -79,6 +79,8 @@ function Phone() {
|
||||
return null;
|
||||
}
|
||||
|
||||
const calling = true;
|
||||
|
||||
return (
|
||||
<ThemeProvider theme={currentTheme()}>
|
||||
<div className="PhoneWrapper">
|
||||
@@ -107,10 +109,17 @@ function Phone() {
|
||||
]}
|
||||
/>
|
||||
<div className="PhoneAppContainer">
|
||||
<Route exact path="/" component={HomeApp} />
|
||||
{allApps.map((App) => (
|
||||
<App.Route key={App.id} />
|
||||
))}
|
||||
{calling ? (
|
||||
<CallModal />
|
||||
) : (
|
||||
<>
|
||||
<Route exact path="/" component={HomeApp} />
|
||||
|
||||
{allApps.map((App) => (
|
||||
<App.Route key={App.id} />
|
||||
))}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<Navigation />
|
||||
</>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"wallpaper": "default.png",
|
||||
"frame": "default.png",
|
||||
"theme": "default-dark"
|
||||
}
|
||||
"wallpaper": "default.png",
|
||||
"frame": "s10.png",
|
||||
"theme": "default-dark"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import React from "react";
|
||||
import { makeStyles } from "@material-ui/core";
|
||||
import { AppWrapper } from "../../ui/components/AppWrapper";
|
||||
import { AppTitle } from "../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../ui/components/AppContent";
|
||||
import { Button } from "../../ui/components/Button";
|
||||
|
||||
export const CallModal = () => {
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle app="Call" />
|
||||
<AppContent>
|
||||
<h1
|
||||
style={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
Call
|
||||
</h1>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
import { atom } from "recoil";
|
||||
|
||||
export const callerState = {
|
||||
caller: atom({
|
||||
key: "callerList",
|
||||
default: [],
|
||||
}),
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
import { useRecoilValue } from "recoil";
|
||||
import { callerState } from "./state";
|
||||
|
||||
export const useCall = () => {
|
||||
const caller = useRecoilState(callerState.caller);
|
||||
return { caller };
|
||||
};
|
||||
@@ -0,0 +1,10 @@
|
||||
import { useNuiEvent } from "../../os/nui-events/hooks/useNuiEvent";
|
||||
import { useSetRecoilState } from "recoil";
|
||||
import { callerState } from "./state";
|
||||
import { useCall } from "./useCall";
|
||||
|
||||
export const useCallService = () => {
|
||||
const setCaller = useSetRecoilState(callerState.caller);
|
||||
useNuiEvent("CALL", "setCaller", setCaller);
|
||||
return useCall();
|
||||
};
|
||||
@@ -18,7 +18,7 @@ RegisterNUICallback('phone:startCall', function(data)
|
||||
startCall(phoneNumber)
|
||||
end)
|
||||
|
||||
RegisterNetEvent("phone:acceptCall")
|
||||
--[[RegisterNetEvent("phone:acceptCall")
|
||||
AddEventHandler("phone:acceptCall", function(phoneNumber, initiator)
|
||||
print("should accept")
|
||||
if inCall == false then
|
||||
@@ -42,17 +42,17 @@ AddEventHandler("phone:acceptCall", function(phoneNumber, initiator)
|
||||
SetNuiFocus(true, true)
|
||||
TriggerServerEvent('phone:getCredentials', source)
|
||||
end
|
||||
end)
|
||||
end)--]]
|
||||
|
||||
RegisterCommand('answer', function(source) -- Toggles Phone
|
||||
local rocko = 2222222
|
||||
local chip = 1111111
|
||||
acceptCall (rocko)
|
||||
acceptCall(rocko, chip)
|
||||
print(rocko)
|
||||
end, false)
|
||||
|
||||
function startCall (phoneNumber)
|
||||
TriggerServerEvent('phone:startCall', phoneNumber)
|
||||
function startCall(transmitter, target)
|
||||
TriggerServerEvent('phone:startCall', transmitter, target)
|
||||
end
|
||||
|
||||
function acceptCall (phoneNumber)
|
||||
|
||||
@@ -100,16 +100,3 @@ AddEventHandler('phone:initalizeCall', function(source, phoneNumber)
|
||||
end)
|
||||
|
||||
|
||||
RegisterServerEvent('phone:acceptCall')
|
||||
AddEventHandler('phone:acceptCall', function(source, phoneNumber)
|
||||
if phoneNumber ~= nil then
|
||||
getSourceFromIdentifier(zPlayer, function (target)
|
||||
if target ~= nil then
|
||||
TriggerClientEvent('phone:acceptCall', sourcePlayer, phoneNumber, true)
|
||||
TriggerClientEvent('phone:acceptCall', target, phoneNumber, false)
|
||||
else
|
||||
TriggerClientEvent('phone:acceptCall', sourcePlayer, phoneNumber, true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
Reference in new issue
Block a user