-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.tsx
57 lines (51 loc) · 1.46 KB
/
App.tsx
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
52
53
54
55
56
57
import * as eva from "@eva-design/eva";
import {
ApplicationProvider,
IconRegistry
} from "@ui-kitten/components";
import { EvaIconsPack } from "@ui-kitten/eva-icons";
import * as SQLite from "expo-sqlite";
import { StatusBar } from "expo-status-bar";
import React, { useEffect, useState } from "react";
import { StyleSheet, View } from "react-native";
import FAB from "./components/FAB";
import TasksPage from "./components/TasksPage";
import { DatabaseContext } from "./context";
import { TaskDatabase } from "./db/TaskDatabase";
const db = SQLite.openDatabase("mydb.db");
export default () => {
useEffect(() => {
db.transaction((tx) => {
tx.executeSql(
"create table if not exists tasks (id integer primary key autoincrement, title string, completed integer)",
);
});
return () => {
db.closeAsync();
};
}, []);
const taskDb = new TaskDatabase(db);
const [isDataFetched, fetchData] = useState<boolean>(true);
return (
<>
<StatusBar style="light" />
<IconRegistry icons={EvaIconsPack} />
<ApplicationProvider
{...eva}
theme={eva.dark}
>
<DatabaseContext.Provider
value={{ db, taskDb, isDataFetched, fetchData }}
>
<View style={styles.container}>
<TasksPage />
<FAB />
</View>
</DatabaseContext.Provider>
</ApplicationProvider>
</>
);
};
const styles = StyleSheet.create({
container: { flex: 1 },
});