-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbottom-nav.tsx
62 lines (57 loc) · 1.63 KB
/
bottom-nav.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
import React, { useState, useEffect } from 'react';
import BottomNavigation from '@mui/material/BottomNavigation';
import BottomNavigationAction from '@mui/material/BottomNavigationAction';
import { useNavigate } from "react-router-dom";
import { Box, Fab } from "@mui/material";
import { Add, Home, BarChart, TextFields } from '@mui/icons-material';
const routes = [
"/",
"/data",
"/form"
];
declare var rpc: any;
export default function() {
const [value, setValue] = useState(0);
const [iOS, setIOS] = useState(false);
const navigate = useNavigate();
useEffect(() => {
rpc().platform().then((platform: string) => setIOS(platform === "ios"));
}, [])
return (
<Box sx={{
position: 'fixed',
bottom: 0,
left: 0,
right: 0,
display: "flex",
flexDirection: "column",
"& .MuiBottomNavigation-root": {
height: iOS ? "76px" : null,
"& .MuiButtonBase-root": {
paddingBottom: iOS ? "20px" : null
}
}
}}>
<Fab
color="primary"
sx={{
margin: "0 16px 16px auto"
}}
>
<Add />
</Fab>
<BottomNavigation
showLabels
value={value}
onChange={(_, newValue) => {
setValue(newValue);
navigate(routes[newValue]);
}}
>
<BottomNavigationAction label="Home" icon={<Home />} />
<BottomNavigationAction label="Data" icon={<BarChart />} />
<BottomNavigationAction label="Form" icon={<TextFields />} />
</BottomNavigation>
</Box>
);
}