mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-03 22:16:54 +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"
|
||||
style={{
|
||||
transformOrigin: 'right bottom',
|
||||
transform: `scale(${settings.zoom}`,
|
||||
transform: `scale(${settings.zoom.value}`,
|
||||
bottom,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="PhoneFrame"
|
||||
style={{
|
||||
backgroundImage: `url(./media/frames/${settings.frame})`,
|
||||
backgroundImage: `url(./media/frames/${settings.frame.value})`,
|
||||
}}
|
||||
/>
|
||||
<div
|
||||
id="phone"
|
||||
className="PhoneScreen"
|
||||
style={{
|
||||
backgroundImage: `url(./media/backgrounds/${settings.wallpaper})`,
|
||||
backgroundImage: `url(./media/backgrounds/${settings.wallpaper.value})`,
|
||||
}}
|
||||
>
|
||||
<>
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
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;
|
||||
label: string;
|
||||
value?: string | number | null;
|
||||
@@ -9,11 +16,35 @@ interface IProps {
|
||||
icon: JSX.Element;
|
||||
}
|
||||
|
||||
export const SettingItem = ({ options, label, value, onClick, icon }: IProps) => {
|
||||
return (
|
||||
<ListItem divider onClick={() => onClick?.(options)} button>
|
||||
<ListItemIcon>{icon}</ListItemIcon>
|
||||
<ListItemText primary={label} secondary={value ? value : undefined} />
|
||||
</ListItem>
|
||||
);
|
||||
};
|
||||
export const SettingItem = ({ options, label, value, onClick, icon }: ISettingItem) => (
|
||||
<ListItem divider onClick={() => onClick?.(options)} button>
|
||||
<ListItemIcon>{icon}</ListItemIcon>
|
||||
<ListItemText primary={label} secondary={value ? value : undefined} />
|
||||
</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 { AppTitle } from '../../../ui/components/AppTitle';
|
||||
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 { List } from '../../../ui/components/List';
|
||||
import { useSimcard } from '../../../os/simcard/hooks/useSimcard';
|
||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||
import { SettingItem } from './SettingItem';
|
||||
import { SettingItem, SettingItemSlider } from './SettingItem';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import {
|
||||
@@ -20,17 +20,8 @@ import {
|
||||
VolumeUp,
|
||||
} from '@material-ui/icons';
|
||||
|
||||
import {
|
||||
Box,
|
||||
ListItem,
|
||||
ListItemIcon,
|
||||
ListItemSecondaryAction,
|
||||
ListItemText,
|
||||
ListSubheader,
|
||||
Slider,
|
||||
} from '@material-ui/core';
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { settingsState } from '../hooks/useSettings';
|
||||
import { ListSubheader } from '@material-ui/core';
|
||||
import { useSettings } from '../hooks/useSettings';
|
||||
|
||||
const SubHeaderComp = (props: { text: string }) => (
|
||||
<ListSubheader color="primary" component="div" disableSticky>
|
||||
@@ -42,57 +33,39 @@ export const SettingsApp = () => {
|
||||
const settingsApp = useApp('SETTINGS');
|
||||
const [config] = useConfig();
|
||||
const simcard = useSimcard();
|
||||
const [settings, setSettings] = useRecoilState(settingsState);
|
||||
const [settings, setSettings] = useSettings();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const handleSettingChange = (key: string | number, value: unknown) => {
|
||||
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(
|
||||
MapStringOptions(settings.wallpaper, (val: string) => handleSettingChange('wallpaper', val)),
|
||||
MapSettingItem(settings.wallpaper, (val: SettingOption) =>
|
||||
handleSettingChange('wallpaper', val),
|
||||
),
|
||||
);
|
||||
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(
|
||||
MapStringOptions(settings.theme, (val: string) => handleSettingChange('theme', val)),
|
||||
const themes = config.themes.map(
|
||||
MapSettingItem(settings.theme, (val: SettingOption) => handleSettingChange('theme', val)),
|
||||
);
|
||||
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(
|
||||
MapStringOptions(settings.ringtone, (val: string) => handleSettingChange('ringtone', val)),
|
||||
MapSettingItem(settings.ringtone, (val: SettingOption) => handleSettingChange('ringtone', val)),
|
||||
);
|
||||
const notifications = config.notifications.map(
|
||||
MapStringOptions(settings.notification, (val: string) =>
|
||||
handleSettingChange('notification', val),
|
||||
const notifications = config.notiSounds.map(
|
||||
MapSettingItem(settings.notiSound, (val: SettingOption) =>
|
||||
handleSettingChange('notiSound', val),
|
||||
),
|
||||
);
|
||||
|
||||
const twitterNotifications = config.notifications.map(
|
||||
MapStringOptions(settings.notification, (val: string) =>
|
||||
handleSettingChange('TWITTER_notification', val),
|
||||
const twitterNotifications = config.notiSounds.map(
|
||||
MapSettingItem(settings.notiSound, (item: SettingOption) =>
|
||||
handleSettingChange('TWITTER_notiSound', item),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -109,84 +82,56 @@ export const SettingsApp = () => {
|
||||
/>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_RINGTONE')}
|
||||
value={settings.ringtone}
|
||||
value={settings.ringtone.label}
|
||||
options={ringtones}
|
||||
onClick={openMenu}
|
||||
icon={<LibraryMusic />}
|
||||
/>
|
||||
<ListItem divider>
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
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>
|
||||
<SettingItemSlider
|
||||
label={t('APPS_SETTINGS_OPTION_RINGTONEVOL')}
|
||||
icon={<VolumeUp />}
|
||||
value={settings.ringtoneVol}
|
||||
onCommit={(e, val) => handleSettingChange('ringtoneVol', val)}
|
||||
/>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
||||
value={settings.notification}
|
||||
value={settings.notiSound.label}
|
||||
options={notifications}
|
||||
onClick={openMenu}
|
||||
icon={<LibraryMusic />}
|
||||
/>
|
||||
<ListItem divider>
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
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>
|
||||
<SettingItemSlider
|
||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
||||
icon={<VolumeUp />}
|
||||
value={settings.notiSoundVol}
|
||||
onCommit={(e, val) => handleSettingChange('notiSoundVol', val)}
|
||||
/>
|
||||
</List>
|
||||
<List disablePadding subheader={<SubHeaderComp text="Appearance" />}>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_THEME')}
|
||||
value={settings.theme}
|
||||
value={settings.theme.label}
|
||||
options={themes}
|
||||
onClick={openMenu}
|
||||
icon={<Brush />}
|
||||
/>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_WALLPAPER')}
|
||||
value={settings.wallpaper}
|
||||
value={settings.wallpaper.label}
|
||||
options={wallpapers}
|
||||
onClick={openMenu}
|
||||
icon={<Wallpaper />}
|
||||
/>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_FRAME')}
|
||||
value={settings.frame}
|
||||
value={settings.frame.label}
|
||||
options={frames}
|
||||
onClick={openMenu}
|
||||
icon={<Smartphone />}
|
||||
/>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_ZOOM')}
|
||||
value={settings.zoom}
|
||||
value={settings.zoom.label}
|
||||
options={zoomOptions}
|
||||
onClick={openMenu}
|
||||
icon={<ZoomIn />}
|
||||
@@ -195,34 +140,17 @@ export const SettingsApp = () => {
|
||||
<List disablePadding subheader={<SubHeaderComp text={t('APPS_TWITTER')} />}>
|
||||
<SettingItem
|
||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATION')}
|
||||
value={settings.TWITTER_notification}
|
||||
value={settings.TWITTER_notiSound.label}
|
||||
options={twitterNotifications}
|
||||
onClick={openMenu}
|
||||
icon={<LibraryMusic />}
|
||||
/>
|
||||
<ListItem divider>
|
||||
<ListItemIcon>
|
||||
<VolumeUp />
|
||||
</ListItemIcon>
|
||||
<ListItemText
|
||||
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>
|
||||
<SettingItemSlider
|
||||
label={t('APPS_SETTINGS_OPTION_NOTIFICATIONVOL')}
|
||||
value={settings.TWITTER_notiSoundVol}
|
||||
onCommit={(e, val) => handleSettingChange('TWITTER_notiSoundVol', val)}
|
||||
icon={<VolumeUp />}
|
||||
/>
|
||||
</List>
|
||||
</AppContent>
|
||||
<ContextMenu />
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { atom, DefaultValue, useRecoilState } from 'recoil';
|
||||
import config from '../../../config/default.json';
|
||||
import { SettingOption } from '../../../ui/hooks/useContextMenu';
|
||||
|
||||
const localStorageEffect = (key) => ({ setSelf, onSet }) => {
|
||||
const savedVal = localStorage.getItem(key);
|
||||
@@ -23,19 +24,19 @@ export const settingsState = atom({
|
||||
});
|
||||
|
||||
export interface IPhoneSettings {
|
||||
wallpaper: string;
|
||||
frame: string;
|
||||
theme: string;
|
||||
zoom: number;
|
||||
ringtone: string;
|
||||
wallpaper: SettingOption;
|
||||
frame: SettingOption;
|
||||
theme: SettingOption;
|
||||
zoom: SettingOption;
|
||||
ringtone: SettingOption;
|
||||
ringtoneVol: number;
|
||||
notification: string;
|
||||
notificationVol: number;
|
||||
TWITTER_notification: string;
|
||||
TWITTER_notificationVol: number;
|
||||
notiSound: SettingOption;
|
||||
notiSoundVol: number;
|
||||
TWITTER_notiSound: SettingOption;
|
||||
TWITTER_notiSoundVol: number;
|
||||
TWITTER_notifyNewFeedTweet: boolean;
|
||||
}
|
||||
|
||||
export const useSettings = () => {
|
||||
return useRecoilState<IPhoneSettings>(settingsState);
|
||||
return useRecoilState(settingsState);
|
||||
};
|
||||
+129
-60
@@ -1,73 +1,142 @@
|
||||
{
|
||||
"cellProvider": "AT&T",
|
||||
"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": {
|
||||
"wallpaper": "projecterror.jpg",
|
||||
"frame": "default.png",
|
||||
"theme": "taso-dark",
|
||||
"zoom": 1,
|
||||
"ringtone": "pixel",
|
||||
"wallpaper": {
|
||||
"label": "Project Error",
|
||||
"value":"projecterror.jpg"
|
||||
},
|
||||
"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,
|
||||
"notification": "online",
|
||||
"notificationVol": 50,
|
||||
"TWITTER_notification": "online",
|
||||
"TWITTER_notificationVol": 100,
|
||||
"notiSoundVol": 50,
|
||||
"TWITTER_notiSound": {
|
||||
"label": "Online",
|
||||
"value": "online"
|
||||
},
|
||||
"TWITTER_notiSoundVol": 100,
|
||||
"TWITTER_notifyNewFeedTweet": true
|
||||
},
|
||||
"themes": [
|
||||
{
|
||||
"label": "Taso Dark",
|
||||
"value": "taso-dark"
|
||||
},
|
||||
{
|
||||
"label": "Default Dark",
|
||||
"value": "default-dark"
|
||||
},
|
||||
{
|
||||
"label": "Default Light",
|
||||
"value": "default-light"
|
||||
}
|
||||
],
|
||||
"debug": {
|
||||
"printDebugLogs": true,
|
||||
"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
|
||||
}
|
||||
@@ -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>,
|
||||
) => {
|
||||
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 }) =>
|
||||
setAlerts((curr) => [...curr, [n, persist, update, url]]),
|
||||
);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
import { useMemo } from 'react';
|
||||
import { createMuiTheme } from '@material-ui/core';
|
||||
import { useSettings } from '../../../apps/settings/hooks/useSettings';
|
||||
import * as config from '../../../config/default.json';
|
||||
import themes from '../../../config/themes.json';
|
||||
|
||||
export const usePhoneTheme = () => {
|
||||
const [settings] = useSettings();
|
||||
|
||||
return useMemo(() => createMuiTheme(config.themes[settings.theme]), [settings.theme]);
|
||||
return useMemo(() => createMuiTheme(themes[settings.theme.value]), [settings.theme]);
|
||||
};
|
||||
@@ -3,25 +3,25 @@ import { getNotificationPath, getRingtonePath } from '../../../apps/settings/uti
|
||||
|
||||
const getPath = {
|
||||
ringtone: getRingtonePath,
|
||||
notification: getNotificationPath,
|
||||
notiSound: getNotificationPath,
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the configuration for SoundProvider based on settings and apps
|
||||
*/
|
||||
export const getSoundSettings = (
|
||||
type: 'ringtone' | 'notification',
|
||||
type: 'ringtone' | 'notiSound',
|
||||
settings: IPhoneSettings,
|
||||
app?: string,
|
||||
) => {
|
||||
try {
|
||||
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,
|
||||
}
|
||||
: {
|
||||
sound: getPath[type](settings[type]),
|
||||
sound: getPath[type](settings[type as string].value),
|
||||
volume: settings[`${type}Vol`] / 100,
|
||||
};
|
||||
} catch (e) {
|
||||
|
||||
@@ -30,7 +30,7 @@ function Notification({ children, handleClose, open }) {
|
||||
if (!config) return null;
|
||||
|
||||
const { horizontal, vertical } = config.notificationPosition;
|
||||
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme]);
|
||||
const currentTheme = () => createMuiTheme(themeConfig.themes[settings.theme.value]);
|
||||
|
||||
return (
|
||||
<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 => {
|
||||
const [open, setOpen] = useState(false);
|
||||
const [options, setOptions] = useState(_options || []);
|
||||
|
||||
Reference in new issue
Block a user