Browse Source

cosmetics

master
DemiBSel 2 years ago
parent
commit
4f80824933
2 changed files with 40 additions and 21 deletions
  1. 22
    12
      components/add_depense.js
  2. 18
    9
      components/depenses_list.js

+ 22
- 12
components/add_depense.js View File

1
 import React from 'react';
1
 import React from 'react';
2
-import { StyleSheet, Text, View, TextInput, Button } from 'react-native';
2
+import { StyleSheet, Text, View, TextInput, Button, Pressable } from 'react-native';
3
 import { sqlite_exec_parameterised } from '../db/query';
3
 import { sqlite_exec_parameterised } from '../db/query';
4
 
4
 
5
 export default function AddDepense(props){
5
 export default function AddDepense(props){
30
                         }}
30
                         }}
31
                     />
31
                     />
32
                 </View>
32
                 </View>
33
-                <Button 
33
+                <Pressable 
34
+                    style={add_depenses_styles.button_add} 
34
                     onPress={() => 
35
                     onPress={() => 
35
                         {
36
                         {
36
                             console.log(depenseValue);
37
                             console.log(depenseValue);
43
                                     }
44
                                     }
44
                                     );
45
                                     );
45
                             }
46
                             }
46
-                        }}
47
-                    title="Ajouter"/>
47
+                        }}>
48
+                        <Text>Ajouter</Text>
49
+                    </Pressable>
48
             </View>
50
             </View>
49
          : <View/>}
51
          : <View/>}
50
     </View>
52
     </View>
51
     <View style={ add_depenses_styles.button_add_parent }>
53
     <View style={ add_depenses_styles.button_add_parent }>
52
-        <Button 
54
+        <Pressable
53
             style={add_depenses_styles.button_add} 
55
             style={add_depenses_styles.button_add} 
54
-            title={!addingDepense ? "+" : "-"}
55
-            onPress={() => onAddDepense(!addingDepense)}></Button>
56
+            onPress={() => onAddDepense(!addingDepense)}> 
57
+            
58
+            <Text>{!addingDepense ? "+" : "-"}</Text>
59
+        
60
+        </Pressable>
56
     </View>
61
     </View>
57
     </View>
62
     </View>
58
     );
63
     );
67
 
72
 
68
     },
73
     },
69
     form_area: {
74
     form_area: {
70
-        backgroundColor: '#f2c596',
75
+        backgroundColor: '#f2f2f2',
71
         zIndex: 10,
76
         zIndex: 10,
72
         elevation: 10,
77
         elevation: 10,
78
+        margin: 5,
79
+        marginTop: '50%',
73
         display: 'flex',
80
         display: 'flex',
74
-        flexDirection: 'column'
75
-
81
+        flexDirection: 'column',
82
+        justifyContent: "space-between",
83
+        borderWidth: 1,
76
     },
84
     },
77
     form_entry :{
85
     form_entry :{
78
         display: 'flex',
86
         display: 'flex',
80
     },
88
     },
81
     input :{
89
     input :{
82
         width: "50%",
90
         width: "50%",
83
-        borderWidth: 1
91
+        borderWidth: 1,
92
+        textAlign: 'center',
84
     },
93
     },
85
     button_add: {
94
     button_add: {
86
-        
95
+        borderWidth: 1,
96
+        padding: 10,
87
     },
97
     },
88
     button_add_parent: {
98
     button_add_parent: {
89
         position: 'absolute',
99
         position: 'absolute',

+ 18
- 9
components/depenses_list.js View File

9
     const [depenses, onGetDepenses] = React.useState([]);
9
     const [depenses, onGetDepenses] = React.useState([]);
10
     useEffect( () => {
10
     useEffect( () => {
11
         sqlite_exec_query(`create table if not exists expense (id integer primary key not null, value real, description text, date integer);`,(res)=>{
11
         sqlite_exec_query(`create table if not exists expense (id integer primary key not null, value real, description text, date integer);`,(res)=>{
12
-            sqlite_exec_query("select * from expense", (res) => {
12
+            sqlite_exec_query("select * from expense order by date desc", (res) => {
13
                 onGetDepenses(res.rows._array);
13
                 onGetDepenses(res.rows._array);
14
             });
14
             });
15
         });
15
         });
16
         
16
         
17
     });
17
     });
18
+
18
     let content = []
19
     let content = []
19
 
20
 
20
-    depenses
21
-        .sort((a,b) => (a.date > b.date) ? -1 : (b.date > a.date) ? 1 : 0)
22
-        .forEach( function(depense){
23
-        content.push(
24
-            <DepenseListEntry key={"depense_list_depense"+depense.id} depense={depense}/>
25
-            
26
-        )
27
-    });
21
+
22
+    if(depenses.length > 0)
23
+    {
24
+        // get latest and oldest depense
25
+        let latest_depense = depenses[0];
26
+        let oldest_depense = depenses[depenses.length - 1]
27
+        
28
+
29
+    }
30
+        depenses
31
+            .forEach( function(depense){
32
+            content.push(
33
+                <DepenseListEntry key={"depense_list_depense"+depense.id} depense={depense}/>
34
+            )
35
+        });
36
+    
28
 
37
 
29
     return(
38
     return(
30
     <View>
39
     <View>

Loading…
Cancel
Save