From 3e01fc456cc1bde75c7e573031ceee289bf8461f Mon Sep 17 00:00:00 2001 From: Taso Date: Mon, 19 Apr 2021 13:28:10 -0400 Subject: [PATCH] tweak(phone): Split Phone component into wrapper --- phone/src/Phone.tsx | 100 +++++++++++++------------------------ phone/src/PhoneWrapper.tsx | 46 +++++++++++++++++ 2 files changed, 81 insertions(+), 65 deletions(-) create mode 100644 phone/src/PhoneWrapper.tsx diff --git a/phone/src/Phone.tsx b/phone/src/Phone.tsx index f7e292b..2c3f2d8 100644 --- a/phone/src/Phone.tsx +++ b/phone/src/Phone.tsx @@ -4,7 +4,7 @@ import './i18n'; import { Route } from 'react-router-dom'; import { CallModal } from './os/call/components/CallModal'; import { HomeApp } from './apps/home/components/Home'; -import { Box, Paper, Slide, Typography } from '@material-ui/core'; +import { Box, Paper, Typography } from '@material-ui/core'; import { NotificationBar } from './os/notifications/components/NotificationBar'; import { Navigation } from './os/navigation-bar/components/Navigation'; import { useSimcardService } from './os/simcard/hooks/useSimcardService'; @@ -23,7 +23,6 @@ import { isSettingsSchemaValid, useSettings } from './apps/settings/hooks/useSet import { useCallService } from './os/call/hooks/useCallService'; import { useDialService } from './apps/dialer/hooks/useDialService'; import InjectDebugData from './os/debug/InjectDebugData'; -import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility'; import { PhoneSnackbar } from './ui/components/PhoneSnackbar'; import { NotificationAlert } from './os/notifications/components/NotificationAlert'; import { useCallModal } from './os/call/hooks/useCallModal'; @@ -33,8 +32,8 @@ import { useTranslation } from 'react-i18next'; import { useSnackbar } from './ui/hooks/useSnackbar'; import { PhoneEvents } from '../../typings/phone'; import dayjs from 'dayjs'; -import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper'; import { useKeyboardService } from './os/keyboard/hooks/useKeyboardService'; +import PhoneWrapper from './PhoneWrapper'; function Phone() { const { t, i18n } = useTranslation(); @@ -78,74 +77,45 @@ function Phone() { useDialService(); const { modal: callModal } = useCallModal(); - const { bottom, visibility } = usePhoneVisibility(); const { isPhoneReady } = usePhone(); return (
- -
-
-
-
- {isPhoneReady ? ( - <> - -
- <> - - {callModal && } - {apps.map((App) => ( - - ))} - - - -
- - - ) : ( - - - NPWD {t('INITIALIZING')} - - {t('GENERIC_WAIT')} - - )} + + {isPhoneReady ? ( + <> + +
+ <> + + {callModal && } + {apps.map((App) => ( + + ))} + + +
-
-
- + + + ) : ( + + + NPWD {t('INITIALIZING')} + + {t('GENERIC_WAIT')} + + )} +
); } diff --git a/phone/src/PhoneWrapper.tsx b/phone/src/PhoneWrapper.tsx new file mode 100644 index 0000000..d02d566 --- /dev/null +++ b/phone/src/PhoneWrapper.tsx @@ -0,0 +1,46 @@ +import React from 'react'; +import { isDefaultWallpaper } from './apps/settings/utils/isDefaultWallpaper'; +import { useSettings } from './apps/settings/hooks/useSettings'; +import { usePhoneVisibility } from './os/phone/hooks/usePhoneVisibility'; +import { Slide } from '@material-ui/core'; + +const PhoneWrapper: React.FC = ({ children }) => { + const [settings] = useSettings(); + const { bottom, visibility } = usePhoneVisibility(); + + return ( + +
+
+
+
+ {children} +
+
+
+ + ); +}; + +export default PhoneWrapper;