diff --git a/config.json b/config.json index 6b01a9c..c0c10cd 100644 --- a/config.json +++ b/config.json @@ -9,7 +9,7 @@ "DestroyPhoneReCheck": 3, "notificationPosition": { "horizontal": "right", - "vertical": "bottom" + "vertical": "top" }, "twitter": { "showNotifications": true, @@ -22,5 +22,8 @@ "enableEmojis": true, "enableImages": true, "maxImages": 3 + }, + "bank": { + "showNotifications": true } } \ No newline at end of file diff --git a/phone/src/Phone.css b/phone/src/Phone.css index d61685c..f4daefb 100644 --- a/phone/src/Phone.css +++ b/phone/src/Phone.css @@ -33,6 +33,9 @@ top: 100px; display: flex; flex-direction: column; + background-position: center; + background-size: cover; + background-repeat: no-repeat; } .PhoneAppContainer { diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx index c3a0eb1..4adb30e 100644 --- a/phone/src/Phone.tsx +++ b/phone/src/Phone.tsx @@ -21,6 +21,7 @@ import { useTwitterService } from "./apps/twitter/hooks/useTwitterService"; import { useSelloutService } from "./apps/sellout/hooks/useSelloutService"; import { useBankService } from './apps/bank/hooks/useBankService'; import { useMessagesService } from "./apps/messages/hooks/useMessageService"; +import { useNotesService } from "./apps/notes/hooks/useNotesService"; //These events are just for testing. Comment it out before building. setTimeout(() => { @@ -35,25 +36,35 @@ setTimeout(() => { ); }, 1000); +setTimeout(() => { + window.dispatchEvent( + new MessageEvent("message", { + data: { + app: "PHONE", + method: "setVisibility", + data: true, + }, + }) + ); +}, 1000); + setTimeout(() => { window.dispatchEvent( new MessageEvent("message", { - data: { - app: "MESSAGES", - method: "setConversations", + data: { + app: 'NOTES', + method: 'setNotes', data: [ { id: 1, - name: 'rocky' + title: 'First note', + content: 'Hello, this is my shitty note' }, { id: 2, - name: 'ark' + title: 'Second note', + content: 'Hello, this is another shitty note' }, - { - id: 3, - name: 'kire' - } ] } }) @@ -61,39 +72,30 @@ setTimeout(() => { }, 1000) setTimeout(() => { - window.dispatchEvent( - new MessageEvent("message", { + new MessageEvent("messsage", { + data: { + app: "BANK", + method: "setNotification", data: { - app: "MESSAGES", - method: "setMessages", - data: [ - { - id: 1, - sender: 'chip', - receiver: 'rocky', - sms: 'Hello there', - owner: 1 - }, - { - id: 2, - sender: 'chip', - receiver: 'depo', - sms: 'Hello man', - owner: 1 - }, - { - id: 2, - sender: 'rocky', - receiver: 'kire', - sms: 'Hello dude', - owner: 1 - } - ] + id: 1, + message: "ahhaha" } - }) - ); -}, 1000); + } + }) +}, 1000) +setTimeout(() => { + new MessageEvent("messsage", { + data: { + app: "TWITTER", + method: "setNotification", + data: { + id: 1, + message: "ahhaha" + } + } + }) +}, 1000) setTimeout(() => { window.dispatchEvent( @@ -170,7 +172,7 @@ setTimeout(() => { id: 1, number: "345-4366", display: "chip", - avatar: 'https://i.imgur.com/Qpw6j8D.png' + avatar: 'https://upload.wikimedia.org/wikipedia/commons/thumb/2/2c/Rotating_earth_%28large%29.gif/200px-Rotating_earth_%28large%29.gif' }, { id: 2, @@ -190,18 +192,6 @@ setTimeout(() => { ); }, 1000); -setTimeout(() => { - window.dispatchEvent( - new MessageEvent("message", { - data: { - app: "PHONE", - method: "setVisibility", - data: true, - }, - }) - ); -}, 1000); - setTimeout(() => { window.dispatchEvent( new MessageEvent("message", { @@ -244,6 +234,7 @@ function Phone() { useSelloutService(); useBankService(); useMessagesService() + useNotesService(); if (visibility === false) { return null; diff --git a/phone/src/apps/bank/components/BankApp.css b/phone/src/apps/bank/components/BankApp.css index 64993ad..ad19ba4 100644 --- a/phone/src/apps/bank/components/BankApp.css +++ b/phone/src/apps/bank/components/BankApp.css @@ -31,6 +31,11 @@ color: #388CF8 !important; } + +#bank-app .MuiSnackbar-root { + position: absolute; +} + #bank-title { font-family: 'Bebas Neue', cursive; font-size: 50px; diff --git a/phone/src/apps/bank/components/BankApp.tsx b/phone/src/apps/bank/components/BankApp.tsx index cfc38c9..55415f5 100644 --- a/phone/src/apps/bank/components/BankApp.tsx +++ b/phone/src/apps/bank/components/BankApp.tsx @@ -21,6 +21,7 @@ import { NavigationBar } from "./navigation/NavigationBar"; import { BankHome } from './home/BankHome'; import { BankAccount } from './account/BankAccount'; import { TransactionList } from "./transactions/TransactionList"; +import { BankAlert } from "./alert/BankAlert"; const useStyles = makeStyles((theme) => ({ root: { @@ -67,6 +68,7 @@ export const BankApp = () => { + diff --git a/phone/src/apps/bank/components/alert/Alert.tsx b/phone/src/apps/bank/components/alert/Alert.tsx new file mode 100644 index 0000000..2ba1e67 --- /dev/null +++ b/phone/src/apps/bank/components/alert/Alert.tsx @@ -0,0 +1,8 @@ +import React from "react"; +import MuiAlert from "@material-ui/lab/Alert"; + +export function Alert(props) { + return ; +} + +export default Alert; diff --git a/phone/src/apps/bank/components/alert/BankAlert.tsx b/phone/src/apps/bank/components/alert/BankAlert.tsx new file mode 100644 index 0000000..cda9c51 --- /dev/null +++ b/phone/src/apps/bank/components/alert/BankAlert.tsx @@ -0,0 +1,43 @@ +import React, { useState, useEffect } from "react"; +import { useBankAlert } from "../../hooks/useBankAlert"; +import Snackbar from "@material-ui/core/Snackbar"; +import Alert from "./Alert"; +import { useTranslation } from "react-i18next"; + +export const BankAlert = () => { + const { t } = useTranslation(); + const [open, setOpen] = useState(false); + const { bankAlert, setBankAlert } = useBankAlert(); + const [ message, setMessage ] = useState(null); + const [severity, setSeverity] = useState(""); + + const _handleClose = () => { + setOpen(false); + setBankAlert(null); + }; + + useEffect(() => { + if (bankAlert === true ) { + setOpen(true); + setMessage(t("APPS_BANK_ALERT_TRANSFER_SUCCESS")); + setSeverity("success") + } else if (bankAlert === false) { + setOpen(true); + setMessage(t("APPS_BANK_ALERT_TRANSFER_FAILURE")); + setSeverity("error") + } + }, [bankAlert]) + + return ( + + + {message} + + + ); +}; \ No newline at end of file diff --git a/phone/src/apps/bank/components/notification/BankNotification.tsx b/phone/src/apps/bank/components/notification/BankNotification.tsx index 6f64552..122bff0 100644 --- a/phone/src/apps/bank/components/notification/BankNotification.tsx +++ b/phone/src/apps/bank/components/notification/BankNotification.tsx @@ -1,16 +1,45 @@ -import React from 'react' -import Alert from '@material-ui/lab/Alert'; -import Notification from '../../../../ui/components/Notification'; -import { useBankAlert } from './../../hooks/useBankAlert'; +import React, { useEffect, useState } from "react"; +import Notification from "../../../../ui/components/Notification"; +import { usePhone } from "../../../../os/phone/hooks/usePhone"; +import { useTranslation } from "react-i18next"; +import useStyles from './notification.style'; +import { useBankNotification } from "../../hooks/useBankNotification"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faWonSign } from "@fortawesome/free-solid-svg-icons"; -export const BankNotification = ({ alert }) => { - const { setBankAlert } = useBankAlert(); +export const BankNotification = () => { + const { notification } = useBankNotification() + const classes = useStyles() + const { t } = useTranslation(); + const [visible, setVisible ] = useState(false); + const { config } = usePhone() - const handleClose = () => { - setBankAlert(false) - } + useEffect(() => { + if (notification) { + setVisible(true); + } + }, [notification?.id]) + + if (!config?.bank.showNotifications || !notification) return null; return ( -
- ) -} + setVisible(false)} + > +
+
+
+
+ +
+
{notification.type}
+
+
{t("APPS_BANK_TIME_JUST_NOW")}
+
+
{notification.source} sent you ${notification.transferAmount}.

