|
@@ -1,24 +1,57 @@
|
1
|
1
|
import React from 'react';
|
2
|
2
|
import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
|
3
|
|
-
|
|
3
|
+import { sqlite_exec_parameterised } from '../db/query';
|
4
|
4
|
|
5
|
5
|
export default function AddDepense(props){
|
6
|
6
|
const [addingDepense, onAddDepense] = React.useState(false);
|
|
7
|
+ const [depenseValue, onValueEdit] = React.useState(null);
|
|
8
|
+ const [descriptionValue, onDescriptionEdit] = React.useState(null);
|
7
|
9
|
|
8
|
|
-
|
9
|
|
- return (<View style={add_depenses_styles.overlay}>
|
|
10
|
+ return (<View style={ add_depenses_styles.overlay }>
|
10
|
11
|
<View >
|
11
|
12
|
{addingDepense ?
|
12
|
|
- <View style={ add_depenses_styles.form_area}>
|
13
|
|
- <Text> Le form</Text>
|
14
|
|
- <Button title="Ajouter"/>
|
|
13
|
+ <View style={ add_depenses_styles.form_area }>
|
|
14
|
+ <Text> Nouvelle dépense</Text>
|
|
15
|
+ <View style={ add_depenses_styles.form_entry }>
|
|
16
|
+ <Text> 💸</Text>
|
|
17
|
+ <TextInput
|
|
18
|
+ keyboardType="numeric"
|
|
19
|
+ style={ add_depenses_styles.input }
|
|
20
|
+ onChangeText={ (value) => {
|
|
21
|
+ onValueEdit(value);
|
|
22
|
+ }}
|
|
23
|
+ />
|
|
24
|
+ </View>
|
|
25
|
+ <View style={ add_depenses_styles.form_entry }>
|
|
26
|
+ <Text> 📃</Text>
|
|
27
|
+ <TextInput style={ add_depenses_styles.input }
|
|
28
|
+ onChangeText={ (value) => {
|
|
29
|
+ onDescriptionEdit(value);
|
|
30
|
+ }}
|
|
31
|
+ />
|
|
32
|
+ </View>
|
|
33
|
+ <Button
|
|
34
|
+ onPress={() =>
|
|
35
|
+ {
|
|
36
|
+ console.log(depenseValue);
|
|
37
|
+ if(null != depenseValue)
|
|
38
|
+ {
|
|
39
|
+ sqlite_exec_parameterised(
|
|
40
|
+ "INSERT INTO expense (value, description, date) values (?, ?, ?)",
|
|
41
|
+ [depenseValue, descriptionValue, Date.now()], (res) => {
|
|
42
|
+ onAddDepense(false);
|
|
43
|
+ }
|
|
44
|
+ );
|
|
45
|
+ }
|
|
46
|
+ }}
|
|
47
|
+ title="Ajouter"/>
|
15
|
48
|
</View>
|
16
|
49
|
: <View/>}
|
17
|
50
|
</View>
|
18
|
51
|
<View style={ add_depenses_styles.button_add_parent }>
|
19
|
52
|
<Button
|
20
|
53
|
style={add_depenses_styles.button_add}
|
21
|
|
- title="+"
|
|
54
|
+ title={!addingDepense ? "+" : "-"}
|
22
|
55
|
onPress={() => onAddDepense(!addingDepense)}></Button>
|
23
|
56
|
</View>
|
24
|
57
|
</View>
|
|
@@ -34,11 +67,23 @@ const add_depenses_styles = StyleSheet.create({
|
34
|
67
|
|
35
|
68
|
},
|
36
|
69
|
form_area: {
|
37
|
|
- backgroundColor: '#282828',
|
|
70
|
+ backgroundColor: '#f2c596',
|
|
71
|
+ zIndex: 10,
|
|
72
|
+ elevation: 10,
|
|
73
|
+ display: 'flex',
|
|
74
|
+ flexDirection: 'column'
|
38
|
75
|
|
39
|
76
|
},
|
|
77
|
+ form_entry :{
|
|
78
|
+ display: 'flex',
|
|
79
|
+ flexDirection: 'row',
|
|
80
|
+ },
|
|
81
|
+ input :{
|
|
82
|
+ width: "50%",
|
|
83
|
+ borderWidth: 1
|
|
84
|
+ },
|
40
|
85
|
button_add: {
|
41
|
|
-
|
|
86
|
+
|
42
|
87
|
},
|
43
|
88
|
button_add_parent: {
|
44
|
89
|
position: 'absolute',
|