mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +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 { Route } from "react-router-dom";
|
||||||
import { useSettings } from "./apps/settings/hooks/useSettings";
|
import { useSettings } from "./apps/settings/hooks/useSettings";
|
||||||
import MessageIcon from "@material-ui/icons/Email";
|
import MessageIcon from "@material-ui/icons/Email";
|
||||||
|
import { CallModal } from "./modal/components/CallModal";
|
||||||
import { HomeApp } from "./apps/home/components/Home";
|
import { HomeApp } from "./apps/home/components/Home";
|
||||||
import { ThemeProvider } from "@material-ui/core";
|
import { ThemeProvider } from "@material-ui/core";
|
||||||
import { useInitKeyboard } from "./os/keyboard/hooks/useKeyboard";
|
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";
|
import { useContactsService } from "./apps/contacts/hooks/useContactsService";
|
||||||
|
|
||||||
// These events are just for testing. Comment it out before building.
|
//These events are just for testing. Comment it out before building.
|
||||||
//setTimeout(() => {
|
setTimeout(() => {
|
||||||
// window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
// new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
// data: {
|
data: {
|
||||||
// app: "SIMCARD",
|
app: "SIMCARD",
|
||||||
// method: "setNumber",
|
method: "setNumber",
|
||||||
// data: "111-1134",
|
data: "111-1134",
|
||||||
// },
|
},
|
||||||
// })
|
})
|
||||||
// );
|
);
|
||||||
//}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
//setTimeout(() => {
|
setTimeout(() => {
|
||||||
// window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
// new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
// data: {
|
data: {
|
||||||
// app: "BANK",
|
app: "BANK",
|
||||||
// method: "setContacts",
|
method: "setContacts",
|
||||||
// data: [
|
data: [
|
||||||
// {
|
{
|
||||||
// id: 1,
|
id: 1,
|
||||||
// number: "345-4366",
|
number: "345-4366",
|
||||||
// display: "Kevin",
|
display: "Kevin",
|
||||||
// },
|
},
|
||||||
// {
|
{
|
||||||
// id: 2,
|
id: 2,
|
||||||
// number: "345-4366",
|
number: "345-4366",
|
||||||
// display: "Kevin",
|
display: "Kevin",
|
||||||
// },
|
},
|
||||||
// ],
|
],
|
||||||
// },
|
},
|
||||||
// })
|
})
|
||||||
// );
|
);
|
||||||
//}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
//setTimeout(() => {
|
setTimeout(() => {
|
||||||
// window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
// new MessageEvent("message", {
|
new MessageEvent("message", {
|
||||||
// data: {
|
data: {
|
||||||
// app: "PHONE",
|
app: "PHONE",
|
||||||
// method: "setVisibility",
|
method: "setVisibility",
|
||||||
// data: true,
|
data: true,
|
||||||
// },
|
},
|
||||||
// })
|
})
|
||||||
// );
|
);
|
||||||
//}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
useNuiService();
|
useNuiService();
|
||||||
@@ -79,6 +79,8 @@ function Phone() {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const calling = true;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={currentTheme()}>
|
<ThemeProvider theme={currentTheme()}>
|
||||||
<div className="PhoneWrapper">
|
<div className="PhoneWrapper">
|
||||||
@@ -107,10 +109,17 @@ function Phone() {
|
|||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
<div className="PhoneAppContainer">
|
<div className="PhoneAppContainer">
|
||||||
<Route exact path="/" component={HomeApp} />
|
{calling ? (
|
||||||
{allApps.map((App) => (
|
<CallModal />
|
||||||
<App.Route key={App.id} />
|
) : (
|
||||||
))}
|
<>
|
||||||
|
<Route exact path="/" component={HomeApp} />
|
||||||
|
|
||||||
|
{allApps.map((App) => (
|
||||||
|
<App.Route key={App.id} />
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<Navigation />
|
<Navigation />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"wallpaper": "default.png",
|
"wallpaper": "default.png",
|
||||||
"frame": "default.png",
|
"frame": "s10.png",
|
||||||
"theme": "default-dark"
|
"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)
|
startCall(phoneNumber)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent("phone:acceptCall")
|
--[[RegisterNetEvent("phone:acceptCall")
|
||||||
AddEventHandler("phone:acceptCall", function(phoneNumber, initiator)
|
AddEventHandler("phone:acceptCall", function(phoneNumber, initiator)
|
||||||
print("should accept")
|
print("should accept")
|
||||||
if inCall == false then
|
if inCall == false then
|
||||||
@@ -42,17 +42,17 @@ AddEventHandler("phone:acceptCall", function(phoneNumber, initiator)
|
|||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
TriggerServerEvent('phone:getCredentials', source)
|
TriggerServerEvent('phone:getCredentials', source)
|
||||||
end
|
end
|
||||||
end)
|
end)--]]
|
||||||
|
|
||||||
RegisterCommand('answer', function(source) -- Toggles Phone
|
RegisterCommand('answer', function(source) -- Toggles Phone
|
||||||
local rocko = 2222222
|
local rocko = 2222222
|
||||||
local chip = 1111111
|
local chip = 1111111
|
||||||
acceptCall (rocko)
|
acceptCall(rocko, chip)
|
||||||
print(rocko)
|
print(rocko)
|
||||||
end, false)
|
end, false)
|
||||||
|
|
||||||
function startCall (phoneNumber)
|
function startCall(transmitter, target)
|
||||||
TriggerServerEvent('phone:startCall', phoneNumber)
|
TriggerServerEvent('phone:startCall', transmitter, target)
|
||||||
end
|
end
|
||||||
|
|
||||||
function acceptCall (phoneNumber)
|
function acceptCall (phoneNumber)
|
||||||
|
|||||||
@@ -100,16 +100,3 @@ AddEventHandler('phone:initalizeCall', function(source, phoneNumber)
|
|||||||
end)
|
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