mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 06:28:51 +00:00
Add config and settings!
This commit is contained in:
1 parent
16004a9a86
commit
3900b9fa83
14 files changed
+90
-9
No files matched your search
+1
-1
@@ -1,7 +1,7 @@
|
||||
import React from "react";
|
||||
import "./Phone.css";
|
||||
import { HomeApp } from "./apps/home";
|
||||
import { Route } from "react-router-dom";
|
||||
import { HomeApp } from "./apps/home/components/Home";
|
||||
|
||||
function Phone() {
|
||||
return (
|
||||
|
||||
Whitespace-only changes.
@@ -0,0 +1,7 @@
|
||||
import React from "react";
|
||||
import { useSettings } from "../../settings/hooks/useSettings";
|
||||
|
||||
export const AppIcon = ({ label, icon }) => {
|
||||
const [settings] = useSettings();
|
||||
return <span>{label}</span>;
|
||||
};
|
||||
@@ -0,0 +1,14 @@
|
||||
import React from "react";
|
||||
import { AppIcon } from "./AppIcon";
|
||||
|
||||
export const GridMenu = ({ apps }) => {
|
||||
return (
|
||||
<div style={{ display: "flex" }}>
|
||||
{apps.map((app) => (
|
||||
<div style={{ flex: '1 1 20%', }}>
|
||||
<AppIcon icon={app.icon} label={app.name} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,6 +1,17 @@
|
||||
import React from 'react';
|
||||
import { AppWrapper } from '../../../ui/components';
|
||||
import React from "react";
|
||||
import { AppWrapper } from "../../../ui/components";
|
||||
import { useSettings } from "../../settings/hooks/useSettings";
|
||||
import { GridMenu } from "./GridMenu";
|
||||
|
||||
export const HomeApp = ({}) => {
|
||||
return <AppWrapper style={{backgroundImage: `${process.env.PUBLIC_URL}url(/media/backgrounds/default.png)` }}>Home!</AppWrapper>
|
||||
export const HomeApp = () => {
|
||||
const [settings] = useSettings();
|
||||
return (
|
||||
<AppWrapper
|
||||
style={{
|
||||
backgroundImage: `${process.env.PUBLIC_URL}url(/media/backgrounds/${settings.wallpaper})`,
|
||||
}}
|
||||
>
|
||||
<GridMenu apps={settings.apps} />
|
||||
</AppWrapper>
|
||||
);
|
||||
};
|
||||
@@ -1 +0,0 @@
|
||||
export * from './components/Home';
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"wallpaper": "default.png",
|
||||
"apps": [
|
||||
{
|
||||
"name": "Contacts",
|
||||
"icon": "contacts.png"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import { createContext } from 'react';
|
||||
import Default from '../default.json';
|
||||
import { useConfig } from '../../../config/hooks/useConfig';
|
||||
|
||||
export const SettingsContext = createContext(Default);
|
||||
|
||||
export const useSettings = () => {
|
||||
return useConfig(SettingsContext);
|
||||
};
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"4gNetowrk": "AT&T",
|
||||
"language": "en_US"
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
import { createContext, useContext, useEffect, useState } from "react";
|
||||
import _set from "lodash/set";
|
||||
import Default from "../default.json";
|
||||
|
||||
export const ConfigContext = createContext(Default);
|
||||
|
||||
export const useConfig = (Context = ConfigContext) => {
|
||||
const configCtx = useContext(Context);
|
||||
const [config, _setConfig] = useState({ ...configCtx });
|
||||
|
||||
useEffect(() => {
|
||||
_setConfig({ ...configCtx });
|
||||
}, [configCtx]);
|
||||
|
||||
const setConfig = (key, value) => {
|
||||
const state = { ...config };
|
||||
_setConfig(_set(state, key, value));
|
||||
};
|
||||
return [config, setConfig];
|
||||
};
|
||||
@@ -1,5 +1,12 @@
|
||||
import React from 'react';
|
||||
import React from "react";
|
||||
|
||||
export const AppWrapper = ({ children, style, ...props }) => {
|
||||
return <div {...props} style={{width: '100%', height: '100%', display: 'flex', ...style}}>{children}</div>
|
||||
return (
|
||||
<div
|
||||
{...props}
|
||||
style={{ width: "100%", height: "100%", display: "flex", ...style }}
|
||||
>
|
||||
<div style={{ padding: "1em" }}>{children}</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user