2024-05-29 22:58:26 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2024-06-09 12:42:17 +00:00
|
|
|
import 'package:kalodings/food_entry_bloc.dart';
|
|
|
|
import 'package:kalodings/row_with_spacers_widget.dart';
|
2024-05-29 22:58:26 +00:00
|
|
|
|
|
|
|
class FoodEntryWidget extends StatelessWidget {
|
2024-06-09 12:42:17 +00:00
|
|
|
final FoodEntry entry;
|
2024-06-09 17:06:10 +00:00
|
|
|
final Function(BuildContext context) onDelete;
|
2024-06-01 10:41:58 +00:00
|
|
|
|
2024-06-09 17:06:10 +00:00
|
|
|
const FoodEntryWidget(
|
|
|
|
{super.key, required this.entry, required this.onDelete});
|
2024-05-29 22:58:26 +00:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2024-06-09 12:42:17 +00:00
|
|
|
return Card(
|
2024-06-10 15:35:21 +00:00
|
|
|
child: Padding(
|
|
|
|
padding: const EdgeInsets.only(left: 4.0),
|
|
|
|
child: RowWidget(
|
|
|
|
Text(entry.name),
|
2024-06-11 17:11:23 +00:00
|
|
|
Text(entry.mass.ceil().toString()),
|
|
|
|
Text(entry.kcalPerMass.ceil().toString()),
|
|
|
|
Text((entry.mass * entry.kcalPerMass / 100).ceil().toString()),
|
2024-06-10 15:35:21 +00:00
|
|
|
IconButton(
|
|
|
|
style: IconButton.styleFrom(padding: EdgeInsets.zero),
|
|
|
|
onPressed: () {
|
|
|
|
onDelete(context);
|
|
|
|
},
|
|
|
|
icon: const Icon(Icons.delete_forever_rounded)),
|
|
|
|
),
|
2024-06-09 12:42:17 +00:00
|
|
|
),
|
2024-05-29 22:58:26 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|