Pārlūkot izejas kodu

fix week recognition

master
DemiSel 2 gadus atpakaļ
vecāks
revīzija
9a0fd09c43

+ 3
- 1
components/depenses_list.js Parādīt failu

@@ -7,7 +7,9 @@ import DayList from './list/day_list';
7 7
 import WeekList from './list/week_list';
8 8
 
9 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){
11
+    var first_day = new Date(i_date.getFullYear(),0,1)
12
+    return Math.ceil(((i_date-first_day+ (first_day.getDay()-1) * 86400000)/86400000)/7)}
11 13
 
12 14
 function DepensesList(props)
13 15
 {

+ 2
- 2
components/list/day_list.js Parādīt failu

@@ -5,7 +5,7 @@ import { strLPad } from '../../utils/util';
5 5
 
6 6
 export default function DayList(props)
7 7
 {
8
-    const [ showDepenses, onToggleDepenses] = React.useState(true);
8
+    const [ showDepenses, onToggleDepenses] = React.useState(false);
9 9
     let content = []
10 10
 
11 11
     let total = 0;
@@ -43,7 +43,7 @@ export default function DayList(props)
43 43
                 <Text style={day_list_styles.day_list_day}>{props.date.toDateString()}</Text>
44 44
                 <Text style={[day_list_styles.day_list_day, {color: text_color}]}>{"Total : "+total}</Text>
45 45
             </Pressable>
46
-            {showDepenses ? content : <View/>}
46
+            {showDepenses || isCurrentday ? content : <View/>}
47 47
         </View>
48 48
     )
49 49
 }

+ 1
- 1
components/list/week_list.js Parādīt failu

@@ -5,7 +5,7 @@ import { LinearGradient } from 'expo-linear-gradient';
5 5
 
6 6
 export default function WeekList(props)
7 7
 {
8
-    const [ showDays, onToggleDays] = React.useState(true);
8
+    const [ showDays, onToggleDays] = React.useState(false);
9 9
     
10 10
     let days = []
11 11
 

Notiek ielāde…
Atcelt
Saglabāt