Skip to content

Commit

Permalink
fix:继续修复一些细节bug。
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanotsu committed Dec 31, 2023
1 parent d1b3273 commit 2242fff
Show file tree
Hide file tree
Showing 17 changed files with 138 additions and 34 deletions.
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<application
android:label="Free Fitness"
android:name="${applicationName}"
Expand Down
13 changes: 11 additions & 2 deletions lib/common/utils/db_dietary_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -412,17 +412,26 @@ class DBDietaryHelper {
Future<CusDataResult> 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 = <FoodAndServingInfo>[];
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions lib/l10n/app_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@
},

"photoLabel":"照片 ({count})",
"photoUnitLabel":"张照片",

"dietaryAddTabs": "{num, select, 0{最近记录} 1{食物列表} 2{数量} 3{单位} 4{添加新单位?} 5{餐次} other{其他} }",
"@dietaryAddTabs": {
Expand Down
2 changes: 2 additions & 0 deletions lib/views/diary/diary_modify_rich_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ class _DiaryModifyRichTextState extends State<DiaryModifyRichText> {
options: options,
// 标签被选中时的颜色
selectedColor: Colors.blue,
// 不显示选中图标
showCheckmark: false,
// 选项列表中文字样式
labelStyle: TextStyle(
fontSize: CusFontSizes.flagTiny,
Expand Down
2 changes: 2 additions & 0 deletions lib/views/diary/index_timeline.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ class _IndexTimelineState extends State<IndexTimeline> {

List<Diary> newData = temp.data as List<Diary>;

print(newData);

// 如果没有更多数据,则在底部显示回弹
if (newData.isEmpty) {
if (!mounted) return;
Expand Down
16 changes: 8 additions & 8 deletions lib/views/dietary/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ class _DietaryState extends State<Dietary> {
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,
),
),
),
Expand All @@ -82,10 +82,10 @@ class _DietaryState extends State<Dietary> {
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,
),
),
),
Expand Down
6 changes: 5 additions & 1 deletion lib/views/dietary/meal_gallery/meal_photo_gallery.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,15 @@ class _MealPhotoGalleryState extends State<MealPhotoGallery> {
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),
],
),
);
Expand Down
2 changes: 1 addition & 1 deletion lib/views/dietary/records/add_intake_item/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class _AddIntakeItemState extends State<AddIntakeItem>
temp.dailyFoodItemId = null;
// 最主要的摄入量、食物编号、单份营养素编号不用改
temp.userId = CacheUser.userId;
temp.date = getCurrentDate();
temp.date = currentDate;
temp.mealCategory = dropdownValue.enLabel;
temp.gmtCreate = getCurrentDateTime();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@ class _SimpleFoodDetailState extends State<SimpleFoodDetail> {
initialValue: cusDoubleTryToIntString(inputServingValue),
decoration: InputDecoration(
labelText: CusAL.of(context).dietaryAddTabs('2'),
// 背景透明色
filled: true,
fillColor: Colors.transparent,
),
keyboardType: TextInputType.number,
validator: FormBuilderValidators.compose([
Expand All @@ -300,6 +303,9 @@ class _SimpleFoodDetailState extends State<SimpleFoodDetail> {
name: 'serving_unit',
decoration: InputDecoration(
labelText: CusAL.of(context).dietaryAddTabs('3'),
// 背景透明色
filled: true,
fillColor: Colors.transparent,
),
initialValue: servingUnitOptions[0],
items: servingUnitOptions
Expand Down Expand Up @@ -336,6 +342,9 @@ class _SimpleFoodDetailState extends State<SimpleFoodDetail> {
name: 'new_mealtime',
decoration: InputDecoration(
labelText: CusAL.of(context).dietaryAddTabs('5'),
// 背景透明色
filled: true,
fillColor: Colors.transparent,
),
initialValue: inputMealtimeValue,
items: mealtimeList
Expand Down
21 changes: 18 additions & 3 deletions lib/views/dietary/records/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ class _DietaryRecordsState extends State<DietaryRecords> {
);

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) {
Expand All @@ -171,7 +181,7 @@ class _DietaryRecordsState extends State<DietaryRecords> {
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();
Expand Down Expand Up @@ -223,7 +233,11 @@ class _DietaryRecordsState extends State<DietaryRecords> {
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),
),
),
),
],
Expand Down Expand Up @@ -626,6 +640,7 @@ class _DietaryRecordsState extends State<DietaryRecords> {
mealtime: mealtime,
mealItems: dfiwfsMealItems,
mealPhoto: mealPhotoNums[mealtime.enLabel],
date: selectedDateStr,
),
),
).then((value) {
Expand All @@ -635,7 +650,7 @@ class _DietaryRecordsState extends State<DietaryRecords> {
});
});
},
icon: const Icon(Icons.photo),
icon: const Icon(Icons.add),
label: Text(
CusAL.of(context).photoLabel(_getPhotoCount(mealtime)),
),
Expand Down
33 changes: 30 additions & 3 deletions lib/views/dietary/records/save_meal_photo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<DailyFoodItemWithFoodServing> mealItems;

// 如果是修改,则会带上之前实例的照片;没有则是新增没有旧照片(也是用这个判断是新增还是修改)
final MealPhoto? mealPhoto;

const SaveMealPhotos({
super.key,
required this.date,
required this.mealtime,
required this.mealItems,
this.mealPhoto,
Expand Down Expand Up @@ -73,7 +77,25 @@ class _SaveMealPhotosState extends State<SaveMealPhotos> {
// 最上面图片走马灯,下面餐次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(
Expand Down Expand Up @@ -105,7 +127,7 @@ class _SaveMealPhotosState extends State<SaveMealPhotos> {
: '';

var tempMp = MealPhoto(
date: getCurrentDate(),
date: widget.date,
mealCategory: widget.mealtime.enLabel,
photos: photos,
gmtCreate: getCurrentDateTime(),
Expand Down Expand Up @@ -165,6 +187,7 @@ class _SaveMealPhotosState extends State<SaveMealPhotos> {
),
body: Column(
children: [
SizedBox(height: 10.sp),
if (imagesUrls.isNotEmpty && !isEditing)
buildImageCarouselSlider(imagesUrls),
const SizedBox(height: 10),
Expand All @@ -179,6 +202,10 @@ class _SaveMealPhotosState extends State<SaveMealPhotos> {
child: FormBuilderFilePicker(
name: 'images',
initialValue: initImages,
decoration: const InputDecoration(
filled: true,
fillColor: Colors.transparent,
),
maxFiles: null,
allowMultiple: true,
previewImages: true,
Expand Down
6 changes: 3 additions & 3 deletions lib/views/dietary/reports/export/report_pdf_export.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ Future<Uint8List> 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'))
],
),
);

Expand Down
5 changes: 4 additions & 1 deletion lib/views/dietary/reports/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,10 @@ class _DietaryReportsState extends State<DietaryReports> {
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,
),
Expand Down
1 change: 1 addition & 0 deletions lib/views/training/reports/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ class _TrainingReportsState extends State<TrainingReports> {
return AlertDialog(
title: Text(CusAL.of(context).exportRangeNote),
content: DropdownMenu<CusLabel>(
width: 0.6.sw,
initialSelection: exportDateList.first,
onSelected: (CusLabel? value) {
setState(() {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
50 changes: 40 additions & 10 deletions readme-merged.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 都还保留

0 comments on commit 2242fff

Please sign in to comment.