import React, { useState } from 'react'; import Modal from '../../../ui/components/Modal'; import { useCustomWallpaperModal, useSettings } from '../hooks/useSettings'; import { Box, Button, TextField } from '@material-ui/core'; import { PictureThumbnail } from '../../../ui/components/PictureThumbnail'; import { useTranslation } from 'react-i18next'; import { makeStyles } from '@material-ui/core/styles'; import { StatusButton } from '../../../ui/components/StatusButton'; const useStyles = makeStyles({ input: { marginTop: 10, marginBottom: 10, }, inputProps: { fontSize: 18, }, }); export default function WallpaperModal() { const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal(); const [settings, setSettings] = useSettings(); const { t } = useTranslation(); const [value, setValue] = useState(settings.customWallpaper ? settings.customWallpaper : ''); const classes = useStyles(); const isImage = (url) => { return /(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|png|jpeg|gif)/g.test(url); }; const handleCloseModal = () => { setCustomWallpaperModal(false); }; const handleSettingChange = (key: string | number, value: unknown) => { setSettings({ ...settings, [key]: value }); }; const handleNewWallpaper = () => { handleSettingChange('customWallpaper', value); }; const handleRemoveWallpaper = () => { handleSettingChange('customWallpaper', ''); }; return ( {settings.customWallpaper && ( )} setValue(e.currentTarget.value)} inputProps={{ className: classes.inputProps, }} placeholder="Image URL" /> {settings.customWallpaper && ( {t('GENERIC_DELETE')} )} ); }