tweak(phone/settings): simplify custom background

This commit is contained in:
Christopher committed 2021-03-31 00:43:21 +02:00
1 parent 3157cafd5a
commit c0cca9ceb8
5 files changed
+18 -37

No files matched your search

+4 -3
View File
@@ -104,9 +104,10 @@ function Phone() {
id="phone"
className="PhoneScreen"
style={{
backgroundImage: settings.customWallpaper
? `url(${settings.customWallpaper})`
: `url(media/backgrounds/${settings.wallpaper.value})`,
backgroundImage:
settings.wallpaper.label === 'Custom Wallpaper'
? `url(${settings.customWallpaper})`
: `url(media/backgrounds/${settings.wallpaper.value})`,
}}
>
{isPhoneReady ? (
@@ -109,15 +109,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, { useEffect, useState } 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,12 @@ export const SettingsApp = () => {
};
const wallpapers = config.wallpapers.map(
MapSettingItem(settings.wallpaper, (val: SettingOption) =>
handleSettingChange('wallpaper', val),
),
MapSettingItem(settings.wallpaper, (val: SettingOption) => {
if (val.label === 'Custom Wallpaper') {
setCustomWallpaperModal(true);
}
return handleSettingChange('wallpaper', val);
}),
);
const frames = config.frames.map(
MapSettingItem(settings.frame, (val: SettingOption) => handleSettingChange('frame', val)),
@@ -213,13 +215,6 @@ export const SettingsApp = () => {
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}
@@ -37,11 +37,8 @@ export default function WallpaperModal() {
};
const handleNewWallpaper = () => {
handleSettingChange('customWallpaper', value);
};
const handleRemoveWallpaper = () => {
handleSettingChange('customWallpaper', '');
handleSettingChange('wallpaper', { label: 'Custom Wallpaper', value });
setCustomWallpaperModal(false);
};
return (
@@ -59,6 +56,7 @@ export default function WallpaperModal() {
<TextField
value={value}
variant="outlined"
size="small"
className={classes.input}
onChange={(e) => setValue(e.currentTarget.value)}
inputProps={{
@@ -75,11 +73,6 @@ export default function WallpaperModal() {
>
{t('APPS_SETTINGS_SET_CUSTOM_WALLPAPER')}
</Button>
{settings.customWallpaper && (
<StatusButton color="error" variant="contained" onClick={handleRemoveWallpaper}>
{t('GENERIC_DELETE')}
</StatusButton>
)}
</Box>
</Modal>
);
+4
View File
@@ -17,6 +17,10 @@
{
"label": "Project Error",
"value": "projecterror.jpg"
},
{
"label": "Custom Wallpaper",
"value": ""
}
],
"frames": [