-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainlayout.tsx
More file actions
40 lines (35 loc) · 1.59 KB
/
Mainlayout.tsx
File metadata and controls
40 lines (35 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { useLocation } from 'react-router-dom';
import { detectPWA, detectPlatform, detectWebView } from '@utils/Detector';
import { webPath } from '@router/index';
import BottomNavigation from '@layout/BottomNavigation/BottomNavigation';
import Header from '@layout/Header/Header';
import AppInstallPopUp from '@components/PopUp/AppInstallPopUp/AppInstallPopUp';
import PWAInfoPopUp from '@components/PopUp/PWAinfoPopUp/PWAInfoPopUp';
import Footer from '../Footer/Footer';
import { LayoutProps } from './Mainlayout.Props';
import { MainContent, StyledMainlayout } from './Mainlayout.Style';
const Mainlayout = ({ children }: LayoutProps) => {
const location = useLocation();
const platform = detectPlatform();
const isMobileDevice = platform === 'iOS' || platform === 'Android';
const visiblePWAInfoPopUp = false;
const isRootPage = location.pathname === '/';
const isBottomNavigationVisible = (
['login', 'register', 'editProfile', 'withdraw', 'term', 'usage', 'notification'] as (keyof typeof webPath)[]
).reduce((acc, path) => {
return acc && !location.pathname.startsWith(webPath[path]());
}, true);
return (
<StyledMainlayout>
<MainContent isNavActive={isBottomNavigationVisible}>
<Header location={location.pathname} />
{children}
{isRootPage && <Footer />}
</MainContent>
{visiblePWAInfoPopUp && isRootPage && !detectPWA() && <PWAInfoPopUp />}
{isMobileDevice && isRootPage && !detectWebView() && <AppInstallPopUp />}
{isBottomNavigationVisible && <BottomNavigation />}
</StyledMainlayout>
);
};
export default Mainlayout;