-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.tsx
75 lines (60 loc) · 2.23 KB
/
App.tsx
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { IonApp, IonContent, IonFab, IonFabButton, IonIcon, IonSplitPane, setupIonicReact } from '@ionic/react';
import Menu from './components/menu/Menu';
/* Core CSS required for Ionic components to work properly */
import '@ionic/react/css/core.css';
/* Basic CSS for apps built with Ionic */
import '@ionic/react/css/normalize.css';
import '@ionic/react/css/structure.css';
import '@ionic/react/css/typography.css';
/* Optional CSS utils that can be commented out */
import '@ionic/react/css/padding.css';
import '@ionic/react/css/float-elements.css';
import '@ionic/react/css/text-alignment.css';
import '@ionic/react/css/text-transformation.css';
import '@ionic/react/css/flex-utils.css';
import '@ionic/react/css/display.css';
/* Theme variables */
import './theme/variables.scss';
import './App.scss'
import { usePages } from './hooks/usePages';
import React, { useEffect, useState } from 'react';
import Header from './components/header/Header';
import { addOutline, addSharp } from 'ionicons/icons';
import NewAddress from './components/new-address/NewAddress';
import { Outlet, Route, Routes, useNavigate } from 'react-router-dom';
setupIonicReact();
const App: React.FC = () => {
const { pages, getCurrentPage } = usePages();
const [isOpen, setOpen] = useState(false);
const navigate = useNavigate();
// Load the first page in the app
// when user tries to access a page
// that is not defined in the router
useEffect(() => {
const currentPage = getCurrentPage();
navigate(currentPage.url);
}, [])
return (
<IonApp>
<IonSplitPane contentId="main" >
<Menu />
<IonContent id="main" fullscreen>
<Header />
<div id="PageContent">
<Routes>
{pages.map((page, index) => <Route key={index} path={page.url} element={page.component} />)}
</Routes>
<Outlet />
</div>
</IonContent>
</IonSplitPane>
<IonFab slot="fixed" vertical="bottom" horizontal="end">
<IonFabButton onClick={() => setOpen(true)}>
<IonIcon ios={addOutline} md={addSharp} />
</IonFabButton>
</IonFab>
<NewAddress isOpen={isOpen} onClose={() => setOpen(false)} />
</IonApp >
);
};
export default App;