Compare commits
2 Commits
bd50859e73
...
22b863f2bf
Author | SHA1 | Date | |
---|---|---|---|
22b863f2bf | |||
4569c33430 |
@ -15,7 +15,9 @@ class QueryScreen extends StatefulWidget {
|
||||
|
||||
class _QueryScreenState extends State<QueryScreen> {
|
||||
bool _isLoading = false;
|
||||
bool _hasApiKey = true;
|
||||
|
||||
int? _totalCount;
|
||||
List<FoodData> _foodData = List.empty();
|
||||
|
||||
Future<void> _searchFood(String probe) async {
|
||||
@ -24,11 +26,15 @@ class _QueryScreenState extends State<QueryScreen> {
|
||||
setState(() => _isLoading = true);
|
||||
|
||||
final FoodDataController data = Get.find();
|
||||
if (data.getApiKey() == null) return;
|
||||
if (data.getApiKey() == null) {
|
||||
setState(() => _hasApiKey = false);
|
||||
return;
|
||||
}
|
||||
|
||||
final result = await data.searchFood(probe);
|
||||
|
||||
setState(() {
|
||||
_totalCount = result.totalHits;
|
||||
_foodData = result.foods;
|
||||
_isLoading = false;
|
||||
});
|
||||
@ -48,6 +54,14 @@ class _QueryScreenState extends State<QueryScreen> {
|
||||
child: SafeArea(
|
||||
child: Column(
|
||||
children: [
|
||||
if (!_hasApiKey)
|
||||
Text('searchNoKeyHint'.tr).paddingSymmetric(vertical: 8)
|
||||
else if (_totalCount != null)
|
||||
Text('searchResultHint'
|
||||
.trParams({'count': _totalCount.toString()}))
|
||||
.paddingSymmetric(vertical: 8)
|
||||
else
|
||||
Text('searchHint'.tr).paddingSymmetric(vertical: 8),
|
||||
SearchBar(
|
||||
padding: const WidgetStatePropertyAll<EdgeInsets>(
|
||||
EdgeInsets.symmetric(horizontal: 16.0),
|
||||
|
@ -1,17 +1,52 @@
|
||||
const i18nEnglish = {
|
||||
'appName': 'DietaryGuard',
|
||||
'appDescription': 'Your Healthy Dietary Guard',
|
||||
'appCopyright': 'Copyright © 2024 Solsynth LLC\nOriginal Author @littlesheep',
|
||||
'query': 'Query',
|
||||
'settings': 'Settings',
|
||||
'preparingData': 'Preparing data...',
|
||||
'settingsApplied': 'Settings Applied',
|
||||
'preparingData': 'Preparing data…',
|
||||
'settingsApplied': 'Settings applied',
|
||||
'settingsDataSection': 'Data Source',
|
||||
'settingsAlertSection': 'Alert',
|
||||
'dataSourceSettings': 'Data Source Settings',
|
||||
'alertSettings': 'Alert Configuration',
|
||||
'newAlert': 'New Alert',
|
||||
'apply': 'Apply',
|
||||
'searchHistoryNotIncluded': 'Search History not Included, yet',
|
||||
'searchHistoryNotIncluded': 'Search history not implemented yet',
|
||||
'nutrients': 'Nutrients',
|
||||
'alertNutrientId': 'Nutrient ID',
|
||||
'alertMaxValue': 'Max',
|
||||
'alertMinValue': 'Min',
|
||||
'alertMaxValue': 'Alert Max Value',
|
||||
'alertMinValue': 'Alert Min Value',
|
||||
'alerts': 'Alerts',
|
||||
'alertOutOfRange':
|
||||
'@count alert rules triggered, click the button on the right for details',
|
||||
'alertUnclear':
|
||||
'@count alert rules lack supporting data, click the button on the right for details',
|
||||
'alertEmpty': 'No alert rules configured, go to settings to add rules',
|
||||
'alertSafe': 'No alert rules triggered, safe to consume',
|
||||
'alertDetectResult': 'Alert Match Details',
|
||||
'undetected': 'Not Detected',
|
||||
'dataCollectionSelection': 'Search Data Collection Range',
|
||||
'dataCollectionFoundation': 'Foundation Data Collection',
|
||||
'dataCollectionFoundationDescription':
|
||||
'Includes food raw materials, with a smaller range but comprehensive data accuracy',
|
||||
'dataCollectionBranded': 'Branded Data Collection',
|
||||
'dataCollectionBrandedDescription':
|
||||
'Includes various branded processed foods',
|
||||
'dataCollectionSurvey': 'Survey Data Collection',
|
||||
'dataCollectionSurveyDescription':
|
||||
'Uses data from the "What We Eat in America" journal',
|
||||
'dataCollectionLegacy': 'Legacy Data Collection',
|
||||
'dataCollectionLegacyDescription':
|
||||
'Historical data from analysis, calculations, and public literature',
|
||||
'fdcApiKey': 'USDA Food Data Central API Key',
|
||||
'fdcApiKeyHint':
|
||||
'DietaryGuard’s data comes from the USDA public API, so you need to configure an API key. But don’t worry, it’s completely free! Check our wiki to learn how to get an API key.',
|
||||
'fdcApiCredit':
|
||||
'DietaryGuard’s food data comes from the U.S. Department of Agriculture, Agricultural Research Service, Beltsville Human Nutrition Research Center. FoodData Central. We appreciate their generous contribution of food data released into the public domain.',
|
||||
'loading': 'Loading',
|
||||
'searchHint': 'Type keywords below to search',
|
||||
'searchNoKeyHint':
|
||||
'No API key, please first set up the API key in "Settings" > "Data Source"',
|
||||
'searchResultHint': '@count records matched (up to the first 100)',
|
||||
};
|
||||
|
@ -39,4 +39,7 @@ const i18nSimplifiedChinese = {
|
||||
'fdcApiCredit':
|
||||
'DietaryGuard 的食品数据来源于 U.S. Department of Agriculture, Agricultural Research Service, Beltsville Human Nutrition Research Center. FoodData Central. 在此感谢他们慷慨贡献的食品数据并发布在公有领域。',
|
||||
'loading': '加载中',
|
||||
'searchHint': '在下方键入关键词来搜索',
|
||||
'searchNoKeyHint': '无 API 令牌,请先在「设置」>「数据源」设置 API 密钥',
|
||||
'searchResultHint': '共命中 @count 条记录(截取前 100 条)',
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user