mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
120 in printWidth since rocky got md
This commit is contained in:
1 parent
f552c1212c
commit
d27aeb3b0e
90 files changed
+398
-1146
No files matched your search
@@ -1,13 +1,7 @@
|
||||
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';
|
||||
@@ -28,26 +22,11 @@ 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 {
|
||||
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';
|
||||
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';
|
||||
|
||||
export interface IAppConfig {
|
||||
id: string;
|
||||
@@ -99,9 +78,7 @@ export const APPS: IAppConfig[] = [
|
||||
backgroundColor: purple[500],
|
||||
color: grey[50],
|
||||
path: '/calculator',
|
||||
Route: () => (
|
||||
<AppRoute id="CALCULATOR" path="/calculator" component={CalculatorApp} />
|
||||
),
|
||||
Route: () => <AppRoute id="CALCULATOR" path="/calculator" component={CalculatorApp} />,
|
||||
},
|
||||
{
|
||||
id: 'SETTINGS',
|
||||
|
||||
@@ -12,10 +12,7 @@ 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 };
|
||||
};
|
||||
|
||||
|
||||
@@ -5,9 +5,7 @@ import { callerState } from './state';
|
||||
export const useDuration = () => {
|
||||
const [duration, setDuration] = useRecoilState(callerState.callDuration);
|
||||
|
||||
const resetDuration = useCallback(() => setDuration({ ms: 0, s: 0, m: 0, h: 0 }), [
|
||||
setDuration,
|
||||
]);
|
||||
const resetDuration = useCallback(() => setDuration({ ms: 0, s: 0, m: 0, h: 0 }), [setDuration]);
|
||||
|
||||
return { duration, setDuration, resetDuration };
|
||||
};
|
||||
@@ -34,15 +34,7 @@ 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;
|
||||
|
||||
|
||||
@@ -28,16 +28,8 @@ export const Navigation = () => {
|
||||
value();
|
||||
}}
|
||||
>
|
||||
<BottomNavigationAction
|
||||
label="Home"
|
||||
value={() => history.push('/')}
|
||||
icon={<AppsIcon />}
|
||||
/>
|
||||
<BottomNavigationAction
|
||||
label="Close"
|
||||
value={closePhone}
|
||||
icon={<RadioButtonUncheckedIcon />}
|
||||
/>
|
||||
<BottomNavigationAction label="Home" value={() => history.push('/')} icon={<AppsIcon />} />
|
||||
<BottomNavigationAction label="Close" value={closePhone} icon={<RadioButtonUncheckedIcon />} />
|
||||
<BottomNavigationAction
|
||||
label="Back"
|
||||
value={() => !isExact && history.goBack()}
|
||||
|
||||
@@ -1,15 +1,5 @@
|
||||
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';
|
||||
@@ -66,13 +56,7 @@ 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 (
|
||||
<>
|
||||
@@ -87,12 +71,7 @@ export const NotificationBar = () => {
|
||||
>
|
||||
<Grid container item wrap="nowrap">
|
||||
{icons.map((notifIcon) => (
|
||||
<Grid
|
||||
item
|
||||
key={notifIcon.key}
|
||||
component={IconButton}
|
||||
className={classes.icon}
|
||||
>
|
||||
<Grid item key={notifIcon.key} component={IconButton} className={classes.icon}>
|
||||
{notifIcon.icon}
|
||||
</Grid>
|
||||
))}
|
||||
@@ -139,11 +118,7 @@ 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,13 +1,6 @@
|
||||
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) => ({
|
||||
|
||||
@@ -25,9 +25,7 @@ const unshiftApp = (arr: IAppConfig[], app) => {
|
||||
export const useQuickAccess = () => {
|
||||
const history = useHistory();
|
||||
const { apps, getApp } = useApps();
|
||||
const [recentlyUsed, setRecentlyUsed] = useRecoilState<IAppConfig[]>(
|
||||
state.recentlyUsed,
|
||||
);
|
||||
const [recentlyUsed, setRecentlyUsed] = useRecoilState<IAppConfig[]>(state.recentlyUsed);
|
||||
|
||||
useEffect(() => {
|
||||
setRecentlyUsed([getApp('SETTINGS')]);
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
import React, {
|
||||
createContext,
|
||||
useState,
|
||||
useCallback,
|
||||
useMemo,
|
||||
useRef,
|
||||
useEffect,
|
||||
} from 'react';
|
||||
import React, { createContext, useState, useCallback, useMemo, useRef, useEffect } from 'react';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { useSettings } from '../../../apps/settings/hooks/useSettings';
|
||||
import { phoneState } from '../../phone/hooks/state';
|
||||
@@ -53,11 +46,7 @@ export const NotificationsContext = createContext<{
|
||||
updateId(id: string, value: Partial<INotification>): void;
|
||||
removeId(id: string): void;
|
||||
hasNotification(app: string): number;
|
||||
addNotificationAlert(
|
||||
n: INotification,
|
||||
persist: boolean,
|
||||
update?: Partial<INotification>,
|
||||
);
|
||||
addNotificationAlert(n: INotification, persist: boolean, update?: Partial<INotification>);
|
||||
}>(null);
|
||||
|
||||
export function NotificationsProvider({ children }) {
|
||||
@@ -72,9 +61,7 @@ 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(() => {
|
||||
@@ -127,12 +114,7 @@ export function NotificationsProvider({ children }) {
|
||||
);
|
||||
|
||||
const _showAlert = useCallback(
|
||||
(
|
||||
n: INotification,
|
||||
persist: boolean,
|
||||
update: Partial<INotification>,
|
||||
soundUrl: string,
|
||||
) => {
|
||||
(n: INotification, persist: boolean, update: Partial<INotification>, soundUrl: string) => {
|
||||
return new Promise<void>((res) => {
|
||||
const resolve = () => {
|
||||
if (persist) {
|
||||
@@ -172,16 +154,10 @@ 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]]);
|
||||
|
||||
@@ -21,16 +21,7 @@ const useSound = (url: string, options: ISoundOptions = DEFAULT_OPTIONS) => {
|
||||
|
||||
const [isPlaying, setPlaying] = useState<boolean>(false);
|
||||
|
||||
const {
|
||||
mount,
|
||||
play,
|
||||
stop,
|
||||
playing,
|
||||
volume,
|
||||
loop,
|
||||
remove,
|
||||
isMounted,
|
||||
} = useSoundProvider();
|
||||
const { mount, play, stop, playing, volume, loop, remove, isMounted } = useSoundProvider();
|
||||
|
||||
const previousInterrupt = usePreviousState(interrupt);
|
||||
const previousUrl = usePreviousState(url);
|
||||
@@ -50,20 +41,7 @@ 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) {
|
||||
|
||||
@@ -7,12 +7,7 @@ interface IMountResponse {
|
||||
}
|
||||
|
||||
interface ISoundContext {
|
||||
mount(
|
||||
url: string,
|
||||
volume?: number,
|
||||
loop?: boolean,
|
||||
autoplay?: boolean,
|
||||
): Promise<IMountResponse>;
|
||||
mount(url: string, volume?: number, loop?: boolean, autoplay?: boolean): Promise<IMountResponse>;
|
||||
play(url?: string, volume?: number, loop?: boolean): void;
|
||||
stop(url: string): void;
|
||||
remove(url: string): boolean;
|
||||
@@ -31,55 +26,47 @@ 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 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();
|
||||
}
|
||||
return res({ howl: find.howl, url });
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
});
|
||||
}, []);
|
||||
|
||||
const play = useCallback(
|
||||
(url: string, volume: number, loop: boolean) => {
|
||||
@@ -167,9 +154,7 @@ export const SoundProvider = ({ children }: { children: React.ReactNode }) => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<soundContext.Provider
|
||||
value={{ mount, play, stop, playing, remove, volume, loop, isMounted }}
|
||||
>
|
||||
<soundContext.Provider value={{ mount, play, stop, playing, remove, volume, loop, isMounted }}>
|
||||
{children}
|
||||
</soundContext.Provider>
|
||||
);
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { IPhoneSettings } from '../../../apps/settings/hooks/useSettings';
|
||||
import {
|
||||
getNotificationPath,
|
||||
getRingtonePath,
|
||||
} from '../../../apps/settings/utils/getRingtonePath';
|
||||
import { getNotificationPath, getRingtonePath } from '../../../apps/settings/utils/getRingtonePath';
|
||||
|
||||
const getPath = {
|
||||
ringtone: getRingtonePath,
|
||||
@@ -12,11 +9,7 @@ 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
|
||||
? {
|
||||
|
||||
Reference in new issue
Block a user