2024-05-29 22:58:26 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_bloc/flutter_bloc.dart';
|
2024-06-09 12:42:17 +00:00
|
|
|
import 'package:kalodings/app_drawer.dart';
|
2024-05-29 22:58:26 +00:00
|
|
|
import 'package:kalodings/enter_food_widget.dart';
|
|
|
|
import 'package:kalodings/food_entry_bloc.dart';
|
|
|
|
import 'package:kalodings/food_entry_widget.dart';
|
2024-06-09 12:42:17 +00:00
|
|
|
import 'package:kalodings/sum_widget.dart';
|
2024-05-29 22:58:26 +00:00
|
|
|
|
2024-06-09 12:42:17 +00:00
|
|
|
class PerDay extends StatelessWidget {
|
|
|
|
final DateTime day;
|
|
|
|
const PerDay(this.day, {super.key});
|
2024-05-29 22:58:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-06-09 12:42:17 +00:00
|
|
|
return Scaffold(
|
|
|
|
appBar: AppBar(
|
|
|
|
title: Text(day.toString()),
|
|
|
|
),
|
|
|
|
drawer: const AppDrawer(),
|
|
|
|
body: BlocBuilder<FoodEntryBloc, FoodEntryState>(
|
|
|
|
builder: (context, state) {
|
|
|
|
return ListView.builder(
|
|
|
|
itemCount: state.foodEntries.length + 2,
|
|
|
|
itemBuilder: (BuildContext itemBuilderContext, int index) {
|
|
|
|
if (index == state.foodEntries.length) {
|
|
|
|
return const SumWidget();
|
|
|
|
}
|
|
|
|
if (index == state.foodEntries.length + 1) {
|
|
|
|
return const EnterFoodWidget();
|
|
|
|
}
|
2024-05-29 22:58:26 +00:00
|
|
|
|
2024-06-09 12:42:17 +00:00
|
|
|
return FoodEntryWidget(entry: state.foodEntries[index]);
|
|
|
|
},
|
|
|
|
);
|
|
|
|
},
|
|
|
|
));
|
2024-05-29 22:58:26 +00:00
|
|
|
}
|
|
|
|
}
|