zhang
2025-05-20 1313906bb1eb983d3beece810035e7fc28d6a92f
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
import React, { useState, useRef, useEffect, useMemo } from "react";
import { useTranslate } from "react-admin";
import {
    Fab,
    Box,
    Backdrop,
    useTheme,
} from '@mui/material';
import AltRouteIcon from '@mui/icons-material/AltRoute';
import CircularProgress from '@mui/material/CircularProgress';
import * as Tool from '../tool';
 
const RouteFab = (props) => {
    const { curZone, showRoutes, setShowRoutes, notify } = props;
    const translate = useTranslate();
    const theme = useTheme();   // theme.palette.primary.main
 
    const [loading, setLoading] = React.useState(false);
 
    const handleClick = () => {
        if (showRoutes) {
            Tool.hideRoutes(curZone, setShowRoutes);
        } else {
            Tool.showRoutes(curZone, setShowRoutes, setLoading);
        }
    }
 
    return (
        <>
            <Fab
                variant="extended"
                color={showRoutes ? 'primary' : 'default'}
                size="small"
                disabled={loading}
                onClick={handleClick}
            >
                <AltRouteIcon />
                &nbsp;{translate('page.map.action.route')}&nbsp;
                {loading && (
                    <>
                        <svg width={0} height={0}>
                            <defs>
                                <linearGradient id="my_gradient" x1="0%" y1="0%" x2="0%" y2="100%">
                                    <stop offset="0%" stopColor="#e01cd5" />
                                    <stop offset="100%" stopColor="#1CB5E0" />
                                </linearGradient>
                            </defs>
                        </svg>
                        <CircularProgress size={18} thickness={8} sx={{ 'svg circle': { stroke: 'url(#my_gradient)' } }} />
                    </>
                )}
            </Fab>
            {/* global */}
            {/* <Backdrop
                sx={{ color: '#fff', zIndex: (theme) => theme.zIndex.drawer + 1 }}
                open={loading}
            >
                <CircularProgress color="inherit" />
            </Backdrop> */}
        </>
    )
}
 
export default RouteFab;