diff --git a/phone/src/Phone.js b/phone/src/Phone.js index 33c730a..381721d 100644 --- a/phone/src/Phone.js +++ b/phone/src/Phone.js @@ -16,19 +16,39 @@ import { useSimcardService } from "./os/simcard/hooks/useSimcardService"; import { usePhoneService } from "./os/phone/hooks/usePhoneService"; import { useApps } from "./os/apps/hooks/useApps"; +import { useContactsService } from "./apps/contacts/hooks/useContactsService"; + // @TODO: Remove this testing shit // Used for testing NUI events while we work on clientside -setTimeout(() => { - window.dispatchEvent( - new MessageEvent("message", { - data: { - app: "SIMCARD", - method: "setNumber", - data: "111-1111", - }, - }) - ); -}, 1000); +//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' +// }, +// ], +// }, +// }) +// ); +//}, 1000); //setTimeout(() => { // window.dispatchEvent( @@ -36,7 +56,7 @@ setTimeout(() => { // data: { // app: "PHONE", // method: "setVisibility", -// data: true, +// data: false, // }, // }) // ); @@ -44,24 +64,17 @@ setTimeout(() => { function Phone() { useNuiService(); - const { visibility, powerOff } = usePhoneService(); + const { visibility } = usePhoneService(); const { settings, currentTheme } = useSettings(); const { allApps } = useApps(); useSimcardService(); + useContactsService(); useInitKeyboard(); if (visibility === false) { return null; } - const screenStyle = powerOff - ? { - backgroundColor: "black", - } - : { - backgroundImage: `url(${process.env.PUBLIC_URL}/media/backgrounds/${settings.wallpaper})`, - }; - return (
@@ -73,26 +86,30 @@ function Phone() { backgroundImage: `url(${process.env.PUBLIC_URL}/media/frames/${settings.frame})`, }} >
-
- {!powerOff && ( - <> - , - }, - ]} - /> -
- - {allApps.map((App) => ( - - ))} -
- - - )} +
+ <> + , + }, + ]} + /> +
+ + {allApps.map((App) => ( + + ))} +
+ +
diff --git a/phone/src/apps/contacts/components/ContactList.js b/phone/src/apps/contacts/components/ContactList.js index aac2da0..665c5f2 100644 --- a/phone/src/apps/contacts/components/ContactList.js +++ b/phone/src/apps/contacts/components/ContactList.js @@ -6,20 +6,19 @@ import PhoneIcon from "@material-ui/icons/Phone"; import ChatIcon from "@material-ui/icons/Chat"; import { List } from "../../../ui/components/List"; import { ListItem } from "../../../ui/components/ListItem"; +import { useContacts } from "../hooks/useContacts"; -export const ContactList = ({ contacts, onCall, onMessage }) => { +export const ContactList = () => { + const contacts = useContacts(); return ( - {contacts.map((contact) => ( + {contacts.contacts.map((contact) => ( - - - diff --git a/phone/src/apps/contacts/components/ContactsApp.js b/phone/src/apps/contacts/components/ContactsApp.js index b98c0bf..c196a3d 100644 --- a/phone/src/apps/contacts/components/ContactsApp.js +++ b/phone/src/apps/contacts/components/ContactsApp.js @@ -2,22 +2,16 @@ import React from "react"; import { AppWrapper } from "../../../ui/components"; import { AppTitle } from "../../../ui/components/AppTitle"; import { AppContent } from "../../../ui/components/AppContent"; -import { useContacts } from "../hooks/useContacts"; import { ContactList } from "./ContactList"; import { useApp } from "../../../os/apps/hooks/useApps"; export const ContactsApp = () => { - const { contactList } = useContacts(); const contacts = useApp("CONTACTS"); return ( - console.log(contact)} - onMessage={() => console.log("Opening messages")} - /> + ); diff --git a/phone/src/apps/contacts/hooks/state.js b/phone/src/apps/contacts/hooks/state.js new file mode 100644 index 0000000..feea75f --- /dev/null +++ b/phone/src/apps/contacts/hooks/state.js @@ -0,0 +1,8 @@ +import { atom } from "recoil"; + +export const contactsState = { + contacts: atom({ + key: "contactsList", + default: [], + }), +}; diff --git a/phone/src/apps/contacts/hooks/useContacts.js b/phone/src/apps/contacts/hooks/useContacts.js index 56b6951..7d575bd 100644 --- a/phone/src/apps/contacts/hooks/useContacts.js +++ b/phone/src/apps/contacts/hooks/useContacts.js @@ -1,22 +1,28 @@ -import { useRecoilState, atom } from "recoil"; - -const contactListState = atom({ - key: "contactList", - default: [ - { - id: 0, - display: "Test Contact", - phoneNumber: "000-1111", - }, - { - id: 1, - display: "Test Contact 2", - phoneNumber: "000-1112", - }, - ], -}); +import { useRecoilValue } from "recoil"; +import { contactsState } from "./state"; export const useContacts = () => { - const [contactList, setContactList] = useRecoilState(contactListState); - return { contactList, setContactList }; + const contacts = useRecoilValue(contactsState.contacts); + return { contacts }; }; + +//const contactListState = atom({ +// key: "contactList", +// default: [ +// { +// id: 0, +// display: "Test Contact", +// phoneNumber: "000-1111", +// }, +// { +// id: 1, +// display: "Test Contact 2", +// phoneNumber: "000-1112", +// }, +// ], +//}); +// +//export const useContacts = () => { +// const [contactList, setContactList] = useRecoilState//(contactListState); +// return { contactList, setContactList }; +//}; diff --git a/phone/src/apps/contacts/hooks/useContactsService.js b/phone/src/apps/contacts/hooks/useContactsService.js new file mode 100644 index 0000000..2753228 --- /dev/null +++ b/phone/src/apps/contacts/hooks/useContactsService.js @@ -0,0 +1,10 @@ +import { useNuiEvent } from "../../../os/nui-events/hooks/useNuiEvent"; +import { useSetRecoilState } from "recoil"; +import { contactsState } from "./state"; +import { useContacts } from "./useContacts"; + +export const useContactsService = () => { + const setContacts = useSetRecoilState(contactsState.contacts); + useNuiEvent("BANK", "setContacts", setContacts); + return useContacts(); +}; diff --git a/phone/src/os/phone/hooks/state.js b/phone/src/os/phone/hooks/state.js index 15c2fbb..041521d 100644 --- a/phone/src/os/phone/hooks/state.js +++ b/phone/src/os/phone/hooks/state.js @@ -5,8 +5,4 @@ export const phoneState = { key: "phoneVisibility", default: false, }), - powerOff: atom({ - key: "phonePowerOff", - default: true, - }), }; diff --git a/phone/src/os/phone/hooks/usePhone.js b/phone/src/os/phone/hooks/usePhone.js index 3a55419..baac5ef 100644 --- a/phone/src/os/phone/hooks/usePhone.js +++ b/phone/src/os/phone/hooks/usePhone.js @@ -3,6 +3,5 @@ import { phoneState } from "./state"; export const usePhone = () => { const visibility = useRecoilValue(phoneState.visibility); - const powerOff = useRecoilValue(phoneState.powerOff); - return { visibility, powerOff }; + return { visibility }; }; diff --git a/phone/src/os/phone/hooks/usePhoneService.js b/phone/src/os/phone/hooks/usePhoneService.js index 618dfaf..a425585 100644 --- a/phone/src/os/phone/hooks/usePhoneService.js +++ b/phone/src/os/phone/hooks/usePhoneService.js @@ -5,8 +5,6 @@ import { usePhone } from "./usePhone"; export const usePhoneService = () => { const setVisibility = useSetRecoilState(phoneState.visibility); - const setPowerOff = useSetRecoilState(phoneState.powerOff); - useNuiEvent("PHONE", "setPowerOff", setPowerOff); useNuiEvent("PHONE", "setVisibility", setVisibility); return usePhone(); };