diff --git a/App.tsx b/App.tsx
index d0d89b6..e8482e1 100644
--- a/App.tsx
+++ b/App.tsx
@@ -13,7 +13,6 @@ import {
import MaterialIcon from "react-native-vector-icons/MaterialCommunityIcons";
import AppSnack from "./AppSnack";
import AppStack from "./AppStack";
-import TimerProgress from "./TimerProgress";
import { AppDataSource } from "./data-source";
import { settingsRepo } from "./db";
import { ThemeContext } from "./use-theme";
@@ -37,6 +36,7 @@ export const CombinedDarkTheme = {
};
const App = () => {
+ console.log("Re rendered app");
const systemTheme = useColorScheme();
const [appSettings, setAppSettings] = useState({
@@ -108,7 +108,6 @@ const App = () => {
-
);
};
diff --git a/AppDrawer.tsx b/AppDrawer.tsx
index d833e7e..54e594c 100644
--- a/AppDrawer.tsx
+++ b/AppDrawer.tsx
@@ -11,6 +11,7 @@ import TimerPage from "./TimerPage";
import WeightList from "./WeightList";
import { DrawerParams } from "./drawer-param-list";
import useDark from "./use-dark";
+import TimerProgress from "./TimerProgress";
const Drawer = createDrawerNavigator();
@@ -24,60 +25,63 @@ export default function AppDrawer({
const dark = useDark();
return (
-
- }}
- />
- }}
- />
- }}
- />
- ,
+ <>
+
- }}
- />
- }}
- />
- ,
- }}
- />
- }}
- />
-
+ initialRouteName={
+ (route.params.startup as keyof DrawerParams) || "History"
+ }
+ >
+ }}
+ />
+ }}
+ />
+ }}
+ />
+ ,
+ }}
+ />
+ }}
+ />
+ }}
+ />
+ ,
+ }}
+ />
+ }}
+ />
+
+
+ >
);
}
diff --git a/TimerProgress.tsx b/TimerProgress.tsx
index 77228b6..9d3c0b5 100644
--- a/TimerProgress.tsx
+++ b/TimerProgress.tsx
@@ -1,20 +1,24 @@
-import { useEffect, useState } from "react";
-import { emitter } from "./emitter";
-import { TickEvent } from "./TimerPage";
+import { useFocusEffect } from "@react-navigation/native";
+import { useCallback, 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;
- }, []);
+ useFocusEffect(
+ useCallback(() => {
+ const description = emitter.addListener(
+ "tick",
+ ({ minutes, seconds }: TickEvent) => {
+ setProgress((Number(minutes) * 60 + Number(seconds)) / 210);
+ console.log({ minutes, seconds });
+ }
+ );
+ return description.remove;
+ }, [])
+ );
if (progress === 0) return null;