mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
Add phone service, rename phone app to dialer, etc improvements
This commit is contained in:
1 parent
bf2e7fa295
commit
b2e0cba844
24 files changed
+311
-255
No files matched your search
@@ -1,73 +0,0 @@
|
||||
import React, { useEffect } from "react";
|
||||
import { useConfig } from "../../../config/hooks/useConfig";
|
||||
import { blue, grey, green, orange } from "@material-ui/core/colors";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import ContactsIcon from "@material-ui/icons/Contacts";
|
||||
import SettingsIcon from '@material-ui/icons/Settings'
|
||||
import PhoneIcon from '@material-ui/icons/Phone';
|
||||
import AccountBalanceIcon from '@material-ui/icons/AccountBalance';
|
||||
import { atom } from "recoil";
|
||||
import { useSettings } from "../../settings/hooks/useSettings";
|
||||
import { CalculatorIcon } from "../../calculator/components/CalculatorIcon";
|
||||
|
||||
const appsState = atom({
|
||||
key: "apps",
|
||||
default: { preinstalled: [] },
|
||||
});
|
||||
|
||||
export const useApps = () => {
|
||||
const [apps, setApps] = useConfig(appsState);
|
||||
const { currentTheme } = useSettings();
|
||||
const { t } = useTranslation();
|
||||
useEffect(() => {
|
||||
setApps("preinstalled", [
|
||||
{
|
||||
id: "phone",
|
||||
name: t("APPS_PHONE"),
|
||||
icon: <PhoneIcon />,
|
||||
backgroundColor: green[400],
|
||||
color: green[50],
|
||||
path: "/phone",
|
||||
},
|
||||
{
|
||||
id: "contacts",
|
||||
name: t("APPS_CONTACTS"),
|
||||
icon: <ContactsIcon />,
|
||||
backgroundColor: blue[500],
|
||||
color: blue[50],
|
||||
path: "/contacts",
|
||||
},
|
||||
{
|
||||
id: "calculator",
|
||||
name: t("APPS_CALCULATOR"),
|
||||
icon: <CalculatorIcon />,
|
||||
backgroundColor: currentTheme().palette.primary.light,
|
||||
color: currentTheme().palette.primary.contrastText,
|
||||
path: "/calculator",
|
||||
},
|
||||
{
|
||||
id: "settings",
|
||||
name: t("APPS_SETTINGS"),
|
||||
icon: <SettingsIcon />,
|
||||
backgroundColor: grey[700],
|
||||
color: grey[50],
|
||||
path: '/settings'
|
||||
},
|
||||
{
|
||||
id: 'bank',
|
||||
name: t('APPS_BANK'),
|
||||
icon: <AccountBalanceIcon />,
|
||||
backgroundColor: orange[600],
|
||||
color: orange[50],
|
||||
path: '/bank'
|
||||
},
|
||||
]);
|
||||
// eslint-disable-next-line
|
||||
}, []);
|
||||
|
||||
const allApps = [...apps.preinstalled];
|
||||
|
||||
const getApp = (id) => allApps.find((a) => a.id === id) || {};
|
||||
|
||||
return { apps, allApps, setApps, getApp };
|
||||
};
|
||||
@@ -5,9 +5,10 @@ import { AppWrapper } from "../../../ui/components";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Button } from "@material-ui/core";
|
||||
import { useBank } from '../hooks/useBank';
|
||||
import { TransactionList } from './transactionList';
|
||||
import { useBank } from "../hooks/useBank";
|
||||
import { TransactionList } from "./TransactionList";
|
||||
import "./BankApp.css";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -33,11 +34,10 @@ export const BankApp = () => {
|
||||
const { transactionList } = useBank();
|
||||
const { t } = useTranslation();
|
||||
const classes = useStyles();
|
||||
const bank = useApp("BANK");
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle className={classes.root}>
|
||||
<h1 className={classes.header}>WhoDis Banking</h1>
|
||||
</AppTitle>
|
||||
<AppTitle {...bank} className={classes.root} />
|
||||
<AppContent>
|
||||
<div className={classes.bankOptions}>
|
||||
<Button className={classes.bankOptionsButton}>
|
||||
@@ -50,9 +50,7 @@ export const BankApp = () => {
|
||||
{t("APPS_BANK_TRANSFER")}
|
||||
</Button>
|
||||
</div>
|
||||
<TransactionList
|
||||
transactions={transactionList}
|
||||
/>
|
||||
<TransactionList transactions={transactionList} />
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
import React from 'react';
|
||||
import { List } from '../../../ui/components/List';
|
||||
import { ListItem } from '../../../ui/components/ListItem';
|
||||
import React from "react";
|
||||
import { List } from "../../../ui/components/List";
|
||||
import { ListItem } from "../../../ui/components/ListItem";
|
||||
import ListItemText from "@material-ui/core/ListItemText";
|
||||
|
||||
export const TransactionList = ({ transactions }) => {
|
||||
return (
|
||||
<List>
|
||||
{transactions.map((transaction) => (
|
||||
<ListItem key={transaction.id} divider>
|
||||
<ListItemText
|
||||
primary={transaction.amount}
|
||||
secondary={transaction.type}
|
||||
/>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<List>
|
||||
{transactions.map((transaction) => (
|
||||
<ListItem key={transaction.id} divider>
|
||||
<ListItemText
|
||||
primary={transaction.amount}
|
||||
secondary={transaction.type}
|
||||
/>
|
||||
</ListItem>
|
||||
))}
|
||||
</List>
|
||||
);
|
||||
};
|
||||
@@ -2,18 +2,14 @@ import React from "react";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useApps } from "../../appmarket/hooks/useApps";
|
||||
import { Calculator } from "./Calculator";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
|
||||
export const CalculatorApp = () => {
|
||||
const { t } = useTranslation();
|
||||
const { getApp } = useApps();
|
||||
const calculator = useApp("CALCULATOR");
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle color={getApp("calculator").backgroundColor}>
|
||||
{t("APPS_CALCULATOR")}
|
||||
</AppTitle>
|
||||
<AppTitle {...calculator} />
|
||||
<AppContent>
|
||||
<Calculator />
|
||||
</AppContent>
|
||||
|
||||
@@ -2,24 +2,20 @@ import React from "react";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useContacts } from "../hooks/useContacts";
|
||||
import { ContactList } from "./ContactList";
|
||||
import { useApps } from "../../appmarket/hooks/useApps";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
|
||||
export const ContactsApp = () => {
|
||||
const { contactList } = useContacts();
|
||||
const { getApp } = useApps();
|
||||
const { t } = useTranslation();
|
||||
const contacts = useApp("CONTACTS");
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle color={getApp("contacts").backgroundColor}>
|
||||
{t("APPS_CONTACTS")}
|
||||
</AppTitle>
|
||||
<AppTitle {...contacts} />
|
||||
<AppContent>
|
||||
<ContactList
|
||||
contacts={contactList}
|
||||
onCall={(contact => console.log(contact))}
|
||||
onCall={(contact) => console.log(contact)}
|
||||
onMessage={() => console.log("Opening messages")}
|
||||
/>
|
||||
</AppContent>
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { DialerHistory } from "./DialerHistory";
|
||||
import { useDialerHistory } from "../hooks/useDialerHistory";
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
|
||||
export const DialerApp = () => {
|
||||
const { history } = useDialerHistory();
|
||||
const dialer = useApp("DIALER");
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle {...dialer} />
|
||||
<AppContent>
|
||||
<DialerHistory calls={history} />
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
+1
-1
@@ -10,7 +10,7 @@ const CallTypeIcon = {
|
||||
outgoing: <PhoneForwardedIcon />,
|
||||
};
|
||||
|
||||
export const PhoneList = ({ calls }) => {
|
||||
export const DialerHistory = ({ calls }) => {
|
||||
return (
|
||||
<List>
|
||||
{calls.map((call) => (
|
||||
@@ -0,0 +1,24 @@
|
||||
import { useRecoilState, atom } from "recoil";
|
||||
|
||||
const dialerHistoryState = atom({
|
||||
key: "dialerHistory",
|
||||
default: [
|
||||
{
|
||||
id: 0,
|
||||
caller: "Kidz",
|
||||
phoneNumber: "000-1111",
|
||||
type: "incoming",
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
caller: "ROCKY",
|
||||
phoneNumber: "000-1112",
|
||||
type: "outgoing",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const useDialerHistory = () => {
|
||||
const [history, setHistory] = useRecoilState(dialerHistoryState);
|
||||
return { history, setHistory };
|
||||
};
|
||||
@@ -1,14 +1,16 @@
|
||||
import React from "react";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { Box } from "@material-ui/core";
|
||||
import { useApps } from "../../appmarket/hooks/useApps";
|
||||
import { GridMenu } from "../../../ui/components/GridMenu";
|
||||
import { useApps } from "../../../os/apps/hooks/useApps";
|
||||
|
||||
export const HomeApp = () => {
|
||||
const { apps } = useApps();
|
||||
return (
|
||||
<AppWrapper>
|
||||
<Box width="100%" mt={6} px={1}>{apps && <GridMenu items={apps.preinstalled} />}</Box>
|
||||
<Box width="100%" mt={6} px={1}>
|
||||
{apps && <GridMenu items={apps.preinstalled} />}
|
||||
</Box>
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
@@ -1,26 +0,0 @@
|
||||
import React from 'react'
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useApps } from "../../appmarket/hooks/useApps";
|
||||
import { PhoneList } from './PhoneList';
|
||||
import { useCalls } from '../hooks/useCalls';
|
||||
|
||||
export const PhoneApp = () => {
|
||||
const { callList } = useCalls();
|
||||
const { getApp } = useApps();
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle color={getApp("phone").backgroundColor}>
|
||||
{t("APPS_PHONE")}
|
||||
</AppTitle>
|
||||
<AppContent>
|
||||
<PhoneList
|
||||
calls={callList}
|
||||
/>
|
||||
</AppContent>
|
||||
</AppWrapper>
|
||||
)
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
import { useRecoilState, atom } from 'recoil';
|
||||
|
||||
const callListState = atom({
|
||||
key: 'callList',
|
||||
default: [
|
||||
{
|
||||
id: 0,
|
||||
caller: 'Kidz',
|
||||
phoneNumber: "000-1111",
|
||||
type: 'incoming'
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
caller: 'ROCKY',
|
||||
phoneNumber: '000-1112',
|
||||
type: 'outgoing'
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
export const useCalls = () => {
|
||||
const [callList, setCallList] = useRecoilState
|
||||
(callListState);
|
||||
return { callList, setCallList };
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import React from "react";
|
||||
import { ListItem, ListItemText, Divider } from "@material-ui/core";
|
||||
|
||||
export const SettingItem = ({ options, label, value, onClick }) => {
|
||||
return (
|
||||
<>
|
||||
<ListItem onClick={() => onClick(options)} button>
|
||||
<ListItemText primary={label} secondary={value} />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
</>
|
||||
);
|
||||
};
|
||||
@@ -1,37 +1,23 @@
|
||||
import React from "react";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { ListItemText, Divider } from "@material-ui/core";
|
||||
import { AppTitle } from "../../../ui/components/AppTitle";
|
||||
import { AppContent } from "../../../ui/components/AppContent";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
useContextMenu,
|
||||
MapStringOptions,
|
||||
} from "../../../ui/hooks/useContextMenu";
|
||||
import { useConfig } from "../../../config/hooks/useConfig";
|
||||
import { useSettings } from "../hooks/useSettings";
|
||||
import { useApps } from "../../appmarket/hooks/useApps";
|
||||
import { List } from "../../../ui/components/List";
|
||||
import { ListItem } from "../../../ui/components/ListItem";
|
||||
import { useSimcard } from "../../../os/simcard/hooks/useSimcard";
|
||||
|
||||
export const SettingItem = ({ options, label, value, onClick }) => {
|
||||
return (
|
||||
<>
|
||||
<ListItem onClick={() => onClick(options)} button>
|
||||
<ListItemText primary={label} secondary={value} />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
</>
|
||||
);
|
||||
};
|
||||
import { useApp } from "../../../os/apps/hooks/useApps";
|
||||
import { SettingItem } from "./SettingItem";
|
||||
|
||||
export const SettingsApp = () => {
|
||||
const { t } = useTranslation();
|
||||
const settingsApp = useApp("SETTINGS");
|
||||
const [config] = useConfig();
|
||||
const { getApp } = useApps();
|
||||
const { setSettings, settings } = useSettings();
|
||||
const simcard = useSimcard();
|
||||
const simcard = useSimcard();
|
||||
|
||||
const wallpapers = config.wallpapers.map(
|
||||
MapStringOptions(settings.wallpaper, (val) => setSettings("wallpaper", val))
|
||||
@@ -46,9 +32,7 @@ export const SettingsApp = () => {
|
||||
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
|
||||
return (
|
||||
<AppWrapper>
|
||||
<AppTitle color={getApp("settings").backgroundColor}>
|
||||
{t("APPS_SETTINGS")}
|
||||
</AppTitle>
|
||||
<AppTitle {...settingsApp} />
|
||||
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
||||
<List>
|
||||
<SettingItem
|
||||
@@ -69,10 +53,7 @@ export const SettingsApp = () => {
|
||||
options={frames}
|
||||
onClick={openMenu}
|
||||
/>
|
||||
<SettingItem
|
||||
label="Phone Number"
|
||||
value={simcard.number}
|
||||
/>
|
||||
<SettingItem label="Phone Number" value={simcard.number} />
|
||||
</List>
|
||||
</AppContent>
|
||||
<ContextMenu />
|
||||
|
||||
Reference in new issue
Block a user