{notification.message}
+
+
+ ) +} \ No newline at end of file diff --git a/phone/src/apps/bank/components/notification/notification.style.ts b/phone/src/apps/bank/components/notification/notification.style.ts new file mode 100644 index 0000000..7d80b71 --- /dev/null +++ b/phone/src/apps/bank/components/notification/notification.style.ts @@ -0,0 +1,43 @@ +import { makeStyles, createStyles, Theme } from "@material-ui/core/styles"; + +const useStyles = makeStyles((theme: Theme) => + createStyles({ + content: { + padding: theme.spacing(2), + overflowY: 'hidden' + }, + title: { + display: "flex", + flexFlow: "row nowrap", + justifyContent: "space-between", + alignItems: "center", + }, + titleLeft: { + display: "flex", + flexFlow: "row nowrap", + justifyContent: "flex-start", + alignItems: "center", + }, + icon: { + marginTop: "3px", + marginRight: "5px", + }, + heading: { + marginBottom: "3px", + }, + justNow: { + fontSize: "18px", + fontStyle: "italic", + paddingRight: "3px", + }, + message: { + fontSize: "16px", + overflow: "hidden", + display: "-webkit-box", + WebkitLineClamp: 2, + WebkitBoxOrient: "vertical", + }, + }) +) + +export default useStyles; \ No newline at end of file diff --git a/phone/src/apps/bank/components/transfers/TransferModal.tsx b/phone/src/apps/bank/components/transfers/TransferModal.tsx index fe4050b..6759bf0 100644 --- a/phone/src/apps/bank/components/transfers/TransferModal.tsx +++ b/phone/src/apps/bank/components/transfers/TransferModal.tsx @@ -6,6 +6,7 @@ import CloseIcon from '@material-ui/icons/Close'; import Nui from '../../../../os/nui-events/utils/Nui'; import { useBankModal} from '../../hooks/useBankModal'; +import { Message } from '@material-ui/icons'; const useStyles = makeStyles((theme) => ({ input: { @@ -50,15 +51,13 @@ export const TransferModal = () => { } const addTransfer = () => { + const transferAmount = parseInt(amount); Nui.send('phone:addTransfer', { targetID, - amount, + transferAmount, message }) - setTimeout(() => { - setShowBankModal(false) - }, 200) - + setShowBankModal(false) } return ( diff --git a/phone/src/apps/bank/hooks/state.ts b/phone/src/apps/bank/hooks/state.ts index 2f17396..70ad8d4 100644 --- a/phone/src/apps/bank/hooks/state.ts +++ b/phone/src/apps/bank/hooks/state.ts @@ -9,12 +9,16 @@ export const bankState = { key: 'modalVisibility', default: false, }), - bankAlert: atom({ + transferSuccessful: atom({ key: 'bankAlert', - default: false + default: null }), bankCredentials: atom({ key: 'bankCredentails', default: null + }), + notification: atom({ + key: 'bankNotification', + default: null }) } \ No newline at end of file diff --git a/phone/src/apps/bank/hooks/useBankAlert.ts b/phone/src/apps/bank/hooks/useBankAlert.ts index 2fb828a..da6deb0 100644 --- a/phone/src/apps/bank/hooks/useBankAlert.ts +++ b/phone/src/apps/bank/hooks/useBankAlert.ts @@ -1,7 +1,7 @@ import { useRecoilState } from 'recoil'; import { bankState } from './state'; -export const useBankAlert = () => { - const [ bankAlert, setBankAlert ] = useRecoilState(bankState.bankAlert); +export const useBankAlert = (): any => { + const [ bankAlert, setBankAlert ] = useRecoilState(bankState.transferSuccessful); return { bankAlert, setBankAlert }; } \ No newline at end of file diff --git a/phone/src/apps/bank/hooks/useBankNotification.ts b/phone/src/apps/bank/hooks/useBankNotification.ts new file mode 100644 index 0000000..e67087f --- /dev/null +++ b/phone/src/apps/bank/hooks/useBankNotification.ts @@ -0,0 +1,13 @@ +import { useRecoilValue } from 'recoil'; + +import { Transfer } from '../../../common/interfaces/bank'; +import { bankState } from './state'; + +interface IBankNotification { + notification: Transfer | null; +} + +export const useBankNotification = (): IBankNotification => { + const notification = useRecoilValue(bankState.notification); + return { notification } +} \ No newline at end of file diff --git a/phone/src/apps/bank/hooks/useBankService.ts b/phone/src/apps/bank/hooks/useBankService.ts index 168b3f8..f853886 100644 --- a/phone/src/apps/bank/hooks/useBankService.ts +++ b/phone/src/apps/bank/hooks/useBankService.ts @@ -2,12 +2,21 @@ import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; import { bankState } from './state'; import { useTransactions } from './useTransactions' import { useCredentials } from './useCredentials'; +import { useBankAlert } from './useBankAlert'; import { useSetRecoilState } from 'recoil' +import { useBankNotification } from './useBankNotification'; export const useBankService = () => { const setTransaction = useSetRecoilState(bankState.transactions) const setCredentials = useSetRecoilState(bankState.bankCredentials) + const setAlertMessage = useSetRecoilState(bankState.transferSuccessful) + const setNotification = useSetRecoilState(bankState.notification); + + /// + useNuiEvent('BANK', 'setTransaction', setTransaction); - useNuiEvent('BANK', 'setCredentials', setCredentials) - return {useTransactions, useCredentials}; + useNuiEvent('BANK', 'setCredentials', setCredentials); + useNuiEvent('BANK', 'setAlert', setAlertMessage); + useNuiEvent('BANK', 'setNotification', setNotification); + return { useTransactions, useCredentials, useBankAlert, useBankNotification }; } \ No newline at end of file diff --git a/phone/src/apps/contacts/components/ContactsApp.tsx b/phone/src/apps/contacts/components/ContactsApp.tsx index fa47d34..7ef050c 100644 --- a/phone/src/apps/contacts/components/ContactsApp.tsx +++ b/phone/src/apps/contacts/components/ContactsApp.tsx @@ -8,9 +8,11 @@ import { useApp } from "../../../os/apps/hooks/useApps"; import { AddContactModal } from "./ContactModal"; import { useModal } from "../hooks/useModal"; import { SearchContacts } from "./List/SearchContacts"; -import PersonAddIcon from '@material-ui/icons/PersonAdd' -import Fab from '@material-ui/core/Fab'; -import { useContactModal } from '../hooks/useContactModal'; +import PersonAddIcon from "@material-ui/icons/PersonAdd"; +import Fab from "@material-ui/core/Fab"; +import { useContactModal } from "../hooks/useContactModal"; +import { InfoModal } from "./modal/InfoModal"; +import { useContactDetail } from "../hooks/useContactDetail"; const useStyles = makeStyles((theme: Theme) => createStyles({ @@ -36,7 +38,7 @@ export const ContactsApp = () => { const classes = useStyles(); const { showModal, setShowModal } = useModal(); const contacts = useApp("CONTACTS"); - const { showContactModal } = useContactModal(); + const { contactDetail } = useContactDetail(); const openModal = () => { setShowModal(true); @@ -47,6 +49,7 @@ export const ContactsApp = () => { +
diff --git a/phone/src/apps/contacts/components/List/ContactList.tsx b/phone/src/apps/contacts/components/List/ContactList.tsx index 699111c..2edfdcf 100644 --- a/phone/src/apps/contacts/components/List/ContactList.tsx +++ b/phone/src/apps/contacts/components/List/ContactList.tsx @@ -1,14 +1,14 @@ import React from "react"; import ListItemText from "@material-ui/core/ListItemText"; -import { - Button, +import { + Button, ListItemAvatar, Avatar as MuiAvatar, List, ListItem, TextField, Collapse, - makeStyles + makeStyles, } from "@material-ui/core"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; @@ -18,39 +18,43 @@ import { useFilteredContacts } from "../../hooks/useFilteredContacts"; import PhoneIcon from "@material-ui/icons/Phone"; import ChatIcon from "@material-ui/icons/Chat"; +import MoreVertIcon from "@material-ui/icons/MoreVert"; import { useContacts } from "../../hooks/useContacts"; -import { useContactModal } from '../../hooks/useContactModal'; +import { useContactModal } from "../../hooks/useContactModal"; +import { useContactDetail } from "../../hooks/useContactDetail"; import Nui from "../../../../os/nui-events/utils/Nui"; -import "../Contact.css" +import "../Contact.css"; const useStyles = makeStyles((theme) => ({ updateButton: { - margin: 'auto', + margin: "auto", fontSize: 14, width: 150, background: "#2196f3", marginBottom: 10, - padding: 8 + padding: 8, }, collapseItem: { - margin: 'auto', - width: '50%' - } -})) - + margin: "auto", + width: "50%", + }, +})); export const ContactList = () => { - const classes = useStyles() + const classes = useStyles(); const { filteredContacts } = useFilteredContacts(); - const { showContactModal, setShowContactModal } = useContactModal(); + const { setShowContactModal } = useContactModal(); + const { contactDetail, setContactDetail } = useContactDetail(); const contacts = useContacts(); - const openContactInfo = () => { - setShowContactModal(!showContactModal); - } + const openContactInfo = (contact) => { + setShowContactModal(true); + setContactDetail(contact); + console.log("CONTACT", contactDetail); + }; const startCall = (number) => { console.log(number); Nui.send("phone:startCall", { @@ -60,52 +64,47 @@ export const ContactList = () => { return ( - {contacts.contacts.filter(contact => contact.display.includes(filteredContacts) || contact.number.includes(filteredContacts)).map((contact) => ( - <> - - - {contact.avatar ? ( - - ): ( - {contact.display.slice(0, 1).toUpperCase()} - )} - - - - - - - - - - + contact.display.includes(filteredContacts) || + contact.number.includes(filteredContacts) + ) + .map((contact) => ( + <> + + + {contact.avatar ? ( + + ) : ( + + {contact.display.slice(0, 1).toUpperCase()} + + )} + + - - - - - - + + - - - - ))} + + ))} ); }; diff --git a/phone/src/apps/contacts/components/modal/InfoModal.tsx b/phone/src/apps/contacts/components/modal/InfoModal.tsx new file mode 100644 index 0000000..07456b3 --- /dev/null +++ b/phone/src/apps/contacts/components/modal/InfoModal.tsx @@ -0,0 +1,111 @@ +import React, { useState } from "react"; +import { + Paper, + Slide, + Button, + TextField, + Avatar as MuiAvatar, +} from "@material-ui/core"; +import useStyles from "./modal.styles"; +import { useContactModal } from "../../hooks/useContactModal"; +import ArrowBackIcon from "@material-ui/icons/ArrowBack"; + +import { useTranslation } from "react-i18next"; +import { useContactDetail } from "../../hooks/useContactDetail"; +import Nui from "../../../../os/nui-events/utils/Nui"; + +export const InfoModal = () => { + const classes = useStyles(); + const { showContactModal, setShowContactModal } = useContactModal(); + const { t } = useTranslation(); + const { contactDetail, setContactDetail } = useContactDetail(); + + const [display, setDisplay] = useState( + contactDetail ? contactDetail.display : "" + ); + console.log(contactDetail); + const [number, setNumber] = useState( + contactDetail ? contactDetail.number : "" + ); + const [avatar, setAvatar] = useState( + contactDetail ? contactDetail.avatar : "" + ); + + const closeModal = () => { + setShowContactModal(false); + setContactDetail(null); + }; + + const updateContact = () => { + Nui.send("phone:updateContact", { + id: contactDetail.id, + display, + number, + avatar, + }); + setContactDetail(null); + setShowContactModal(false); + }; + + const deleteContact = () => { + Nui.send("phone:deleteContact", { + id: contactDetail.id, + }); + setContactDetail(null); + setShowContactModal(false); + }; + + return ( + + + +
+ + setDisplay(e.target.value)} + placeholder={t("APPS_CONTACT_FORM_NAME")} + fullWidth + inputProps={{ + className: classes.inputProps, + }} + /> + setNumber(e.target.value)} + placeholder={t("APPS_CONTACT_FORM_NUMBER")} + fullWidth + inputProps={{ + className: classes.inputProps, + }} + /> + setAvatar(e.target.value)} + inputProps={{ + className: classes.inputProps, + }} + /> + +
+ + +
+
+
+
+ ); +}; diff --git a/phone/src/apps/contacts/components/modal/modal.styles.ts b/phone/src/apps/contacts/components/modal/modal.styles.ts new file mode 100644 index 0000000..7f0af19 --- /dev/null +++ b/phone/src/apps/contacts/components/modal/modal.styles.ts @@ -0,0 +1,49 @@ +import { makeStyles } from '@material-ui/core'; + +const useStyles = makeStyles((theme) => ({ + modalRoot: { + zIndex: 10, + position: 'absolute', + height: '100%', + width: '100%' + }, + modalHide: { + display: 'none' + }, + listContainer: { + marginTop: 30, + width: '75%', + margin: '0 auto', + textAlign: 'center', + }, + avatar: { + margin: 'auto', + height: '125px', + width: '124px', + marginBottom: 29 + }, + input: { + marginBottom: 20, + margin: 'auto', + textAlign: 'center', + }, + inputProps: { + fontSize: 22 + }, + updateButton: { + background: '#2196f3', + width: 150, + height: 45, + fontSize: 16, + marginTop: 29, + marginBottom: 29 + }, + deleteButton: { + background: '#d32f2f', + width: 150, + height: 40, + fontSize: 16 + } +})) + +export default useStyles; \ No newline at end of file diff --git a/phone/src/apps/contacts/hooks/state.ts b/phone/src/apps/contacts/hooks/state.ts index 8d725c3..0c5321b 100644 --- a/phone/src/apps/contacts/hooks/state.ts +++ b/phone/src/apps/contacts/hooks/state.ts @@ -16,5 +16,9 @@ export const contactsState = { showContactsModal: atom({ key: 'showContactModal', default: false + }), + contactDetail: atom({ + key: 'contactDetail', + default: null }) }; diff --git a/phone/src/apps/contacts/hooks/useContactDetail.ts b/phone/src/apps/contacts/hooks/useContactDetail.ts new file mode 100644 index 0000000..9c064e9 --- /dev/null +++ b/phone/src/apps/contacts/hooks/useContactDetail.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { contactsState } from './state'; + +export const useContactDetail = (): any => { + const [ contactDetail, setContactDetail ] = useRecoilState(contactsState.contactDetail); + return { contactDetail, setContactDetail }; +} \ No newline at end of file diff --git a/phone/src/apps/dialer/hooks/useDialerHistory.ts b/phone/src/apps/dialer/hooks/useDialerHistory.ts index cfc6d31..6a8e19a 100644 --- a/phone/src/apps/dialer/hooks/useDialerHistory.ts +++ b/phone/src/apps/dialer/hooks/useDialerHistory.ts @@ -3,12 +3,6 @@ import { useRecoilState, atom } from "recoil"; const dialerHistoryState = atom({ key: "dialerHistory", default: [ - { - id: 0, - caller: "Kidz", - phoneNumber: "000-1111", - type: "incoming", - }, { id: 1, caller: "ROCKY", diff --git a/phone/src/apps/notes/NotesApp.css b/phone/src/apps/notes/NotesApp.css new file mode 100644 index 0000000..ed44c69 --- /dev/null +++ b/phone/src/apps/notes/NotesApp.css @@ -0,0 +1,7 @@ +#notes-app .Mui-focused::after { + border-bottom: 3px solid #f9a825; +} + +#notes-app .MuiOutlinedInput-root { + border: 2px soild #f9a825; +} \ No newline at end of file diff --git a/phone/src/apps/notes/NotesApp.tsx b/phone/src/apps/notes/NotesApp.tsx new file mode 100644 index 0000000..d7d51bd --- /dev/null +++ b/phone/src/apps/notes/NotesApp.tsx @@ -0,0 +1,48 @@ +import React from "react"; +import { AppWrapper } from "../../ui/components/AppWrapper"; +import { AppContent } from "../../ui/components/AppContent"; +import NotesTitle from "./NotesTitle"; +import NoteList from "./list/NoteList"; + +import { useNotes } from "./hooks/useNotes"; +import { NoteModal } from "./modal/NoteModal"; +import { Fab } from "@material-ui/core"; +import AddIcon from "@material-ui/icons/Add"; + +import { useNoteModal } from "./hooks/useNoteModal"; +import { useNoteDetail } from "./hooks/useNoteDetail"; + +import useStyles from "./notes.styles"; + +export const NotesApp = () => { + const { setNoteModal } = useNoteModal(); + const { detail, setDetail } = useNoteDetail(); + const notes = useNotes(); + + const classes = useStyles(); + + const handleModal = () => { + setNoteModal(true); + setDetail(null); + }; + + return ( + + + + + + + + + + + ); +}; diff --git a/phone/src/apps/notes/NotesTitle.tsx b/phone/src/apps/notes/NotesTitle.tsx new file mode 100644 index 0000000..8197ac4 --- /dev/null +++ b/phone/src/apps/notes/NotesTitle.tsx @@ -0,0 +1,20 @@ +import React from 'react' + +import { yellow } from "@material-ui/core/colors"; + +import useStyles from './notes.styles'; + +import { Paper } from "@material-ui/core"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faStickyNote } from "@fortawesome/free-solid-svg-icons"; + +const NotesTitle = () => { + const classes = useStyles() + return ( + + + + ) +} + +export default NotesTitle; \ No newline at end of file diff --git a/phone/src/apps/notes/hooks/state.ts b/phone/src/apps/notes/hooks/state.ts new file mode 100644 index 0000000..9599aa0 --- /dev/null +++ b/phone/src/apps/notes/hooks/state.ts @@ -0,0 +1,16 @@ +import { atom } from 'recoil'; + +export const noteStates = { + noteItems: atom({ + key: 'noteItem', + default: [] + }), + noteModal: atom({ + key: 'noteModal', + default: false + }), + noteDetail: atom({ + key: 'noteDetail', + default: null + }) +} \ No newline at end of file diff --git a/phone/src/apps/notes/hooks/useNoteDetail.ts b/phone/src/apps/notes/hooks/useNoteDetail.ts new file mode 100644 index 0000000..9faab1e --- /dev/null +++ b/phone/src/apps/notes/hooks/useNoteDetail.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { noteStates } from './state'; + +export const useNoteDetail = (): any => { + const [detail, setDetail] = useRecoilState(noteStates.noteDetail); + return { detail, setDetail }; +} \ No newline at end of file diff --git a/phone/src/apps/notes/hooks/useNoteModal.ts b/phone/src/apps/notes/hooks/useNoteModal.ts new file mode 100644 index 0000000..adbcc9a --- /dev/null +++ b/phone/src/apps/notes/hooks/useNoteModal.ts @@ -0,0 +1,7 @@ +import { useRecoilState } from 'recoil'; +import { noteStates } from './state'; + +export const useNoteModal = () => { + const [noteModal, setNoteModal] = useRecoilState(noteStates.noteModal); + return { noteModal, setNoteModal }; +} \ No newline at end of file diff --git a/phone/src/apps/notes/hooks/useNotes.ts b/phone/src/apps/notes/hooks/useNotes.ts new file mode 100644 index 0000000..69ce277 --- /dev/null +++ b/phone/src/apps/notes/hooks/useNotes.ts @@ -0,0 +1,7 @@ +import { useRecoilValue } from 'recoil'; +import { noteStates } from './state'; + +export const useNotes = () => { + const notes = useRecoilValue(noteStates.noteItems); + return notes; +} diff --git a/phone/src/apps/notes/hooks/useNotesService.ts b/phone/src/apps/notes/hooks/useNotesService.ts new file mode 100644 index 0000000..3b7df58 --- /dev/null +++ b/phone/src/apps/notes/hooks/useNotesService.ts @@ -0,0 +1,10 @@ +import { useSetRecoilState } from 'recoil' +import { useNuiEvent } from '../../../os/nui-events/hooks/useNuiEvent'; +import { useNotes } from './useNotes'; +import { noteStates } from './state'; + +export const useNotesService = () => { + const setNotes = useSetRecoilState(noteStates.noteItems); + useNuiEvent('NOTES', 'setNotes', setNotes); + return useNotes(); +} \ No newline at end of file diff --git a/phone/src/apps/notes/list/NoteList.tsx b/phone/src/apps/notes/list/NoteList.tsx new file mode 100644 index 0000000..113c3d7 --- /dev/null +++ b/phone/src/apps/notes/list/NoteList.tsx @@ -0,0 +1,28 @@ +import { List, ListItem, ListItemText } from '@material-ui/core'; +import React, { useState } from 'react' + +import { useNoteModal } from '../hooks/useNoteModal'; +import { useNoteDetail } from '../hooks/useNoteDetail'; + +// add search bar later +const NoteList = ({notes}) => { + const { setNoteModal } = useNoteModal(); + const { setDetail } = useNoteDetail(); + + const handleNoteModal = (note) => { + setNoteModal(true) + setDetail(note) + } + + return ( + + {notes.map((note) => ( + handleNoteModal(note)}> + {note.title} + + ))} + + ) +} + +export default NoteList; diff --git a/phone/src/apps/notes/modal/NoteModal.tsx b/phone/src/apps/notes/modal/NoteModal.tsx new file mode 100644 index 0000000..141d752 --- /dev/null +++ b/phone/src/apps/notes/modal/NoteModal.tsx @@ -0,0 +1,116 @@ +import { + Button, + TextField, + Slide, +} from "@material-ui/core"; +import React, { useState } from "react"; +import ArrowBackIcon from "@material-ui/icons/ArrowBack"; + +import { useNoteModal } from "../hooks/useNoteModal"; +import { useNoteDetail } from "../hooks/useNoteDetail"; + +import useStyles from "./modal.styles"; + +import "../NotesApp.css"; +import Nui from "../../../os/nui-events/utils/Nui"; + +export const NoteModal = () => { + const { noteModal, setNoteModal } = useNoteModal(); + const { detail, setDetail } = useNoteDetail(); + console.log(detail); + const [title, setTitle] = useState(detail ? detail.title : ""); + const [content, setContent] = useState(detail ? detail.content : ""); + + const classes = useStyles(); + + const _handleClose = () => { + setNoteModal(false); + setDetail(null); + }; + + const handleNoteSave = () => { + setNoteModal(false); + setDetail(null); + Nui.send("phone:addNote", { + title, + content, + }); + }; + + const handleDeleteNote = () => { + const id = detail.id; + setNoteModal(false); + Nui.send("phone:deleteNote", { + id, + }); + setDetail(null); + }; + + const handleUpdateNote = () => { + Nui.send("phone:updateNote", { + id: detail.id, + title, + content, + }); + setNoteModal(false); + setDetail(null); + }; + + return ( +
+ +
+ +
+ setTitle(e.target.value)} + /> + setContent(e.target.value)} + /> + {!detail && ( + + )} + {detail && ( + + )} + {detail && ( + + )} +
+
+
+
+ ); +}; diff --git a/phone/src/apps/notes/modal/modal.styles.ts b/phone/src/apps/notes/modal/modal.styles.ts new file mode 100644 index 0000000..079dd05 --- /dev/null +++ b/phone/src/apps/notes/modal/modal.styles.ts @@ -0,0 +1,49 @@ +import { makeStyles } from '@material-ui/core'; + +const useStyles = makeStyles((theme) => ({ + modalRoot: { + zIndex: 20, + position: "absolute", + height: '100%', + width: '100%', + background: '#232323', + }, + modalHide: { + display: 'none' + }, + closeButton: { + width: '10%', + position: 'absolute', + top: 10, + left: 0 + }, + noteContainer: { + width: '90%', + marginTop: 80, + margin: '0 auto', + }, + input: { + marginBottom: 20, + }, + inputPropsTitle: { + fontSize: 28, + }, + inputPropsContent: { + fontSize: 20, + }, + saveButton: { + background: '#f9a825', + padding: '10px 30px' + }, + updateButton: { + background: '#f9a825', + padding: '10px 30px', + marginRight: '8px' + }, + deleteButton: { + background: '#c62828', + padding: '10px 30px' + } +})) + +export default useStyles; \ No newline at end of file diff --git a/phone/src/apps/notes/notes.styles.ts b/phone/src/apps/notes/notes.styles.ts new file mode 100644 index 0000000..2623a4d --- /dev/null +++ b/phone/src/apps/notes/notes.styles.ts @@ -0,0 +1,30 @@ +import { makeStyles } from '@material-ui/core'; + +const useStyles = makeStyles((theme) => ({ + header: { + width: '100%', + display: 'flex', + flexFlow: 'row nowrap', + justifyContent: 'center', + alignItems: 'center', + textAlign: 'center', + height: '60px', + }, + backgroundModal: { + background: "black", + opacity: "0.6", + position: "absolute", + top: 0, + left: 0, + right: 0, + bottom: 0, + zIndex: 5, + }, + absolute: { + position: "absolute", + bottom: theme.spacing(2), + right: theme.spacing(3), + }, +})) + +export default useStyles; \ No newline at end of file diff --git a/phone/src/common/interfaces/bank.ts b/phone/src/common/interfaces/bank.ts new file mode 100644 index 0000000..b11a21e --- /dev/null +++ b/phone/src/common/interfaces/bank.ts @@ -0,0 +1,14 @@ +export interface Credentials { + name: string; + balance: number; +} + +export interface Transfer { + id: number; + targetID: number; + source: string; + type: string; + transferAmount: number; + message: string; +} + diff --git a/phone/src/common/interfaces/config.ts b/phone/src/common/interfaces/config.ts index 85715eb..c5f43bf 100644 --- a/phone/src/common/interfaces/config.ts +++ b/phone/src/common/interfaces/config.ts @@ -16,6 +16,10 @@ interface NotificationConfig { vertical: "bottom" | "top"; } +interface BankConfig { + showNotifications: boolean; +} + export interface ServerConfig { Locale: string; KeyTogglePhone: number; @@ -26,5 +30,6 @@ export interface ServerConfig { DestoryChance: number; DestroyPhoneReCheck: number; twitter: TwitterConfig; + bank: BankConfig; notificationPosition: NotificationConfig; } diff --git a/phone/src/common/interfaces/notes.ts b/phone/src/common/interfaces/notes.ts new file mode 100644 index 0000000..8d9cb5d --- /dev/null +++ b/phone/src/common/interfaces/notes.ts @@ -0,0 +1,9 @@ +export interface Note { + id?: number; + title: string; + content: string; +} + +export interface NoteId { + id: number; +} \ No newline at end of file diff --git a/phone/src/index.tsx b/phone/src/index.tsx index c7fc224..eb1d652 100644 --- a/phone/src/index.tsx +++ b/phone/src/index.tsx @@ -8,11 +8,13 @@ import "./main.css"; import Phone from "./Phone"; import * as serviceWorker from "./serviceWorker"; import TwitterNotification from "./apps/twitter/components/notification/TwitterNotification"; +import { BankNotification } from "./apps/bank/components/notification/BankNotification"; ReactDOM.render( + , diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json index 148f759..644289d 100644 --- a/phone/src/locale/en.json +++ b/phone/src/locale/en.json @@ -39,9 +39,19 @@ "APPS_TWITTER_TIME_HOURS": "h", "APPS_TWITTER_TIME_DAYS": "d", - "APPS_BANK_HOME_TITLE": "Welcome, ", + "APPS_BANK_HOME_TITLE": "Welcome", + "APPS_BANK_ACCOUNT_LINK": "Account", + "APPS_BANK_TIME_JUST_NOW": "Just now", "APPS_BANK_ACCOUNT_TITLE": "Account Summary", "APPS_BANK_ACCOUNT_TRANSACTIONS": "Transactions", - "APPS_BANK_ACCOUNT_SEE_TRANSACTION": "See all" + "APPS_BANK_ACCOUNT_SEE_TRANSACTION": "See all", + "APPS_BANK_ACTIONS_TRANSFER": "Transfer", + "APPS_BANK_ALERT_TRANSFER_SUCCESS": "Transfer done successfully!", + "APPS_BANK_ALERT_TRANSFER_FAILURE": "Transfer failed!", + + "APPS_CONTACT_FORM_NAME": "Name", + "APPS_CONTACT_FORM_NUMBER": "Number", + "APPS_CONTACT_FORM_AVATAR": "Avatar URL" + } } diff --git a/phone/src/os/apps/hooks/useApps.tsx b/phone/src/os/apps/hooks/useApps.tsx index f744ab6..40b4d25 100644 --- a/phone/src/os/apps/hooks/useApps.tsx +++ b/phone/src/os/apps/hooks/useApps.tsx @@ -6,6 +6,7 @@ import { grey, green, purple, + yellow, red, amber, } from "@material-ui/core/colors"; @@ -14,7 +15,8 @@ import { faAd, faPlaneArrival, faPhoneAlt, - faWonSign + faWonSign, + faStickyNote } from "@fortawesome/free-solid-svg-icons"; import { faTwitter } from "@fortawesome/free-brands-svg-icons"; @@ -33,6 +35,7 @@ import { MessagesApp } from "../../../apps/messages/components/MessagesApp"; import { TwitterApp } from "../../../apps/twitter/components/TwitterApp"; import { ExampleApp } from "../../../apps/example/components/ExampleApp"; import { SelloutApp } from "../../../apps/sellout/components/SelloutApp"; +import { NotesApp } from "../../../apps/notes/NotesApp"; const appsState = atom({ key: "apps", @@ -110,6 +113,15 @@ const appsState = atom({ path: "/sellout", Route: () => , }, + { + id: 'NOTES', + name: 'APPS_NOTES', + icon: , + backgroundColor: yellow[800], + color: common.white, + path: "/notes", + Route: () => + }, { id: "EXAMPLE", nameLocale: "APPS_EXAMPLE", diff --git a/phone/src/ui/components/AppIcon.tsx b/phone/src/ui/components/AppIcon.tsx index 8b1e4be..2e3f20a 100644 --- a/phone/src/ui/components/AppIcon.tsx +++ b/phone/src/ui/components/AppIcon.tsx @@ -3,6 +3,7 @@ import { makeStyles } from "@material-ui/core/styles"; import Avatar from "@material-ui/core/Avatar"; import { green } from "@material-ui/core/colors"; import { Button } from "@material-ui/core"; +import Nui from "../../os/nui-events/utils/Nui"; interface IStyles { root: any; @@ -28,13 +29,18 @@ const useStyles = makeStyles( }) ); -export const AppIcon = ({ name, icon, backgroundColor, color }) => { +export const AppIcon = ({ id, name, icon, backgroundColor, color }) => { const classes = useStyles({ backgroundColor: backgroundColor || green[50], color: color || green[400], }); + + const openAppCallback = () => { + Nui.send(`phone:app:${id}`) + } + return ( -