-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.tsx
More file actions
51 lines (45 loc) · 1.25 KB
/
Copy pathApp.tsx
File metadata and controls
51 lines (45 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React, { useEffect } from "react";
import { AppState, AppStateStatus } from "react-native";
import { ThemeProvider } from "./src/theme/ThemeProvider";
import AppNavigator from "./src/navigation";
import {
shouldLockApp,
updateLastActiveTimestamp,
} from "./src/services/session";
import { initDB } from "./src/services/db";
export default function App() {
useEffect(() => {
const initialize = async () => {
try {
await initDB();
console.log("Database initialized successfully");
} catch (error) {
console.error("Failed to initialize database:", error);
}
};
initialize();
const handleAppStateChange = async (nextAppState: AppStateStatus) => {
if (nextAppState === "active") {
const shouldLock = await shouldLockApp();
if (shouldLock) {
// In a real app, you would navigate to the PIN verification screen.
console.log("Locking app");
}
} else {
await updateLastActiveTimestamp();
}
};
const subscription = AppState.addEventListener(
"change",
handleAppStateChange,
);
return () => {
subscription.remove();
};
}, []);
return (
<ThemeProvider>
<AppNavigator />
</ThemeProvider>
);
}