52 lines
1.7 KiB
Dart
52 lines
1.7 KiB
Dart
|
import 'package:ernaehrung/android/components/statistics_circular_indicator_component.dart';
|
||
|
import 'package:flutter/cupertino.dart';
|
||
|
import 'package:hive_flutter/adapters.dart';
|
||
|
|
||
|
import '../../android/components/card_component.dart';
|
||
|
import '../../android/components/diet_chart_component.dart';
|
||
|
import '../../android/models/food.dart';
|
||
|
|
||
|
class SectionComponent extends StatelessWidget {
|
||
|
const SectionComponent({Key? key}) : super(key: key);
|
||
|
|
||
|
List<Food> castDynamicToListFood(List<dynamic> dynamicList) {
|
||
|
List<Food> foodList = [];
|
||
|
for (Food element in dynamicList) {
|
||
|
foodList.add(element);
|
||
|
}
|
||
|
|
||
|
return foodList;
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return SingleChildScrollView(
|
||
|
child: Column(
|
||
|
children: [
|
||
|
StatisticsPercentComponent(300, 100, 400),
|
||
|
DietChatComponent(1500),
|
||
|
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(
|
||
|
eatingMealName: box.keyAt(i).toString(),
|
||
|
selectedMeal: castDynamicToListFood(
|
||
|
box.getAt(i)));
|
||
|
}
|
||
|
}
|
||
|
);
|
||
|
}),
|
||
|
],
|
||
|
),
|
||
|
);
|
||
|
}
|
||
|
}
|