diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index 3c53a61..c3760b9 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -1,5 +1,5 @@ - + searchFoodWithServingInfoWithPagination( String keyword, int page, - int pageSize, - ) async { + int pageSize, { + // 2023-12-31 指定创建日期升序或者降序排序 + String? dateSort = "desc", + }) async { final db = await database; final offset = (page - 1) * pageSize; + var sort = dateSort?.toLowerCase(); + if (dateSort != null) { + // 如果有传入创建时间排序,不是传的降序一律升序 + sort = dateSort.toLowerCase() == 'desc' ? 'DESC' : 'ASC'; + } + final foodRows = await db.query( DietaryDdl.tableNameOfFood, where: '(brand LIKE ? OR product LIKE ?) AND is_deleted = ? ', whereArgs: ['%$keyword%', '%$keyword%', 0], limit: pageSize, offset: offset, + orderBy: sort != null ? 'gmt_create $sort' : null, ); final foods = []; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index bca9bb6..c653650 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -264,6 +264,7 @@ "photoLabel":"Photo ({count})", + "photoUnitLabel":"photo(s)", "dietaryAddTabs": "{num, select, 0{Recently Eaten} 1{Food List} 2{Size} 3{Unit} 4{New Unit?} 5{Meal} other{Other} }", "@dietaryAddTabs": { diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb index eddaa40..ea121f7 100644 --- a/lib/l10n/app_zh.arb +++ b/lib/l10n/app_zh.arb @@ -269,6 +269,7 @@ }, "photoLabel":"照片 ({count})", + "photoUnitLabel":"张照片", "dietaryAddTabs": "{num, select, 0{最近记录} 1{食物列表} 2{数量} 3{单位} 4{添加新单位?} 5{餐次} other{其他} }", "@dietaryAddTabs": { diff --git a/lib/views/diary/diary_modify_rich_text.dart b/lib/views/diary/diary_modify_rich_text.dart index 938205a..f203705 100644 --- a/lib/views/diary/diary_modify_rich_text.dart +++ b/lib/views/diary/diary_modify_rich_text.dart @@ -650,6 +650,8 @@ class _DiaryModifyRichTextState extends State { options: options, // 标签被选中时的颜色 selectedColor: Colors.blue, + // 不显示选中图标 + showCheckmark: false, // 选项列表中文字样式 labelStyle: TextStyle( fontSize: CusFontSizes.flagTiny, diff --git a/lib/views/diary/index_timeline.dart b/lib/views/diary/index_timeline.dart index 3ac7815..01d9127 100644 --- a/lib/views/diary/index_timeline.dart +++ b/lib/views/diary/index_timeline.dart @@ -89,6 +89,8 @@ class _IndexTimelineState extends State { List newData = temp.data as List; + print(newData); + // 如果没有更多数据,则在底部显示回弹 if (newData.isEmpty) { if (!mounted) return; diff --git a/lib/views/dietary/index.dart b/lib/views/dietary/index.dart index 47dd8cd..be8fd3b 100644 --- a/lib/views/dietary/index.dart +++ b/lib/views/dietary/index.dart @@ -70,10 +70,10 @@ class _DietaryState extends State { height: screenHeight / 4, child: buildCoverCard( context, - const MealPhotoGallery(), - CusAL.of(context).mealGallery, - CusAL.of(context).mealGallerySubtitle, - dietaryMealImageUrl, + const DietaryFoods(), + CusAL.of(context).foodCompo, + CusAL.of(context).foodCompoSubtitle, + dietaryNutritionImageUrl, ), ), ), @@ -82,10 +82,10 @@ class _DietaryState extends State { height: screenHeight / 4, child: buildCoverCard( context, - const DietaryFoods(), - CusAL.of(context).foodCompo, - CusAL.of(context).foodCompoSubtitle, - dietaryNutritionImageUrl, + const MealPhotoGallery(), + CusAL.of(context).mealGallery, + CusAL.of(context).mealGallerySubtitle, + dietaryMealImageUrl, ), ), ), diff --git a/lib/views/dietary/meal_gallery/meal_photo_gallery.dart b/lib/views/dietary/meal_gallery/meal_photo_gallery.dart index 3307fa9..2cdf8e1 100644 --- a/lib/views/dietary/meal_gallery/meal_photo_gallery.dart +++ b/lib/views/dietary/meal_gallery/meal_photo_gallery.dart @@ -115,11 +115,15 @@ class _MealPhotoGalleryState extends State { elevation: 5, child: Column( children: [ + SizedBox(height: 10.sp), ListTile( title: Text(mp.date), - subtitle: Text(showCusLableMapLabel(context, temp)), + subtitle: Text( + '[${showCusLable(temp)}] ${photoList.length} ${CusAL.of(context).photoUnitLabel}', + ), ), buildImageCarouselSlider(photoList), + SizedBox(height: 10.sp), ], ), ); diff --git a/lib/views/dietary/records/add_intake_item/index.dart b/lib/views/dietary/records/add_intake_item/index.dart index c595cde..45937b1 100644 --- a/lib/views/dietary/records/add_intake_item/index.dart +++ b/lib/views/dietary/records/add_intake_item/index.dart @@ -233,7 +233,7 @@ class _AddIntakeItemState extends State temp.dailyFoodItemId = null; // 最主要的摄入量、食物编号、单份营养素编号不用改 temp.userId = CacheUser.userId; - temp.date = getCurrentDate(); + temp.date = currentDate; temp.mealCategory = dropdownValue.enLabel; temp.gmtCreate = getCurrentDateTime(); diff --git a/lib/views/dietary/records/add_intake_item/simple_food_detail.dart b/lib/views/dietary/records/add_intake_item/simple_food_detail.dart index fd73fde..bdcef25 100644 --- a/lib/views/dietary/records/add_intake_item/simple_food_detail.dart +++ b/lib/views/dietary/records/add_intake_item/simple_food_detail.dart @@ -275,6 +275,9 @@ class _SimpleFoodDetailState extends State { initialValue: cusDoubleTryToIntString(inputServingValue), decoration: InputDecoration( labelText: CusAL.of(context).dietaryAddTabs('2'), + // 背景透明色 + filled: true, + fillColor: Colors.transparent, ), keyboardType: TextInputType.number, validator: FormBuilderValidators.compose([ @@ -300,6 +303,9 @@ class _SimpleFoodDetailState extends State { name: 'serving_unit', decoration: InputDecoration( labelText: CusAL.of(context).dietaryAddTabs('3'), + // 背景透明色 + filled: true, + fillColor: Colors.transparent, ), initialValue: servingUnitOptions[0], items: servingUnitOptions @@ -336,6 +342,9 @@ class _SimpleFoodDetailState extends State { name: 'new_mealtime', decoration: InputDecoration( labelText: CusAL.of(context).dietaryAddTabs('5'), + // 背景透明色 + filled: true, + fillColor: Colors.transparent, ), initialValue: inputMealtimeValue, items: mealtimeList diff --git a/lib/views/dietary/records/index.dart b/lib/views/dietary/records/index.dart index 65c428d..8234c61 100644 --- a/lib/views/dietary/records/index.dart +++ b/lib/views/dietary/records/index.dart @@ -145,6 +145,16 @@ class _DietaryRecordsState extends State { ); setState(() { + // 2023-12-31 需要先清空之前的,否则即便没有也会展示旧的数据 + // mealPhotoNums = { + // MealLabels.enBreakfast: null, + // MealLabels.enLunch: null, + // MealLabels.enDinner: null, + // MealLabels.enOther: null, + // }; + + mealPhotoNums.clear(); + // 正常来讲,每天每个餐次最多只有一条数据,只要有数据,照片就是修改或删除了 for (var e in temp) { if (e.mealCategory == MealLabels.enBreakfast) { @@ -171,7 +181,7 @@ class _DietaryRecordsState extends State { if (!mounted) return; if (picked != null) { // 包含了月日星期,其他格式修改 MMMEd 为其他即可 - var formatDate = DateFormat('MMMEd', "zh_CN").format(picked); + var formatDate = DateFormat.MMMEd().format(picked); // 昨天今天明天三天的显示可以特殊一点,比较的话就比较对应年月日转换的字符串即可 var today = DateTime.now(); @@ -223,7 +233,11 @@ class _DietaryRecordsState extends State { bottom: BorderSide(color: Colors.white, width: 1.sp), ), ), - child: Text(showedDateStr, textAlign: TextAlign.center), + child: Text( + showedDateStr, + textAlign: TextAlign.center, + style: TextStyle(fontSize: CusFontSizes.pageTitle), + ), ), ), ], @@ -626,6 +640,7 @@ class _DietaryRecordsState extends State { mealtime: mealtime, mealItems: dfiwfsMealItems, mealPhoto: mealPhotoNums[mealtime.enLabel], + date: selectedDateStr, ), ), ).then((value) { @@ -635,7 +650,7 @@ class _DietaryRecordsState extends State { }); }); }, - icon: const Icon(Icons.photo), + icon: const Icon(Icons.add), label: Text( CusAL.of(context).photoLabel(_getPhotoCount(mealtime)), ), diff --git a/lib/views/dietary/records/save_meal_photo.dart b/lib/views/dietary/records/save_meal_photo.dart index 05472d0..f99ca8a 100644 --- a/lib/views/dietary/records/save_meal_photo.dart +++ b/lib/views/dietary/records/save_meal_photo.dart @@ -15,14 +15,18 @@ import '../../../models/cus_app_localizations.dart'; import '../../../models/dietary_state.dart'; class SaveMealPhotos extends StatefulWidget { -// 需要传入餐次和对应餐次的饮食条目,方便展示 + // 2023-12-31 还需要传是为哪一天的餐次添加照片 + final String date; + // 需要传入餐次和对应餐次的饮食条目,方便展示 final CusLabel mealtime; final List mealItems; + // 如果是修改,则会带上之前实例的照片;没有则是新增没有旧照片(也是用这个判断是新增还是修改) final MealPhoto? mealPhoto; const SaveMealPhotos({ super.key, + required this.date, required this.mealtime, required this.mealItems, this.mealPhoto, @@ -73,7 +77,25 @@ class _SaveMealPhotosState extends State { // 最上面图片走马灯,下面餐次item信息,action是保存和取消/返回按钮 return Scaffold( appBar: AppBar( - title: Text(CusAL.of(context).mealPhotos), + title: RichText( + textAlign: TextAlign.left, + text: TextSpan( + children: [ + TextSpan( + text: CusAL.of(context).mealPhotos, + style: TextStyle( + fontSize: CusFontSizes.pageTitle, + ), + ), + TextSpan( + text: "\n${widget.date}", + style: TextStyle( + fontSize: CusFontSizes.pageAppendix, + ), + ), + ], + ), + ), actions: [ if (!isEditing) IconButton( @@ -105,7 +127,7 @@ class _SaveMealPhotosState extends State { : ''; var tempMp = MealPhoto( - date: getCurrentDate(), + date: widget.date, mealCategory: widget.mealtime.enLabel, photos: photos, gmtCreate: getCurrentDateTime(), @@ -165,6 +187,7 @@ class _SaveMealPhotosState extends State { ), body: Column( children: [ + SizedBox(height: 10.sp), if (imagesUrls.isNotEmpty && !isEditing) buildImageCarouselSlider(imagesUrls), const SizedBox(height: 10), @@ -179,6 +202,10 @@ class _SaveMealPhotosState extends State { child: FormBuilderFilePicker( name: 'images', initialValue: initImages, + decoration: const InputDecoration( + filled: true, + fillColor: Colors.transparent, + ), maxFiles: null, allowMultiple: true, previewImages: true, diff --git a/lib/views/dietary/reports/export/report_pdf_export.dart b/lib/views/dietary/reports/export/report_pdf_export.dart index de5287c..67bf7a0 100644 --- a/lib/views/dietary/reports/export/report_pdf_export.dart +++ b/lib/views/dietary/reports/export/report_pdf_export.dart @@ -66,9 +66,9 @@ Future makeReportPdf( // bold: await PdfGoogleFonts.notoSerifHKBold(), // 但是使用知道的本地字体,会增加app体积 base: Font.ttf(await rootBundle.load("assets/MiSans-Regular.ttf")), - // fontFallback: [ - // pw.Font.ttf(await rootBundle.load('assets/MiSans-Regular.ttf')) - // ], + fontFallback: [ + pw.Font.ttf(await rootBundle.load('assets/MiSans-Regular.ttf')) + ], ), ); diff --git a/lib/views/dietary/reports/index.dart b/lib/views/dietary/reports/index.dart index 0fac2f2..1bd316b 100644 --- a/lib/views/dietary/reports/index.dart +++ b/lib/views/dietary/reports/index.dart @@ -863,7 +863,10 @@ class _DietaryReportsState extends State { showCusLable(value), style: TextStyle( color: Colors.white, - fontSize: CusFontSizes.pageSubContent, + // fontSize: CusFontSizes.pageSubContent, + fontSize: (box.read('language') == "en" + ? CusFontSizes.pageSubContent + : CusFontSizes.pageSubTitle), ), textAlign: TextAlign.end, ), diff --git a/lib/views/training/reports/index.dart b/lib/views/training/reports/index.dart index 52a8f56..00b4e52 100644 --- a/lib/views/training/reports/index.dart +++ b/lib/views/training/reports/index.dart @@ -186,6 +186,7 @@ class _TrainingReportsState extends State { return AlertDialog( title: Text(CusAL.of(context).exportRangeNote), content: DropdownMenu( + width: 0.6.sw, initialSelection: exportDateList.first, onSelected: (CusLabel? value) { setState(() { diff --git a/pubspec.yaml b/pubspec.yaml index 66385bc..f7dae5d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 0.0.1+1 +version: 0.0.1-beta+1 environment: sdk: '>=3.0.1 <4.0.0' diff --git a/readme-merged.md b/readme-merged.md index f15f546..09b388c 100644 --- a/readme-merged.md +++ b/readme-merged.md @@ -196,7 +196,6 @@ flutter build apk --split-per-abi - done 基础动作条件查询时,如果有弹出键盘,点击 appbar 返回按钮时会有像素溢出问题,(训练、计划模块也是如此,饮食模块中子模块返回亦同) - 这个问题就是点击返回按钮时键盘没有收起来,所以即便加上了 expanded,还是有一瞬间看到被压缩的子模块的样子 - 就算修改了 appbar 的 leading,点击时先收起键盘`FocusScope.of(context).unfocus();`再 pop,还是有一瞬间能看到压缩后的样子。 - - 切换中英文后,弹窗的文字没有变,要有其他动作(比如点击)之后才改变为目标文字 - done 所有的 exercise 的轮播图和公共轮播组件不一致,没有点击缩放预览功能 - done 训练新增动作时,动作配置页面的图片不对 - done 不同地方的取消和确定按钮的样式不对(有点左边是确定,有的右边是确定,有的都是 TextButton,有的是 ElevatedButton) @@ -208,12 +207,43 @@ flutter build apk --split-per-abi --- -- done 手记的时间线模式应该按照时间倒序 -- 有修改过的手记,在时间线模式的时间戳没显示时间 -- 编辑手记时分类和心情被选中的模式要改一下,不要前面的勾,因为被挤压变现严重 -- 饮食报告的 pdf,中文标题无法显示,正文的中文倒是正常(运动的 pdf 没有问题) -- 餐次相册,在饮食日记给对应餐次添加照片,好像全是当日的餐次,如果是切换到其他日期,也是今天的。 -- 此外假如正在预览昨天的饮食记录,看到显示的图片及其数量也是今天的。 -- 餐次相册模块的照片下方应该有点空余,不然不好看 -- 饮食报告的今天昨天本周上周的下拉框字体大小不是 16 和 12sp -- 食物列表应该按食物新增时间倒序排序,不管是食物成分模块还是新增饮食记录 +### 2023-12-31 + +- bug 或需要修改的问题列表: + + - done 手记的时间线模式应该按照时间倒序 + - done 有修改过的手记,在时间线模式的时间戳没显示时间 + - 时间戳统一显示创建时间,因为修改时间可能比较乱 + - done half 编辑手记时分类和心情被选中的模式要改一下,不要前面的勾,因为被挤压变现严重 + - 多选的组件支持不显示勾,单选则不支持取消 + - ???新增手记,又修改之后,创建时间不对了。也不一定,偶尔有发生创建时间为 null 的情况,原因不明 + - 等待复现 + - done 饮食报告的 pdf,中文标题无法显示,正文的中文倒是正常(运动的 pdf 没有问题) + - base 和 fontFallback 都加载本地支持 unicode 的字体资源即可 + - done 训练日志的导出的范围下拉框宽度不对,和饮食记录的不一致 + - 修改宽度即可 + - done 餐次相册,在饮食日记给对应餐次添加照片,好像全是当日的餐次,如果是切换到其他日期,也是今天的。 + - 查询餐次摄入照片后,没有清空旧的就直接替换新的数据 + - done 此外假如正在预览昨天的饮食记录,看到显示的图片及其数量也是今天的。 + - 同上 + - done 饮食条目不是给今天添加,也会添加到今天 + - 添加最近饮食记录条目时,date 栏位不对 + - done 餐次相册模块的照片下方应该有点空余,不然不好看 + - done 饮食报告的今天昨天本周上周的下拉框字体大小不是 16 和 12sp + - done 食物列表应该按食物新增时间倒序排序,不管是食物成分模块还是新增饮食记录 + - done 饮食条目添加的详情页面的表单有背景色 + - done 全量备份有问题 + - `AndroidManifest.xml` 还是需要 WRITE_EXTERNAL_STORAGE 权限 + - done 保存餐次相册的图片预览上方应该有点空隙 + +- --- 暂不急 + + - 切换中英文后,弹窗的文字没有变,要有其他动作(比如点击)之后才改变为目标文字 + - 其中包括原生的日历等组件 + - 中英文和深色主题不算完全适配,先中文的浅色背景吧。 + +- 比较重点但改动可能较大 + - 训练和计划的查询非常慢 + - 很多数据库操作没有 trycatch 等操作 + - 许多同意逻辑的代码但写得五花八门 + - 很多没用的组件代码块还保留,注释的代码还保留,甚至 print 都还保留