2023-04-23 13:08:04 +02:00
|
|
|
import 'package:flutter/material.dart';
|
2023-05-10 00:04:33 +02:00
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
2023-05-12 18:12:28 +02:00
|
|
|
import '../../components/card_component.dart';
|
|
|
|
import '../../components/diet_chart_component.dart';
|
|
|
|
import '../../components/statistics_circular_indicator_component.dart';
|
|
|
|
import '../../models/food.dart';
|
2023-04-23 13:08:04 +02:00
|
|
|
|
2023-05-13 13:13:40 +02:00
|
|
|
class TodayPage extends StatefulWidget{
|
|
|
|
|
2023-04-23 13:08:04 +02:00
|
|
|
final String title;
|
2023-05-13 13:13:40 +02:00
|
|
|
final Color backgroundColor = const Color(0xff47a44b);
|
2023-04-23 13:08:04 +02:00
|
|
|
|
|
|
|
const TodayPage({Key? key, required this.title}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
State<TodayPage> createState() => _TodayPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _TodayPageState extends State<TodayPage> {
|
2023-04-29 15:56:04 +02:00
|
|
|
|
2023-05-10 00:04:33 +02:00
|
|
|
List<Food> castDynamicToListFood(List<dynamic> dynamicList) {
|
|
|
|
List<Food> foodList = [];
|
|
|
|
for (Food element in dynamicList) {
|
|
|
|
foodList.add(element);
|
|
|
|
}
|
|
|
|
|
|
|
|
return foodList;
|
2023-04-29 15:56:04 +02:00
|
|
|
}
|
2023-04-23 13:08:04 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2023-04-29 15:56:04 +02:00
|
|
|
body: SizedBox(
|
2023-05-10 00:04:33 +02:00
|
|
|
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(
|
2023-05-13 13:13:40 +02:00
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 5, vertical: 0),
|
2023-05-10 00:04:33 +02:00
|
|
|
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)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
),
|
|
|
|
)),
|
|
|
|
));
|
2023-04-23 13:08:04 +02:00
|
|
|
}
|
|
|
|
}
|