mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 22:16:40 +00:00
feat(phone/icon-sets): Add icon sets configurable in settings
This commit is contained in:
1 parent
2c9f260417
commit
e76e6c5296
60 files changed
+292
-30
No files matched your search
@@ -49,7 +49,7 @@ export type IApp = IAppConfig & {
|
||||
icon: JSX.Element;
|
||||
notificationIcon: JSX.Element;
|
||||
NotificationIcon: React.FC<SvgIconProps>;
|
||||
Icon: React.FC<SvgIconProps>;
|
||||
Icon?: React.FC<SvgIconProps>;
|
||||
};
|
||||
|
||||
export const APPS: IAppConfig[] = [
|
||||
|
||||
@@ -4,27 +4,31 @@ import { createLazyAppIcon } from '../utils/createLazyAppIcon';
|
||||
import { APPS, IApp } from '../config/apps';
|
||||
import { SvgIconComponent } from '@material-ui/icons';
|
||||
import { useTheme } from '@material-ui/core';
|
||||
import { useSettings, useSettingsValue } from '../../../apps/settings/hooks/useSettings';
|
||||
|
||||
const DEFAULT_ICONSET = 'default';
|
||||
export interface IconSetObject {
|
||||
custom: boolean;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export const useApps = () => {
|
||||
const { icons } = useNotifications();
|
||||
const theme = useTheme();
|
||||
const iconset = DEFAULT_ICONSET;
|
||||
const apps: IApp[] = useMemo(
|
||||
() =>
|
||||
APPS.map((app) => {
|
||||
|
||||
const SvgIcon = React.lazy<SvgIconComponent>(
|
||||
() => import(`${__dirname}/../icons/${iconset}/svg/${app.id}`),
|
||||
);
|
||||
const AppIcon = React.lazy<SvgIconComponent>(
|
||||
() => import(`${__dirname}/../icons/${iconset}/app/${app.id}`),
|
||||
);
|
||||
const curIconSet = useSettingsValue().iconSet.value as IconSetObject;
|
||||
|
||||
const NotificationIcon = createLazyAppIcon(SvgIcon);
|
||||
const Icon = createLazyAppIcon(AppIcon);
|
||||
const apps: IApp[] = useMemo(() => {
|
||||
return APPS.map((app) => {
|
||||
const SvgIcon = React.lazy<SvgIconComponent>(
|
||||
() => import(`${__dirname}/../icons/${curIconSet.name}/svg/${app.id}`),
|
||||
);
|
||||
const AppIcon = React.lazy<SvgIconComponent>(
|
||||
() => import(`${__dirname}/../icons/${curIconSet.name}/app/${app.id}`),
|
||||
);
|
||||
|
||||
const NotificationIcon = createLazyAppIcon(SvgIcon);
|
||||
const Icon = createLazyAppIcon(AppIcon);
|
||||
|
||||
if (curIconSet.custom) {
|
||||
return {
|
||||
...app,
|
||||
notification: icons.find((i) => i.key === app.id),
|
||||
@@ -35,9 +39,18 @@ export const useApps = () => {
|
||||
),
|
||||
icon: <Icon />,
|
||||
};
|
||||
}),
|
||||
[icons, iconset, theme],
|
||||
);
|
||||
}
|
||||
|
||||
return {
|
||||
...app,
|
||||
notification: icons.find((i) => i.key === app.id),
|
||||
NotificationIcon,
|
||||
notificationIcon: <NotificationIcon htmlColor={app.color} fontSize="small" />,
|
||||
icon: <Icon />,
|
||||
};
|
||||
});
|
||||
}, [icons, curIconSet, theme]);
|
||||
|
||||
const getApp = useCallback((id: string): IApp => apps.find((a) => a.id === id) || null, [apps]);
|
||||
return { apps, getApp };
|
||||
};
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import { Money } from '@material-ui/icons';
|
||||
import React from 'react';
|
||||
|
||||
const BankIcon: React.FC = () => <Money fontSize="large" />;
|
||||
|
||||
export default BankIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { CalculatorIcon } from '../../../../../apps/calculator/components/CalculatorIcon';
|
||||
|
||||
const Calculator: React.FC = () => <CalculatorIcon fontSize="large" />;
|
||||
|
||||
export default Calculator;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { CameraAlt } from '@material-ui/icons';
|
||||
|
||||
const Camera: React.FC = () => <CameraAlt fontSize="large" />;
|
||||
|
||||
export default Camera;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Contacts } from '@material-ui/icons';
|
||||
|
||||
const ContactIcon: React.FC = () => <Contacts fontSize="large" />;
|
||||
|
||||
export default ContactIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Phone } from '@material-ui/icons';
|
||||
|
||||
const DialerIcon: React.FC = () => <Phone fontSize="large" />;
|
||||
|
||||
export default DialerIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Email } from '@material-ui/icons';
|
||||
|
||||
const EmailIcon: React.FC = () => <Email fontSize="large" />;
|
||||
|
||||
export default EmailIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Help } from '@material-ui/icons';
|
||||
|
||||
const ExampleIcon: React.FC = () => <Help fontSize="large" />;
|
||||
|
||||
export default ExampleIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { MonetizationOn } from '@material-ui/icons';
|
||||
|
||||
const MarketplaceIcon: React.FC = () => <MonetizationOn fontSize="large" />;
|
||||
|
||||
export default MarketplaceIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Favorite } from '@material-ui/icons';
|
||||
|
||||
const MatchIcon: React.FC = () => <Favorite fontSize="large" />;
|
||||
|
||||
export default MatchIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Message } from '@material-ui/icons';
|
||||
|
||||
const MessagesIcon: React.FC = () => <Message fontSize="large" />;
|
||||
|
||||
export default MessagesIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import StickyNote from '../misc/StickyNote';
|
||||
|
||||
const NotesIcon: React.FC = () => <StickyNote fontSize="large" />;
|
||||
|
||||
export default NotesIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Settings } from '@material-ui/icons';
|
||||
|
||||
const SettingsIcon: React.FC = () => <Settings fontSize="large" />;
|
||||
|
||||
export default SettingsIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Twitter } from '@material-ui/icons';
|
||||
|
||||
const TwitterIcon: React.FC = () => <Twitter fontSize="large" />;
|
||||
|
||||
export default TwitterIcon;
|
||||
@@ -0,0 +1,14 @@
|
||||
import { SvgIconProps } from '@material-ui/core/SvgIcon';
|
||||
import React from 'react';
|
||||
import { SvgIcon } from '@material-ui/core';
|
||||
|
||||
const StickyNote: React.FC<SvgIconProps> = (props) => (
|
||||
<SvgIcon {...props}>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
||||
<rect fill="none" />
|
||||
<path d="M19,3H4.99C3.89,3,3,3.9,3,5l0.01,14c0,1.1,0.89,2,1.99,2h10l6-6V5C21,3.9,20.1,3,19,3z M7,8h10v2H7V8z M12,14H7v-2h5V14z M14,19.5V14h5.5L14,19.5z" />
|
||||
</svg>
|
||||
</SvgIcon>
|
||||
);
|
||||
|
||||
export default StickyNote;
|
||||
@@ -0,0 +1,6 @@
|
||||
import { Money } from '@material-ui/icons';
|
||||
import React from 'react';
|
||||
|
||||
const BankIcon: React.FC = () => <Money fontSize="small" />;
|
||||
|
||||
export default BankIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { CalculatorIcon } from '../../../../../apps/calculator/components/CalculatorIcon';
|
||||
|
||||
const Calculator: React.FC = () => <CalculatorIcon fontSize="small" />;
|
||||
|
||||
export default Calculator;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { CameraAlt } from '@material-ui/icons';
|
||||
|
||||
const Camera: React.FC = () => <CameraAlt fontSize="small" />;
|
||||
|
||||
export default Camera;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Contacts } from '@material-ui/icons';
|
||||
|
||||
const ContactIcon: React.FC = () => <Contacts fontSize="small" />;
|
||||
|
||||
export default ContactIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Phone } from '@material-ui/icons';
|
||||
|
||||
const DialerIcon: React.FC = () => <Phone fontSize="small" />;
|
||||
|
||||
export default DialerIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Email } from '@material-ui/icons';
|
||||
|
||||
const EmailIcon: React.FC = () => <Email fontSize="small" />;
|
||||
|
||||
export default EmailIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Help } from '@material-ui/icons';
|
||||
|
||||
const ExampleIcon: React.FC = () => <Help fontSize="small" />;
|
||||
|
||||
export default ExampleIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { MonetizationOn } from '@material-ui/icons';
|
||||
|
||||
const MarketplaceIcon: React.FC = () => <MonetizationOn fontSize="small" />;
|
||||
|
||||
export default MarketplaceIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Favorite } from '@material-ui/icons';
|
||||
|
||||
const MatchIcon: React.FC = () => <Favorite fontSize="small" />;
|
||||
|
||||
export default MatchIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Message } from '@material-ui/icons';
|
||||
|
||||
const MessagesIcon: React.FC = () => <Message fontSize="small" />;
|
||||
|
||||
export default MessagesIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import StickyNote from '../misc/StickyNote';
|
||||
|
||||
const NotesIcon: React.FC = () => <StickyNote fontSize="small" />;
|
||||
|
||||
export default NotesIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Settings } from '@material-ui/icons';
|
||||
|
||||
const SettingsIcon: React.FC = () => <Settings fontSize="small" />;
|
||||
|
||||
export default SettingsIcon;
|
||||
@@ -0,0 +1,6 @@
|
||||
import React from 'react';
|
||||
import { Twitter } from '@material-ui/icons';
|
||||
|
||||
const TwitterIcon: React.FC = () => <Twitter fontSize="small" />;
|
||||
|
||||
export default TwitterIcon;
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Reference in new issue
Block a user