Merge remote-tracking branch 'origin/feature/show-only-today-meals-on-today-page' into feature/show-only-today-meals-on-today-page

pull/4/head
Bogdan Kotikov 2023-06-02 00:38:48 +02:00
commit 947ab18251
2 changed files with 65 additions and 5 deletions

View File

@ -0,0 +1,63 @@
import 'package:ernaehrung/android/components/meal_page_text/days_component.dart';
import 'package:ernaehrung/android/config/statistics.dart';
import 'package:hive/hive.dart';
import '../models/food.dart';
// TODO REMOVE IN PROD
mockDataForWholeWeek(){
StatisticsService statisticsService = StatisticsService.instance;
Box box = Hive.box('STATISTICS_MAIN');
int timestamp = statisticsService.getTimestampFromNow();
List<int> currentWeek = statisticsService.getTimestampsByTimestampAndTimespan(TimeSpan.week, timestamp);
for(int i = 0;i < currentWeek.length;i++){
print(mockFood(i));
box.put(currentWeek[i], mockFood(i));
}
}
mockFood(int i) {
List<Map<String,List<dynamic>>> foods = [
{
'FRÜHSTÜCK':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'MITTAGESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'ABENDESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
},
{
'FRÜHSTÜCK':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'MITTAGESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'ABENDESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
},
{
'FRÜHSTÜCK':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'MITTAGESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'ABENDESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
},
{
'FRÜHSTÜCK':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'MITTAGESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'ABENDESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
},
{
'FRÜHSTÜCK':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'MITTAGESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'ABENDESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
},
{
'FRÜHSTÜCK':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'MITTAGESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'ABENDESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
},
{
'FRÜHSTÜCK':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'MITTAGESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
'ABENDESSEN':[ Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),Food(167543,"Snacks Granola Bars Hard Almond","Snacks",495,25.5,7.7,62,0,4.8,),],
},
];
return foods[i];
}

View File

@ -1,4 +1,4 @@
import 'package:ernaehrung/android/models/food.dart';
gitimport 'package:ernaehrung/android/models/food.dart';
import 'package:ernaehrung/android/models/user.dart';
import 'package:ernaehrung/web/web_app.dart';
import 'package:flutter/material.dart';
@ -12,16 +12,12 @@ import 'android/config/setup_todaybox_config.dart';
void main() async {
await dotenv.load(fileName: ".env");
await Hive.initFlutter();
if (!Hive.isAdapterRegistered(0)) {
Hive.registerAdapter(FoodAdapter());
}
if (!Hive.isAdapterRegistered(1)) {
Hive.registerAdapter(UserAdapter());
}
await Hive.openBox(dotenv.env['STATISTICS_TODAY_BOX'] ?? 'STATISTICS_TODAY_BOX');
await Hive.openBox( dotenv.env['STATISTICS_PROGRESS_BOX'] ?? 'STATISTICS_PROGRESS_BOX');
await Hive.openBox(dotenv.env['STATISTICS_MAIN_BOX'] ?? 'STATISTICS_MAIN_BOX');
@ -29,6 +25,7 @@ void main() async {
await Hive.openBox<User>('USER_BOX');
//Hive.deleteFromDisk();
setupTodayBox();
//mockDataForWholeWeek();
if (defaultTargetPlatform == TargetPlatform.android) {
runApp(const AndroidApp());