mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
tweak(phone/settings): Added a SettingItemIconAction component
Currently used for phone number
This commit is contained in:
1 parent
140a28bef7
commit
eae06b2dc6
2 files changed
+63
-3
No files matched your search
@@ -6,6 +6,9 @@ import {
|
|||||||
ListItemSecondaryAction,
|
ListItemSecondaryAction,
|
||||||
Box,
|
Box,
|
||||||
Slider,
|
Slider,
|
||||||
|
IconButton,
|
||||||
|
Tooltip,
|
||||||
|
Typography,
|
||||||
} from '@material-ui/core';
|
} from '@material-ui/core';
|
||||||
|
|
||||||
interface ISettingItem {
|
interface ISettingItem {
|
||||||
@@ -48,3 +51,39 @@ export const SettingItemSlider = ({ icon, label, value, onCommit }: ISettingSlid
|
|||||||
</ListItemSecondaryAction>
|
</ListItemSecondaryAction>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
interface ISettingItemIconAction {
|
||||||
|
icon: JSX.Element;
|
||||||
|
actionIcon: JSX.Element;
|
||||||
|
label: string;
|
||||||
|
labelSecondary: string;
|
||||||
|
handleAction: () => void;
|
||||||
|
actionLabel: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const SettingItemIconAction = ({
|
||||||
|
icon,
|
||||||
|
label,
|
||||||
|
handleAction,
|
||||||
|
actionIcon,
|
||||||
|
labelSecondary,
|
||||||
|
actionLabel,
|
||||||
|
}: ISettingItemIconAction) => (
|
||||||
|
<>
|
||||||
|
<ListItem divider>
|
||||||
|
<ListItemIcon>{icon}</ListItemIcon>
|
||||||
|
<ListItemText primary={label} secondary={labelSecondary} />
|
||||||
|
<ListItemSecondaryAction>
|
||||||
|
<Tooltip
|
||||||
|
arrow
|
||||||
|
title={<Typography variant="body2">{actionLabel}</Typography>}
|
||||||
|
placement="top-end"
|
||||||
|
>
|
||||||
|
<IconButton edge="end" onClick={handleAction}>
|
||||||
|
{actionIcon}
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
</ListItemSecondaryAction>
|
||||||
|
</ListItem>
|
||||||
|
</>
|
||||||
|
);
|
||||||
@@ -7,7 +7,7 @@ import { useConfig } from '../../../config/hooks/useConfig';
|
|||||||
import { List } from '../../../ui/components/List';
|
import { List } from '../../../ui/components/List';
|
||||||
import { useSimcard } from '../../../os/simcard/hooks/useSimcard';
|
import { useSimcard } from '../../../os/simcard/hooks/useSimcard';
|
||||||
import { useApp } from '../../../os/apps/hooks/useApps';
|
import { useApp } from '../../../os/apps/hooks/useApps';
|
||||||
import { SettingItem, SettingItemSlider } from './SettingItem';
|
import { SettingItem, SettingItemIconAction, SettingItemSlider } from './SettingItem';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -18,10 +18,12 @@ import {
|
|||||||
ZoomIn,
|
ZoomIn,
|
||||||
LibraryMusic,
|
LibraryMusic,
|
||||||
VolumeUp,
|
VolumeUp,
|
||||||
|
FileCopy,
|
||||||
} from '@material-ui/icons';
|
} from '@material-ui/icons';
|
||||||
|
|
||||||
import { ListSubheader } from '@material-ui/core';
|
import { ListSubheader } from '@material-ui/core';
|
||||||
import { useSettings } from '../hooks/useSettings';
|
import { useSettings } from '../hooks/useSettings';
|
||||||
|
// import { useSnackbar } from '../../../ui/hooks/useSnackbar';
|
||||||
|
|
||||||
const SubHeaderComp = (props: { text: string }) => (
|
const SubHeaderComp = (props: { text: string }) => (
|
||||||
<ListSubheader color="primary" component="div" disableSticky>
|
<ListSubheader color="primary" component="div" disableSticky>
|
||||||
@@ -35,6 +37,8 @@ export const SettingsApp = () => {
|
|||||||
const simcard = useSimcard();
|
const simcard = useSimcard();
|
||||||
const [settings, setSettings] = useSettings();
|
const [settings, setSettings] = useSettings();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
// TODO: Uncomment when #135 is merged
|
||||||
|
// const { addAlert } = useSnackbar();
|
||||||
|
|
||||||
const handleSettingChange = (key: string | number, value: unknown) => {
|
const handleSettingChange = (key: string | number, value: unknown) => {
|
||||||
setSettings({ ...settings, [key]: value });
|
setSettings({ ...settings, [key]: value });
|
||||||
@@ -69,16 +73,33 @@ export const SettingsApp = () => {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const handleCopyPhoneNumber = () => {
|
||||||
|
// TODO: Dependent on #132 merge
|
||||||
|
// setClipboard(simcard.number)
|
||||||
|
// TODO: Dependent on #135 merge
|
||||||
|
// addAlert({
|
||||||
|
// message: t('GENERIC_WRITE_TO_CLIPBOARD_MESSAGE', {
|
||||||
|
// content: 'number',
|
||||||
|
// }),
|
||||||
|
// type: 'success',
|
||||||
|
// });
|
||||||
|
};
|
||||||
|
|
||||||
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
|
const [openMenu, closeMenu, ContextMenu, isMenuOpen] = useContextMenu();
|
||||||
return (
|
return (
|
||||||
<AppWrapper>
|
<AppWrapper>
|
||||||
<AppTitle app={settingsApp} />
|
<AppTitle app={settingsApp} />
|
||||||
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
<AppContent backdrop={isMenuOpen} onClickBackdrop={closeMenu}>
|
||||||
<List disablePadding subheader={<SubHeaderComp text="Phone" />}>
|
<List disablePadding subheader={<SubHeaderComp text="Phone" />}>
|
||||||
<SettingItem
|
<SettingItemIconAction
|
||||||
label={t('APPS_SETTINGS_PHONE_NUMBER')}
|
label={t('APPS_SETTINGS_PHONE_NUMBER')}
|
||||||
value={simcard.number}
|
labelSecondary={simcard.number}
|
||||||
|
actionLabel={t('GENERIC_WRITE_TO_CLIPBOARD_TOOLTIP', {
|
||||||
|
content: 'number',
|
||||||
|
})}
|
||||||
icon={<Phone />}
|
icon={<Phone />}
|
||||||
|
actionIcon={<FileCopy />}
|
||||||
|
handleAction={handleCopyPhoneNumber}
|
||||||
/>
|
/>
|
||||||
<SettingItem
|
<SettingItem
|
||||||
label={t('APPS_SETTINGS_OPTION_RINGTONE')}
|
label={t('APPS_SETTINGS_OPTION_RINGTONE')}
|
||||||
|
|||||||
Reference in new issue
Block a user