多语言后端数据
This commit is contained in:
@@ -36,172 +36,180 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
try {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['yc'] == null ||
|
||||
widget.sleepReport['yc'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
List<Map<String, dynamic>> data = (widget.sleepReport['yc'] as List)
|
||||
.map((e) => e as Map<String, dynamic>)
|
||||
.toList();
|
||||
Map<String, double> today = {};
|
||||
Map<String, double> yesterday = {};
|
||||
try {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['yc'] == null ||
|
||||
widget.sleepReport['yc'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
List<Map<String, dynamic>> data = (widget.sleepReport['yc'] as List)
|
||||
.map((e) => e as Map<String, dynamic>)
|
||||
.toList();
|
||||
Map<String, double> today = {};
|
||||
Map<String, double> yesterday = {};
|
||||
|
||||
for (var item in data) {
|
||||
String typeKey = 'type${item['id']}';
|
||||
today[typeKey] = (item['t'] as num).toDouble();
|
||||
yesterday[typeKey] = (item['y'] as num).toDouble();
|
||||
}
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"与昨日对比分析".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 0.rpx, 14.rpx, 0), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
// "与昨日对比分析介绍".tr,
|
||||
"基于时间维度的横向比较分析方法,通过将当前(今日)的数据、状态、行为等与前一日(昨日)的同类信息进行对照,识别差异、趋势或变化规律,查看用户短期时间序列的动态变化。".tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
for (var item in data) {
|
||||
String typeKey = 'type${item['id']}';
|
||||
today[typeKey] = (item['t'] as num).toDouble();
|
||||
yesterday[typeKey] = (item['y'] as num).toDouble();
|
||||
}
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius), // 你可以按需调整圆角半径
|
||||
),
|
||||
child: Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 29.rpx, 26.rpx, 45.rpx),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Container(
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
"与昨日对比分析".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: Colors.white, // 或设置为你需要的水波纹颜色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
14.rpx, 0.rpx, 14.rpx, 0), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
// "与昨日对比分析介绍".tr,
|
||||
"基于时间维度的横向比较分析方法,通过将当前(今日)的数据、状态、行为等与前一日(昨日)的同类信息进行对照,识别差异、趋势或变化规律,查看用户短期时间序列的动态变化。"
|
||||
.tr,
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: Colors.black,
|
||||
),
|
||||
),
|
||||
),
|
||||
backgroundColor: Color(0xFFFFFFFF),
|
||||
colors: [
|
||||
Color(0XFF1592AA),
|
||||
Color(0xFF0C83A7),
|
||||
Color(0xFF006FA3)
|
||||
],
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
);
|
||||
},
|
||||
child: Container(
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
// Padding(
|
||||
// padding:
|
||||
// EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
// child: SleepRadarChart(
|
||||
// today: today,
|
||||
// yesterday: yesterday,
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Stack(
|
||||
children: [
|
||||
// 雷达图
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0, 0.rpx, 0.rpx, 0), // 外部 padding 移到内部
|
||||
width: 28.rpx,
|
||||
height: 28.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/explain.svg',
|
||||
fit: BoxFit.cover,
|
||||
color: themeController.currentColor.sc4,
|
||||
30.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: SleepRadarChart(
|
||||
// today: today,
|
||||
// yesterday: yesterday,
|
||||
data: data,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 31.rpx,
|
||||
),
|
||||
// Padding(
|
||||
// padding:
|
||||
// EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
// child: SleepRadarChart(
|
||||
// today: today,
|
||||
// yesterday: yesterday,
|
||||
// ),
|
||||
// ),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Stack(
|
||||
children: [
|
||||
// 雷达图
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: SleepRadarChart(
|
||||
// today: today,
|
||||
// yesterday: yesterday,
|
||||
data: data,
|
||||
),
|
||||
),
|
||||
// 在左侧添加一个 Text
|
||||
Positioned(
|
||||
left: 0, // 这里可以修改文本左边的距离
|
||||
top: 0, // 这里可以修改文本顶部的距离
|
||||
child: Container(
|
||||
color: Colors.transparent, // 不需要背景色,可以去掉
|
||||
child: Column(
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
// 长条容器
|
||||
Container(
|
||||
width:
|
||||
34.rpx, // 你可以设置容器的宽度,或者使用 Expanded 填充剩余空间
|
||||
height: 2.rpx, // 容器的高度
|
||||
color: stringToColor("#00C1AA"), // 容器的颜色
|
||||
),
|
||||
SizedBox(width: 13.rpx), // 文字和容器之间的间距
|
||||
// 文字
|
||||
Text(
|
||||
'今日数据'.tr, // 文字内容
|
||||
style: TextStyle(
|
||||
fontSize: 18.rpx, // 文字大小
|
||||
color:
|
||||
themeController.currentColor.sc4, // 文字颜色
|
||||
// 在左侧添加一个 Text
|
||||
Positioned(
|
||||
left: 0, // 这里可以修改文本左边的距离
|
||||
top: 0, // 这里可以修改文本顶部的距离
|
||||
child: Container(
|
||||
color: Colors.transparent, // 不需要背景色,可以去掉
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
// 长条容器
|
||||
Container(
|
||||
width:
|
||||
34.rpx, // 你可以设置容器的宽度,或者使用 Expanded 填充剩余空间
|
||||
height: 2.rpx, // 容器的高度
|
||||
color: stringToColor("#00C1AA"), // 容器的颜色
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
// 长条容器
|
||||
Container(
|
||||
width:
|
||||
34.rpx, // 你可以设置容器的宽度,或者使用 Expanded 填充剩余空间
|
||||
height: 2.rpx, // 容器的高度
|
||||
color: stringToColor("#FFD251"), // 容器的颜色
|
||||
),
|
||||
SizedBox(width: 13.rpx), // 文字和容器之间的间距
|
||||
// 文字
|
||||
Text(
|
||||
'昨日数据'.tr, // 文字内容
|
||||
style: TextStyle(
|
||||
fontSize: 18.rpx, // 文字大小
|
||||
color:
|
||||
themeController.currentColor.sc4, // 文字颜色
|
||||
SizedBox(width: 13.rpx), // 文字和容器之间的间距
|
||||
// 文字
|
||||
Text(
|
||||
'今日数据'.tr, // 文字内容
|
||||
style: TextStyle(
|
||||
fontSize: 18.rpx, // 文字大小
|
||||
color: themeController
|
||||
.currentColor.sc4, // 文字颜色
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
].divide(SizedBox(height: 25.rpx)),
|
||||
],
|
||||
),
|
||||
Row(
|
||||
children: [
|
||||
// 长条容器
|
||||
Container(
|
||||
width:
|
||||
34.rpx, // 你可以设置容器的宽度,或者使用 Expanded 填充剩余空间
|
||||
height: 2.rpx, // 容器的高度
|
||||
color: stringToColor("#FFD251"), // 容器的颜色
|
||||
),
|
||||
SizedBox(width: 13.rpx), // 文字和容器之间的间距
|
||||
// 文字
|
||||
Text(
|
||||
'昨日数据'.tr, // 文字内容
|
||||
style: TextStyle(
|
||||
fontSize: 18.rpx, // 文字大小
|
||||
color: themeController
|
||||
.currentColor.sc4, // 文字颜色
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
].divide(SizedBox(height: 25.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
} catch (e) {
|
||||
);
|
||||
} catch (e) {
|
||||
es.EasyDartModule.logger.error("打鼾监测绘制异常${e}");
|
||||
return Container();
|
||||
}
|
||||
return Container();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user