DietaryGuard/lib/screens/food/details.dart
2024-08-15 01:38:29 +08:00

46 lines
1.5 KiB
Dart

import 'package:dietary_guard/models/food_data.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class FoodDetailsScreen extends StatelessWidget {
final FoodData item;
const FoodDetailsScreen({super.key, required this.item});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(item.description),
),
body: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('nutrients'.tr).paddingOnly(left: 24, right: 24, bottom: 8),
Expanded(
child: ListView.builder(
itemCount: item.foodNutrients.length,
itemBuilder: (context, idx) {
final entry = item.foodNutrients[idx];
final unitName = unitNameValues.reverse[entry.unitName];
return ListTile(
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
title: Row(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Text(entry.nutrientName),
const SizedBox(width: 6),
Badge(label: Text('#${entry.nutrientId}'))
],
),
subtitle: Text('${entry.nutrientNumber} ${unitName}'),
);
},
),
)
],
).paddingSymmetric(vertical: 24),
);
}
}