Browse Source

affichage par mois

master
DemiSel 3 years ago
parent
commit
80d2cccc32
7 changed files with 89 additions and 35 deletions
  1. 1
    0
      App.js
  2. 2
    0
      components/add_depense.js
  3. 5
    9
      components/depenses_list.js
  4. 22
    4
      components/list/day_list.js
  5. 48
    20
      components/list/week_list.js
  6. 8
    0
      package-lock.json
  7. 3
    2
      package.json

+ 1
- 0
App.js View File

57
   home: {
57
   home: {
58
     width: '100%',
58
     width: '100%',
59
     height: '100%',
59
     height: '100%',
60
+    backgroundColor: '#FFFFFF',
60
   },
61
   },
61
   container: {
62
   container: {
62
     flex: 1,
63
     flex: 1,

+ 2
- 0
components/add_depense.js View File

36
     button_add: {
36
     button_add: {
37
         borderWidth: 1,
37
         borderWidth: 1,
38
         padding: 10,
38
         padding: 10,
39
+        backgroundColor: "#FFFFFF",
40
+        elevation:5,
39
     },
41
     },
40
     button_add_parent: {
42
     button_add_parent: {
41
         position: 'absolute',
43
         position: 'absolute',

+ 5
- 9
components/depenses_list.js View File

6
 import DayList from './list/day_list';
6
 import DayList from './list/day_list';
7
 import WeekList from './list/week_list';
7
 import WeekList from './list/week_list';
8
 
8
 
9
-var getDaysArray = function(s,e) {for(var a=[],d=new Date(s);d<=e;d.setDate(d.getDate()+1)){ a.push(new Date(d));}return a;};
9
+var getDaysArray = function(s,e) {for(var a=[],d=new Date(s);d<=e.setHours(23,59,59);d.setDate(d.getDate()+1)){ a.push(new Date(d));}return a;};
10
 var getWeek=function(i_date){return Math.ceil(((i_date-new Date(i_date.getFullYear(),0,1)+86400000)/86400000)/7)}
10
 var getWeek=function(i_date){return Math.ceil(((i_date-new Date(i_date.getFullYear(),0,1)+86400000)/86400000)/7)}
11
 
11
 
12
 function DepensesList(props)
12
 function DepensesList(props)
36
         let curDate = new Date(latest_depense.date);
36
         let curDate = new Date(latest_depense.date);
37
         let oldestDate = new Date(oldest_depense.date);
37
         let oldestDate = new Date(oldest_depense.date);
38
 
38
 
39
-        let days = getDaysArray(oldestDate, curDate ).reverse();
39
+        let days = getDaysArray(oldestDate, curDate )
40
+        days.reverse();
40
         let data = [];
41
         let data = [];
41
         let renderItem = null;
42
         let renderItem = null;
42
         switch(props.durationMode)
43
         switch(props.durationMode)
46
                     // get depenses that are on the current day
47
                     // get depenses that are on the current day
47
                     var depenses_day = depenses.filter( obj => {
48
                     var depenses_day = depenses.filter( obj => {
48
                         var tpDate = new Date(obj.date);
49
                         var tpDate = new Date(obj.date);
49
-                        return tpDate.getFullYear() == day.getFullYear() && tpDate.getMonth() == day.getMonth() && tpDate.getDate() == day.getDate()
50
+                        return tpDate.getUTCFullYear() == day.getUTCFullYear() && tpDate.getUTCMonth() == day.getUTCMonth() && tpDate.getUTCDate() == day.getUTCDate()
50
                     } )
51
                     } )
51
 
52
 
52
                     data.push(
53
                     data.push(
85
                     data.push(week);
86
                     data.push(week);
86
                     days.forEach( (day) => {
87
                     days.forEach( (day) => {
87
                         week_number = getWeek(day);
88
                         week_number = getWeek(day);
88
-                        console.log("\n\n");
89
                         if( week_number+"_"+day.getFullYear() == week.id)
89
                         if( week_number+"_"+day.getFullYear() == week.id)
90
                             week.days.push(
90
                             week.days.push(
91
                                 {
91
                                 {
140
 
140
 
141
     return(
141
     return(
142
     <SafeAreaView >
142
     <SafeAreaView >
143
-        <View>
144
             {content}
143
             {content}
145
-        </View>
146
     </SafeAreaView >
144
     </SafeAreaView >
147
     )
145
     )
148
 }
146
 }
149
 
147
 
150
 const depense_list_style = StyleSheet.create({
148
 const depense_list_style = StyleSheet.create({
151
-    list_container: {
152
-        flex: 1
153
-    }
149
+
154
   });
150
   });
155
 
151
 
156
 export default DepensesList
152
 export default DepensesList

+ 22
- 4
components/list/day_list.js View File

10
 
10
 
11
     let total = 0;
11
     let total = 0;
12
 
12
 
13
-    
13
+    var currentDay = new Date();
14
+    let isCurrentday = (
15
+        currentDay.getFullYear() === props.date.getFullYear() && 
16
+        currentDay.getMonth() === props.date.getMonth() && 
17
+        currentDay.getDate() === props.date.getDate());
18
+
14
     props.depenses.forEach( function(depense){
19
     props.depenses.forEach( function(depense){
15
         content.push(
20
         content.push(
16
             <DepenseListEntry fetchDepenses={props.fetchDepenses} key={"depense_list_depense"+depense.id} depense={depense}/>
21
             <DepenseListEntry fetchDepenses={props.fetchDepenses} key={"depense_list_depense"+depense.id} depense={depense}/>
30
             strLPad(parseInt(255 + Math.max(-255, (result / props.dailyObjective) * 100)).toString(16), 2, '0')
35
             strLPad(parseInt(255 + Math.max(-255, (result / props.dailyObjective) * 100)).toString(16), 2, '0')
31
 
36
 
32
     return (
37
     return (
33
-        <View style={[day_list_styles.day_list_container, {backgroundColor: bg_color}]}>
38
+        <View style={[day_list_styles.day_list_container, {backgroundColor: bg_color}, isCurrentday ? day_list_styles.current_day_container : null]}>
34
             <Pressable 
39
             <Pressable 
35
                 style={day_list_styles.day_list_entry}
40
                 style={day_list_styles.day_list_entry}
36
                 onPress={() => {onToggleDepenses(!showDepenses)}}>
41
                 onPress={() => {onToggleDepenses(!showDepenses)}}>
46
 
51
 
47
 const day_list_styles = StyleSheet.create({
52
 const day_list_styles = StyleSheet.create({
48
     day_list_container: {
53
     day_list_container: {
49
-        borderWidth: 1,
54
+        // borderWidth: 1,
50
         margin: 1,
55
         margin: 1,
56
+        marginTop: 15,
57
+        elevation: 5,
58
+        
59
+    },
60
+    current_day_container: {
61
+        shadowColor: "#0000FF",
62
+        shadowOffset: {
63
+            width: 0,
64
+            height: 10,
65
+        },
66
+        shadowOpacity: 0,
67
+        shadowRadius: 10,
68
+        elevation: 10,
51
     },
69
     },
52
     day_list_entry: {
70
     day_list_entry: {
53
         display: 'flex',
71
         display: 'flex',
54
         flexDirection: 'row',
72
         flexDirection: 'row',
55
         justifyContent: 'space-between',
73
         justifyContent: 'space-between',
56
-        marginTop: 5,
74
+        marginBottom: 10,
57
     },
75
     },
58
     day_list_day: {
76
     day_list_day: {
59
         fontWeight: '900',
77
         fontWeight: '900',

+ 48
- 20
components/list/week_list.js View File

1
 import React from 'react';
1
 import React from 'react';
2
-import { StyleSheet, Text, View, TextInput, Alert, Pressable } from 'react-native';
3
-import DepenseListEntry from '../depense_list_entry';
4
-import { strLPad } from '../../utils/util';
2
+import { StyleSheet, Text, View, Pressable } from 'react-native';
5
 import DayList from './day_list';
3
 import DayList from './day_list';
4
+import { LinearGradient } from 'expo-linear-gradient';
6
 
5
 
7
 export default function WeekList(props)
6
 export default function WeekList(props)
8
 {
7
 {
10
     
9
     
11
     let days = []
10
     let days = []
12
 
11
 
13
-    if(showDays)
14
-        props.days.forEach(element => {
15
-            days.push(
16
-                <DayList
17
-                    dailyObjective={props.dailyObjective}
18
-                    fetchDepenses={props.fetchDepenses}
19
-                    date={element.date}
20
-                    depenses={element.expenses}
21
-                    />
22
-            )
23
-        });
12
+    let objective = props.dailyObjective * 7 
13
+    let total_payed = 0;
14
+
15
+
16
+    props.days.forEach(element => {
17
+        element.expenses.forEach( (expense) => {
18
+            total_payed += expense.value;
19
+        })
20
+
21
+        days.push(
22
+            <DayList
23
+                key={"daylist_"+element.date}    
24
+                dailyObjective={props.dailyObjective}
25
+                fetchDepenses={props.fetchDepenses}
26
+                date={element.date}
27
+                depenses={element.expenses}
28
+                />
29
+        )
30
+    });
31
+
32
+    let scale = Math.min(1, total_payed/objective)
33
+
24
     return (
34
     return (
25
     <View style={week_list_styles.week_list_container}>
35
     <View style={week_list_styles.week_list_container}>
36
+        <View>
37
+        <LinearGradient
38
+                    // Background Linear Gradient
39
+                    colors={[scale > 0 ? '#FFDDDDFF' : '#FFFFFF','#FFFFFF', '#FFFFFF']}
40
+                    locations={[scale, scale+0.05, 1]}
41
+                    end={{x:1,y:0}}
42
+                    style={week_list_styles.background}
43
+                />   
26
         <Pressable
44
         <Pressable
27
             style={week_list_styles.week_header}
45
             style={week_list_styles.week_header}
28
             onPress={() => {onToggleDays(!showDays)}}>
46
             onPress={() => {onToggleDays(!showDays)}}>
29
-            <Text>{"Week " + props.number}</Text>
47
+                             
48
+                <Text>{"Week " + props.number}</Text>
49
+                <Text>{total_payed+"/"+objective}</Text>
50
+                
30
         </Pressable>
51
         </Pressable>
31
-        {days}
52
+        {showDays ? days : <View/>}
53
+        </View>
32
     </View>
54
     </View>
33
     );
55
     );
34
 }
56
 }
36
 
58
 
37
 const week_list_styles = StyleSheet.create({
59
 const week_list_styles = StyleSheet.create({
38
     week_list_container: {
60
     week_list_container: {
39
-        borderWidth: 1,
61
+        borderWidth: 0.5,
40
         margin: 1,
62
         margin: 1,
63
+        marginTop: 25,
64
+        elevation:5,
65
+        
41
     },
66
     },
42
     week_header: {
67
     week_header: {
43
         display: 'flex',
68
         display: 'flex',
45
         justifyContent: 'space-between',
70
         justifyContent: 'space-between',
46
         marginTop: 5,
71
         marginTop: 5,
47
         marginBottom: 5,
72
         marginBottom: 5,
73
+        padding: 3,
74
+        // elevation: 10,
48
     },
75
     },
49
-    day_list_day: {
50
-        fontWeight: '900',
51
-        margin: 4,
76
+    background: {
77
+        position: 'absolute',
78
+        width: '100%',
79
+        height: "100%",
52
     }
80
     }
53
 });
81
 });

+ 8
- 0
package-lock.json View File

3359
       "resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-10.0.0.tgz",
3359
       "resolved": "https://registry.npmjs.org/expo-keep-awake/-/expo-keep-awake-10.0.0.tgz",
3360
       "integrity": "sha512-x5zRTjIvSry/EISKvjWpnLERGZj5maCwEouOfiDk0JPa0UTg/zFkT7pmiadAfHT95XUgjjb2DOku+wj6J7el7Q=="
3360
       "integrity": "sha512-x5zRTjIvSry/EISKvjWpnLERGZj5maCwEouOfiDk0JPa0UTg/zFkT7pmiadAfHT95XUgjjb2DOku+wj6J7el7Q=="
3361
     },
3361
     },
3362
+    "expo-linear-gradient": {
3363
+      "version": "10.0.3",
3364
+      "resolved": "https://registry.npmjs.org/expo-linear-gradient/-/expo-linear-gradient-10.0.3.tgz",
3365
+      "integrity": "sha512-zKkBhHvTvDywpb0y5BJDHTbxX5/2C60qW/M8uyZXKIZcTUwY7j/9Kcx0YzoNNglq7p6aQ/DWO7sM8LHr93985Q==",
3366
+      "requires": {
3367
+        "expo-modules-core": "~0.4.4"
3368
+      }
3369
+    },
3362
     "expo-manifests": {
3370
     "expo-manifests": {
3363
       "version": "0.2.2",
3371
       "version": "0.2.2",
3364
       "resolved": "https://registry.npmjs.org/expo-manifests/-/expo-manifests-0.2.2.tgz",
3372
       "resolved": "https://registry.npmjs.org/expo-manifests/-/expo-manifests-0.2.2.tgz",

+ 3
- 2
package.json View File

8
   },
8
   },
9
   "dependencies": {
9
   "dependencies": {
10
     "@databases/expo": "^5.0.0",
10
     "@databases/expo": "^5.0.0",
11
+    "@react-native-community/datetimepicker": "3.5.2",
11
     "expo": "^43.0.3",
12
     "expo": "^43.0.3",
13
+    "expo-linear-gradient": "^10.0.3",
12
     "expo-splash-screen": "~0.13.5",
14
     "expo-splash-screen": "~0.13.5",
13
     "expo-sqlite": "~10.0.3",
15
     "expo-sqlite": "~10.0.3",
14
     "expo-status-bar": "~1.1.0",
16
     "expo-status-bar": "~1.1.0",
21
     "react-native-safe-area-context": "3.3.2",
23
     "react-native-safe-area-context": "3.3.2",
22
     "react-native-screens": "~3.8.0",
24
     "react-native-screens": "~3.8.0",
23
     "react-native-sqlite-storage": "^6.0.1",
25
     "react-native-sqlite-storage": "^6.0.1",
24
-    "react-native-web": "0.17.1",
25
-    "@react-native-community/datetimepicker": "3.5.2"
26
+    "react-native-web": "0.17.1"
26
   },
27
   },
27
   "devDependencies": {
28
   "devDependencies": {
28
     "@babel/core": "^7.12.9",
29
     "@babel/core": "^7.12.9",

Loading…
Cancel
Save