mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-02 06:28:52 +00:00
Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3fdab50485 | ||
|
|
bb8d765bc6 | ||
|
|
e268dae34b | ||
|
|
d14e534b9a | ||
|
|
9896f2384e | ||
|
|
64beb6b69b | ||
|
|
4c73f66ab5 | ||
|
|
c0cca9ceb8 |
No files matched your search
+3
-2
@@ -33,6 +33,7 @@ import WindowSnackbar from './ui/components/WindowSnackbar';
|
||||
import { usePhone } from './os/phone/hooks/usePhone';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||
import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
|
||||
|
||||
function Phone() {
|
||||
const { t, i18n } = useTranslation();
|
||||
@@ -104,8 +105,8 @@ function Phone() {
|
||||
id="phone"
|
||||
className="PhoneScreen"
|
||||
style={{
|
||||
backgroundImage: settings.customWallpaper
|
||||
? `url(${settings.customWallpaper})`
|
||||
backgroundImage: !isDefaultWallpaper(settings.wallpaper.value)
|
||||
? `url(${settings.wallpaper.value})`
|
||||
: `url(media/backgrounds/${settings.wallpaper.value})`,
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -10,10 +10,7 @@ import {
|
||||
Tooltip,
|
||||
Typography,
|
||||
Switch,
|
||||
TextField,
|
||||
} from '@material-ui/core';
|
||||
import CreateIcon from '@material-ui/icons/Create';
|
||||
import { PictureThumbnail } from '../../../ui/components/PictureThumbnail';
|
||||
|
||||
interface ISettingItem {
|
||||
options?: any;
|
||||
@@ -109,15 +106,3 @@ export const SettingItemIconAction = ({
|
||||
</ListItem>
|
||||
</>
|
||||
);
|
||||
|
||||
export const SettingItemModal = ({ icon, label, secondary, onClick }) => (
|
||||
<ListItem divider>
|
||||
<ListItemIcon>{icon}</ListItemIcon>
|
||||
<ListItemText primary={label} secondary={secondary} />
|
||||
<ListItemSecondaryAction>
|
||||
<IconButton onClick={onClick}>
|
||||
<CreateIcon />
|
||||
</IconButton>
|
||||
</ListItemSecondaryAction>
|
||||
</ListItem>
|
||||
);
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
import { AppWrapper } from '../../../ui/components';
|
||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||
import { AppContent } from '../../../ui/components/AppContent';
|
||||
@@ -12,7 +12,6 @@ import {
|
||||
SettingItemIconAction,
|
||||
SettingItemSlider,
|
||||
SettingSwitch,
|
||||
SettingItemModal,
|
||||
} from './SettingItem';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import VisibilityOffIcon from '@material-ui/icons/VisibilityOff';
|
||||
@@ -73,9 +72,9 @@ export const SettingsApp = () => {
|
||||
};
|
||||
|
||||
const wallpapers = config.wallpapers.map(
|
||||
MapSettingItem(settings.wallpaper, (val: SettingOption) =>
|
||||
handleSettingChange('wallpaper', val),
|
||||
),
|
||||
MapSettingItem(settings.wallpaper, (val: SettingOption) => {
|
||||
handleSettingChange('wallpaper', val);
|
||||
}),
|
||||
);
|
||||
const frames = config.frames.map(
|
||||
MapSettingItem(settings.frame, (val: SettingOption) => handleSettingChange('frame', val)),
|
||||
@@ -128,6 +127,13 @@ export const SettingsApp = () => {
|
||||
},
|
||||
];
|
||||
|
||||
const customWallpaper: IContextMenuOption = {
|
||||
selected: false,
|
||||
onClick: () => setCustomWallpaperModal(true),
|
||||
key: 'CUSTOM_WALLPAPER',
|
||||
label: t('APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER'),
|
||||
};
|
||||
|
||||
const handleCopyPhoneNumber = () => {
|
||||
setClipboard(simcard.number);
|
||||
addAlert({
|
||||
@@ -209,17 +215,10 @@ export const SettingsApp = () => {
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_WALLPAPER')}
|
||||
value={settings.wallpaper.label}
|
||||
options={wallpapers}
|
||||
options={[...wallpapers, customWallpaper]}
|
||||
onClick={openMenu}
|
||||
icon={<Wallpaper />}
|
||||
/>
|
||||
{/* CUSTOM BACKGROUND */}
|
||||
<SettingItemModal
|
||||
icon={<Wallpaper />}
|
||||
label={t('APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER')}
|
||||
secondary={settings.customWallpaper}
|
||||
onClick={() => setCustomWallpaperModal(true)}
|
||||
/>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_FRAME')}
|
||||
value={settings.frame.label}
|
||||
|
||||
@@ -1,86 +1,52 @@
|
||||
import React, { useState } from 'react';
|
||||
import Modal from '../../../ui/components/Modal';
|
||||
import { useCustomWallpaperModal, useSettings } from '../hooks/useSettings';
|
||||
import { Box, Button, TextField } from '@material-ui/core';
|
||||
import { PictureThumbnail } from '../../../ui/components/PictureThumbnail';
|
||||
import { TextField } from '@material-ui/core';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { StatusButton } from '../../../ui/components/StatusButton';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
input: {
|
||||
marginTop: 10,
|
||||
marginBottom: 10,
|
||||
},
|
||||
inputProps: {
|
||||
fontSize: 18,
|
||||
},
|
||||
});
|
||||
import DialogForm from '../../../ui/components/DialogForm';
|
||||
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||
|
||||
export default function WallpaperModal() {
|
||||
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
|
||||
const [settings, setSettings] = useSettings();
|
||||
const { t } = useTranslation();
|
||||
const [value, setValue] = useState(settings.customWallpaper ? settings.customWallpaper : '');
|
||||
const classes = useStyles();
|
||||
const [value, setValue] = useState('');
|
||||
const { addAlert } = useSnackbar();
|
||||
|
||||
const isImage = (url) => {
|
||||
const isImageAndUrl = (url) => {
|
||||
return /(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|png|jpeg|gif)/g.test(url);
|
||||
};
|
||||
|
||||
const handleCloseModal = () => {
|
||||
setCustomWallpaperModal(false);
|
||||
};
|
||||
|
||||
const handleSettingChange = (key: string | number, value: unknown) => {
|
||||
setSettings({ ...settings, [key]: value });
|
||||
};
|
||||
|
||||
const handleNewWallpaper = () => {
|
||||
handleSettingChange('customWallpaper', value);
|
||||
};
|
||||
|
||||
const handleRemoveWallpaper = () => {
|
||||
handleSettingChange('customWallpaper', '');
|
||||
if (isImageAndUrl(value)) {
|
||||
handleSettingChange('wallpaper', {
|
||||
label: t('APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER'),
|
||||
value,
|
||||
});
|
||||
setCustomWallpaperModal(false);
|
||||
} else {
|
||||
addAlert({ message: t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_ERROR'), type: 'error' });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal visible={customWallpaperModal} handleClose={handleCloseModal}>
|
||||
<Box
|
||||
display="flex"
|
||||
justifyContent="center"
|
||||
alignItems="center"
|
||||
textAlign="center"
|
||||
flexDirection="column"
|
||||
>
|
||||
{settings.customWallpaper && (
|
||||
<PictureThumbnail src={settings.customWallpaper} alt="chipisbest" />
|
||||
)}
|
||||
<TextField
|
||||
value={value}
|
||||
variant="outlined"
|
||||
className={classes.input}
|
||||
onChange={(e) => setValue(e.currentTarget.value)}
|
||||
inputProps={{
|
||||
className: classes.inputProps,
|
||||
}}
|
||||
placeholder="Image URL"
|
||||
/>
|
||||
<Button
|
||||
color="primary"
|
||||
variant="contained"
|
||||
disabled={!isImage(value)}
|
||||
onClick={handleNewWallpaper}
|
||||
style={{ marginBottom: 10 }}
|
||||
>
|
||||
{t('APPS_SETTINGS_SET_CUSTOM_WALLPAPER')}
|
||||
</Button>
|
||||
{settings.customWallpaper && (
|
||||
<StatusButton color="error" variant="contained" onClick={handleRemoveWallpaper}>
|
||||
{t('GENERIC_DELETE')}
|
||||
</StatusButton>
|
||||
)}
|
||||
</Box>
|
||||
</Modal>
|
||||
<DialogForm
|
||||
open={customWallpaperModal}
|
||||
handleClose={() => setCustomWallpaperModal(false)}
|
||||
onSubmit={handleNewWallpaper}
|
||||
title={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_TITLE')}
|
||||
content={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_CONTENT')}
|
||||
>
|
||||
<TextField
|
||||
value={value}
|
||||
error={!isImageAndUrl(value) && true}
|
||||
onChange={(e) => setValue(e.currentTarget.value)}
|
||||
placeholder={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_PLACEHOLDER')}
|
||||
fullWidth
|
||||
/>
|
||||
</DialogForm>
|
||||
);
|
||||
}
|
||||
@@ -23,7 +23,6 @@ const settingsSchema: Schema = {
|
||||
properties: {
|
||||
language: { $ref: '/SettingOption' },
|
||||
wallpaper: { $ref: '/SettingOption' },
|
||||
customWallpaper: { type: 'string' },
|
||||
frame: { $ref: '/SettingOption' },
|
||||
theme: { $ref: '/SettingOption' },
|
||||
zoom: { $ref: '/SettingOption' },
|
||||
@@ -64,7 +63,6 @@ export function isSettingsSchemaValid(): boolean {
|
||||
export interface IPhoneSettings {
|
||||
language: SettingOption;
|
||||
wallpaper: SettingOption;
|
||||
customWallpaper: string;
|
||||
frame: SettingOption;
|
||||
theme: SettingOption;
|
||||
zoom: SettingOption;
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import config from '../../../config/default.json';
|
||||
|
||||
export const isDefaultWallpaper = (value: string) => {
|
||||
const wallpapers = config.wallpapers;
|
||||
for (const wallpaper of wallpapers) {
|
||||
if (wallpaper.value === value) return true;
|
||||
}
|
||||
};
|
||||
@@ -191,6 +191,10 @@
|
||||
{
|
||||
"label": "Default Light",
|
||||
"value": "default-light"
|
||||
},
|
||||
{
|
||||
"label": "Kiddo Dark",
|
||||
"value": "kiddo-dark"
|
||||
}
|
||||
],
|
||||
"debug": {
|
||||
|
||||
@@ -34,5 +34,20 @@
|
||||
}
|
||||
},
|
||||
"divider": "rgba(255, 255, 255, 0.12)"
|
||||
},
|
||||
"kiddo-dark": {
|
||||
"palette": {
|
||||
"type": "dark",
|
||||
"primary": {
|
||||
"main": "#EBFEF3"
|
||||
},
|
||||
"secondary": {
|
||||
"main": "#5E0035"
|
||||
},
|
||||
"background": {
|
||||
"default": "#033A18",
|
||||
"paper": "#011308"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,13 @@
|
||||
"OPTIONS": {
|
||||
"LANGUAGE": "Language",
|
||||
"RESET_SETTINGS": "Reset Settings",
|
||||
"RESET_SETTINGS_DESC": "This will clear your locally stored data"
|
||||
"RESET_SETTINGS_DESC": "This will clear your locally stored data",
|
||||
"CUSTOM_WALLPAPER": {
|
||||
"DIALOG_TITLE": "Custom Wallpaper",
|
||||
"DIALOG_CONTENT": "Set a custom wallpaper by entering the URL of the image below!",
|
||||
"DIALOG_PLACEHOLDER": "Image URL",
|
||||
"DIALOG_ERROR": "Invalid image or link"
|
||||
}
|
||||
},
|
||||
"MESSAGES": {
|
||||
"INVALID_SETTINGS": "Invalid stored settings! Please reset in the Settings App.",
|
||||
@@ -195,7 +201,6 @@
|
||||
"APPS_SETTINGS_OPTION_NOTIFICATION": "Notification",
|
||||
"APPS_SETTINGS_OPTION_NOTIFICATIONVOL": "Notification Volume",
|
||||
"APPS_SETTING_STREAMER_MODE_DESC": "Hide images before they are shown",
|
||||
"APPS_SETTINGS_SET_CUSTOM_WALLPAPER": "Set new wallpaper",
|
||||
|
||||
"APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Successfully created a new listing",
|
||||
"APPS_MARKETPLACE_CREATE_LISTING_FAILED": "Failed to create a new listing",
|
||||
|
||||
@@ -1,46 +1,9 @@
|
||||
import React, { createContext, useRef, useState } from 'react';
|
||||
import React from 'react';
|
||||
import { AppWrapperTypes } from '../interface/InterfaceUI';
|
||||
import { Computer } from '@material-ui/icons';
|
||||
import PhoneDrawer from './PhoneDrawer';
|
||||
|
||||
const items = [
|
||||
{
|
||||
onClick: () => console.log(),
|
||||
icon: <Computer color="inherit" />,
|
||||
text: 'Item Thing',
|
||||
},
|
||||
{
|
||||
onClick: () => console.log(),
|
||||
icon: <Computer color="inherit" />,
|
||||
text: 'Item Thing',
|
||||
},
|
||||
{
|
||||
onClick: () => console.log(),
|
||||
icon: <Computer color="inherit" />,
|
||||
text: 'Item Thing',
|
||||
},
|
||||
{
|
||||
onClick: () => console.log(),
|
||||
icon: <Computer color="inherit" />,
|
||||
text: 'Item Thing',
|
||||
},
|
||||
];
|
||||
|
||||
export const AppWrapper = ({
|
||||
children,
|
||||
style,
|
||||
handleClickAway,
|
||||
sideMenu,
|
||||
appName,
|
||||
...props
|
||||
}: AppWrapperTypes) => {
|
||||
const ref = useRef();
|
||||
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
export const AppWrapper = ({ children, style, handleClickAway, ...props }: AppWrapperTypes) => {
|
||||
return (
|
||||
<div
|
||||
ref={ref}
|
||||
{...props}
|
||||
style={{
|
||||
padding: 0,
|
||||
@@ -54,13 +17,6 @@ export const AppWrapper = ({
|
||||
...style,
|
||||
}}
|
||||
>
|
||||
<PhoneDrawer
|
||||
open={open}
|
||||
handleClose={() => setOpen(false)}
|
||||
appTitle={'Side Menu Thing'}
|
||||
containerEl={ref.current}
|
||||
items={items}
|
||||
/>
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
import React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { Button, DialogContent, DialogContentText, DialogTitle, Paper } from '@material-ui/core';
|
||||
import DialogActions from '@material-ui/core/DialogActions';
|
||||
|
||||
const useStyles = makeStyles({
|
||||
root: {
|
||||
paddingLeft: '10px',
|
||||
zIndex: 10,
|
||||
width: '90%',
|
||||
display: 'flex',
|
||||
flexFlow: 'column nowrap',
|
||||
position: 'absolute',
|
||||
top: '80px',
|
||||
},
|
||||
displayBlock: {
|
||||
/*Sets modal to center*/
|
||||
display: 'flex',
|
||||
flexFlow: 'column nowrap',
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
position: 'relative',
|
||||
},
|
||||
displayNone: {
|
||||
display: 'none',
|
||||
},
|
||||
});
|
||||
|
||||
interface DialogFormProps {
|
||||
children: React.ReactNode;
|
||||
open: boolean;
|
||||
handleClose: any; // No idea what those types are
|
||||
onSubmit: any;
|
||||
title: string;
|
||||
content: string;
|
||||
}
|
||||
|
||||
export default function DialogForm({
|
||||
children,
|
||||
open,
|
||||
handleClose,
|
||||
onSubmit,
|
||||
title,
|
||||
content,
|
||||
}: DialogFormProps) {
|
||||
const classes = useStyles();
|
||||
|
||||
const showHideClassName = open ? classes.displayBlock : classes.displayNone;
|
||||
|
||||
return (
|
||||
<div className={showHideClassName}>
|
||||
<Paper className={classes.root}>
|
||||
<DialogTitle id="form-dialog-title">{title}</DialogTitle>
|
||||
<DialogContent>
|
||||
<DialogContentText>{content}</DialogContentText>
|
||||
{children}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button color="primary" onClick={handleClose}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button color="primary" onClick={onSubmit}>
|
||||
Confirm
|
||||
</Button>
|
||||
</DialogActions>
|
||||
</Paper>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
import React from 'react';
|
||||
import {
|
||||
ListItem,
|
||||
List,
|
||||
ListItemText,
|
||||
ListItemIcon,
|
||||
Drawer,
|
||||
Typography,
|
||||
Box,
|
||||
Divider,
|
||||
Button,
|
||||
useTheme,
|
||||
} from '@material-ui/core';
|
||||
import { ChevronLeft, Settings } from '@material-ui/icons';
|
||||
import { makeStyles, Theme } from '@material-ui/core/styles';
|
||||
|
||||
interface DrawerItem {
|
||||
onClick: () => void;
|
||||
text: string;
|
||||
icon?: JSX.Element;
|
||||
}
|
||||
|
||||
const BackAction = ({ handleClose }) => (
|
||||
<Button
|
||||
component={Box}
|
||||
display="flex"
|
||||
flexDirection="row"
|
||||
alignItems="center"
|
||||
left="16px"
|
||||
position="absolute"
|
||||
bottom="16px"
|
||||
onClick={handleClose}
|
||||
>
|
||||
<ChevronLeft color="secondary" />
|
||||
<Typography variant="body1" color="textSecondary">
|
||||
Close
|
||||
</Typography>
|
||||
</Button>
|
||||
);
|
||||
|
||||
interface PhoneDrawer {
|
||||
open: boolean;
|
||||
handleClose: () => void;
|
||||
containerEl: Element;
|
||||
items: DrawerItem[];
|
||||
appTitle?: string;
|
||||
}
|
||||
|
||||
const useStyles = makeStyles((theme: Theme) => ({
|
||||
sidebarTitle: {
|
||||
marginLeft: 20,
|
||||
color: theme.palette.secondary.contrastText,
|
||||
},
|
||||
}));
|
||||
|
||||
const PhoneDrawer: React.FC<PhoneDrawer> = ({
|
||||
items,
|
||||
open,
|
||||
containerEl,
|
||||
handleClose,
|
||||
appTitle,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
|
||||
const classes = useStyles();
|
||||
|
||||
return (
|
||||
<Drawer
|
||||
open={open}
|
||||
onClose={() => {}}
|
||||
PaperProps={{ style: { position: 'absolute', width: '70%' } }}
|
||||
BackdropProps={{ style: { position: 'absolute' } }}
|
||||
ModalProps={{
|
||||
container: containerEl,
|
||||
style: { position: 'absolute' },
|
||||
}}
|
||||
variant="temporary"
|
||||
>
|
||||
<Box height="100%">
|
||||
<Box
|
||||
display="flex"
|
||||
flexDirection="row"
|
||||
alignItems="center"
|
||||
p={2}
|
||||
bgcolor={theme.palette.secondary.main}
|
||||
>
|
||||
<Settings htmlColor={theme.palette.secondary.contrastText} />
|
||||
{appTitle && (
|
||||
<Typography variant="h6" className={classes.sidebarTitle}>
|
||||
{appTitle}
|
||||
</Typography>
|
||||
)}
|
||||
</Box>
|
||||
<List disablePadding>
|
||||
{items.map((item) => (
|
||||
<>
|
||||
<ListItem
|
||||
button
|
||||
onClick={item.onClick}
|
||||
style={{ color: theme.palette.text.secondary }}
|
||||
>
|
||||
{item?.icon && <ListItemIcon>{item.icon}</ListItemIcon>}
|
||||
<ListItemText primary={item.text} />
|
||||
</ListItem>
|
||||
<Divider />
|
||||
</>
|
||||
))}
|
||||
</List>
|
||||
<BackAction handleClose={handleClose} />
|
||||
</Box>
|
||||
</Drawer>
|
||||
);
|
||||
};
|
||||
|
||||
export default PhoneDrawer;
|
||||
@@ -9,9 +9,7 @@ export interface AppContentTypes {
|
||||
|
||||
export interface AppWrapperTypes {
|
||||
id?: string;
|
||||
appName?: string;
|
||||
children?: JSX.Element | JSX.Element[];
|
||||
style?: CSSProperties;
|
||||
handleClickAway?: (...args: any[]) => void;
|
||||
sideMenu?: string[];
|
||||
}
|
||||
Reference in new issue
Block a user