Skip to content

Commit aae2795

Browse files
author
Ayaan Farooqui
committed
added loading page and improved onBoarding pages
1 parent 9263ca9 commit aae2795

16 files changed

+228
-117
lines changed

public/favicon.ico

95 KB
Binary file not shown.

public/logo192.png

-3.13 KB
Loading

public/logo512.png

810 Bytes
Loading

public/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"short_name": "React App",
3-
"name": "Create React App Sample",
2+
"short_name": "Sign-it",
3+
"name": "Sign-it ASL Translator App",
44
"icons": [
55
{
66
"src": "favicon.ico",

public/res/Sign-it.png

26 KB
Loading

public/res/onBoardingImage2.png

348 KB
Loading

src/App.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import Detector from "./detector/Detector";
22
import { useState, useLayoutEffect } from 'react';
3-
import { getCookie } from "./helperFunctions";
3+
// import { getCookie } from "./helperFunctions";
44
import OnBoardingScreen from "./onBoardingScreen/OnBoardingScreen";
55
import { theme } from "./Theme";
66
import { ThemeProvider } from '@mui/material/styles';
77
import './onBoardingScreen/transitionStyles.css';
88

99
const stepColors = {
1010
0: "#4abdac",
11-
1: "#e8a87c",
11+
1: "#7d94b5",
1212
2: "#eb6e80",
1313
}
1414

@@ -22,7 +22,7 @@ function App() {
2222
const handleSkip = () => setShowOnboardingScreen(false)
2323

2424
useLayoutEffect(() => {
25-
let isUserOnboarded = getCookie("isUserOnboarded");
25+
// let isUserOnboarded = getCookie("isUserOnboarded");
2626
// if (isUserOnboarded === "") {
2727
// document.cookie = "isUserOnboarded=true";
2828
// }
@@ -35,20 +35,17 @@ function App() {
3535
return (
3636

3737
<ThemeProvider theme={theme}>
38-
<div className="App" style={{ display: "flex", justifyContent: "center", backgroundColor: showOnboardingScreen ? stepColors[activeStep] : "#dfdce3", height: "100vh", width: "100vw" }}>
39-
<div style={{ width: "min(100%, 800px)" }}>
40-
{
41-
showOnboardingScreen ?
42-
<OnBoardingScreen
43-
handleNext={handleNext}
44-
handleSkip={handleSkip}
45-
activeStep={activeStep}
46-
/>
47-
:
48-
<></>
49-
}
50-
{/* <Detector /> */}
51-
</div>
38+
<div className="App" style={{ display: "flex", justifyContent: "center", backgroundColor: showOnboardingScreen ? stepColors[activeStep] : "#dfdce3", height: "100vh", width: "100%" }}>
39+
{
40+
showOnboardingScreen ?
41+
<OnBoardingScreen
42+
handleNext={handleNext}
43+
handleSkip={handleSkip}
44+
activeStep={activeStep}
45+
/>
46+
:
47+
<Detector />
48+
}
5249
</div>
5350
</ThemeProvider>
5451
)

src/Theme.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ export const theme = createTheme({
66
fontFamily: " 'Roboto', sans-serif",
77
button: {
88
textTransform: "none",
9+
},
10+
h1: {
11+
fontSize: 40,
12+
},
13+
h2: {
14+
fontSize: 32,
15+
},
16+
h3: {
17+
fontSize: 25,
918
}
1019
}
1120
});

src/detector/Detector.js

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
import { useEffect, useRef, useState } from "react";
1+
import { useEffect, useRef, useState, useCallback } from "react";
22
import * as mpHolistic from "@mediapipe/holistic";
33
import * as tf from '@tensorflow/tfjs';
4-
import { CircularProgress } from "@mui/material";
54
import { Camera } from '@mediapipe/camera_utils';
65
import { onResults } from "./helperFunctions";
6+
import { Typography } from "@mui/material";
7+
import LoadingComponent from './LoadingComponent';
78

89
function Detector() {
910

10-
const [showLoadingSpinner, setShowLoadingSpinner] = useState(true)
11+
const [loadingStates, setLoadingStates] = useState(0)
1112
const videoElementRef = useRef();
1213
const [holisticModel, setHolisticModel] = useState(null);
1314

14-
useEffect(() => {
15+
const initCamera = useCallback(() => {
1516
// Start the camera using mediapipe camera utility
1617
if (typeof videoElementRef.current !== "undefined" && videoElementRef.current !== null && holisticModel !== null) {
1718
const camera = new Camera(videoElementRef.current, {
@@ -26,12 +27,14 @@ function Detector() {
2627
// --------------------------------------------------
2728
}, [videoElementRef, holisticModel])
2829

30+
console.log(initCamera)
31+
2932
useEffect(() => {
3033
// load our custom model and set it
3134
const speechSynthesisUtterance = new SpeechSynthesisUtterance();
3235
tf.loadLayersModel('jsonmodel/model.json')
3336
.then(fetched_model => {
34-
console.log("fetched custom model")
37+
setLoadingStates(1)
3538
// initialize the holistic model
3639
const holistic = new mpHolistic.Holistic({
3740
locateFile: (file) => {
@@ -43,8 +46,7 @@ function Detector() {
4346
holistic.onResults((results) => onResults(results, fetched_model, speechSynthesisUtterance));
4447
holistic.initialize()
4548
.then(res => {
46-
console.log("Initialized Mp holistic model")
47-
setShowLoadingSpinner(false)
49+
setLoadingStates(2)
4850
setHolisticModel(holistic)
4951
})
5052
// -----------------------------
@@ -55,20 +57,15 @@ function Detector() {
5557
// ------------------------------------------
5658
}, [])
5759

58-
if (showLoadingSpinner)
60+
if (loadingStates < 2)
5961
return (
60-
<div className="loading">
61-
<CircularProgress />
62-
</div>
62+
<LoadingComponent loadingStates={loadingStates} />
6363
)
6464
else
6565
return (
66-
<div className="App">
67-
<div className="container">
68-
<p >Webcam Input</p>
69-
<video ref={videoElementRef} ></video>
70-
</div>
71-
66+
<div className="container">
67+
<Typography >Webcam Input</Typography>
68+
<video ref={videoElementRef} ></video>
7269
</div>
7370
)
7471
}

src/detector/LoadingComponent.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { LoadingDiv } from "./detectorStyles";
2+
import { Typography, Box, CircularProgress } from "@mui/material";
3+
4+
export default function LoadingComponent(props) {
5+
return (
6+
<LoadingDiv >
7+
<div>
8+
<div className="dot1">
9+
</div>
10+
<div className="dot2">
11+
</div>
12+
<div className="dot3">
13+
</div>
14+
</div>
15+
<div style={{ margin: "50px 50px 25px 50px" }}>
16+
<Typography component="h3" textAlign="center">Please wait while we get a few things ready!</Typography>
17+
</div>
18+
<Box sx={{ position: 'relative', display: 'inline-flex' }}>
19+
<CircularProgress variant="determinate" value={props.loadingStates === 0 ? 0 : props.loadingStates === 1 ? 50 : 100} />
20+
<Box
21+
sx={{
22+
top: 0,
23+
left: 0,
24+
bottom: 0,
25+
right: 0,
26+
position: 'absolute',
27+
display: 'flex',
28+
alignItems: 'center',
29+
justifyContent: 'center',
30+
}}
31+
>
32+
<Typography
33+
variant="caption"
34+
component="div"
35+
color="text.secondary"
36+
>{props.loadingStates}/2</Typography>
37+
</Box>
38+
</Box>
39+
</LoadingDiv>
40+
);
41+
};

0 commit comments

Comments
 (0)