多语言
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import 'package:ef/base/chart/drawer.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/pages/mh_page/component/easychart.dart';
|
||||
@@ -19,11 +20,11 @@ Widget MonthDataWidget(
|
||||
return [
|
||||
AvgSleepScoreWidget(
|
||||
sleepReport: sleepReport,
|
||||
mediumLabel: "本月平均分",
|
||||
mediumLabel: "本月平均分".tr,
|
||||
), //睡眠评分
|
||||
SleepChartContainer(
|
||||
title: "每日得分",
|
||||
tipText: "用户本月睡眠分数的汇总。",
|
||||
title: "每日得分".tr,
|
||||
tipText: "用户本月睡眠分数的汇总。".tr,
|
||||
sleepReport: sleepReport,
|
||||
chartContent: LineView(
|
||||
xLabels: [
|
||||
@@ -75,7 +76,7 @@ Widget MonthDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['scoreList']['data'], '分', 1),
|
||||
tips: buildValueTexts(sleepReport['scoreList']['data'], '分'.tr, 1),
|
||||
xCount: buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth']
|
||||
.toInt(),
|
||||
yCount: sleepReport['scoreList']['yLable'].length,
|
||||
@@ -92,9 +93,9 @@ Widget MonthDataWidget(
|
||||
highlightItem: data['itemName'],
|
||||
),
|
||||
IndicatorCompareCard(
|
||||
title: "与上月对比",
|
||||
headers: ["名称", "上月", "本月", "参考范围"],
|
||||
tooltip: "睡眠分数与上月分数进行对比,是通过量化分析近期睡眠质量变化,可了解自身睡眠状态的波动情况,进而调整用户的作息习惯。",
|
||||
title: "与上月对比".tr,
|
||||
headers: ["名称".tr, "上月".tr, "本月".tr, "参考范围".tr],
|
||||
tooltip: "睡眠分数与上月分数进行对比,是通过量化分析近期睡眠质量变化,可了解自身睡眠状态的波动情况,进而调整用户的作息习惯。".tr,
|
||||
rows: (sleepReport['cwl'] ?? []).map<List<Widget>>((item) {
|
||||
return [
|
||||
Text(
|
||||
@@ -120,8 +121,8 @@ Widget MonthDataWidget(
|
||||
}).toList(),
|
||||
),
|
||||
SleepChartContainer(
|
||||
title: "本月睡眠时长",
|
||||
tipText: "本月睡眠时长是指从月初到月末,用户每天实际睡眠的时间总和。",
|
||||
title: "本月睡眠时长".tr,
|
||||
tipText: "本月睡眠时长是指从月初到月末,用户每天实际睡眠的时间总和".tr,
|
||||
sleepReport: sleepReport,
|
||||
chartContent: LineView(
|
||||
xLabels: [
|
||||
@@ -172,7 +173,14 @@ Widget MonthDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildSleepValueTexts(sleepReport['csd']['data'], '小时', 1),
|
||||
tips: buildSleepValueTexts(
|
||||
sleepReport['csd']['data'],
|
||||
'小时'.tr,
|
||||
1,
|
||||
sleepDurationLabel: 'sleep_duration'.tr,
|
||||
deepSleepLabel: 'deep_sleep'.tr,
|
||||
lightSleepLabel: 'light_sleep'.tr,
|
||||
),
|
||||
xCount: buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth']
|
||||
.toInt(),
|
||||
yCount: sleepReport['csd']['yLable'].length,
|
||||
@@ -239,7 +247,8 @@ Widget MonthDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][0]['value'], '入睡时间:', 0),
|
||||
tips:
|
||||
buildValueTexts(sleepReport['dysp'][0]['value'], '入睡时间:'.tr, 0),
|
||||
xCount:
|
||||
buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth']
|
||||
.toInt(),
|
||||
@@ -305,7 +314,8 @@ Widget MonthDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][1]['value'], '起床时间:', 0),
|
||||
tips:
|
||||
buildValueTexts(sleepReport['dysp'][1]['value'], '起床时间:'.tr, 0),
|
||||
xCount:
|
||||
buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth']
|
||||
.toInt(),
|
||||
@@ -371,7 +381,7 @@ Widget MonthDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][2]['value'], '次', 1),
|
||||
tips: buildValueTexts(sleepReport['dysp'][2]['value'], '次'.tr, 1),
|
||||
xCount:
|
||||
buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth']
|
||||
.toInt(),
|
||||
@@ -437,7 +447,7 @@ Widget MonthDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][3]['value'], '毫秒', 1),
|
||||
tips: buildValueTexts(sleepReport['dysp'][3]['value'], '毫秒'.tr, 1),
|
||||
xCount:
|
||||
buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth']
|
||||
.toInt(),
|
||||
@@ -503,7 +513,7 @@ Widget MonthDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][4]['value'], '次/分', 1),
|
||||
tips: buildValueTexts(sleepReport['dysp'][4]['value'], '次/分'.tr, 1),
|
||||
xCount:
|
||||
buildMonthlyChartData(sleepReport['scoreList'])['daysInMonth']
|
||||
.toInt(),
|
||||
@@ -561,10 +571,10 @@ List<String> buildValueTexts(
|
||||
}
|
||||
|
||||
List<String> buildSleepValueTexts(
|
||||
List<dynamic> data,
|
||||
String unit,
|
||||
int direction, // 0 左侧,1 右侧
|
||||
) {
|
||||
List<dynamic> data, String unit, int direction, // 0 左侧,1 右侧
|
||||
{required String sleepDurationLabel,
|
||||
required String deepSleepLabel,
|
||||
required String lightSleepLabel}) {
|
||||
if (data.isEmpty) return [];
|
||||
|
||||
return data.map((item) {
|
||||
@@ -575,22 +585,13 @@ List<String> buildSleepValueTexts(
|
||||
final prefix = direction == 1 ? '' : unit;
|
||||
final suffix = direction == 1 ? unit : '';
|
||||
|
||||
// 格式化日期(不带时间)
|
||||
String dateStr = '';
|
||||
if (item['st'] != null) {
|
||||
final dt = DateTime.fromMillisecondsSinceEpoch(item['st']);
|
||||
dateStr =
|
||||
"${dt.year}年${dt.month.toString().padLeft(2, '0')}月${dt.day.toString().padLeft(2, '0')}日";
|
||||
}
|
||||
var lines = [
|
||||
'$sleepDurationLabel:$prefix$slt$suffix',
|
||||
'$deepSleepLabel:$prefix$dst$suffix',
|
||||
'$lightSleepLabel:$prefix$lst$suffix',
|
||||
].join('\n');
|
||||
|
||||
var q = [
|
||||
"睡眠时长:$prefix$slt$suffix",
|
||||
"深睡:$prefix$dst$suffix",
|
||||
"浅睡:$prefix$lst$suffix",
|
||||
dateStr,
|
||||
].join("\n");
|
||||
print(q);
|
||||
return q;
|
||||
return lines;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user