✨ Basic details page
This commit is contained in:
parent
7797c1b635
commit
07f8112c7a
@ -62,10 +62,10 @@ class Aggregations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class DataType {
|
class DataType {
|
||||||
int branded;
|
int? branded;
|
||||||
int surveyFndds;
|
int? surveyFndds;
|
||||||
int srLegacy;
|
int? srLegacy;
|
||||||
int foundation;
|
int? foundation;
|
||||||
|
|
||||||
DataType({
|
DataType({
|
||||||
required this.branded,
|
required this.branded,
|
||||||
|
45
lib/screens/food/details.dart
Normal file
45
lib/screens/food/details.dart
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
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),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,7 @@
|
|||||||
|
import 'package:animations/animations.dart';
|
||||||
import 'package:dietary_guard/controllers/food_data.dart';
|
import 'package:dietary_guard/controllers/food_data.dart';
|
||||||
import 'package:dietary_guard/models/food_data.dart';
|
import 'package:dietary_guard/models/food_data.dart';
|
||||||
|
import 'package:dietary_guard/screens/food/details.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
@ -57,22 +59,31 @@ class _QueryScreenState extends State<QueryScreen> {
|
|||||||
).paddingSymmetric(horizontal: 24),
|
).paddingSymmetric(horizontal: 24),
|
||||||
if (_isLoading)
|
if (_isLoading)
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
width: 20,
|
width: 28,
|
||||||
height: 20,
|
height: 28,
|
||||||
child: CircularProgressIndicator(strokeWidth: 3),
|
child: CircularProgressIndicator(strokeWidth: 3),
|
||||||
).paddingSymmetric(vertical: 16)
|
).paddingSymmetric(vertical: 24)
|
||||||
else
|
else
|
||||||
Expanded(
|
Expanded(
|
||||||
child: ListView.builder(
|
child: ListView.builder(
|
||||||
itemCount: _foodData.length,
|
itemCount: _foodData.length,
|
||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final item = _foodData[index];
|
final item = _foodData[index];
|
||||||
return ListTile(
|
return OpenContainer(
|
||||||
contentPadding: const EdgeInsets.symmetric(horizontal: 24),
|
closedBuilder: (_, open) => ListTile(
|
||||||
|
contentPadding:
|
||||||
|
const EdgeInsets.symmetric(horizontal: 24),
|
||||||
title: Text(item.description),
|
title: Text(item.description),
|
||||||
subtitle: Text(
|
subtitle: Text(
|
||||||
DateFormat("yyyy-MM-dd").format(item.publishedDate),
|
DateFormat("yyyy-MM-dd").format(item.publishedDate),
|
||||||
),
|
),
|
||||||
|
onTap: () => open(),
|
||||||
|
),
|
||||||
|
openBuilder: (_, __) => FoodDetailsScreen(item: item),
|
||||||
|
openElevation: 0,
|
||||||
|
closedElevation: 0,
|
||||||
|
closedColor: Colors.transparent,
|
||||||
|
openColor: Colors.transparent,
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
).paddingOnly(top: 8),
|
).paddingOnly(top: 8),
|
||||||
|
@ -5,4 +5,5 @@ const i18nEnglish = {
|
|||||||
'settingsApplied': 'Settings Applied',
|
'settingsApplied': 'Settings Applied',
|
||||||
'apply': 'Apply',
|
'apply': 'Apply',
|
||||||
'searchHistoryNotIncluded': 'Search History not Included, yet',
|
'searchHistoryNotIncluded': 'Search History not Included, yet',
|
||||||
|
'nutrients': 'Nutrients',
|
||||||
};
|
};
|
||||||
|
@ -5,4 +5,5 @@ const i18nSimplifiedChinese = {
|
|||||||
'settingsApplied': '设置已应用',
|
'settingsApplied': '设置已应用',
|
||||||
'apply': '应用',
|
'apply': '应用',
|
||||||
'searchHistoryNotIncluded': '搜索记录还没实现',
|
'searchHistoryNotIncluded': '搜索记录还没实现',
|
||||||
|
'nutrients': '营养物质',
|
||||||
};
|
};
|
||||||
|
@ -1,6 +1,14 @@
|
|||||||
# Generated by pub
|
# Generated by pub
|
||||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||||
packages:
|
packages:
|
||||||
|
animations:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: animations
|
||||||
|
sha256: d3d6dcfb218225bbe68e87ccf6378bbb2e32a94900722c5f81611dad089911cb
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.0.11"
|
||||||
async:
|
async:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -41,6 +41,7 @@ dependencies:
|
|||||||
sqflite: ^2.3.3+1
|
sqflite: ^2.3.3+1
|
||||||
dio: ^5.6.0
|
dio: ^5.6.0
|
||||||
intl: ^0.19.0
|
intl: ^0.19.0
|
||||||
|
animations: ^2.0.11
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
|
Loading…
Reference in New Issue
Block a user