Change themes!!!

This commit is contained in:
J Francisco Rader committed 2020-08-22 18:39:31 -03:00
1 parent bc20bfac99
commit 362ab8be4d
7 files changed
+84 -23

No files matched your search

+4 -2
View File
@@ -17,14 +17,16 @@
z-index: 999;
width: 500px;
height: 1000px;
pointer-events:none;
pointer-events: none;
}
.PhoneScreen {
overflow: hidden;
position: absolute;
background-color: black;
border: 8px solid black;
border-top: 2px solid black;
border-left: 4px solid black;
border-right: 4px solid black;
bottom: 100px;
left: 50px;
right: 50px;
+1 -1
View File
@@ -1,12 +1,12 @@
import React from "react";
import "./Phone.css";
import "./i18n";
import MessageIcon from "@material-ui/icons/Email";
import { Route } from "react-router-dom";
import { useSettings } from "./apps/settings/hooks/useSettings";
import { NotificationBar } from "./os/components/NotificationBar";
import { NotificationIcon } from "./os/components/NotificationIcon";
import { NavigationBar } from "./os/components/NavigationBar";
import MessageIcon from "@material-ui/icons/Email";
import { HomeApp } from "./apps/home/components/Home";
import { ContactsApp } from "./apps/contacts/components/Contacts";
+43 -13
View File
@@ -4,34 +4,64 @@ 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 { useContextMenu } from "../../../ui/hooks/useContextMenu";
import {
useContextMenu,
MapStringOptions,
} from "../../../ui/hooks/useContextMenu";
import { useConfig } from "../../../config/hooks/useConfig";
import { useSettings } from "../hooks/useSettings";
import { useApps } from "../../appmarket/hooks/useApps";
export const SettingItem = ({ options, label, value, onClick }) => {
return (
<ListItem onClick={() => onClick(options)} button>
<ListItemText primary={label} secondary={value} />
</ListItem>
);
};
export const SettingsApp = () => {
const { t } = useTranslation();
const [config] = useConfig();
const { getApp } = useApps();
const { setSettings, settings } = useSettings();
const wallpaperOptions = config.wallpapers.map((w) => ({
label: w,
key: w,
onClick: () => setSettings("wallpaper", w),
}));
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu(
wallpaperOptions
const wallpapers = config.wallpapers.map(
MapStringOptions(settings.wallpaper, (val) => setSettings("wallpaper", val))
);
const frames = config.frames.map(
MapStringOptions(settings.frame, (val) => setSettings("frame", val))
);
const themes = Object.keys(config.themes).map(
MapStringOptions(settings.theme, (val) => setSettings("theme", val))
);
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
return (
<AppWrapper>
<AppTitle color={getApp("settings").backgroundColor}>{t("APPS_SETTINGS")}</AppTitle>
<AppTitle color={getApp("settings").backgroundColor}>
{t("APPS_SETTINGS")}
</AppTitle>
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
<List>
<ListItem onClick={openMenu} button>
<ListItemText primary={t("APPS_SETTINGS_OPTIONS_WALLPAPER")} secondary={settings.wallpaper} />
</ListItem>
<SettingItem
label="Theme"
value={settings.theme}
options={themes}
onClick={openMenu}
/>
<SettingItem
label="Wallpaper"
value={settings.wallpaper}
options={wallpapers}
onClick={openMenu}
/>
<SettingItem
label="Frame"
value={settings.frame}
options={frames}
onClick={openMenu}
/>
</List>
</AppContent>
<ContextMenu />
+7 -1
View File
@@ -2,11 +2,17 @@
"4gNetowrk": "AT&T",
"language": "en_US",
"wallpapers": ["default.png", "dragon.jpg", "legacy.jpg"],
"frames": ["default.png", "s10.png"],
"themes": {
"default-dark": {
"palette": {
"type": "dark"
}
},
"default-light": {
"palette": {
"type": "light"
}
}
}
}
}
+2 -1
View File
@@ -5,6 +5,7 @@
"APPS_CONTACTS": "Contacts",
"APPS_MESSAGES": "Messages",
"APPS_SETTINGS": "Settings",
"APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper"
"APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper",
"APPS_SETTINGS_OPTIONS_FRAME": "Frame"
}
}
+2 -1
View File
@@ -12,7 +12,7 @@ import {
const useStyles = makeStyles((theme) => ({
root: {
width: "100%",
position: 'absolute',
position: "absolute",
bottom: 0,
zIndex: 2,
},
@@ -26,6 +26,7 @@ export const ContextMenu = ({ open, onClose, options }) => {
<List aria-label="context menu">
{options.map((option) => (
<ListItem
selected={option.selected}
button
key={option.key || option.label}
onClick={(e) => {
+25 -4
View File
@@ -1,9 +1,30 @@
import React, { useState } from "react";
import { ContextMenu } from "../components/ContextMenu";
export const useContextMenu = (options = []) => {
export const MapStringOptions = (current, onClick) => (string) => {
return {
selected: current === string,
label: string,
key: string,
onClick: () => onClick(string)
};
};
export const useContextMenu = (_options = []) => {
const [open, setOpen] = useState();
const [options, setOptions] = useState(_options);
const onClose = () => setOpen(false);
const onOpen = () => setOpen(true);
return [onOpen, onClose, () => <ContextMenu open={open} onClose={onClose} options={options} />, open]
};
const onOpen = (opts) => {
setOptions(opts);
setOpen(true);
};
return [
onOpen,
onClose,
() => <ContextMenu open={open} onClose={onClose} options={options} />,
open,
];
};