Spaces:
Running

File size: 2,166 Bytes
1afccd9
 
 
 
 
 
 
 
 
 
0d3288e
1afccd9
 
 
 
 
 
0d3288e
1afccd9
 
 
 
 
 
 
0d3288e
1afccd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e9ea6b5
1afccd9
 
 
 
 
 
 
 
 
 
0d3288e
 
 
 
 
 
 
 
 
 
1afccd9
 
 
 
 
 
 
 
 
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
76
77
78
79
80
81
82
83
84
85
86
87
import {
  Alert,
  Button,
  Paper,
  Stack,
  Typography,
  useTheme,
} from '@mui/material';

interface FaceTrackingControlCardProps {
  trackingRequested: boolean | null;
  disabled: boolean;
  feedback: {
    severity: 'error' | 'info' | 'success';
    message: string;
  } | null;
  onToggle(): void;
  onManualControl(): void;
}

export default function FaceTrackingControlCard({
  trackingRequested,
  disabled,
  feedback,
  onToggle,
  onManualControl,
}: FaceTrackingControlCardProps) {
  const theme = useTheme();

  return (
    <Paper
      elevation={0}
      sx={{
        p: 1.75,
        display: 'flex',
        flexDirection: 'column',
        gap: 1,
        borderRadius: 1,
        border: `1px solid ${theme.palette.divider}`,
        boxShadow: 'none',
        backgroundColor: theme.palette.background.paper,
      }}
    >
      <Stack
        direction={{ xs: 'column', sm: 'row' }}
        spacing={1.25}
        sx={{
          alignItems: { xs: 'stretch', sm: 'center' },
          justifyContent: 'space-between',
        }}
      >
        <Stack spacing={0.25}>
          <Typography variant="subtitle2" sx={{ fontWeight: 700 }}>
            Face tracking
          </Typography>
          <Typography variant="caption" color="text.secondary">
            Following can continue after disconnecting on a keep-awake robot.
          </Typography>
        </Stack>
        <Button
          variant={trackingRequested ? 'outlined' : 'contained'}
          onClick={onToggle}
          disabled={disabled}
          sx={{ minHeight: 48, minWidth: { xs: '100%', sm: 152 }, flexShrink: 0 }}
        >
          {trackingRequested ? 'Stop tracking' : 'Start tracking'}
        </Button>
        {trackingRequested === null && (
          <Button
            variant="outlined"
            onClick={onManualControl}
            disabled={disabled}
            sx={{ minHeight: 48, flexShrink: 0 }}
          >
            Manual control
          </Button>
        )}
      </Stack>
      {feedback && (
        <Alert severity={feedback.severity} sx={{ py: 0 }}>
          {feedback.message}
        </Alert>
      )}
    </Paper>
  );
}