From 2b94b56c9218059e25ad2e2376324a2c345f4c88 Mon Sep 17 00:00:00 2001 From: J Francisco Rader Date: Sat, 22 Aug 2020 02:59:35 -0300 Subject: [PATCH] Wohoo --- package.json | 1 + src/apps/appmarket/hooks/useApps.js | 33 ++++++++++++++++++++++++ src/apps/contacts/components/Contacts.js | 26 ++++++++++++++----- src/apps/home/components/AppIcon.js | 4 +-- src/apps/home/components/GridMenu.js | 6 ++--- src/apps/home/components/Home.js | 7 ++--- src/apps/settings/default.json | 24 +---------------- src/ui/components/AppContent.js | 10 +++++++ src/ui/components/AppTitle.js | 10 +++++++ src/ui/components/AppWrapper.js | 12 +++++++-- yarn.lock | 7 +++++ 11 files changed, 99 insertions(+), 41 deletions(-) create mode 100644 src/apps/appmarket/hooks/useApps.js create mode 100644 src/ui/components/AppContent.js create mode 100644 src/ui/components/AppTitle.js diff --git a/package.json b/package.json index 86ea291..767ec24 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "private": true, "dependencies": { "@material-ui/core": "^4.11.0", + "@material-ui/icons": "^4.9.1", "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.5.0", "@testing-library/user-event": "^7.2.1", diff --git a/src/apps/appmarket/hooks/useApps.js b/src/apps/appmarket/hooks/useApps.js new file mode 100644 index 0000000..1df2a2a --- /dev/null +++ b/src/apps/appmarket/hooks/useApps.js @@ -0,0 +1,33 @@ +import React, { createContext, useEffect } from "react"; +import { useConfig } from "../../../config/hooks/useConfig"; +import ContactsIcon from "@material-ui/icons/Contacts"; + +const AppsContext = createContext(null); + +export const useApps = () => { + const [apps, setApps] = useConfig(AppsContext); + + useEffect(() => { + setApps("preinstalled", [ + { + name: "Contacts", + icon: , + }, + { + name: "Contacts1", + }, + { + name: "Contacts2", + }, + { + name: "Contacts3", + }, + { + name: "Contacts4", + }, + ]); + // eslint-disable-next-line + }, []); + + return [apps, setApps]; +}; diff --git a/src/apps/contacts/components/Contacts.js b/src/apps/contacts/components/Contacts.js index d4585b0..c41c56f 100644 --- a/src/apps/contacts/components/Contacts.js +++ b/src/apps/contacts/components/Contacts.js @@ -1,15 +1,27 @@ import React from "react"; import { AppWrapper } from "../../../ui/components"; -import { useSettings } from "../../settings/hooks/useSettings"; -import { Box } from "@material-ui/core"; +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"; + +const useStyles = makeStyles(() => ({ + root: { + backgroundColor: lightBlue[50], + }, + title: { + backgroundColor: lightBlue[300], + }, +})); export const ContactsApp = () => { - const [settings] = useSettings(); + const classes = useStyles(); return ( - - - Contacts !!! - + + Contacts + + Coming soon... + ); }; diff --git a/src/apps/home/components/AppIcon.js b/src/apps/home/components/AppIcon.js index ba9cf21..c0a0933 100644 --- a/src/apps/home/components/AppIcon.js +++ b/src/apps/home/components/AppIcon.js @@ -1,7 +1,6 @@ import React from "react"; import { makeStyles } from "@material-ui/core/styles"; import Avatar from "@material-ui/core/Avatar"; -import { useSettings } from "../../settings/hooks/useSettings"; import { Button } from "@material-ui/core"; const useStyles = makeStyles((theme) => ({ @@ -19,7 +18,6 @@ const useStyles = makeStyles((theme) => ({ })); export const AppIcon = ({ label, icon }) => { - const [settings] = useSettings(); const classes = useStyles(); - return ; + return ; }; diff --git a/src/apps/home/components/GridMenu.js b/src/apps/home/components/GridMenu.js index a3826aa..438171d 100644 --- a/src/apps/home/components/GridMenu.js +++ b/src/apps/home/components/GridMenu.js @@ -5,9 +5,9 @@ import { Link } from "react-router-dom"; export const GridMenu = ({ apps }) => { return ( - - {apps.map((app) => ( - + + {apps && apps.length && apps.map((app) => ( + ))} diff --git a/src/apps/home/components/Home.js b/src/apps/home/components/Home.js index c250ac9..5cc2d5d 100644 --- a/src/apps/home/components/Home.js +++ b/src/apps/home/components/Home.js @@ -3,18 +3,19 @@ import { AppWrapper } from "../../../ui/components"; import { useSettings } from "../../settings/hooks/useSettings"; import { GridMenu } from "./GridMenu"; import { Box } from "@material-ui/core"; +import { useApps } from "../../appmarket/hooks/useApps"; export const HomeApp = () => { const [settings] = useSettings(); + const [apps] = useApps(); + console.log(apps) return ( - - - + {apps && } ); }; diff --git a/src/apps/settings/default.json b/src/apps/settings/default.json index 8f0642e..e0a2dc4 100644 --- a/src/apps/settings/default.json +++ b/src/apps/settings/default.json @@ -1,25 +1,3 @@ { - "wallpaper": "default.png", - "apps": [ - { - "name": "Contacts", - "icon": "contacts.png" - }, - { - "name": "Contacts", - "icon": "contacts.png" - }, - { - "name": "Contacts", - "icon": "contacts.png" - }, - { - "name": "Contacts", - "icon": "contacts.png" - }, - { - "name": "Contacts", - "icon": "contacts.png" - } - ] + "wallpaper": "default.png" } \ No newline at end of file diff --git a/src/ui/components/AppContent.js b/src/ui/components/AppContent.js new file mode 100644 index 0000000..c3d4e9f --- /dev/null +++ b/src/ui/components/AppContent.js @@ -0,0 +1,10 @@ +import React from "react"; +import { Box } from "@material-ui/core"; + +export const AppContent = ({ children, style, ...props }) => { + return ( + + {children} + + ); +}; diff --git a/src/ui/components/AppTitle.js b/src/ui/components/AppTitle.js new file mode 100644 index 0000000..058de73 --- /dev/null +++ b/src/ui/components/AppTitle.js @@ -0,0 +1,10 @@ +import React from "react"; +import { Typography, Box } from "@material-ui/core"; + +export const AppTitle = ({ children, style, ...props }) => { + return ( + + {children} + + ); +}; diff --git a/src/ui/components/AppWrapper.js b/src/ui/components/AppWrapper.js index 5357899..8424ee3 100644 --- a/src/ui/components/AppWrapper.js +++ b/src/ui/components/AppWrapper.js @@ -4,9 +4,17 @@ export const AppWrapper = ({ children, style, ...props }) => { return (
-
{children}
+ {children}
); }; diff --git a/yarn.lock b/yarn.lock index 6909ac9..9124a3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1379,6 +1379,13 @@ react-is "^16.8.0" react-transition-group "^4.4.0" +"@material-ui/icons@^4.9.1": + version "4.9.1" + resolved "https://registry.yarnpkg.com/@material-ui/icons/-/icons-4.9.1.tgz#fdeadf8cb3d89208945b33dbc50c7c616d0bd665" + integrity sha512-GBitL3oBWO0hzBhvA9KxqcowRUsA0qzwKkURyC8nppnC3fw54KPKZ+d4V1Eeg/UnDRSzDaI9nGCdel/eh9AQMg== + dependencies: + "@babel/runtime" "^7.4.4" + "@material-ui/styles@^4.10.0": version "4.10.0" resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.10.0.tgz#2406dc23aa358217aa8cc772e6237bd7f0544071"