import React, { useState } from 'react';
import { AppWrapper } from '../../../ui/components';
import { AppTitle } from '../../../ui/components/AppTitle';
import { AppContent } from '../../../ui/components/AppContent';
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,
SettingItemIconAction,
SettingItemSlider,
SettingSwitch,
SettingItemModal,
} from './SettingItem';
import { useTranslation } from 'react-i18next';
import VisibilityOffIcon from '@material-ui/icons/VisibilityOff';
import {
FilterList,
Brush,
Wallpaper,
Phone,
Smartphone,
ZoomIn,
LibraryMusic,
VolumeUp,
FileCopy,
Book,
DeleteForever,
} from '@material-ui/icons';
import { makeStyles } from '@material-ui/core/styles';
import { ListSubheader } from '@material-ui/core';
import { useCustomWallpaperModal, useResetSettings, useSettings } from '../hooks/useSettings';
import { setClipboard } from '../../../os/phone/hooks/useClipboard';
import { useSnackbar } from '../../../ui/hooks/useSnackbar';
import { IContextMenuOption } from '../../../ui/components/ContextMenu';
import WallpaperModal from './WallpaperModal';
const SubHeaderComp = (props: { text: string }) => (
{props.text}
);
const useStyles = makeStyles({
backgroundModal: {
background: 'black',
opacity: '0.6',
position: 'absolute',
top: 0,
left: 0,
right: 0,
bottom: 0,
zIndex: 5,
},
});
export const SettingsApp = () => {
const settingsApp = useApp('SETTINGS');
const [config] = useConfig();
const simcard = useSimcard();
const [settings, setSettings] = useSettings();
const { t } = useTranslation();
const { customWallpaperModal, setCustomWallpaperModal } = useCustomWallpaperModal();
const { addAlert } = useSnackbar();
const resetSettings = useResetSettings();
const handleSettingChange = (key: string | number, value: unknown) => {
setSettings({ ...settings, [key]: value });
};
const wallpapers = config.wallpapers.map(
MapSettingItem(settings.wallpaper, (val: SettingOption) =>
handleSettingChange('wallpaper', val),
),
);
const frames = config.frames.map(
MapSettingItem(settings.frame, (val: SettingOption) => handleSettingChange('frame', val)),
);
const themes = config.themes.map(
MapSettingItem(settings.theme, (val: SettingOption) => handleSettingChange('theme', val)),
);
const zoomOptions = config.zoomOptions.map(
MapSettingItem(settings.zoom, (val: SettingOption) => handleSettingChange('zoom', val)),
);
const ringtones = config.ringtones.map(
MapSettingItem(settings.ringtone, (val: SettingOption) => handleSettingChange('ringtone', val)),
);
const notifications = config.notiSounds.map(
MapSettingItem(settings.notiSound, (val: SettingOption) =>
handleSettingChange('notiSound', val),
),
);
const twitterNotifications = config.notiSounds.map(
MapSettingItem(settings.TWITTER_notiSound, (val: SettingOption) =>
handleSettingChange('TWITTER_notiSound', val),
),
);
const twitterNotificationFilters = config.notiFilters.map(
MapSettingItem(settings.TWITTER_notiFilter, (val: SettingOption) =>
handleSettingChange('TWITTER_notiFilter', val),
),
);
const languages = config.languages.map(
MapSettingItem(settings.language, (val: SettingOption) => handleSettingChange('language', val)),
);
const handleResetOptions = () => {
resetSettings();
addAlert({
message: t('SETTINGS.MESSAGES.SETTINGS_RESET'),
type: 'success',
});
};
const resetSettingsOpts: IContextMenuOption[] = [
{
selected: false,
onClick: () => handleResetOptions(),
key: 'RESET_SETTINGS',
label: t('SETTINGS.OPTIONS.RESET_SETTINGS'),
},
];
const handleCopyPhoneNumber = () => {
setClipboard(simcard.number);
addAlert({
message: t('GENERIC_WRITE_TO_CLIPBOARD_MESSAGE', {
content: 'number',
}),
type: 'success',
});
};
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
const classes = useStyles();
return (
}>
}
actionIcon={}
handleAction={handleCopyPhoneNumber}
/>
}
/>
}
value={settings.ringtoneVol}
onCommit={(e, val) => handleSettingChange('ringtoneVol', val)}
/>
}
/>
}
value={settings.notiSoundVol}
onCommit={(e, val) => handleSettingChange('notiSoundVol', val)}
/>
}
value={settings.streamerMode}
onClick={(curr) => handleSettingChange('streamerMode', !curr)}
/>
}>
}
/>
}
/>
}
/>
{/* CUSTOM BACKGROUND */}
}
label={t('APPS_SETTINGS_OPTIONS_CUSTOM_WALLPAPER')}
secondary={settings.customWallpaper}
onClick={() => setCustomWallpaperModal(true)}
/>
}
/>
}
/>
}>
}
/>
}
/>
handleSettingChange('TWITTER_notiSoundVol', val)}
icon={}
/>
}>
}
onClick={openMenu}
options={resetSettingsOpts}
/>
);
};