多语言
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';
|
||||
@@ -22,8 +23,8 @@ Widget WeekDataWidget(
|
||||
sleepReport: sleepReport,
|
||||
),
|
||||
SleepChartContainer(
|
||||
title: "每日得分",
|
||||
tipText: "用户本周睡眠分数的汇总。",
|
||||
title: "每日得分".tr,
|
||||
tipText: "用户本周睡眠分数的汇总".tr,
|
||||
sleepReport: sleepReport,
|
||||
chartContent: LineView(
|
||||
xLabels: [
|
||||
@@ -51,7 +52,15 @@ Widget WeekDataWidget(
|
||||
min: 0, //最小值0
|
||||
max: 7, //最大值30
|
||||
q: 6, //labels第一个与最后一个的真实距离,也就是30-1 = 29
|
||||
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
labels: [
|
||||
'周一'.tr,
|
||||
'周二'.tr,
|
||||
'周三'.tr,
|
||||
'周四'.tr,
|
||||
'周五'.tr,
|
||||
'周六'.tr,
|
||||
'周日'.tr
|
||||
],
|
||||
indexs: [0, 1, 2, 3, 4, 5, 6], //每一个标签的对应在X轴的真实位置
|
||||
offset: Offset(0, -50.rpx), //标签相对于原点的偏移,下方60像素位置
|
||||
ondrawer: (canvas, offset, index, label, align, style) {
|
||||
@@ -105,9 +114,9 @@ Widget WeekDataWidget(
|
||||
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(
|
||||
@@ -133,8 +142,8 @@ Widget WeekDataWidget(
|
||||
}).toList(),
|
||||
),
|
||||
SleepChartContainer(
|
||||
title: "本周睡眠时长",
|
||||
tipText: "本周睡眠时长是指从周一到周日内,每天实际睡眠的时间总和。",
|
||||
title: "本周睡眠时长".tr,
|
||||
tipText: "本周睡眠时长是指从周一到周日内,每天实际睡眠的时间总和。".tr,
|
||||
sleepReport: sleepReport,
|
||||
chartContent: LineView(
|
||||
xLabels: [
|
||||
@@ -162,7 +171,15 @@ Widget WeekDataWidget(
|
||||
min: 0, //最小值0
|
||||
max: 7, //最大值30
|
||||
q: 6, //labels第一个与最后一个的真实距离,也就是30-1 = 29
|
||||
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
labels: [
|
||||
'周一'.tr,
|
||||
'周二'.tr,
|
||||
'周三'.tr,
|
||||
'周四'.tr,
|
||||
'周五'.tr,
|
||||
'周六'.tr,
|
||||
'周日'.tr
|
||||
],
|
||||
indexs: [0, 1, 2, 3, 4, 5, 6], //每一个标签的对应在X轴的真实位置
|
||||
offset: Offset(0, -50.rpx), //标签相对于原点的偏移,下方60像素位置
|
||||
ondrawer: (canvas, offset, index, label, align, style) {
|
||||
@@ -204,7 +221,14 @@ Widget WeekDataWidget(
|
||||
dualBarPoints: buildTripleBarData(sleepReport['csd']),
|
||||
displayMode: ChartDisplayMode.dualBar,
|
||||
xUnit: sleepReport['csd']['yUnit'],
|
||||
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,
|
||||
),
|
||||
barWidth: 0.2,
|
||||
),
|
||||
showLabel: sleepReport['csd']['type'],
|
||||
@@ -239,7 +263,15 @@ Widget WeekDataWidget(
|
||||
min: 0, //最小值0
|
||||
max: 7, //最大值30
|
||||
q: 6, //labels第一个与最后一个的真实距离,也就是30-1 = 29
|
||||
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
labels: [
|
||||
'周一'.tr,
|
||||
'周二'.tr,
|
||||
'周三'.tr,
|
||||
'周四'.tr,
|
||||
'周五'.tr,
|
||||
'周六'.tr,
|
||||
'周日'.tr
|
||||
],
|
||||
indexs: [0, 1, 2, 3, 4, 5, 6], //每一个标签的对应在X轴的真实位置
|
||||
offset: Offset(0, -50.rpx), //标签相对于原点的偏移,下方60像素位置
|
||||
ondrawer: (canvas, offset, index, label, align, style) {
|
||||
@@ -277,7 +309,8 @@ Widget WeekDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][0]['value'], '入睡时间:', 0),
|
||||
tips:
|
||||
buildValueTexts(sleepReport['dysp'][0]['value'], '入睡时间:'.tr, 0),
|
||||
xCount: 7,
|
||||
yCount: sleepReport['dysp'][0]['yLable'].length,
|
||||
points: buildGeneralPoints(sleepReport['dysp'][0]),
|
||||
@@ -317,7 +350,15 @@ Widget WeekDataWidget(
|
||||
min: 0, //最小值0
|
||||
max: 7, //最大值30
|
||||
q: 6, //labels第一个与最后一个的真实距离,也就是30-1 = 29
|
||||
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
labels: [
|
||||
'周一'.tr,
|
||||
'周二'.tr,
|
||||
'周三'.tr,
|
||||
'周四'.tr,
|
||||
'周五'.tr,
|
||||
'周六'.tr,
|
||||
'周日'.tr
|
||||
],
|
||||
indexs: [0, 1, 2, 3, 4, 5, 6], //每一个标签的对应在X轴的真实位置
|
||||
offset: Offset(0, -50.rpx), //标签相对于原点的偏移,下方60像素位置
|
||||
ondrawer: (canvas, offset, index, label, align, style) {
|
||||
@@ -355,7 +396,8 @@ Widget WeekDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][1]['value'], '起床时间:', 0),
|
||||
tips:
|
||||
buildValueTexts(sleepReport['dysp'][1]['value'], '起床时间:'.tr, 0),
|
||||
xCount: 7,
|
||||
yCount: sleepReport['dysp'][1]['yLable'].length,
|
||||
points: buildGeneralPoints(sleepReport['dysp'][1]),
|
||||
@@ -395,7 +437,15 @@ Widget WeekDataWidget(
|
||||
min: 0, //最小值0
|
||||
max: 7, //最大值30
|
||||
q: 6, //labels第一个与最后一个的真实距离,也就是30-1 = 29
|
||||
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
labels: [
|
||||
'周一'.tr,
|
||||
'周二'.tr,
|
||||
'周三'.tr,
|
||||
'周四'.tr,
|
||||
'周五'.tr,
|
||||
'周六'.tr,
|
||||
'周日'.tr
|
||||
],
|
||||
indexs: [0, 1, 2, 3, 4, 5, 6], //每一个标签的对应在X轴的真实位置
|
||||
offset: Offset(0, -50.rpx), //标签相对于原点的偏移,下方60像素位置
|
||||
ondrawer: (canvas, offset, index, label, align, style) {
|
||||
@@ -433,7 +483,7 @@ Widget WeekDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][2]['value'], '次', 1),
|
||||
tips: buildValueTexts(sleepReport['dysp'][2]['value'], '次'.tr, 1),
|
||||
xCount: 7,
|
||||
yCount: sleepReport['dysp'][2]['yLable'].length,
|
||||
points: buildGeneralPoints(sleepReport['dysp'][2]),
|
||||
@@ -473,7 +523,15 @@ Widget WeekDataWidget(
|
||||
min: 0, //最小值0
|
||||
max: 7, //最大值30
|
||||
q: 6, //labels第一个与最后一个的真实距离,也就是30-1 = 29
|
||||
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
labels: [
|
||||
'周一'.tr,
|
||||
'周二'.tr,
|
||||
'周三'.tr,
|
||||
'周四'.tr,
|
||||
'周五'.tr,
|
||||
'周六'.tr,
|
||||
'周日'.tr
|
||||
],
|
||||
indexs: [0, 1, 2, 3, 4, 5, 6], //每一个标签的对应在X轴的真实位置
|
||||
offset: Offset(0, -50.rpx), //标签相对于原点的偏移,下方60像素位置
|
||||
ondrawer: (canvas, offset, index, label, align, style) {
|
||||
@@ -511,7 +569,7 @@ Widget WeekDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][3]['value'], '毫秒', 1),
|
||||
tips: buildValueTexts(sleepReport['dysp'][3]['value'], '毫秒'.tr, 1),
|
||||
xCount: 7,
|
||||
yCount: sleepReport['dysp'][3]['yLable'].length,
|
||||
points: buildGeneralPoints(sleepReport['dysp'][3]),
|
||||
@@ -551,7 +609,15 @@ Widget WeekDataWidget(
|
||||
min: 0, //最小值0
|
||||
max: 7, //最大值30
|
||||
q: 6, //labels第一个与最后一个的真实距离,也就是30-1 = 29
|
||||
labels: ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
|
||||
labels: [
|
||||
'周一'.tr,
|
||||
'周二'.tr,
|
||||
'周三'.tr,
|
||||
'周四'.tr,
|
||||
'周五'.tr,
|
||||
'周六'.tr,
|
||||
'周日'.tr
|
||||
],
|
||||
indexs: [0, 1, 2, 3, 4, 5, 6], //每一个标签的对应在X轴的真实位置
|
||||
offset: Offset(0, -50.rpx), //标签相对于原点的偏移,下方60像素位置
|
||||
ondrawer: (canvas, offset, index, label, align, style) {
|
||||
@@ -589,7 +655,7 @@ Widget WeekDataWidget(
|
||||
},
|
||||
),
|
||||
],
|
||||
tips: buildValueTexts(sleepReport['dysp'][4]['value'], '次/分', 1),
|
||||
tips: buildValueTexts(sleepReport['dysp'][4]['value'], '次/分'.tr, 1),
|
||||
xCount: 7,
|
||||
yCount: sleepReport['dysp'][4]['yLable'].length,
|
||||
points: buildGeneralPoints(sleepReport['dysp'][4]),
|
||||
@@ -653,10 +719,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) {
|
||||
@@ -667,13 +733,13 @@ List<String> buildSleepValueTexts(
|
||||
final prefix = direction == 1 ? '' : unit;
|
||||
final suffix = direction == 1 ? unit : '';
|
||||
|
||||
var q = [
|
||||
"睡眠时长:$prefix$slt$suffix",
|
||||
"深睡:$prefix$dst$suffix",
|
||||
"浅睡:$prefix$lst$suffix",
|
||||
].join("\n");
|
||||
print(q);
|
||||
return q;
|
||||
var lines = [
|
||||
'$sleepDurationLabel:$prefix$slt$suffix',
|
||||
'$deepSleepLabel:$prefix$dst$suffix',
|
||||
'$lightSleepLabel:$prefix$lst$suffix',
|
||||
].join('\n');
|
||||
|
||||
return lines;
|
||||
}).toList();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user