Make styling!!

This commit is contained in:
J Francisco Rader committed 2020-08-22 17:20:44 -03:00
1 parent 0bbd463c01
commit bc20bfac99
13 files changed
+115 -114

No files matched your search

+21 -16
View File
@@ -11,9 +11,12 @@ import { NavigationBar } from "./os/components/NavigationBar";
import { HomeApp } from "./apps/home/components/Home";
import { ContactsApp } from "./apps/contacts/components/Contacts";
import { SettingsApp } from "./apps/settings/components/Settings";
import { ThemeProvider, createMuiTheme } from "@material-ui/core";
import { useConfig } from "./config/hooks/useConfig";
function Phone() {
const { settings } = useSettings();
const [config] = useConfig();
return (
<div className="PhoneWrapper">
<div style={{ zoom: "80%" }}>
@@ -24,23 +27,25 @@ function Phone() {
backgroundImage: `${process.env.PUBLIC_URL}url(/media/frames/${settings.frame})`,
}}
></div>
<div
id="phone"
className="PhoneScreen"
style={{
backgroundImage: `${process.env.PUBLIC_URL}url(/media/backgrounds/${settings.wallpaper})`,
}}
>
<NotificationBar
notifications={[<NotificationIcon Icon={MessageIcon} />]}
/>
<div className="PhoneAppContainer">
<Route exact path="/" component={HomeApp} />
<Route exact path="/contacts" component={ContactsApp} />
<Route exact path="/settings" component={SettingsApp} />
<ThemeProvider theme={createMuiTheme(config.themes[settings.theme])}>
<div
id="phone"
className="PhoneScreen"
style={{
backgroundImage: `${process.env.PUBLIC_URL}url(/media/backgrounds/${settings.wallpaper})`,
}}
>
<NotificationBar
notifications={[<NotificationIcon Icon={MessageIcon} />]}
/>
<div className="PhoneAppContainer">
<Route exact path="/" component={HomeApp} />
<Route exact path="/contacts" component={ContactsApp} />
<Route exact path="/settings" component={SettingsApp} />
</div>
<NavigationBar />
</div>
<NavigationBar />
</div>
</ThemeProvider>
</div>
</div>
</div>
+8 -2
View File
@@ -8,7 +8,7 @@ import { atom } from "recoil";
const appsState = atom({
key: 'apps',
default: null
default: { preinstalled: [] }
});
export const useApps = () => {
@@ -17,6 +17,7 @@ export const useApps = () => {
useEffect(() => {
setApps("preinstalled", [
{
id: 'contacts',
name: t('APPS_CONTACTS'),
icon: <ContactsIcon />,
backgroundColor: blue[500],
@@ -24,6 +25,7 @@ export const useApps = () => {
path: '/contacts'
},
{
id: 'settings',
name: t('APPS_SETTINGS'),
icon: <SettingsIcon />,
backgroundColor: grey[700],
@@ -34,5 +36,9 @@ export const useApps = () => {
// eslint-disable-next-line
}, []);
return { apps, setApps };
const allApps = [...apps.preinstalled];
const getApp = id => allApps.find(a => a.id === id) || {};
return { apps, allApps, setApps, getApp };
};
+4 -17
View File
@@ -1,5 +1,4 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import List from "@material-ui/core/List";
import ListItem from "@material-ui/core/ListItem";
import ListItemText from "@material-ui/core/ListItemText";
@@ -8,31 +7,19 @@ import { Button } from "@material-ui/core";
import PhoneIcon from "@material-ui/icons/Phone";
import ChatIcon from "@material-ui/icons/Chat";
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
maxWidth: 360,
color: "#fff",
},
listItem: {
color: "#fff",
},
}));
export const ContactList = ({ contacts, onCall, onMessage }) => {
const classes = useStyles();
return (
<List component="nav" className={classes.root}>
<List>
{contacts.map((contact) => (
<ListItem divider className={classes.listItem}>
<ListItem key={contact.id} divider>
<ListItemText
primary={contact.display}
secondary={contact.phoneNumber}
/>
<Button className={classes.listItem} onClick={onCall}>
<Button onClick={onCall}>
<PhoneIcon />
</Button>
<Button className={classes.listItem} onClick={onMessage}>
<Button onClick={onMessage}>
<ChatIcon />
</Button>
</ListItem>
+12 -18
View File
@@ -1,33 +1,27 @@
import React from "react";
import { AppWrapper } from "../../../ui/components";
import { makeStyles } from "@material-ui/core";
import lightBlue from "@material-ui/core/colors/lightBlue";
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';
const useStyles = makeStyles(() => ({
root: {
backgroundColor: '#232323',
},
title: {
backgroundColor: lightBlue[300],
textAlign: 'center'
},
}));
import { ContactList } from "./ContactList";
import { useApps } from "../../appmarket/hooks/useApps";
export const ContactsApp = () => {
const classes = useStyles();
const { contactList } = useContacts();
const { getApp } = useApps();
const { t } = useTranslation();
return (
<AppWrapper className={classes.root}>
<AppTitle className={classes.title}>{t("APPS_CONTACTS")}</AppTitle>
<AppWrapper>
<AppTitle color={getApp("contacts").backgroundColor}>
{t("APPS_CONTACTS")}
</AppTitle>
<AppContent>
<ContactList contacts={contactList} onCall={() => console.log("Calling")} onMessage={() => console.log("Opening messages")}/>
<ContactList
contacts={contactList}
onCall={() => console.log("Calling")}
onMessage={() => console.log("Opening messages")}
/>
</AppContent>
</AppWrapper>
);
+2
View File
@@ -4,10 +4,12 @@ const contactListState = atom({
key: "contactList",
default: [
{
id: 0,
display: "Test Contact",
phoneNumber: "000-1111",
},
{
id: 1,
display: "Test Contact 2",
phoneNumber: "000-1112",
},
+8 -16
View File
@@ -1,31 +1,23 @@
import React from "react";
import { AppWrapper } from "../../../ui/components";
import { makeStyles, List, ListItem } from "@material-ui/core";
import { List, ListItem, ListItemText } from "@material-ui/core";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppContent } from "../../../ui/components/AppContent";
import { useTranslation } from "react-i18next";
import { grey } from "@material-ui/core/colors";
import { useContextMenu } from "../../../ui/hooks/useContextMenu";
import { useConfig } from "../../../config/hooks/useConfig";
import { useSettings } from "../hooks/useSettings";
const useStyles = makeStyles(() => ({
root: {
backgroundColor: grey[50],
},
title: {
backgroundColor: grey[600],
},
}));
import { useApps } from "../../appmarket/hooks/useApps";
export const SettingsApp = () => {
const classes = useStyles();
const { t } = useTranslation();
const [config] = useConfig();
const { setSettings } = useSettings();
const { getApp } = useApps();
const { setSettings, settings } = useSettings();
const wallpaperOptions = config.wallpapers.map((w) => ({
label: w,
key: w,
onClick: () => setSettings("wallpaper", w),
}));
@@ -33,12 +25,12 @@ export const SettingsApp = () => {
wallpaperOptions
);
return (
<AppWrapper className={classes.root}>
<AppTitle className={classes.title}>{t("APPS_SETTINGS")}</AppTitle>
<AppWrapper>
<AppTitle color={getApp("settings").backgroundColor}>{t("APPS_SETTINGS")}</AppTitle>
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
<List>
<ListItem onClick={openMenu} button>
{t("APPS_SETTINGS_OPTIONS_WALLPAPER")}
<ListItemText primary={t("APPS_SETTINGS_OPTIONS_WALLPAPER")} secondary={settings.wallpaper} />
</ListItem>
</List>
</AppContent>
+2 -1
View File
@@ -1,4 +1,5 @@
{
"wallpaper": "default.png",
"frame": "default.png"
"frame": "default.png",
"theme": "default-dark"
}
+10 -7
View File
@@ -1,9 +1,12 @@
{
"4gNetowrk": "AT&T",
"language": "en_US",
"wallpapers": [
"default.png",
"dragon.jpg",
"legacy.jpg"
]
"4gNetowrk": "AT&T",
"language": "en_US",
"wallpapers": ["default.png", "dragon.jpg", "legacy.jpg"],
"themes": {
"default-dark": {
"palette": {
"type": "dark"
}
}
}
}
+10 -13
View File
@@ -2,37 +2,34 @@ import React from "react";
import {
makeStyles,
BottomNavigation,
BottomNavigationAction,
BottomNavigationAction
} from "@material-ui/core";
import { grey } from "@material-ui/core/colors";
import KeyboardArrowLeftIcon from "@material-ui/icons/KeyboardArrowLeft";
import AppsIcon from "@material-ui/icons/Apps";
import { useHistory } from "react-router-dom";
const useStyles = makeStyles(() => ({
const useStyles = makeStyles((theme) => ({
root: {
backgroundColor: grey[800],
color: "white",
zIndex: 2
zIndex: 2,
backgroundColor: theme.palette.background.default,
},
icon: {
color: "white"
}
}));
export const NavigationBar = ({ notifications = [] }) => {
const classes = useStyles();
const history = useHistory()
const history = useHistory();
return (
<BottomNavigation
className={classes.root}
onChange={(_e, value) => value === 'back' ? history.goBack() : history.push('/')}
onChange={(_e, value) =>
value === "back" ? history.goBack() : history.push("/")
}
>
<BottomNavigationAction
label="Back"
value="back"
icon={<KeyboardArrowLeftIcon className={classes.icon} />}
icon={<KeyboardArrowLeftIcon />}
/>
<BottomNavigationAction
label="Home"
+14 -14
View File
@@ -1,5 +1,5 @@
import React from "react";
import { Box, makeStyles, Backdrop } from "@material-ui/core";
import { Box, makeStyles, Backdrop, Paper } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
box: {
@@ -10,6 +10,10 @@ const useStyles = makeStyles((theme) => ({
position: "absolute",
zIndex: 1,
},
paper: {
width: "100%",
height: "100%",
},
}));
export const AppContent = ({
@@ -21,19 +25,15 @@ export const AppContent = ({
}) => {
const classes = useStyles();
return (
<Box
px={2}
pt={1}
flexGrow={1}
style={{ width: "100%", ...props }}
{...props}
>
<Backdrop
className={classes.backdrop}
open={backdrop}
onClick={onClickBackdrop}
></Backdrop>
{children}
<Box flexGrow={1} className={classes.box} {...props}>
<Paper square px={2} pt={1} elevation={0} className={classes.paper}>
<Backdrop
className={classes.backdrop}
open={backdrop || false}
onClick={onClickBackdrop}
></Backdrop>
{children}
</Paper>
</Box>
);
};
+16 -4
View File
@@ -1,10 +1,22 @@
import React from "react";
import { Typography, Box } from "@material-ui/core";
import { Typography, Box, makeStyles } from "@material-ui/core";
export const AppTitle = ({ children, style, ...props }) => {
const useStyle = makeStyles(theme => ({
root: ({ color }) => ({
width: '100%',
textAlign: 'center',
backgroundColor: color || theme.palette.background.default
}),
text: {
color: theme.palette.text.primary
}
}));
export const AppTitle = ({ children, color, ...props }) => {
const classes = useStyle({ color });
return (
<Box px={2} pt={4} style={{ width: '100%', ...props }} {...props}>
<Typography paragraph variant="h4">{children}</Typography>
<Box px={2} pt={4} className={classes.root} {...props}>
<Typography className={classes.text} paragraph variant="h4">{children}</Typography>
</Box>
);
};
+1
View File
@@ -10,6 +10,7 @@ export const AppWrapper = ({ children, style, handleClickAway, ...props }) => {
width: "100%",
height: "100%",
display: "flex",
position: 'relative',
flexDirection: "column",
...style,
}}
+7 -6
View File
@@ -6,13 +6,14 @@ import {
ListItemText,
Slide,
makeStyles,
Paper,
} from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
backgroundColor: theme.palette.background.default,
color: "black",
position: 'absolute',
bottom: 0,
zIndex: 2,
},
}));
@@ -21,12 +22,12 @@ export const ContextMenu = ({ open, onClose, options }) => {
const classes = useStyles();
return (
<Slide direction="up" in={open} mountOnEnter unmountOnExit>
<div className={classes.root}>
<List component="nav" aria-label="context menu">
<Paper square className={classes.root}>
<List aria-label="context menu">
{options.map((option) => (
<ListItem
button
key={option.key}
key={option.key || option.label}
onClick={(e) => {
option.onClick(e, option);
onClose();
@@ -37,7 +38,7 @@ export const ContextMenu = ({ open, onClose, options }) => {
</ListItem>
))}
</List>
</div>
</Paper>
</Slide>
);
};