printWidth: 100

This commit is contained in:
Christopher committed 2021-03-02 21:03:06 +01:00
1 parent d27aeb3b0e
commit 6f4ee009a9
63 files changed
+602 -223

No files matched your search

+19 -4
View File
@@ -1,7 +1,13 @@
import React from 'react';
import { blue, common, grey, purple } from '@material-ui/core/colors';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { faAd, faPlaneArrival, faPhoneAlt, faWonSign, faStickyNote } from '@fortawesome/free-solid-svg-icons';
import {
faAd,
faPlaneArrival,
faPhoneAlt,
faWonSign,
faStickyNote,
} from '@fortawesome/free-solid-svg-icons';
import { faTwitter } from '@fortawesome/free-brands-svg-icons';
import ContactsIcon from '@material-ui/icons/Contacts';
@@ -22,9 +28,18 @@ import { NotesApp } from '../../../apps/notes/NotesApp';
import CameraApp from '../../../apps/camera/components/CameraApp';
import { AppRoute } from '../components/AppRoute';
import { MESSAGES_APP_PRIMARY_COLOR, MESSAGES_APP_TEXT_COLOR } from '../../../apps/messages/messages.theme';
import { CONTACTS_APP_PRIMARY_COLOR, CONTACTS_APP_TEXT_COLOR } from '../../../apps/contacts/contacts.theme';
import { SELLOUT_APP_PRIMARY_COLOR, SELLOUT_APP_ICON_COLOR } from '../../../apps/sellout/sellout.theme';
import {
MESSAGES_APP_PRIMARY_COLOR,
MESSAGES_APP_TEXT_COLOR,
} from '../../../apps/messages/messages.theme';
import {
CONTACTS_APP_PRIMARY_COLOR,
CONTACTS_APP_TEXT_COLOR,
} from '../../../apps/contacts/contacts.theme';
import {
SELLOUT_APP_PRIMARY_COLOR,
SELLOUT_APP_ICON_COLOR,
} from '../../../apps/sellout/sellout.theme';
import { NOTES_APP_ICON_COLOR, NOTES_APP_PRIMARY_COLOR } from '../../../apps/notes/notes.theme';
import { DIALER_APP_PRIMARY_COLOR, DIALER_APP_TEXT_COLOR } from '../../../apps/dialer/dialer.theme';
+3 -1
View File
@@ -12,7 +12,9 @@ export const useApps = () => {
})),
[icons],
);
const getApp = useCallback((id: string): IAppConfig => apps.find((a) => a.id === id) || null, [apps]);
const getApp = useCallback((id: string): IAppConfig => apps.find((a) => a.id === id) || null, [
apps,
]);
return { apps, getApp };
};
@@ -34,7 +34,15 @@ const keyboardState = {
}),
};
const validKeys = ['ArrowRight', 'ArrowLeft', 'ArrowUp', 'ArrowDown', 'Backspace', 'Enter', 'Escape'];
const validKeys = [
'ArrowRight',
'ArrowLeft',
'ArrowUp',
'ArrowDown',
'Backspace',
'Enter',
'Escape',
];
const isKeyValid = (key) => validKeys.indexOf(key) !== -1;
@@ -29,7 +29,11 @@ export const Navigation = () => {
}}
>
<BottomNavigationAction label="Home" value={() => history.push('/')} icon={<AppsIcon />} />
<BottomNavigationAction label="Close" value={closePhone} icon={<RadioButtonUncheckedIcon />} />
<BottomNavigationAction
label="Close"
value={closePhone}
icon={<RadioButtonUncheckedIcon />}
/>
<BottomNavigationAction
label="Back"
value={() => !isExact && history.goBack()}
@@ -1,5 +1,15 @@
import React from 'react';
import { makeStyles, Typography, Grid, IconButton, Slide, Paper, Box, List, Divider } from '@material-ui/core';
import {
makeStyles,
Typography,
Grid,
IconButton,
Slide,
Paper,
Box,
List,
Divider,
} from '@material-ui/core';
import SignalIcon from '@material-ui/icons/SignalCellular3Bar';
import Battery90Icon from '@material-ui/icons/Battery90';
import ArrowDropUpIcon from '@material-ui/icons/ArrowDropUp';
@@ -56,7 +66,13 @@ const useStyles = makeStyles((theme) => ({
export const NotificationBar = () => {
const classes = useStyles();
const { icons, notifications, removeNotification, barUncollapsed, setBarUncollapsed } = useNotifications();
const {
icons,
notifications,
removeNotification,
barUncollapsed,
setBarUncollapsed,
} = useNotifications();
return (
<>
@@ -118,7 +134,11 @@ export const NotificationBar = () => {
</List>
</Box>
<Box display="flex">
<IconButton className={classes.collapseBtn} size="small" onClick={() => setBarUncollapsed(false)}>
<IconButton
className={classes.collapseBtn}
size="small"
onClick={() => setBarUncollapsed(false)}
>
<ArrowDropUpIcon />
</IconButton>
</Box>
@@ -1,6 +1,13 @@
import React from 'react';
import CloseIcon from '@material-ui/icons/Close';
import { IconButton, ListItem, ListItemAvatar, ListItemText, makeStyles, Theme } from '@material-ui/core';
import {
IconButton,
ListItem,
ListItemAvatar,
ListItemText,
makeStyles,
Theme,
} from '@material-ui/core';
import { INotification } from '../providers/NotificationsProvider';
const useStyles = makeStyles<Theme, { cantClose: boolean }>((theme) => ({
@@ -61,7 +61,9 @@ export function NotificationsProvider({ children }) {
const { mount, play } = useSoundProvider();
const alertTimeout = useRef<NodeJS.Timeout>();
const [alerts, setAlerts] = useState<Array<[INotification, boolean, Partial<INotification>, string | undefined]>>([]);
const [alerts, setAlerts] = useState<
Array<[INotification, boolean, Partial<INotification>, string | undefined]>
>([]);
const [currentAlert, setCurrentAlert] = useState<INotificationAlert>();
useEffect(() => {
@@ -154,10 +156,16 @@ export function NotificationsProvider({ children }) {
[addOrUpdateNotification, play],
);
const addNotificationAlert = (n: INotification, persist?: boolean, update?: Partial<INotification>) => {
const addNotificationAlert = (
n: INotification,
persist?: boolean,
update?: Partial<INotification>,
) => {
if (n.sound) {
const { sound, volume } = getSoundSettings('notification', settings, n.app);
mount(sound, volume, false).then(({ url }) => setAlerts((curr) => [...curr, [n, persist, update, url]]));
mount(sound, volume, false).then(({ url }) =>
setAlerts((curr) => [...curr, [n, persist, update, url]]),
);
return;
}
setAlerts((curr) => [...curr, [n, persist, update, undefined]]);
+14 -1
View File
@@ -41,7 +41,20 @@ const useSound = (url: string, options: ISoundOptions = DEFAULT_OPTIONS) => {
}
volume(url, vol);
loop(url, isLoop);
}, [url, vol, isLoop, isMounted, volume, loop, mount, previousUrl, stop, remove, isPlaying, play]);
}, [
url,
vol,
isLoop,
isMounted,
volume,
loop,
mount,
previousUrl,
stop,
remove,
isPlaying,
play,
]);
useEffect(() => {
if (interrupt) {
+41 -38
View File
@@ -26,47 +26,50 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
soundRefs.current = new Map();
}, []);
const mount = useCallback((url: string, volume: number = 1, loop: boolean = false, autoplay: boolean = false) => {
return new Promise<IMountResponse>((res) => {
if (!soundRefs.current) {
soundRefs.current = new Map();
}
const find = soundRefs.current.get(url);
if (find) {
find.howl.volume(volume);
find.howl.loop(loop);
if (autoplay) {
find.howl.play();
const mount = useCallback(
(url: string, volume: number = 1, loop: boolean = false, autoplay: boolean = false) => {
return new Promise<IMountResponse>((res) => {
if (!soundRefs.current) {
soundRefs.current = new Map();
}
return res({ howl: find.howl, url });
}
const instance = new Howl({
src: url,
loop,
volume,
autoplay,
const find = soundRefs.current.get(url);
if (find) {
find.howl.volume(volume);
find.howl.loop(loop);
if (autoplay) {
find.howl.play();
}
return res({ howl: find.howl, url });
}
const instance = new Howl({
src: url,
loop,
volume,
autoplay,
});
soundRefs.current.set(url, { howl: instance, volume });
instance.once('load', () => {
console.log('ready', instance);
res({ howl: instance, url });
});
const onError = (_id, e) => {
res(null);
console.error('Howler Error \n', e, '\nid: ', _id, '\nsrc: ', url);
};
instance.once('loaderror', onError);
instance.once('playerror', onError);
});
soundRefs.current.set(url, { howl: instance, volume });
instance.once('load', () => {
console.log('ready', instance);
res({ howl: instance, url });
});
const onError = (_id, e) => {
res(null);
console.error('Howler Error \n', e, '\nid: ', _id, '\nsrc: ', url);
};
instance.once('loaderror', onError);
instance.once('playerror', onError);
});
}, []);
},
[],
);
const play = useCallback(
(url: string, volume: number, loop: boolean) => {
+5 -1
View File
@@ -9,7 +9,11 @@ const getPath = {
/**
* Gets the configuration for SoundProvider based on settings and apps
*/
export const getSoundSettings = (type: 'ringtone' | 'notification', settings: IPhoneSettings, app?: string) => {
export const getSoundSettings = (
type: 'ringtone' | 'notification',
settings: IPhoneSettings,
app?: string,
) => {
try {
return app
? {