From bb8d765bc64943b732cb25bfe75feed834d8c086 Mon Sep 17 00:00:00 2001 From: Christopher Date: Sat, 3 Apr 2021 16:51:44 +0200 Subject: [PATCH] tweak(phone/settings): custom wallpaper dialog --- phone/src/Phone.tsx | 8 +++---- .../settings/components/WallpaperModal.tsx | 23 +++++-------------- phone/src/apps/settings/hooks/useSettings.ts | 2 -- phone/src/locale/en.json | 10 +++++--- phone/src/ui/components/DialogForm.tsx | 13 +++-------- 5 files changed, 20 insertions(+), 36 deletions(-) diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx index 47b6466..bb799ca 100644 --- a/phone/src/Phone.tsx +++ b/phone/src/Phone.tsx @@ -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,10 +105,9 @@ function Phone() { id="phone" className="PhoneScreen" style={{ - backgroundImage: - settings.wallpaper.label === t('APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER') - ? `url(${settings.wallpaper.value})` - : `url(media/backgrounds/${settings.wallpaper.value})`, + backgroundImage: !isDefaultWallpaper(settings.wallpaper.value) + ? `url(${settings.wallpaper.value})` + : `url(media/backgrounds/${settings.wallpaper.value})`, }} > {isPhoneReady ? ( diff --git a/phone/src/apps/settings/components/WallpaperModal.tsx b/phone/src/apps/settings/components/WallpaperModal.tsx index 7f8c591..4589b35 100644 --- a/phone/src/apps/settings/components/WallpaperModal.tsx +++ b/phone/src/apps/settings/components/WallpaperModal.tsx @@ -1,22 +1,10 @@ import React, { useState } from 'react'; import { useCustomWallpaperModal, useSettings } from '../hooks/useSettings'; -import { Box, Button, TextField, Typography } 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 DialogForm from '../../../ui/components/DialogForm'; import { useSnackbar } from '../../../ui/hooks/useSnackbar'; -const useStyles = makeStyles({ - input: { - marginTop: 10, - marginBottom: 10, - }, - inputProps: { - fontSize: 18, - }, -}); - export default function WallpaperModal() { const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal(); const [settings, setSettings] = useSettings(); @@ -40,7 +28,7 @@ export default function WallpaperModal() { }); setCustomWallpaperModal(false); } else { - addAlert({ message: t('APPS_SETTINGS_INVALID_WALLPAPER'), type: 'error' }); + addAlert({ message: t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_ERROR'), type: 'error' }); } }; @@ -49,13 +37,14 @@ export default function WallpaperModal() { open={customWallpaperModal} handleClose={() => setCustomWallpaperModal(false)} onSubmit={handleNewWallpaper} - title="Custom wallpaper" - content="Set a custom wallpaper by entering the URL of the image below!" + title={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_TITLE')} + content={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_CONTENT')} > setValue(e.currentTarget.value)} - placeholder="Image URL" + placeholder={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_PLACEHOLDER')} fullWidth /> diff --git a/phone/src/apps/settings/hooks/useSettings.ts b/phone/src/apps/settings/hooks/useSettings.ts index dc256e5..9461260 100644 --- a/phone/src/apps/settings/hooks/useSettings.ts +++ b/phone/src/apps/settings/hooks/useSettings.ts @@ -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; diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json index f9becfc..03e6149 100644 --- a/phone/src/locale/en.json +++ b/phone/src/locale/en.json @@ -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,8 +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_SETTINGS_INVALID_WALLPAPER": "Not a valid image or link!", "APPS_MARKETPLACE_CREATE_LISTING_SUCCESS": "Successfully created a new listing", "APPS_MARKETPLACE_CREATE_LISTING_FAILED": "Failed to create a new listing", diff --git a/phone/src/ui/components/DialogForm.tsx b/phone/src/ui/components/DialogForm.tsx index 6e4cee0..60ad769 100644 --- a/phone/src/ui/components/DialogForm.tsx +++ b/phone/src/ui/components/DialogForm.tsx @@ -1,13 +1,6 @@ import React from 'react'; import { makeStyles } from '@material-ui/core/styles'; -import { - Button, - DialogContent, - DialogContentText, - DialogTitle, - Paper, - TextField, -} from '@material-ui/core'; +import { Button, DialogContent, DialogContentText, DialogTitle, Paper } from '@material-ui/core'; import DialogActions from '@material-ui/core/DialogActions'; const useStyles = makeStyles({ @@ -33,7 +26,7 @@ const useStyles = makeStyles({ }, }); -interface DialogForm { +interface DialogFormProps { children: React.ReactNode; open: boolean; handleClose: any; // No idea what those types are @@ -49,7 +42,7 @@ export default function DialogForm({ onSubmit, title, content, -}: DialogForm) { +}: DialogFormProps) { const classes = useStyles(); const showHideClassName = open ? classes.displayBlock : classes.displayNone;