Skip to content

Commit

Permalink
Release v0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kacesensitive committed Nov 10, 2023
1 parent 2e80109 commit cf082d4
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 26 deletions.
39 changes: 25 additions & 14 deletions app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,39 @@ import { Slider } from "@/components/ui/slider";
import { IoPlay, IoStop, IoRefresh } from 'react-icons/io5';
import { MdOutlineTimer } from 'react-icons/md';

interface TimerControlProps {
onStart: () => void;
onStop: () => void;
onReset: () => void;
onSetTime: (time: number) => void;
}

const TimerControlPanel: React.FC<TimerControlProps> = () => {
const [inputTime, setInputTime] = useState<string>(window.localStorage.getItem('inputTime') || '');
const [color, setColor] = useState<string>(window.localStorage.getItem('color') || "#0000ff");
const [textColor, setTextColor] = useState<string>(window.localStorage.getItem('textColor') || "#000000");
const TimerControlPanel: React.FC<any> = () => {
const [inputTime, setInputTime] = useState<string>('');
const [color, setColor] = useState<string>("#0000ff");
const [textColor, setTextColor] = useState<string>("#000000");

useEffect(() => {
window.localStorage.setItem('inputTime', inputTime);
if (typeof window !== 'undefined') {
const storedInputTime = window.localStorage.getItem('inputTime') || '';
const storedColor = window.localStorage.getItem('color') || "#0000ff";
const storedTextColor = window.localStorage.getItem('textColor') || "#000000";

setInputTime(storedInputTime);
setColor(storedColor);
setTextColor(storedTextColor);
}
}, []);

useEffect(() => {
if (typeof window !== 'undefined') {
window.localStorage.setItem('inputTime', inputTime);
}
}, [inputTime]);

useEffect(() => {
window.localStorage.setItem('color', color);
if (typeof window !== 'undefined') {
window.localStorage.setItem('color', color);
}
}, [color]);

useEffect(() => {
window.localStorage.setItem('textColor', textColor);
if (typeof window !== 'undefined') {
window.localStorage.setItem('textColor', textColor);
}
}, [textColor]);

function onStartClick() {
Expand Down
47 changes: 35 additions & 12 deletions app/timer/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,58 @@ import React, { useState, useEffect } from 'react';
import { listen } from '@tauri-apps/api/event';

const TimerPage: React.FC = () => {
const [time, setTime] = useState<number>(parseInt(window.localStorage.getItem('time') || '0'));
const [timerOn, setTimerOn] = useState<boolean>(window.localStorage.getItem('timerOn') === 'true');
const [isCountdown, setIsCountdown] = useState<boolean>(window.localStorage.getItem('isCountdown') === 'true');
const [colorHex, setColorHex] = useState<string>(window.localStorage.getItem('colorHex') || "#0000ff");
const [textColorHex, setTextColorHex] = useState<string>(window.localStorage.getItem('textColorHex') || "#000000");
const [opacity, setOpacity] = useState<number>(parseFloat(window.localStorage.getItem('opacity') || '1'));
const [time, setTime] = useState<number>(0);
const [timerOn, setTimerOn] = useState<boolean>(false);
const [isCountdown, setIsCountdown] = useState<boolean>(false);
const [colorHex, setColorHex] = useState<string>("#0000ff");
const [textColorHex, setTextColorHex] = useState<string>("#000000");
const [opacity, setOpacity] = useState<number>(1);

useEffect(() => {
window.localStorage.setItem('time', time.toString());
if (typeof window !== 'undefined') {
setTime(parseInt(window.localStorage.getItem('time') || '0'));
setTimerOn(window.localStorage.getItem('timerOn') === 'true');
setIsCountdown(window.localStorage.getItem('isCountdown') === 'true');
setColorHex(window.localStorage.getItem('colorHex') || "#0000ff");
setTextColorHex(window.localStorage.getItem('textColorHex') || "#000000");
setOpacity(parseFloat(window.localStorage.getItem('opacity') || '1'));
}
}, []);

useEffect(() => {
if (typeof window !== 'undefined') {
window.localStorage.setItem('time', time.toString());
}
}, [time]);

useEffect(() => {
window.localStorage.setItem('timerOn', timerOn.toString());
if (typeof window !== 'undefined') {
window.localStorage.setItem('timerOn', timerOn.toString());
}
}, [timerOn]);

useEffect(() => {
window.localStorage.setItem('isCountdown', isCountdown.toString());
if (typeof window !== 'undefined') {
window.localStorage.setItem('isCountdown', isCountdown.toString());
}
}, [isCountdown]);

useEffect(() => {
window.localStorage.setItem('colorHex', colorHex);
if (typeof window !== 'undefined') {
window.localStorage.setItem('colorHex', colorHex);
}
}, [colorHex]);

useEffect(() => {
window.localStorage.setItem('textColorHex', textColorHex);
if (typeof window !== 'undefined') {
window.localStorage.setItem('textColorHex', textColorHex);
}
}, [textColorHex]);

useEffect(() => {
window.localStorage.setItem('opacity', opacity.toString());
if (typeof window !== 'undefined') {
window.localStorage.setItem('opacity', opacity.toString());
}
}, [opacity]);

useEffect(() => {
Expand Down

0 comments on commit cf082d4

Please sign in to comment.