mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
tweak(phone/settings): custom wallpaper dialog
This commit is contained in:
1 parent
e268dae34b
commit
bb8d765bc6
5 files changed
+18
-34
No files matched your search
+2
-2
@@ -33,6 +33,7 @@ import WindowSnackbar from './ui/components/WindowSnackbar';
|
|||||||
import { usePhone } from './os/phone/hooks/usePhone';
|
import { usePhone } from './os/phone/hooks/usePhone';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { useSnackbar } from './ui/hooks/useSnackbar';
|
import { useSnackbar } from './ui/hooks/useSnackbar';
|
||||||
|
import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper';
|
||||||
|
|
||||||
function Phone() {
|
function Phone() {
|
||||||
const { t, i18n } = useTranslation();
|
const { t, i18n } = useTranslation();
|
||||||
@@ -104,8 +105,7 @@ function Phone() {
|
|||||||
id="phone"
|
id="phone"
|
||||||
className="PhoneScreen"
|
className="PhoneScreen"
|
||||||
style={{
|
style={{
|
||||||
backgroundImage:
|
backgroundImage: !isDefaultWallpaper(settings.wallpaper.value)
|
||||||
settings.wallpaper.label === t('APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER')
|
|
||||||
? `url(${settings.wallpaper.value})`
|
? `url(${settings.wallpaper.value})`
|
||||||
: `url(media/backgrounds/${settings.wallpaper.value})`,
|
: `url(media/backgrounds/${settings.wallpaper.value})`,
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,22 +1,10 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { useCustomWallpaperModal, useSettings } from '../hooks/useSettings';
|
import { useCustomWallpaperModal, useSettings } from '../hooks/useSettings';
|
||||||
import { Box, Button, TextField, Typography } from '@material-ui/core';
|
import { TextField } from '@material-ui/core';
|
||||||
import { PictureThumbnail } from '../../../ui/components/PictureThumbnail';
|
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
|
||||||
import DialogForm from '../../../ui/components/DialogForm';
|
import DialogForm from '../../../ui/components/DialogForm';
|
||||||
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
|
||||||
input: {
|
|
||||||
marginTop: 10,
|
|
||||||
marginBottom: 10,
|
|
||||||
},
|
|
||||||
inputProps: {
|
|
||||||
fontSize: 18,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default function WallpaperModal() {
|
export default function WallpaperModal() {
|
||||||
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
|
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
|
||||||
const [settings, setSettings] = useSettings();
|
const [settings, setSettings] = useSettings();
|
||||||
@@ -40,7 +28,7 @@ export default function WallpaperModal() {
|
|||||||
});
|
});
|
||||||
setCustomWallpaperModal(false);
|
setCustomWallpaperModal(false);
|
||||||
} else {
|
} 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}
|
open={customWallpaperModal}
|
||||||
handleClose={() => setCustomWallpaperModal(false)}
|
handleClose={() => setCustomWallpaperModal(false)}
|
||||||
onSubmit={handleNewWallpaper}
|
onSubmit={handleNewWallpaper}
|
||||||
title="Custom wallpaper"
|
title={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_TITLE')}
|
||||||
content="Set a custom wallpaper by entering the URL of the image below!"
|
content={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_CONTENT')}
|
||||||
>
|
>
|
||||||
<TextField
|
<TextField
|
||||||
value={value}
|
value={value}
|
||||||
|
error={!isImageAndUrl(value) && true}
|
||||||
onChange={(e) => setValue(e.currentTarget.value)}
|
onChange={(e) => setValue(e.currentTarget.value)}
|
||||||
placeholder="Image URL"
|
placeholder={t('SETTINGS.OPTIONS.CUSTOM_WALLPAPER.DIALOG_PLACEHOLDER')}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</DialogForm>
|
</DialogForm>
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ const settingsSchema: Schema = {
|
|||||||
properties: {
|
properties: {
|
||||||
language: { $ref: '/SettingOption' },
|
language: { $ref: '/SettingOption' },
|
||||||
wallpaper: { $ref: '/SettingOption' },
|
wallpaper: { $ref: '/SettingOption' },
|
||||||
customWallpaper: { type: 'string' },
|
|
||||||
frame: { $ref: '/SettingOption' },
|
frame: { $ref: '/SettingOption' },
|
||||||
theme: { $ref: '/SettingOption' },
|
theme: { $ref: '/SettingOption' },
|
||||||
zoom: { $ref: '/SettingOption' },
|
zoom: { $ref: '/SettingOption' },
|
||||||
@@ -64,7 +63,6 @@ export function isSettingsSchemaValid(): boolean {
|
|||||||
export interface IPhoneSettings {
|
export interface IPhoneSettings {
|
||||||
language: SettingOption;
|
language: SettingOption;
|
||||||
wallpaper: SettingOption;
|
wallpaper: SettingOption;
|
||||||
customWallpaper: string;
|
|
||||||
frame: SettingOption;
|
frame: SettingOption;
|
||||||
theme: SettingOption;
|
theme: SettingOption;
|
||||||
zoom: SettingOption;
|
zoom: SettingOption;
|
||||||
|
|||||||
@@ -11,7 +11,13 @@
|
|||||||
"OPTIONS": {
|
"OPTIONS": {
|
||||||
"LANGUAGE": "Language",
|
"LANGUAGE": "Language",
|
||||||
"RESET_SETTINGS": "Reset Settings",
|
"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": {
|
"MESSAGES": {
|
||||||
"INVALID_SETTINGS": "Invalid stored settings! Please reset in the Settings App.",
|
"INVALID_SETTINGS": "Invalid stored settings! Please reset in the Settings App.",
|
||||||
@@ -195,8 +201,6 @@
|
|||||||
"APPS_SETTINGS_OPTION_NOTIFICATION": "Notification",
|
"APPS_SETTINGS_OPTION_NOTIFICATION": "Notification",
|
||||||
"APPS_SETTINGS_OPTION_NOTIFICATIONVOL": "Notification Volume",
|
"APPS_SETTINGS_OPTION_NOTIFICATIONVOL": "Notification Volume",
|
||||||
"APPS_SETTING_STREAMER_MODE_DESC": "Hide images before they are shown",
|
"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_SUCCESS": "Successfully created a new listing",
|
||||||
"APPS_MARKETPLACE_CREATE_LISTING_FAILED": "Failed to create a new listing",
|
"APPS_MARKETPLACE_CREATE_LISTING_FAILED": "Failed to create a new listing",
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import {
|
import { Button, DialogContent, DialogContentText, DialogTitle, Paper } from '@material-ui/core';
|
||||||
Button,
|
|
||||||
DialogContent,
|
|
||||||
DialogContentText,
|
|
||||||
DialogTitle,
|
|
||||||
Paper,
|
|
||||||
TextField,
|
|
||||||
} from '@material-ui/core';
|
|
||||||
import DialogActions from '@material-ui/core/DialogActions';
|
import DialogActions from '@material-ui/core/DialogActions';
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
@@ -33,7 +26,7 @@ const useStyles = makeStyles({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
interface DialogForm {
|
interface DialogFormProps {
|
||||||
children: React.ReactNode;
|
children: React.ReactNode;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
handleClose: any; // No idea what those types are
|
handleClose: any; // No idea what those types are
|
||||||
@@ -49,7 +42,7 @@ export default function DialogForm({
|
|||||||
onSubmit,
|
onSubmit,
|
||||||
title,
|
title,
|
||||||
content,
|
content,
|
||||||
}: DialogForm) {
|
}: DialogFormProps) {
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
const showHideClassName = open ? classes.displayBlock : classes.displayNone;
|
const showHideClassName = open ? classes.displayBlock : classes.displayNone;
|
||||||
|
|||||||
Reference in new issue
Block a user