From 1f52c7971a7164a34c52f6b703772ef29018e25d Mon Sep 17 00:00:00 2001 From: 98spag Date: Tue, 30 May 2023 14:40:39 +0200 Subject: [PATCH] small cleanup --- lib/android/config/statistics.dart | 14 ++++++-------- lib/android/pages/nav_pages/today_page.dart | 3 +-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/android/config/statistics.dart b/lib/android/config/statistics.dart index 86c2ae4..f44d71c 100644 --- a/lib/android/config/statistics.dart +++ b/lib/android/config/statistics.dart @@ -1,5 +1,4 @@ import 'dart:math'; - import 'package:ernaehrung/android/components/meal_page_text/days_component.dart'; import 'package:ernaehrung/android/config/cast_helper.dart'; import 'package:hive/hive.dart'; @@ -29,7 +28,6 @@ class StatisticsService { updateReducedBoxByTimespan(TimeSpan timeSpan){ clearReducedBoxBeforeUpdate(); - print(timeSpan); DateTime now = DateTime.now(); int timestamp = now.millisecondsSinceEpoch.toInt() ~/ 1000; switch(timeSpan){ @@ -43,9 +41,9 @@ class StatisticsService { } break; case TimeSpan.month: - List currentWeek = getTimestampsByTimestampAndTimespan(TimeSpan.month,timestamp); - for(int i = 0;i < currentWeek.length;i++){ - getNewFoodAndUpdateReducedBoxByTimestamp(currentWeek[i]); + List currentMonth = getTimestampsByTimestampAndTimespan(TimeSpan.month,timestamp); + for(int i = 0;i < currentMonth.length;i++){ + getNewFoodAndUpdateReducedBoxByTimestamp(currentMonth[i]); } break; } @@ -168,7 +166,7 @@ class StatisticsService { getRandomTimestampForTesting(){ DateTime now = DateTime.now(); DateTime startOfWeek = now.subtract(Duration(days: now.weekday - 1)); - DateTime endOfWeek = startOfWeek.add(Duration(days: 6)); + DateTime endOfWeek = startOfWeek.add(const Duration(days: 6)); Random random = Random(); int randomMilliseconds = random.nextInt(endOfWeek.millisecondsSinceEpoch - startOfWeek.millisecondsSinceEpoch); @@ -179,7 +177,7 @@ class StatisticsService { num getAllCaloriesByBoxAndTimestamp(Box box,DateTime date){ int timestamp = date.millisecondsSinceEpoch.toInt() ~/ 1000; - Map>? valueMap = castDynamicMap(box.get(timestamp)); + Map> valueMap = castDynamicMap(box.get(timestamp)); num sum = 0; for(var mealType in valueMap.keys){ if(valueMap.containsKey(mealType)){ @@ -194,7 +192,7 @@ class StatisticsService { num getCaloriesByTimestampAndMealTypeAndBox(Box box,DateTime date, String mealType){ int timestamp = date.millisecondsSinceEpoch.toInt() ~/ 1000; - Map>? valueMap = castDynamicMap(box.get(timestamp)); + Map> valueMap = castDynamicMap(box.get(timestamp)); num sum = 0; if(valueMap.containsKey(mealType)){ List values = valueMap[mealType]!; diff --git a/lib/android/pages/nav_pages/today_page.dart b/lib/android/pages/nav_pages/today_page.dart index 3f3c859..c5de3a1 100644 --- a/lib/android/pages/nav_pages/today_page.dart +++ b/lib/android/pages/nav_pages/today_page.dart @@ -1,8 +1,7 @@ -import 'package:basic_utils/basic_utils.dart'; -import 'package:ernaehrung/android/components/card/card_component.dart'; import 'package:flutter/material.dart'; import 'package:hive/hive.dart'; import '../../components/diet_chart_component.dart'; +import '../../components/food_list_component.dart'; import '../../components/statistics_circular_indicator_component.dart'; class TodayPage extends StatefulWidget {