diff --git a/.dart_tool/package_config.json b/.dart_tool/package_config.json index ecbb926..c5ce656 100644 --- a/.dart_tool/package_config.json +++ b/.dart_tool/package_config.json @@ -584,7 +584,7 @@ "languageVersion": "2.19" } ], - "generated": "2023-05-30T12:41:32.353955Z", + "generated": "2023-05-30T14:26:53.205127Z", "generator": "pub", "generatorVersion": "3.0.2" } diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies index b844c1d..6deb778 100644 --- a/.flutter-plugins-dependencies +++ b/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.2.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.0.27\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.2.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.1.10\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.1.6\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-05-30 15:30:51.485545","version":"3.10.2"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.2.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"android":[{"name":"path_provider_android","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_android-2.0.27\\\\","native_build":true,"dependencies":[]}],"macos":[{"name":"path_provider_foundation","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_foundation-2.2.2\\\\","shared_darwin_source":true,"native_build":true,"dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_linux-2.1.10\\\\","native_build":false,"dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"C:\\\\Users\\\\FUCHSLAU\\\\AppData\\\\Local\\\\Pub\\\\Cache\\\\hosted\\\\pub.dev\\\\path_provider_windows-2.1.6\\\\","native_build":false,"dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2023-05-30 16:26:57.078325","version":"3.10.2"} \ No newline at end of file diff --git a/lib/android/components/card_component.dart b/lib/android/components/card_component.dart index edfe03b..814be87 100644 --- a/lib/android/components/card_component.dart +++ b/lib/android/components/card_component.dart @@ -38,11 +38,11 @@ class _CardComponentState extends State { } getImageOfMeal() { - if (widget.eatingMealName == dotenv.env['BREAKFAST_FIELD']!) { + if (widget.eatingMealName.toLowerCase() == dotenv.env['BREAKFAST_FIELD']!.toLowerCase()) { return const Image(image: AssetImage('assets/images/tea.png')); - } else if (widget.eatingMealName == dotenv.env['LUNCH_FIELD']!) { + } else if (widget.eatingMealName.toLowerCase() == dotenv.env['LUNCH_FIELD']!.toLowerCase()) { return const Image(image: AssetImage('assets/images/fries.png')); - } else if (widget.eatingMealName == dotenv.env['DINNER_FIELD']!) { + } else if (widget.eatingMealName.toLowerCase() == dotenv.env['DINNER_FIELD']!.toLowerCase()) { return const Image(image: AssetImage('assets/images/ice.png')); } } diff --git a/lib/android/config/cast_helper.dart b/lib/android/config/cast_helper.dart index 5220954..d614cfe 100644 --- a/lib/android/config/cast_helper.dart +++ b/lib/android/config/cast_helper.dart @@ -1,7 +1,10 @@ import '../models/food.dart'; -List castDynamicToListFood(List dynamicList) { +List castDynamicToListFood(dynamic dynamicList) { List foodList = []; + if(dynamicList == null){ + return foodList; + } for (Food element in dynamicList) { foodList.add(element); } @@ -17,4 +20,4 @@ Map> castDynamicMap(dynamic dynamicMap){ foodMap.putIfAbsent(key as String , () => castDynamicToListFood(dynamicMap[key])); } return foodMap; -} \ No newline at end of file +} diff --git a/lib/android/config/statistics.dart b/lib/android/config/statistics.dart index e39e2f0..70f9881 100644 --- a/lib/android/config/statistics.dart +++ b/lib/android/config/statistics.dart @@ -168,8 +168,8 @@ class StatisticsService { int getAllEatenCaloriesForTodayStatistics(){ Box box = Hive.box(reducedStatisticsBoxName); num sum = 0; - for(List foods in box.values){ - for(Food food in foods){ + for(int i = 0; i < box.keys.length;i++){ + for(Food food in box.get(box.keys.elementAt(i))){ sum += food.calories; } } diff --git a/lib/android/pages/nav_pages/today_page.dart b/lib/android/pages/nav_pages/today_page.dart index c5de3a1..a714f31 100644 --- a/lib/android/pages/nav_pages/today_page.dart +++ b/lib/android/pages/nav_pages/today_page.dart @@ -1,43 +1,40 @@ +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'; +import 'package:hive_flutter/adapters.dart'; class TodayPage extends StatefulWidget { final String title; final Color backgroundColor = const Color(0xff47a44b); + const TodayPage({Key? key, required this.title}) : super(key: key); + @override State createState() => _TodayPageState(); } class _TodayPageState extends State { - @override Widget build(BuildContext context) { return Scaffold( - body: SizedBox( - width: double.infinity, - height: double.infinity, - child: Container( - decoration: const BoxDecoration( - gradient: LinearGradient( - colors: [Color(0xff000000), Color(0xff47a44b)], - stops: [0.1, 5], - begin: Alignment.bottomCenter, - end: Alignment.topCenter, - )), - child: SingleChildScrollView( - padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0), - child: Column( - children: [ - StatisticsPercentComponent(300, 100, 400), - DietChatComponent(1500), - FoodComponent(box: Hive.box('TODAY'),), - ], - ), - )), - )); + body: SingleChildScrollView( + child: ValueListenableBuilder( + valueListenable: Hive.box("TODAY").listenable(), + builder: (context, box, widget) { + return ListView.builder( + primary: false, + shrinkWrap: true, + itemCount: box.keys.length, + itemBuilder: (context, i) { + if (box.keyAt(i).toString() == "DATE") { + return const SizedBox.shrink(); + } else { + return CardComponent( + StringUtils.capitalize(box.keyAt(i).toString()), + box.getAt(i) + ); + } + }); + }))); } }