mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
enhance(phone/settings): Added labels to settings and misc cleanup
This change alters the default localStorage schema, please clear your localStorage cache for testing
This commit is contained in:
1 parent
5969d33dc3
commit
64c4e0ec16
11 files changed
+290
-210
No files matched your search
+3
-3
@@ -59,21 +59,21 @@ function Phone() {
|
|||||||
className="Phone"
|
className="Phone"
|
||||||
style={{
|
style={{
|
||||||
transformOrigin: 'right bottom',
|
transformOrigin: 'right bottom',
|
||||||
transform: `scale(${settings.zoom}`,
|
transform: `scale(${settings.zoom.value}`,
|
||||||
bottom,
|
bottom,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
className="PhoneFrame"
|
className="PhoneFrame"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(./media/frames/${settings.frame})`,
|
backgroundImage: `url(./media/frames/${settings.frame.value})`,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<div
|
<div
|
||||||
id="phone"
|
id="phone"
|
||||||
className="PhoneScreen"
|
className="PhoneScreen"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(./media/backgrounds/${settings.wallpaper})`,
|
backgroundImage: `url(./media/backgrounds/${settings.wallpaper.value})`,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ListItem, ListItemText, ListItemIcon } from '@material-ui/core';
|
import {
|
||||||
|
ListItem,
|
||||||
|
ListItemText,
|
||||||
|
ListItemIcon,
|
||||||
|
ListItemSecondaryAction,
|
||||||
|
Box,
|
||||||
|
Slider,
|
||||||
|
} from '@material-ui/core';
|
||||||
|
|
||||||
interface IProps {
|
interface ISettingItem {
|
||||||
options?: any;
|
options?: any;
|
||||||
label: string;
|
label: string;
|
||||||
value?: string | number | null;
|
value?: string | number | null;
|
||||||
@@ -9,11 +16,35 @@ interface IProps {
|
|||||||
icon: JSX.Element;
|
icon: JSX.Element;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SettingItem = ({ options, label, value, onClick, icon }: IProps) => {
|
export const SettingItem = ({ options, label, value, onClick, icon }: ISettingItem) => (
|
||||||
return (
|
<ListItem divider onClick={() => onClick?.(options)} button>
|
||||||
<ListItem divider onClick={() => onClick?.(options)} button>
|
<ListItemIcon>{icon}</ListItemIcon>
|
||||||
<ListItemIcon>{icon}</ListItemIcon>
|
<ListItemText primary={label} secondary={value ? value : undefined} />
|
||||||
<ListItemText primary={label} secondary={value ? value : undefined} />
|
</ListItem>
|
||||||
</ListItem>
|
);
|
||||||
);
|
|
||||||
};
|
interface ISettingSlider {
|
||||||
|
label: string;
|
||||||
|
icon: JSX.Element;
|
||||||
|
value: number;
|
||||||
|
onCommit: (event: React.ChangeEvent<{}>, value: number | number[]) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SettingItemSlider = ({ icon, label, value, onCommit }: ISettingSlider) => (
|
||||||
|
<ListItem divider>
|
||||||
|
<ListItemIcon>{icon}</ListItemIcon>
|
||||||
|
<ListItemText primary={label} secondary={`${value}%`} />
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<Box p={2} width={150}>
|
||||||
|
<Slider
|
||||||
|
key={`slider-${value}`}
|
||||||
|
defaultValue={value}
|
||||||
|
min={0}
|
||||||
|
max={100}
|
||||||
|
valueLabelDisplay="auto"
|
||||||
|
onChangeCommitted={onCommit}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
);
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React from 'react';
|
||||||
import { AppWrapper } from '../../../ui/components';
|
import { AppWrapper } from '../../../ui/components';
|
||||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||||
import { AppContent } from '../../../ui/components/AppContent';
|
import { AppContent } from '../../../ui/components/AppContent';
|
||||||
import { useContextMenu, MapStringOptions } from '../../../ui/hooks/useContextMenu';
|
import { useContextMenu, MapSettingItem, SettingOption } from '../../../ui/hooks/useContextMenu';
|
||||||
import { useConfig } from '../../../config/hooks/useConfig';
|
import { useConfig } from '../../../config/hooks/useConfig';
|
||||||
import { List } from '../../../ui/components/List';
|
import { List } from '../../../ui/components/List';
|
||||||
import { useSimcard } from '../../../os/simcard/hooks/useSimcard';
|
import { useSimcard } from '../../../os/simcard/hooks/useSimcard';
|
||||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||||
import { SettingItem } from './SettingItem';
|
import { SettingItem, SettingItemSlider } from './SettingItem';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -20,17 +20,8 @@ import {
|
|||||||
VolumeUp,
|
VolumeUp,
|
||||||
} from '@material-ui/icons';
|
} from '@material-ui/icons';
|
||||||
|
|
||||||
import {
|
import { ListSubheader } from '@material-ui/core';
|
||||||
Box,
|
import { useSettings } from '../hooks/useSettings';
|
||||||
ListItem,
|
|
||||||
ListItemIcon,
|
|
||||||
ListItemSecondaryAction,
|
|
||||||
ListItemText,
|
|
||||||
ListSubheader,
|
|
||||||
Slider,
|
|
||||||
} from '@material-ui/core';
|
|
||||||
import { useRecoilState } from 'recoil';
|
|
||||||
import { settingsState } from '../hooks/useSettings';
|
|
||||||
|
|
||||||
const SubHeaderComp = (props: { text: string }) => (
|
const SubHeaderComp = (props: { text: string }) => (
|
||||||
<ListSubheader color="primary" component="div" disableSticky>
|
<ListSubheader color="primary" component="div" disableSticky>
|
||||||
@@ -42,57 +33,39 @@ export const SettingsApp = () => {
|
|||||||
const settingsApp = useApp('SETTINGS');
|
const settingsApp = useApp('SETTINGS');
|
||||||
const [config] = useConfig();
|
const [config] = useConfig();
|
||||||
const simcard = useSimcard();
|
const simcard = useSimcard();
|
||||||
const [settings, setSettings] = useRecoilState(settingsState);
|
const [settings, setSettings] = useSettings();
|
||||||
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const handleSettingChange = (key: string | number, value: unknown) => {
|
const handleSettingChange = (key: string | number, value: unknown) => {
|
||||||
setSettings({ ...settings, [key]: value });
|
setSettings({ ...settings, [key]: value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const [sliders, setSliders] = useState([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
setSliders((curr) => {
|
|
||||||
if (!curr.length) {
|
|
||||||
return [settings.ringtoneVol, settings.notificationVol, settings.TWITTER_notificationVol];
|
|
||||||
}
|
|
||||||
return curr;
|
|
||||||
});
|
|
||||||
}, [settings.notificationVol, settings.ringtoneVol, settings.TWITTER_notificationVol]);
|
|
||||||
|
|
||||||
const handleSliderChange = (idx) => (_e: any, value: number | number[]) => {
|
|
||||||
setSliders((curr) => {
|
|
||||||
const newValues = [...curr];
|
|
||||||
newValues[idx] = value;
|
|
||||||
return newValues;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const wallpapers = config.wallpapers.map(
|
const wallpapers = config.wallpapers.map(
|
||||||
MapStringOptions(settings.wallpaper, (val: string) => handleSettingChange('wallpaper', val)),
|
MapSettingItem(settings.wallpaper, (val: SettingOption) =>
|
||||||
|
handleSettingChange('wallpaper', val),
|
||||||
|
),
|
||||||
);
|
);
|
||||||
const frames = config.frames.map(
|
const frames = config.frames.map(
|
||||||
MapStringOptions(settings.frame, (val: string) => handleSettingChange('frame', val)),
|
MapSettingItem(settings.frame, (val: SettingOption) => handleSettingChange('frame', val)),
|
||||||
);
|
);
|
||||||
const themes = Object.keys(config.themes).map(
|
const themes = config.themes.map(
|
||||||
MapStringOptions(settings.theme, (val: string) => handleSettingChange('theme', val)),
|
MapSettingItem(settings.theme, (val: SettingOption) => handleSettingChange('theme', val)),
|
||||||
);
|
);
|
||||||
const zoomOptions = config.zoomOptions.map(
|
const zoomOptions = config.zoomOptions.map(
|
||||||
MapStringOptions(settings.zoom, (val: string) => handleSettingChange('zoom', val)),
|
MapSettingItem(settings.zoom, (val: SettingOption) => handleSettingChange('zoom', val)),
|
||||||
);
|
);
|
||||||
const ringtones = config.ringtones.map(
|
const ringtones = config.ringtones.map(
|
||||||
MapStringOptions(settings.ringtone, (val: string) => handleSettingChange('ringtone', val)),
|
MapSettingItem(settings.ringtone, (val: SettingOption) => handleSettingChange('ringtone', val)),
|
||||||
);
|
);
|
||||||
const notifications = config.notifications.map(
|
const notifications = config.notiSounds.map(
|
||||||
MapStringOptions(settings.notification, (val: string) =>
|
MapSettingItem(settings.notiSound, (val: SettingOption) =>
|
||||||
handleSettingChange('notification', val),
|
handleSettingChange('notiSound', val),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
const twitterNotifications = config.notifications.map(
|
const twitterNotifications = config.notiSounds.map(
|
||||||
MapStringOptions(settings.notification, (val: string) =>
|
MapSettingItem(settings.notiSound, (item: SettingOption) =>
|
||||||
handleSettingChange('TWITTER_notification', val),
|
handleSettingChange('TWITTER_notiSound', item),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -109,84 +82,56 @@ export const SettingsApp = () => {
|
|||||||
/>
|
/>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_RINGTONE')}
|
label={t('APPS_SETTINGS_OPTION_RINGTONE')}
|
||||||
value={settings.ringtone}
|
value={settings.ringtone.label}
|
||||||
options={ringtones}
|
options={ringtones}
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
icon={<LibraryMusic />}
|
icon={<LibraryMusic />}
|
||||||
/>
|
/>
|
||||||
<ListItem divider>
|
<SettingItemSlider
|
||||||
<ListItemIcon>
|
label={t('APPS_SETTINGS_OPTION_RINGTONEVOL')}
|
||||||
<VolumeUp />
|
icon={<VolumeUp />}
|
||||||
</ListItemIcon>
|
value={settings.ringtoneVol}
|
||||||
<ListItemText
|
onCommit={(e, val) => handleSettingChange('ringtoneVol', val)}
|
||||||
primary={t('APPS_SETTINGS_OPTION_RINGTONEVOL')}
|
/>
|
||||||
secondary={settings.ringtoneVol}
|
|
||||||
/>
|
|
||||||
<ListItemSecondaryAction>
|
|
||||||
<Box p={2} width={150}>
|
|
||||||
<Slider
|
|
||||||
value={sliders[0] || settings.ringtoneVol}
|
|
||||||
min={0}
|
|
||||||
max={100}
|
|
||||||
onChange={handleSliderChange(0)}
|
|
||||||
onChangeCommitted={() => handleSettingChange('ringtoneVol', sliders[0])}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</ListItemSecondaryAction>
|
|
||||||
</ListItem>
|
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
||||||
value={settings.notification}
|
value={settings.notiSound.label}
|
||||||
options={notifications}
|
options={notifications}
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
icon={<LibraryMusic />}
|
icon={<LibraryMusic />}
|
||||||
/>
|
/>
|
||||||
<ListItem divider>
|
<SettingItemSlider
|
||||||
<ListItemIcon>
|
label={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
||||||
<VolumeUp />
|
icon={<VolumeUp />}
|
||||||
</ListItemIcon>
|
value={settings.notiSoundVol}
|
||||||
<ListItemText
|
onCommit={(e, val) => handleSettingChange('notiSoundVol', val)}
|
||||||
primary={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
/>
|
||||||
secondary={settings.notificationVol}
|
|
||||||
/>
|
|
||||||
<ListItemSecondaryAction>
|
|
||||||
<Box p={2} width={150}>
|
|
||||||
<Slider
|
|
||||||
value={sliders[1] || settings.notificationVol}
|
|
||||||
min={0}
|
|
||||||
max={100}
|
|
||||||
onChange={handleSliderChange(1)}
|
|
||||||
onChangeCommitted={() => handleSettingChange('notificationVol', sliders[1])}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</ListItemSecondaryAction>
|
|
||||||
</ListItem>
|
|
||||||
</List>
|
</List>
|
||||||
<List disablePadding subheader={<SubHeaderComp text="Appearance" />}>
|
<List disablePadding subheader={<SubHeaderComp text="Appearance" />}>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_THEME')}
|
label={t('APPS_SETTINGS_OPTION_THEME')}
|
||||||
value={settings.theme}
|
value={settings.theme.label}
|
||||||
options={themes}
|
options={themes}
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
icon={<Brush />}
|
icon={<Brush />}
|
||||||
/>
|
/>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_WALLPAPER')}
|
label={t('APPS_SETTINGS_OPTION_WALLPAPER')}
|
||||||
value={settings.wallpaper}
|
value={settings.wallpaper.label}
|
||||||
options={wallpapers}
|
options={wallpapers}
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
icon={<Wallpaper />}
|
icon={<Wallpaper />}
|
||||||
/>
|
/>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_FRAME')}
|
label={t('APPS_SETTINGS_OPTION_FRAME')}
|
||||||
value={settings.frame}
|
value={settings.frame.label}
|
||||||
options={frames}
|
options={frames}
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
icon={<Smartphone />}
|
icon={<Smartphone />}
|
||||||
/>
|
/>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_ZOOM')}
|
label={t('APPS_SETTINGS_OPTION_ZOOM')}
|
||||||
value={settings.zoom}
|
value={settings.zoom.label}
|
||||||
options={zoomOptions}
|
options={zoomOptions}
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
icon={<ZoomIn />}
|
icon={<ZoomIn />}
|
||||||
@@ -195,34 +140,17 @@ export const SettingsApp = () => {
|
|||||||
<List disablePadding subheader={<SubHeaderComp text={t('APPS_TWITTER')} />}>
|
<List disablePadding subheader={<SubHeaderComp text={t('APPS_TWITTER')} />}>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
||||||
value={settings.TWITTER_notification}
|
value={settings.TWITTER_notiSound.label}
|
||||||
options={twitterNotifications}
|
options={twitterNotifications}
|
||||||
onClick={openMenu}
|
onClick={openMenu}
|
||||||
icon={<LibraryMusic />}
|
icon={<LibraryMusic />}
|
||||||
/>
|
/>
|
||||||
<ListItem divider>
|
<SettingItemSlider
|
||||||
<ListItemIcon>
|
label={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
||||||
<VolumeUp />
|
value={settings.TWITTER_notiSoundVol}
|
||||||
</ListItemIcon>
|
onCommit={(e, val) => handleSettingChange('TWITTER_notiSoundVol', val)}
|
||||||
<ListItemText
|
icon={<VolumeUp />}
|
||||||
primary={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
/>
|
||||||
secondary={settings.TWITTER_notificationVol}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ListItemSecondaryAction>
|
|
||||||
<Box p={2} width={150}>
|
|
||||||
<Slider
|
|
||||||
value={sliders[2] || settings.TWITTER_notificationVol}
|
|
||||||
min={0}
|
|
||||||
max={100}
|
|
||||||
onChange={handleSliderChange(2)}
|
|
||||||
onChangeCommitted={() =>
|
|
||||||
handleSettingChange('TWITTER_notificationVol', sliders[2])
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</ListItemSecondaryAction>
|
|
||||||
</ListItem>
|
|
||||||
</List>
|
</List>
|
||||||
</AppContent>
|
</AppContent>
|
||||||
<ContextMenu />
|
<ContextMenu />
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { atom, DefaultValue, useRecoilState } from 'recoil';
|
import { atom, DefaultValue, useRecoilState } from 'recoil';
|
||||||
import config from '../../../config/default.json';
|
import config from '../../../config/default.json';
|
||||||
|
import { SettingOption } from '../../../ui/hooks/useContextMenu';
|
||||||
|
|
||||||
const localStorageEffect = (key) => ({ setSelf, onSet }) => {
|
const localStorageEffect = (key) => ({ setSelf, onSet }) => {
|
||||||
const savedVal = localStorage.getItem(key);
|
const savedVal = localStorage.getItem(key);
|
||||||
@@ -23,19 +24,19 @@ export const settingsState = atom({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export interface IPhoneSettings {
|
export interface IPhoneSettings {
|
||||||
wallpaper: string;
|
wallpaper: SettingOption;
|
||||||
frame: string;
|
frame: SettingOption;
|
||||||
theme: string;
|
theme: SettingOption;
|
||||||
zoom: number;
|
zoom: SettingOption;
|
||||||
ringtone: string;
|
ringtone: SettingOption;
|
||||||
ringtoneVol: number;
|
ringtoneVol: number;
|
||||||
notification: string;
|
notiSound: SettingOption;
|
||||||
notificationVol: number;
|
notiSoundVol: number;
|
||||||
TWITTER_notification: string;
|
TWITTER_notiSound: SettingOption;
|
||||||
TWITTER_notificationVol: number;
|
TWITTER_notiSoundVol: number;
|
||||||
TWITTER_notifyNewFeedTweet: boolean;
|
TWITTER_notifyNewFeedTweet: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useSettings = () => {
|
export const useSettings = () => {
|
||||||
return useRecoilState<IPhoneSettings>(settingsState);
|
return useRecoilState(settingsState);
|
||||||
};
|
};
|
||||||
+129
-60
@@ -1,73 +1,142 @@
|
|||||||
{
|
{
|
||||||
"cellProvider": "AT&T",
|
"cellProvider": "AT&T",
|
||||||
"language": "en",
|
"language": "en",
|
||||||
"wallpapers": ["beach.jpg", "minimal.jpg", "surf.jpg", "waves.jpg", "projecterror.jpg"],
|
"wallpapers": [
|
||||||
|
{
|
||||||
|
"label": "Minimal",
|
||||||
|
"value": "minimal.jpg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Surf",
|
||||||
|
"value": "surf.jpg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Waves",
|
||||||
|
"value": "waves.jpg"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Project Error",
|
||||||
|
"value": "projecterror.jpg"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"frames": [
|
||||||
|
{
|
||||||
|
"label": "Default",
|
||||||
|
"value": "default.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Blue",
|
||||||
|
"value": "blue.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Gold",
|
||||||
|
"value": "gold.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Kawaii",
|
||||||
|
"value": "kawaii.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Minimal",
|
||||||
|
"value": "minimal.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Pink",
|
||||||
|
"value": "pink.png"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "White",
|
||||||
|
"value": "white.png"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"zoomOptions": [
|
||||||
|
{
|
||||||
|
"label": "100%",
|
||||||
|
"value": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "90%",
|
||||||
|
"value": 0.9
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "80%",
|
||||||
|
"value": 0.8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "70%",
|
||||||
|
"value": 0.7
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ringtones": [
|
||||||
|
{
|
||||||
|
"label": "Marimba",
|
||||||
|
"value": "marimba"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Pixel",
|
||||||
|
"value": "pixel"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"notiSounds": [
|
||||||
|
{
|
||||||
|
"label": "Online",
|
||||||
|
"value": "online"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "99kr",
|
||||||
|
"value": "99kr"
|
||||||
|
}],
|
||||||
"defaultSettings": {
|
"defaultSettings": {
|
||||||
"wallpaper": "projecterror.jpg",
|
"wallpaper": {
|
||||||
"frame": "default.png",
|
"label": "Project Error",
|
||||||
"theme": "taso-dark",
|
"value":"projecterror.jpg"
|
||||||
"zoom": 1,
|
},
|
||||||
"ringtone": "pixel",
|
"frame": {
|
||||||
|
"label": "Default",
|
||||||
|
"value":"default.png"
|
||||||
|
},
|
||||||
|
"theme": {
|
||||||
|
"label": "taso-dark",
|
||||||
|
"value":"taso-dark"
|
||||||
|
},
|
||||||
|
"zoom": {
|
||||||
|
"label": "100%",
|
||||||
|
"value": 1
|
||||||
|
},
|
||||||
|
"ringtone": {
|
||||||
|
"label": "Pixel",
|
||||||
|
"value": "pixel"
|
||||||
|
},
|
||||||
|
"notiSound": {
|
||||||
|
"label": "Online",
|
||||||
|
"value": "online"
|
||||||
|
},
|
||||||
"ringtoneVol": 50,
|
"ringtoneVol": 50,
|
||||||
"notification": "online",
|
"notiSoundVol": 50,
|
||||||
"notificationVol": 50,
|
"TWITTER_notiSound": {
|
||||||
"TWITTER_notification": "online",
|
"label": "Online",
|
||||||
"TWITTER_notificationVol": 100,
|
"value": "online"
|
||||||
|
},
|
||||||
|
"TWITTER_notiSoundVol": 100,
|
||||||
"TWITTER_notifyNewFeedTweet": true
|
"TWITTER_notifyNewFeedTweet": true
|
||||||
},
|
},
|
||||||
|
"themes": [
|
||||||
|
{
|
||||||
|
"label": "Taso Dark",
|
||||||
|
"value": "taso-dark"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Default Dark",
|
||||||
|
"value": "default-dark"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Default Light",
|
||||||
|
"value": "default-light"
|
||||||
|
}
|
||||||
|
],
|
||||||
"debug": {
|
"debug": {
|
||||||
"printDebugLogs": true,
|
"printDebugLogs": true,
|
||||||
"logLevel": 1
|
"logLevel": 1
|
||||||
},
|
},
|
||||||
"frames": [
|
|
||||||
"default.png",
|
|
||||||
"blue.png",
|
|
||||||
"gold.png",
|
|
||||||
"kawaii.png",
|
|
||||||
"minimal.png",
|
|
||||||
"pink.png",
|
|
||||||
"white.png"
|
|
||||||
],
|
|
||||||
"zoomOptions": [1, 0.9, 0.8],
|
|
||||||
"ringtones": ["marimba", "pixel"],
|
|
||||||
"notifications": ["online", "99kr"],
|
|
||||||
"themes": {
|
|
||||||
"default-dark": {
|
|
||||||
"palette": {
|
|
||||||
"type": "dark",
|
|
||||||
"primary": {
|
|
||||||
"main": "#a6d4fa"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"default-light": {
|
|
||||||
"palette": {
|
|
||||||
"type": "light"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"taso-dark": {
|
|
||||||
"common": {},
|
|
||||||
"palette": {
|
|
||||||
"type": "dark",
|
|
||||||
"primary": {
|
|
||||||
"main": "#a6d4fa"
|
|
||||||
},
|
|
||||||
"background": {
|
|
||||||
"paper": "#1c1c1c",
|
|
||||||
"default": "#121212",
|
|
||||||
"dark": "#000000",
|
|
||||||
"light": "#383838"
|
|
||||||
},
|
|
||||||
"text": {
|
|
||||||
"primary": "#fff",
|
|
||||||
"secondary": "rgba(255, 255, 255, 0.7)",
|
|
||||||
"disabled": "rgba(255, 255, 255, 0.5)",
|
|
||||||
"hint": "rgba(255, 255, 255, 0.5)",
|
|
||||||
"icon": "rgba(255, 255, 255, 0.5)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"divider": "rgba(255, 255, 255, 0.12)"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"SentryErrorMetrics": true
|
"SentryErrorMetrics": true
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
{
|
||||||
|
"default-dark": {
|
||||||
|
"palette": {
|
||||||
|
"type": "dark",
|
||||||
|
"primary": {
|
||||||
|
"main": "#a6d4fa"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"default-light": {
|
||||||
|
"palette": {
|
||||||
|
"type": "light"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"taso-dark": {
|
||||||
|
"common": {},
|
||||||
|
"palette": {
|
||||||
|
"type": "dark",
|
||||||
|
"primary": {
|
||||||
|
"main": "#a6d4fa"
|
||||||
|
},
|
||||||
|
"background": {
|
||||||
|
"paper": "#1c1c1c",
|
||||||
|
"default": "#121212",
|
||||||
|
"dark": "#000000",
|
||||||
|
"light": "#383838"
|
||||||
|
},
|
||||||
|
"text": {
|
||||||
|
"primary": "#fff",
|
||||||
|
"secondary": "rgba(255, 255, 255, 0.7)",
|
||||||
|
"disabled": "rgba(255, 255, 255, 0.5)",
|
||||||
|
"hint": "rgba(255, 255, 255, 0.5)",
|
||||||
|
"icon": "rgba(255, 255, 255, 0.5)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"divider": "rgba(255, 255, 255, 0.12)"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -162,7 +162,7 @@ export function NotificationsProvider({ children }) {
|
|||||||
update?: Partial<INotification>,
|
update?: Partial<INotification>,
|
||||||
) => {
|
) => {
|
||||||
if (n.sound) {
|
if (n.sound) {
|
||||||
const { sound, volume } = getSoundSettings('notification', settings, n.app);
|
const { sound, volume } = getSoundSettings('notiSound', settings, n.app);
|
||||||
mount(sound, volume, false).then(({ url }) =>
|
mount(sound, volume, false).then(({ url }) =>
|
||||||
setAlerts((curr) => [...curr, [n, persist, update, url]]),
|
setAlerts((curr) => [...curr, [n, persist, update, url]]),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
import { useMemo } from 'react';
|
import { useMemo } from 'react';
|
||||||
import { createMuiTheme } from '@material-ui/core';
|
import { createMuiTheme } from '@material-ui/core';
|
||||||
import { useSettings } from '../../../apps/settings/hooks/useSettings';
|
import { useSettings } from '../../../apps/settings/hooks/useSettings';
|
||||||
import * as config from '../../../config/default.json';
|
import themes from '../../../config/themes.json';
|
||||||
|
|
||||||
export const usePhoneTheme = () => {
|
export const usePhoneTheme = () => {
|
||||||
const [settings] = useSettings();
|
const [settings] = useSettings();
|
||||||
|
return useMemo(() => createMuiTheme(themes[settings.theme.value]), [settings.theme]);
|
||||||
return useMemo(() => createMuiTheme(config.themes[settings.theme]), [settings.theme]);
|
|
||||||
};
|
};
|
||||||
@@ -3,25 +3,25 @@ import { getNotificationPath, getRingtonePath } from '../../../apps/settings/uti
|
|||||||
|
|
||||||
const getPath = {
|
const getPath = {
|
||||||
ringtone: getRingtonePath,
|
ringtone: getRingtonePath,
|
||||||
notification: getNotificationPath,
|
notiSound: getNotificationPath,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the configuration for SoundProvider based on settings and apps
|
* Gets the configuration for SoundProvider based on settings and apps
|
||||||
*/
|
*/
|
||||||
export const getSoundSettings = (
|
export const getSoundSettings = (
|
||||||
type: 'ringtone' | 'notification',
|
type: 'ringtone' | 'notiSound',
|
||||||
settings: IPhoneSettings,
|
settings: IPhoneSettings,
|
||||||
app?: string,
|
app?: string,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
return app
|
return app
|
||||||
? {
|
? {
|
||||||
sound: getPath[type](settings[`${app}_${type}`] || settings[type]),
|
sound: getPath[type](settings[`${app}_${type}`].value || settings[type].value),
|
||||||
volume: (settings[`${app}_${type}Vol`] || settings[`${type}Vol`]) / 100,
|
volume: (settings[`${app}_${type}Vol`] || settings[`${type}Vol`]) / 100,
|
||||||
}
|
}
|
||||||
: {
|
: {
|
||||||
sound: getPath[type](settings[type]),
|
sound: getPath[type](settings[type as string].value),
|
||||||
volume: settings[`${type}Vol`] / 100,
|
volume: settings[`${type}Vol`] / 100,
|
||||||
};
|
};
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ function Notification({ children, handleClose, open }) {
|
|||||||
if (!config) return null;
|
if (!config) return null;
|
||||||
|
|
||||||
const { horizontal, vertical } = config.notificationPosition;
|
const { horizontal, vertical } = config.notificationPosition;
|
||||||
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme]);
|
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme.value]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ThemeProvider theme={currentTheme()}>
|
<ThemeProvider theme={currentTheme()}>
|
||||||
|
|||||||
@@ -12,6 +12,20 @@ export const MapStringOptions = (current, onClick) => (string) => {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface SettingOption {
|
||||||
|
label: string;
|
||||||
|
value: string | number;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const MapSettingItem = (current: SettingOption, onClick: Function) => (
|
||||||
|
item: SettingOption,
|
||||||
|
) => ({
|
||||||
|
selected: current.value === item.value,
|
||||||
|
onClick: () => onClick(item),
|
||||||
|
key: item.value,
|
||||||
|
label: item.label,
|
||||||
|
});
|
||||||
|
|
||||||
export const useContextMenu = (_options?): UseContextMenu => {
|
export const useContextMenu = (_options?): UseContextMenu => {
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const [options, setOptions] = useState(_options || []);
|
const [options, setOptions] = useState(_options || []);
|
||||||
|
|||||||
Reference in new issue
Block a user