Quellcode durchsuchen

cosmetics

master
DemiBSel vor 3 Jahren
Ursprung
Commit
4f80824933
2 geänderte Dateien mit 40 neuen und 21 gelöschten Zeilen
  1. 22
    12
      components/add_depense.js
  2. 18
    9
      components/depenses_list.js

+ 22
- 12
components/add_depense.js Datei anzeigen

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

+ 18
- 9
components/depenses_list.js Datei anzeigen

@@ -9,22 +9,31 @@ function DepensesList(props)
9 9
     const [depenses, onGetDepenses] = React.useState([]);
10 10
     useEffect( () => {
11 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 13
                 onGetDepenses(res.rows._array);
14 14
             });
15 15
         });
16 16
         
17 17
     });
18
+
18 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 38
     return(
30 39
     <View>

Laden…
Abbrechen
Speichern