diff --git a/App.tsx b/App.tsx index 7e7a04d..68fb73c 100644 --- a/App.tsx +++ b/App.tsx @@ -17,7 +17,6 @@ import FatalError from "./FatalError"; import { AppDataSource } from "./data-source"; import { settingsRepo } from "./db"; import { ThemeContext } from "./use-theme"; -import TimerProgress from "./TimerProgress"; export const CombinedDefaultTheme = { ...NavigationDefaultTheme, @@ -119,7 +118,6 @@ const App = () => { - ); }; diff --git a/AppDrawer.tsx b/AppDrawer.tsx index 8dc3522..4838eaa 100644 --- a/AppDrawer.tsx +++ b/AppDrawer.tsx @@ -8,7 +8,6 @@ import InsightsPage from "./InsightsPage"; import PlanList from "./PlanList"; import SetList from "./SetList"; import SettingsPage from "./SettingsPage"; -import TimerPage from "./TimerPage"; import WeightList from "./WeightList"; const Drawer = createDrawerNavigator(); @@ -55,11 +54,6 @@ export default function AppDrawer({ drawerIcon: () => , }} /> - }} - /> (); - const { colors } = useTheme(); - - useFocusEffect( - useCallback(() => { - settingsRepo.findOne({ where: {} }).then(setSettings); - }, []) - ); - - const stop = () => { - NativeModules.AlarmModule.stop(); - update(); - }; - - const add = async () => { - console.log(`${TimerPage.name}.add:`, settings); - NativeModules.AlarmModule.add(); - update(); - }; - - return ( - <> - - - - {minutes}:{seconds} - - - - - - - ); -} diff --git a/TimerProgress.tsx b/TimerProgress.tsx deleted file mode 100644 index 1bad7d0..0000000 --- a/TimerProgress.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { useEffect, useState } from "react"; -import { ProgressBar } from "react-native-paper"; -import { TickEvent } from "./TimerPage"; -import { emitter } from "./emitter"; - -export default function TimerProgress() { - const [progress, setProgress] = useState(0); - - useEffect(() => { - const description = emitter.addListener( - "tick", - ({ minutes, seconds }: TickEvent) => { - setProgress((Number(minutes) * 60 + Number(seconds)) / 210); - } - ); - return description.remove; - }, []); - - if (progress === 0) return null; - - return ( - - ); -} diff --git a/use-timer.ts b/use-timer.ts deleted file mode 100644 index 5d3be71..0000000 --- a/use-timer.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { useFocusEffect } from "@react-navigation/native"; -import { useCallback, useState } from "react"; -import { NativeModules } from "react-native"; -import { emitter } from "./emitter"; -import { TickEvent } from "./TimerPage"; - -export default function useTimer() { - const [minutes, setMinutes] = useState("00"); - const [seconds, setSeconds] = useState("00"); - - const update = () => { - const current: number = NativeModules.AlarmModule.getCurrent(); - setMinutes( - Math.floor(current / 1000 / 60) - .toString() - .padStart(2, "0") - ); - setSeconds( - Math.floor((current / 1000) % 60) - .toString() - .padStart(2, "0") - ); - }; - - useFocusEffect( - useCallback(() => { - update(); - const listener = emitter.addListener("tick", (event: TickEvent) => { - console.log(`${useTimer.name}.tick:`, { event }); - setMinutes(event.minutes); - setSeconds(event.seconds); - }); - return listener.remove; - }, []) - ); - - return { minutes, seconds, update }; -}