|
@@ -1,41 +1,44 @@
|
1
|
1
|
import { StatusBar } from 'expo-status-bar';
|
2
|
2
|
import React, { useEffect } from 'react';
|
3
|
3
|
import { StyleSheet, Text, View, TextInput } from 'react-native';
|
|
4
|
+import AddDepense from './components/add_depense';
|
4
|
5
|
import DepensesList from './components/depenses_list';
|
5
|
6
|
import TitleBar from './components/title_bar';
|
6
|
|
-
|
7
|
|
-// https://github.com/expo/examples/blob/master/with-sqlite/App.js
|
8
|
|
-import * as SQLite from 'expo-sqlite';
|
9
|
|
-
|
10
|
|
-const db = SQLite.openDatabase("datacoucou.db");
|
|
7
|
+import sqlite_exec_query from './db/query';
|
11
|
8
|
|
12
|
9
|
|
13
|
10
|
export default function App() {
|
14
|
11
|
const [durationMode, onChangeDuration] = React.useState("days");
|
15
|
|
- const [dailyObjective, onChangeObjective] = React.useState(15);
|
16
|
|
-
|
|
12
|
+ const [dailyObjective, onChangeObjective] = React.useState(1);
|
|
13
|
+ console.log("bah")
|
17
|
14
|
useEffect( () => {
|
18
|
|
- db.transaction((tx) => {
|
19
|
|
- tx.executeSql(
|
20
|
|
- `
|
21
|
|
- create table if not exists expense (id integer primary key not null, value real, description text, date integer);
|
22
|
|
- create table if not exists objective(value integer);
|
23
|
|
- `
|
24
|
|
- );
|
25
|
|
- });
|
26
|
|
- }, [])
|
|
15
|
+ sqlite_exec_query("create table if not exists objective(value integer)", (res)=>{
|
|
16
|
+ sqlite_exec_query("select * from objective", (res) => {
|
|
17
|
+ console.log(res.rows.length);
|
|
18
|
+ if(res.rows.length == 0)
|
|
19
|
+ onChangeObjective(15);
|
|
20
|
+ })
|
|
21
|
+ })
|
|
22
|
+ });
|
27
|
23
|
|
28
|
24
|
return (
|
29
|
|
- <View style={styles.container, {
|
30
|
|
- flexDirection: "column"
|
31
|
|
- }}>
|
32
|
|
- <TitleBar
|
33
|
|
- onChangeDuration={onChangeDuration}
|
34
|
|
- durationMode={durationMode}
|
35
|
|
- dailyExpense={dailyObjective}
|
36
|
|
- onChangeObjective={onChangeObjective}/>
|
37
|
|
- <DepensesList durationMode={durationMode} database={db}/>
|
38
|
|
- <StatusBar hidden />
|
|
25
|
+ <View>
|
|
26
|
+ <View style={styles.container, {
|
|
27
|
+ flexDirection: "column"
|
|
28
|
+ }}>
|
|
29
|
+ <TitleBar
|
|
30
|
+ onChangeDuration={onChangeDuration}
|
|
31
|
+ durationMode={durationMode}
|
|
32
|
+ dailyExpense={dailyObjective}
|
|
33
|
+ onChangeObjective={onChangeObjective}/>
|
|
34
|
+ <DepensesList durationMode={durationMode} />
|
|
35
|
+ <StatusBar hidden />
|
|
36
|
+ </View>
|
|
37
|
+ <View>
|
|
38
|
+ {/* Overlay for expenses */}
|
|
39
|
+ <AddDepense/>
|
|
40
|
+
|
|
41
|
+ </View>
|
39
|
42
|
</View>
|
40
|
43
|
);
|
41
|
44
|
}
|