feat: show only food list from today on today page - test with mock data

pull/4/head
98spag 2023-06-01 14:58:12 +02:00
parent 795de496cd
commit a56fed5450
2 changed files with 64 additions and 4 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

@ -12,16 +12,12 @@ import 'android/config/setup_todaybox_config.dart';
void main() async { void main() async {
await dotenv.load(fileName: ".env"); await dotenv.load(fileName: ".env");
await Hive.initFlutter(); await Hive.initFlutter();
if (!Hive.isAdapterRegistered(0)) { if (!Hive.isAdapterRegistered(0)) {
Hive.registerAdapter(FoodAdapter()); Hive.registerAdapter(FoodAdapter());
} }
if (!Hive.isAdapterRegistered(1)) { if (!Hive.isAdapterRegistered(1)) {
Hive.registerAdapter(UserAdapter()); Hive.registerAdapter(UserAdapter());
} }
await Hive.openBox(dotenv.env['STATISTICS_TODAY_BOX'] ?? 'STATISTICS_TODAY_BOX'); 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_PROGRESS_BOX'] ?? 'STATISTICS_PROGRESS_BOX');
await Hive.openBox(dotenv.env['STATISTICS_MAIN_BOX'] ?? 'STATISTICS_MAIN_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'); await Hive.openBox<User>('USER_BOX');
//Hive.deleteFromDisk(); //Hive.deleteFromDisk();
setupTodayBox(); setupTodayBox();
//mockDataForWholeWeek();
if (defaultTargetPlatform == TargetPlatform.android) { if (defaultTargetPlatform == TargetPlatform.android) {
runApp(const AndroidApp()); runApp(const AndroidApp());