Skip to content

Commit

Permalink
Add wake lock
Browse files Browse the repository at this point in the history
Signed-off-by: Param Siddharth <[email protected]>
  • Loading branch information
paramsiddharth committed Oct 16, 2024
1 parent c5c2243 commit d6dc19e
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
30 changes: 30 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
},
"dependencies": {
"bootstrap": "^5.3.3",
"husky": "^9.1.6",
"invert-color": "^2.0.0",
"luxon": "^3.5.0",
"react": "^18.3.1",
"react-color-palette": "^7.3.0",
"react-dom": "^18.3.1",
"react-screen-wake-lock": "^3.0.2",
"styled-components": "^6.1.13"
},
"devDependencies": {
Expand Down
8 changes: 8 additions & 0 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import invert from "invert-color";
import { DateTime } from "luxon";
import styled from "styled-components";
import { useColor } from "react-color-palette";
import { useWakeLock } from "react-screen-wake-lock";

import "react-color-palette/css";

Expand Down Expand Up @@ -41,11 +42,18 @@ function App() {
() => invert(colour?.hex ?? colour, true),
[colour]
);
const { request: requestWakeLock } = useWakeLock({
onRequest: () => console.log("Wake lock requested."),
});

const [alarmColour, setAlarmColour] = useState("#FFFFFF");
const [alarmEnabled, setAlarmEnabled] = useState(false);
const [alarmTime, setAlarmTime] = useState("00:00");

useEffect(() => {
requestWakeLock();
}, [requestWakeLock]);

useEffect(() => {
if (alarmEnabled) {
const interval = setInterval(() => {
Expand Down

0 comments on commit d6dc19e

Please sign in to comment.