更新睡眠报告
This commit is contained in:
1
assets/img/icon/calendar.svg
Normal file
1
assets/img/icon/calendar.svg
Normal file
@@ -0,0 +1 @@
|
||||
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1748345768165" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3352" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M877.599372 0H146.400628A146.400628 146.400628 0 0 0 0 146.400628v731.198744a146.400628 146.400628 0 0 0 146.400628 146.400628h731.198744a146.400628 146.400628 0 0 0 146.400628-146.400628V146.400628A146.400628 146.400628 0 0 0 877.599372 0z m73.200314 877.599372a73.602514 73.602514 0 0 1-73.200314 73.200314H146.400628a73.200314 73.200314 0 0 1-73.200314-73.200314V292.399057h877.599372zM73.200314 219.198743V146.400628a72.798115 72.798115 0 0 1 73.200314-73.200314h731.198744a73.200314 73.200314 0 0 1 73.200314 73.200314v72.798115z" fill="#1296db" p-id="3353"></path><path d="M694.598586 804.399057h73.200314a36.600157 36.600157 0 0 0 0-73.200314h-73.200314a36.600157 36.600157 0 0 0 0 73.200314zM475.399843 512h73.200314a36.600157 36.600157 0 0 0 0-73.200314h-73.200314a36.600157 36.600157 0 0 0 0 73.200314zM694.598586 657.998429h73.200314a36.600157 36.600157 0 1 0 0-72.798115h-73.200314a36.600157 36.600157 0 1 0 0 72.798115zM694.598586 512h73.200314a36.600157 36.600157 0 1 0 0-73.200314h-73.200314a36.600157 36.600157 0 1 0 0 73.200314zM475.399843 804.399057h73.200314a36.600157 36.600157 0 0 0 0-73.200314h-73.200314a36.600157 36.600157 0 0 0 0 73.200314zM255.7989 804.399057h73.200314a36.600157 36.600157 0 0 0 0-73.200314H255.7989a36.600157 36.600157 0 0 0 0 73.200314zM475.399843 657.998429h73.200314a36.600157 36.600157 0 1 0 0-72.798115h-73.200314a36.600157 36.600157 0 1 0 0 72.798115zM255.7989 657.998429h73.200314a36.600157 36.600157 0 1 0 0-72.798115H255.7989a36.600157 36.600157 0 1 0 0 72.798115z" fill="#1296db" p-id="3354"></path></svg>
|
||||
|
After Width: | Height: | Size: 1.8 KiB |
BIN
assets/img/moon.png
Normal file
BIN
assets/img/moon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
BIN
assets/img/sun.png
Normal file
BIN
assets/img/sun.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.9 KiB |
@@ -373,5 +373,33 @@
|
||||
"报修成功":"报修成功!",
|
||||
"查看报修历史":"查看报修历史",
|
||||
"报修成功标语":"报修申请提交后,我们的后台客服人员会与您取得联系,请保持电话畅通,感谢您对本产品的支持!",
|
||||
"问题描述字数限制":"问题描述字数超过限制"
|
||||
"问题描述字数限制":"问题描述字数超过限制",
|
||||
"30天平均分":"30天平均分",
|
||||
"睡眠等级":"睡眠等级",
|
||||
"睡眠评分":"睡眠评分",
|
||||
"睡眠规律性":"睡眠规律性",
|
||||
"入睡时间":"入睡时间",
|
||||
"睡眠时长":"睡眠时长",
|
||||
"起床时间":"起床时间",
|
||||
"小时":"小时",
|
||||
"分钟":"分钟",
|
||||
"消息提醒设置":"消息提醒设置",
|
||||
"APP消息":"APP消息",
|
||||
"APP消息介绍":"打开“太和e护”APP,可以查看该设备的消息内容",
|
||||
"通用APP消息介绍":"打开“太和e护”APP,可以查看消息内容",
|
||||
"服务号消息":"服务号消息",
|
||||
"服务号消息介绍":"无需打开“太和e护”APP,关注太和e护服务号后,微信内即可接收该设备消息推送",
|
||||
"通用服务号消息介绍":"无需打开“太和e护”APP,关注太和e护服务号后,微信内即可接收消息推送",
|
||||
"消息通知":"消息通知",
|
||||
"绑定操作提示":"设备放置说明",
|
||||
"绑定操作提示介绍":"是否打开设备放置说明的提示",
|
||||
"设备升级通知":"设备升级通知",
|
||||
"设备升级通知介绍":"是否打开设备升级的提示",
|
||||
"设备故障通知":"设备故障通知",
|
||||
"设备故障通知介绍":"是否打开设备故障的提示",
|
||||
"全部消息":"全部消息",
|
||||
"请先在设置里的消息通知打开全部消息配置":"请先在设置里的消息通知打开全部消息配置",
|
||||
"请先打开全部消息配置":"请先打开全部消息配置",
|
||||
"正常值":"正常值:"
|
||||
|
||||
}
|
||||
@@ -23,6 +23,8 @@ class ServiceConstant {
|
||||
static String start_calibration = "/api/caibration";//开始校准
|
||||
static String calibration_process = "/api/caibration";//校准进度
|
||||
static String submit_repair = "/api/device/repair";//提交报修
|
||||
static String user_setting = "/api/user/config";//查询和更新用户自定义配置
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -14,6 +14,27 @@ ThemeController themeController = Get.find();
|
||||
LanguageController languageController = Get.find();
|
||||
|
||||
class MyUtils {
|
||||
static String formatToDate(int timestamp) {
|
||||
final dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
|
||||
return "${dateTime.year}-${dateTime.month}-${dateTime.day.toString().padLeft(2, '0')}";
|
||||
}
|
||||
|
||||
static Map<String, int> diffHoursMinutesMap(int startMillis, int endMillis) {
|
||||
final duration = Duration(milliseconds: endMillis - startMillis);
|
||||
final hours = duration.inHours;
|
||||
final minutes = duration.inMinutes % 60;
|
||||
return {
|
||||
"hours": hours,
|
||||
"minutes": minutes,
|
||||
};
|
||||
}
|
||||
|
||||
static String formatToHHmm(int timestampMillis) {
|
||||
final dateTime = DateTime.fromMillisecondsSinceEpoch(timestampMillis);
|
||||
final twoDigits = (int n) => n.toString().padLeft(2, '0');
|
||||
return '${twoDigits(dateTime.hour)}:${twoDigits(dateTime.minute)}';
|
||||
}
|
||||
|
||||
static ApiResponse formatResponse(
|
||||
ApiResponse res,
|
||||
String successMsg,
|
||||
|
||||
90
lib/component/base/GradientSwitch.dart
Normal file
90
lib/component/base/GradientSwitch.dart
Normal file
@@ -0,0 +1,90 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradientSwitch extends StatefulWidget {
|
||||
final bool value;
|
||||
final ValueChanged<bool> onChanged;
|
||||
final Gradient activeGradient;
|
||||
final Color inactiveColor;
|
||||
final Color activeThumbColor;
|
||||
final Color inactiveThumbColor;
|
||||
|
||||
const GradientSwitch({
|
||||
super.key,
|
||||
required this.value,
|
||||
required this.onChanged,
|
||||
required this.activeGradient,
|
||||
this.inactiveColor = Colors.grey,
|
||||
this.activeThumbColor = Colors.white,
|
||||
this.inactiveThumbColor = Colors.white,
|
||||
});
|
||||
|
||||
@override
|
||||
State<GradientSwitch> createState() => _GradientSwitchState();
|
||||
}
|
||||
|
||||
class _GradientSwitchState extends State<GradientSwitch>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_controller = AnimationController(
|
||||
vsync: this, duration: const Duration(milliseconds: 200));
|
||||
_controller.value = widget.value ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
@override
|
||||
void didUpdateWidget(covariant GradientSwitch oldWidget) {
|
||||
super.didUpdateWidget(oldWidget);
|
||||
if (widget.value != oldWidget.value) {
|
||||
widget.value ? _controller.forward() : _controller.reverse();
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: () => widget.onChanged(!widget.value),
|
||||
child: AnimatedBuilder(
|
||||
animation: _controller,
|
||||
builder: (context, child) {
|
||||
final align = Alignment.lerp(
|
||||
Alignment.centerLeft, Alignment.centerRight, _controller.value)!;
|
||||
|
||||
// 动态计算小球颜色(线性过渡)
|
||||
final thumbColor = Color.lerp(widget.inactiveThumbColor,
|
||||
widget.activeThumbColor, _controller.value)!;
|
||||
|
||||
return Container(
|
||||
width: 60,
|
||||
height: 30,
|
||||
padding: const EdgeInsets.all(3),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(30),
|
||||
gradient: widget.value ? widget.activeGradient : null,
|
||||
color: widget.value ? null : widget.inactiveColor,
|
||||
),
|
||||
child: Align(
|
||||
alignment: align,
|
||||
child: Container(
|
||||
width: 24,
|
||||
height: 24,
|
||||
decoration: BoxDecoration(
|
||||
color: thumbColor,
|
||||
shape: BoxShape.circle,
|
||||
boxShadow: const [
|
||||
BoxShadow(
|
||||
color: Colors.black26,
|
||||
blurRadius: 2,
|
||||
offset: Offset(0, 1)),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ class DynamicReportDetailWidget extends StatelessWidget {
|
||||
final List<SleepDataModuleWidget> sleepDataModuleWidgets;
|
||||
final ThemeController themeController = Get.find();
|
||||
final Map targetDevice;
|
||||
late ScrollController _scrollController;
|
||||
|
||||
DynamicReportDetailWidget({
|
||||
required this.sleepDateWidgets,
|
||||
@@ -25,6 +26,18 @@ class DynamicReportDetailWidget extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_scrollController = ScrollController();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (_scrollController.hasClients) {
|
||||
// _scrollController.jumpTo(_scrollController.position.maxScrollExtent);
|
||||
// 如果你希望有动画,用下面这句替代 jumpTo:
|
||||
_scrollController.animateTo(
|
||||
_scrollController.position.maxScrollExtent,
|
||||
duration: Duration(milliseconds: 300),
|
||||
curve: Curves.easeOut,
|
||||
);
|
||||
}
|
||||
});
|
||||
return Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0, 25.rpx, 0, 25.rpx),
|
||||
child: Container(
|
||||
@@ -40,7 +53,7 @@ class DynamicReportDetailWidget extends StatelessWidget {
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
_buildHeader(context,targetDevice),
|
||||
_buildHeader(context, targetDevice),
|
||||
SizedBox(
|
||||
height: 33.rpx,
|
||||
),
|
||||
@@ -67,7 +80,7 @@ class DynamicReportDetailWidget extends StatelessWidget {
|
||||
borderRadius: 0,
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: () async {
|
||||
await Get.toNamed("/bodyDevice",arguments: targetDevice);
|
||||
await Get.toNamed("/bodyDevice", arguments: targetDevice);
|
||||
},
|
||||
child: Text(
|
||||
'${targetDevice['person']?['name'] == null ? '未命名'.tr : targetDevice['person']['name']}',
|
||||
@@ -132,6 +145,7 @@ class DynamicReportDetailWidget extends StatelessWidget {
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(),
|
||||
child: SingleChildScrollView(
|
||||
controller: _scrollController, // ⭐️ 关键点
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
|
||||
@@ -101,76 +101,51 @@ class _SleepDataModuleWidgetState extends State<SleepDataModuleWidget> {
|
||||
),
|
||||
],
|
||||
),
|
||||
// Container(
|
||||
// width: MediaQuery.sizeOf(context).width * 0.07,
|
||||
// height: MediaQuery.sizeOf(context).height * 0.014,
|
||||
// constraints: BoxConstraints(
|
||||
// minWidth: 43.rpx,
|
||||
// minHeight: 36.rpx,
|
||||
// ),
|
||||
// child: FFButtonWidget(
|
||||
// onPressed: () {
|
||||
// print('Button pressed ...');
|
||||
// },
|
||||
// // text: '${widget.data['level']}',
|
||||
// text: '${widget.data['level']}',
|
||||
// options: FFButtonOptions(
|
||||
// height: 40.rpx,
|
||||
// padding: EdgeInsets.zero,
|
||||
// // color: themeController.currentColor.sc14,
|
||||
// color: stringToColor('${widget.data['color']}'),
|
||||
// textStyle:
|
||||
// FlutterFlowTheme.of(context).titleSmall.override(
|
||||
// fontFamily: 'Inter Tight',
|
||||
// color: themeController.currentColor.sc3,
|
||||
// // color: stringToColor('${widget.data['color']}'),
|
||||
// letterSpacing: 0.0,
|
||||
// fontSize: 15.rpx,
|
||||
// ),
|
||||
// elevation: 0,
|
||||
// borderRadius: BorderRadius.circular(8.rpx),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
ClickableContainer(
|
||||
backgroundColor: stringToColor('${widget.data['color']}'),
|
||||
highlightColor: themeController.currentColor.sc3,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 0.rpx,
|
||||
vertical: 0.rpx,
|
||||
),
|
||||
borderRadius: 8.rpx,
|
||||
onTap: () {
|
||||
print('Button pressed ...');
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 43.rpx,
|
||||
minHeight: 36.rpx,
|
||||
if (widget.data['level'] != null)
|
||||
ClickableContainer(
|
||||
backgroundColor: (widget.data['color'] == null ||
|
||||
widget.data['color'].toString().isEmpty)
|
||||
? Colors.transparent
|
||||
: stringToColor(widget.data['color']),
|
||||
highlightColor: themeController.currentColor.sc3,
|
||||
padding: EdgeInsets.symmetric(
|
||||
horizontal: 0.rpx,
|
||||
vertical: 0.rpx,
|
||||
),
|
||||
child: Text(
|
||||
'${widget.data['level']}',
|
||||
style: FlutterFlowTheme.of(context).titleSmall.override(
|
||||
fontFamily: 'Inter Tight',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 15.rpx,
|
||||
),
|
||||
borderRadius: 8.rpx,
|
||||
onTap: () {
|
||||
print('Button pressed ...');
|
||||
},
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 43.rpx,
|
||||
minHeight: 36.rpx,
|
||||
),
|
||||
child: Text(
|
||||
'${widget.data['level']}',
|
||||
style: FlutterFlowTheme.of(context).titleSmall.override(
|
||||
fontFamily: 'Inter Tight',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0.0,
|
||||
fontSize: 15.rpx,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 0.rpx)),
|
||||
),
|
||||
Text(
|
||||
'${widget.data['range']}',
|
||||
"正常值".tr +
|
||||
'${(widget.data['range'] ?? '').toString().isEmpty ? '未知数据'.tr : widget.data['range']}',
|
||||
style: FlutterFlowTheme.of(context).bodyMedium.override(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants().small_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
@@ -26,7 +26,7 @@ class BlueteethBindModel {
|
||||
@JsonKey(ignore: true)
|
||||
List<BleDeviceData>? betDevicelist = []; //网络状态
|
||||
@JsonKey(ignore: true)
|
||||
List? blelist = [];
|
||||
List? blelist = [];//蓝牙扫描的原始数据
|
||||
|
||||
List bindArr = ["", "", ""];
|
||||
String connectedWifiName = "";
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'common_message_setting_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class CommonMessageSettingModel {
|
||||
int? setting = 0;//总设置 0 关闭 1 开启
|
||||
int? appSetting = 0;//app消息设置
|
||||
int? serviceSetting = 0;//服务号消息
|
||||
int? tipSetting = 0;//设备放置说明
|
||||
int? deviceUpgradeSetting = 0;//设备升级提示
|
||||
int? deviceIssueSetting = 0;//设备故障提示
|
||||
|
||||
|
||||
CommonMessageSettingModel();
|
||||
|
||||
// 从JSON反序列化时的异常处理
|
||||
|
||||
factory CommonMessageSettingModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$CommonMessageSettingModelFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return CommonMessageSettingModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$CommonMessageSettingModelToJson(this);
|
||||
}
|
||||
|
||||
class CommonMessageSettingController extends GetControllerEx<CommonMessageSettingModel> {
|
||||
CommonMessageSettingController() {
|
||||
attr = GetModel(CommonMessageSettingModel()).obs;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'common_message_setting_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
CommonMessageSettingModel _$CommonMessageSettingModelFromJson(
|
||||
Map<String, dynamic> json) =>
|
||||
CommonMessageSettingModel()
|
||||
..setting = (json['setting'] as num?)?.toInt()
|
||||
..appSetting = (json['appSetting'] as num?)?.toInt()
|
||||
..serviceSetting = (json['serviceSetting'] as num?)?.toInt()
|
||||
..tipSetting = (json['tipSetting'] as num?)?.toInt()
|
||||
..deviceUpgradeSetting = (json['deviceUpgradeSetting'] as num?)?.toInt()
|
||||
..deviceIssueSetting = (json['deviceIssueSetting'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$CommonMessageSettingModelToJson(
|
||||
CommonMessageSettingModel instance) =>
|
||||
<String, dynamic>{
|
||||
'setting': instance.setting,
|
||||
'appSetting': instance.appSetting,
|
||||
'serviceSetting': instance.serviceSetting,
|
||||
'tipSetting': instance.tipSetting,
|
||||
'deviceUpgradeSetting': instance.deviceUpgradeSetting,
|
||||
'deviceIssueSetting': instance.deviceIssueSetting,
|
||||
};
|
||||
34
lib/controller/message/message_setting_controller.dart
Normal file
34
lib/controller/message/message_setting_controller.dart
Normal file
@@ -0,0 +1,34 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'message_setting_controller.g.dart'; // 由json_serializable自动生成的部分
|
||||
|
||||
@JsonSerializable()
|
||||
class MessageSettingModel {
|
||||
int? setting = 0;//总设置 0 关闭 1 开启
|
||||
int? appSetting = 0;//app消息设置
|
||||
int? serviceSetting = 0;//服务号消息
|
||||
|
||||
MessageSettingModel();
|
||||
|
||||
// 从JSON反序列化时的异常处理
|
||||
|
||||
factory MessageSettingModel.fromJson(Map<String, dynamic> json) {
|
||||
try {
|
||||
return _$MessageSettingModelFromJson(json);
|
||||
} catch (e) {
|
||||
// 在实际应用中,应该有更细致的异常处理策略和错误日志
|
||||
return MessageSettingModel(); // 或者返回一个带有错误信息的特定DeviceInfoModel实例
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化为JSON时的异常处理
|
||||
Map<String, dynamic> toJson() => _$MessageSettingModelToJson(this);
|
||||
}
|
||||
|
||||
class MessageSettingController extends GetControllerEx<MessageSettingModel> {
|
||||
MessageSettingController() {
|
||||
attr = GetModel(MessageSettingModel()).obs;
|
||||
}
|
||||
|
||||
}
|
||||
21
lib/controller/message/message_setting_controller.g.dart
Normal file
21
lib/controller/message/message_setting_controller.g.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'message_setting_controller.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
MessageSettingModel _$MessageSettingModelFromJson(Map<String, dynamic> json) =>
|
||||
MessageSettingModel()
|
||||
..setting = (json['setting'] as num?)?.toInt()
|
||||
..appSetting = (json['appSetting'] as num?)?.toInt()
|
||||
..serviceSetting = (json['serviceSetting'] as num?)?.toInt();
|
||||
|
||||
Map<String, dynamic> _$MessageSettingModelToJson(
|
||||
MessageSettingModel instance) =>
|
||||
<String, dynamic>{
|
||||
'setting': instance.setting,
|
||||
'appSetting': instance.appSetting,
|
||||
'serviceSetting': instance.serviceSetting,
|
||||
};
|
||||
@@ -27,6 +27,7 @@ class SleepReportModel {
|
||||
class SleepReportController extends GetControllerEx<SleepReportModel> {
|
||||
|
||||
Rx<DateTime?> selectedDate = Rx<DateTime?>(null);
|
||||
RxMap sleepReport = RxMap();
|
||||
SleepReportController() {
|
||||
attr = GetModel(SleepReportModel()).obs;
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ import 'package:vbvs_app/controller/home/home_controller.dart';
|
||||
import 'package:vbvs_app/controller/login/login_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
|
||||
import 'package:vbvs_app/controller/main_bottom/main_page_controller.dart';
|
||||
import 'package:vbvs_app/controller/message/common_message_setting_controller.dart';
|
||||
import 'package:vbvs_app/controller/message/message_controller.dart';
|
||||
import 'package:vbvs_app/controller/message/message_review_controller.dart';
|
||||
import 'package:vbvs_app/controller/message/message_setting_controller.dart';
|
||||
import 'package:vbvs_app/controller/person/person_controller.dart';
|
||||
import 'package:vbvs_app/controller/repair/repair_controller.dart';
|
||||
import 'package:vbvs_app/controller/setting/language/language_controller.dart';
|
||||
@@ -247,6 +249,8 @@ class MyApp extends StatelessWidget {
|
||||
Get.lazyPut(() => CalendarController()),
|
||||
Get.lazyPut(() => SleepReportController()),
|
||||
Get.lazyPut(() => MessageReviewController()),
|
||||
Get.lazyPut(() => MessageSettingController()),
|
||||
Get.lazyPut(() => CommonMessageSettingController()),
|
||||
]));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -328,7 +328,8 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
|
||||
_popupEntry?.remove();
|
||||
_popupEntry = null;
|
||||
// Get.toNamed("/deviceDetail", arguments: widget.device);
|
||||
TopSlideNotification.show(context, text: "待开发功能".tr);
|
||||
Get.toNamed("/messageSettingPage", arguments: widget.device);
|
||||
// TopSlideNotification.show(context, text: "待开发功能".tr);
|
||||
},
|
||||
),
|
||||
]);
|
||||
|
||||
574
lib/pages/device/component/MessageSetting.dart
Normal file
574
lib/pages/device/component/MessageSetting.dart
Normal file
@@ -0,0 +1,574 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/base/GradientSwitch.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/message/common_message_setting_controller.dart';
|
||||
import 'package:vbvs_app/controller/message/message_setting_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
|
||||
class MessageSettingPage extends StatefulWidget {
|
||||
var data;
|
||||
MessageSettingPage({super.key, required this.data});
|
||||
|
||||
@override
|
||||
State<MessageSettingPage> createState() => _MessageSettingPageState();
|
||||
}
|
||||
|
||||
class _MessageSettingPageState extends State<MessageSettingPage> {
|
||||
final ThemeController themeController = Get.find();
|
||||
MessageSettingController messageSettingController = Get.find();
|
||||
CommonMessageSettingController commonMessageSettingController = Get.find();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fetchCommonMessageSetting();
|
||||
_fetchDeviceMessageSetting();
|
||||
}
|
||||
|
||||
Future<void> _fetchCommonMessageSetting() async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "user_message_setting";
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type";
|
||||
requestWithLog(
|
||||
logTitle: "查询用户消息配置",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data == null || res.data.isEmpty) {
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting": 1,
|
||||
"appSetting": 1,
|
||||
"serviceSetting": 1,
|
||||
"tipSetting": 1,
|
||||
"deviceUpgradeSetting": 1,
|
||||
"deviceIssueSetting": 1,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新用户消息配置",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
requestWithLog(
|
||||
logTitle: "查询用户消息配置",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data != null && res.data.isNotEmpty) {
|
||||
var datalist = res.data;
|
||||
commonMessageSettingController.model.setting =
|
||||
datalist['setting'];
|
||||
commonMessageSettingController.model.appSetting =
|
||||
datalist['appSetting'];
|
||||
commonMessageSettingController.model.serviceSetting =
|
||||
datalist['serviceSetting'];
|
||||
commonMessageSettingController.model.tipSetting =
|
||||
datalist['tipSetting'];
|
||||
commonMessageSettingController.model.deviceUpgradeSetting =
|
||||
datalist['deviceUpgradeSetting'];
|
||||
commonMessageSettingController.model.deviceIssueSetting =
|
||||
datalist['deviceIssueSetting'];
|
||||
commonMessageSettingController.updateAll();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
//
|
||||
},
|
||||
);
|
||||
} else {
|
||||
var datalist = res.data;
|
||||
commonMessageSettingController.model.setting = datalist['setting'];
|
||||
commonMessageSettingController.model.appSetting =
|
||||
datalist['appSetting'];
|
||||
commonMessageSettingController.model.serviceSetting =
|
||||
datalist['serviceSetting'];
|
||||
commonMessageSettingController.model.tipSetting =
|
||||
datalist['tipSetting'];
|
||||
commonMessageSettingController.model.deviceUpgradeSetting =
|
||||
datalist['deviceUpgradeSetting'];
|
||||
commonMessageSettingController.model.deviceIssueSetting =
|
||||
datalist['deviceIssueSetting'];
|
||||
commonMessageSettingController.updateAll();
|
||||
}
|
||||
},
|
||||
onFailure: (res) {
|
||||
print(res);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _fetchDeviceMessageSetting() async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String mac = widget.data['mac'];
|
||||
String type = "user_device_message_setting_$mac";
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type";
|
||||
requestWithLog(
|
||||
logTitle: "查询用户消息配置",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data == null || res.data.isEmpty) {
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting": 1,
|
||||
"appSetting": 1,
|
||||
"serviceSetting": 1,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新用户消息配置",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
requestWithLog(
|
||||
logTitle: "查询用户消息配置",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data != null && res.data.isNotEmpty) {
|
||||
var datalist = res.data;
|
||||
messageSettingController.model.setting =
|
||||
datalist['setting'];
|
||||
messageSettingController.model.appSetting =
|
||||
datalist['appSetting'];
|
||||
messageSettingController.model.serviceSetting =
|
||||
datalist['serviceSetting'];
|
||||
messageSettingController.updateAll();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
//
|
||||
},
|
||||
);
|
||||
} else {
|
||||
var datalist = res.data;
|
||||
messageSettingController.model.setting = datalist['setting'];
|
||||
messageSettingController.model.appSetting = datalist['appSetting'];
|
||||
messageSettingController.model.serviceSetting =
|
||||
datalist['serviceSetting'];
|
||||
messageSettingController.updateAll();
|
||||
}
|
||||
},
|
||||
onFailure: (res) {
|
||||
print(res);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodysize) => GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
titleSpacing: 0,
|
||||
title: Container(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
/// 居中标题
|
||||
Text(
|
||||
'消息设置'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'ReadexPro',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: returnIconButtomAddCallback(() {}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [],
|
||||
centerTitle: false,
|
||||
),
|
||||
body: GestureDetector(
|
||||
child: SafeArea(
|
||||
top: true,
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 0, 0.rpx, 0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 15.rpx, 30.rpx, 15.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"消息提醒设置".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize:
|
||||
AppConstants().title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (messageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? true
|
||||
: false)
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
if (commonMessageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(context,
|
||||
text: "请先在设置里的消息通知打开全部消息配置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
String serviceAddress =
|
||||
ServiceConstant.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String mac = widget.data['mac'];
|
||||
String type =
|
||||
"user_device_message_setting_$mac";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting": val == true ? 1 : 0,
|
||||
"appSetting": messageSettingController
|
||||
.model.appSetting,
|
||||
"serviceSetting":
|
||||
messageSettingController
|
||||
.model.serviceSetting,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceMessageSetting();
|
||||
messageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor: stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 21.rpx, 30.rpx, 0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 40.rpx, 30.rpx, 54.rpx),
|
||||
child: Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"APP消息".tr,
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (messageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (messageSettingController
|
||||
.model
|
||||
.appSetting ==
|
||||
1
|
||||
? true
|
||||
: false)
|
||||
: false)
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
if (commonMessageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(context,
|
||||
text:
|
||||
"请先在设置里的消息通知打开全部消息配置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
if (messageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(context,
|
||||
text: "请先打开消息提醒设置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
String serviceAddress =
|
||||
ServiceConstant.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String mac = widget.data['mac'];
|
||||
String type =
|
||||
"user_device_message_setting_$mac";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting":
|
||||
messageSettingController
|
||||
.model.setting,
|
||||
"appSetting": val == true ? 1 : 0,
|
||||
"serviceSetting":
|
||||
messageSettingController
|
||||
.model.serviceSetting,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceMessageSetting();
|
||||
messageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor:
|
||||
stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"APP消息介绍".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"服务号消息".tr,
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (messageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (messageSettingController
|
||||
.model
|
||||
.serviceSetting ==
|
||||
1
|
||||
? true
|
||||
: false)
|
||||
: false)
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
if (commonMessageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(context,
|
||||
text:
|
||||
"请先在设置里的消息通知打开全部消息配置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
if (messageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(context,
|
||||
text: "请先打开消息提醒设置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
String serviceAddress =
|
||||
ServiceConstant.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String mac = widget.data['mac'];
|
||||
String type =
|
||||
"user_device_message_setting_$mac";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting":
|
||||
messageSettingController
|
||||
.model.setting,
|
||||
"appSetting":
|
||||
messageSettingController
|
||||
.model.appSetting,
|
||||
"serviceSetting":
|
||||
val == true ? 1 : 0,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceMessageSetting();
|
||||
messageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor:
|
||||
stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"服务号消息介绍".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
height: 49.rpx,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class _ReviewMessageWidgetWidgetState extends State<ReviewMessageWidgetWidget> {
|
||||
var messageInfo = widget.data;
|
||||
return ClickableContainer(
|
||||
backgroundColor: themeController.currentColor.sc5,
|
||||
highlightColor: themeController.currentColor.sc3,
|
||||
highlightColor: themeController.currentColor.sc21,
|
||||
borderRadius: 20.rpx,
|
||||
padding: EdgeInsetsDirectional.fromSTEB(31.rpx, 33.rpx, 0.rpx, 33.rpx),
|
||||
onTap: () {},
|
||||
|
||||
@@ -92,7 +92,7 @@ class _MessageReviewPageState extends State<MessageReviewPage> {
|
||||
child: ClickableContainer(
|
||||
backgroundColor: themeController.currentColor.sc5,
|
||||
highlightColor:
|
||||
themeController.currentColor.sc5, // 或你希望的点击水波纹颜色
|
||||
themeController.currentColor.sc21, // 或你希望的点击水波纹颜色
|
||||
borderRadius: AppConstants()
|
||||
.normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx
|
||||
padding: EdgeInsets.zero,
|
||||
@@ -288,48 +288,49 @@ class _MessageReviewPageState extends State<MessageReviewPage> {
|
||||
// RepairController repairController = Get.find();
|
||||
// repairController.repairHistory.value = apiResponse.data;
|
||||
// repairController.updateAll();
|
||||
messageReviewController.messageList.value = [
|
||||
{
|
||||
"data": {
|
||||
"title": "实时监测结果通知",
|
||||
'val': [
|
||||
{'k': '消息类型', 'v': '心率异常'},
|
||||
{'k': '检测数值', 'v': '106'},
|
||||
{'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"title": "实时监测结果通知",
|
||||
'val': [
|
||||
{'k': '消息类型', 'v': '心率异常'},
|
||||
{'k': '检测数值', 'v': '106'},
|
||||
{'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"title": "实时监测结果通知",
|
||||
'val': [
|
||||
{'k': '消息类型', 'v': '心率异常'},
|
||||
{'k': '检测数值', 'v': '106'},
|
||||
{'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
],
|
||||
}
|
||||
},
|
||||
{
|
||||
"data": {
|
||||
"title": "实时监测结果通知",
|
||||
'val': [
|
||||
{'k': '消息类型', 'v': '心率异常'},
|
||||
{'k': '检测数值', 'v': '106'},
|
||||
{'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
],
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// messageReviewController.messageList.value = [
|
||||
// {
|
||||
// "data": {
|
||||
// "title": "实时监测结果通知",
|
||||
// 'val': [
|
||||
// {'k': '消息类型', 'v': '心率异常'},
|
||||
// {'k': '检测数值', 'v': '106'},
|
||||
// {'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
// ],
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "data": {
|
||||
// "title": "实时监测结果通知",
|
||||
// 'val': [
|
||||
// {'k': '消息类型', 'v': '心率异常'},
|
||||
// {'k': '检测数值', 'v': '106'},
|
||||
// {'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
// ],
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "data": {
|
||||
// "title": "实时监测结果通知",
|
||||
// 'val': [
|
||||
// {'k': '消息类型', 'v': '心率异常'},
|
||||
// {'k': '检测数值', 'v': '106'},
|
||||
// {'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
// ],
|
||||
// }
|
||||
// },
|
||||
// {
|
||||
// "data": {
|
||||
// "title": "实时监测结果通知",
|
||||
// 'val': [
|
||||
// {'k': '消息类型', 'v': '心率异常'},
|
||||
// {'k': '检测数值', 'v': '106'},
|
||||
// {'k': '发生时间', 'v': '2024-07-30 01:15'},
|
||||
// ],
|
||||
// }
|
||||
// },
|
||||
// ];
|
||||
}
|
||||
|
||||
Widget _buildMessageListView(List dataList) {
|
||||
|
||||
@@ -44,10 +44,13 @@ class _SingleBlueteethDeviceCompoentWidgetState
|
||||
deviceData.mac = deviceData.deviceId.replaceAll(':', '');
|
||||
BleDeviceData device = deviceData;
|
||||
// blueteethBindController.currentDeviceMac = device.mac;
|
||||
device = blueteethBindController.model.betDevicelist!.firstWhere(
|
||||
(d) => d.mac == device.mac,
|
||||
orElse: () => device,
|
||||
);
|
||||
final match = blueteethBindController.model.betDevicelist!
|
||||
.firstWhereOrNull((d) => d.mac == device.mac);
|
||||
|
||||
if (match == null) {
|
||||
return Container();
|
||||
}
|
||||
device = match;
|
||||
return ClickableContainer(
|
||||
backgroundColor: themeController.currentColor.sc5,
|
||||
highlightColor: themeController.currentColor.sc21,
|
||||
|
||||
@@ -28,8 +28,8 @@ class CalibrationPage extends StatefulWidget {
|
||||
class _CalibrationPageState extends State<CalibrationPage> {
|
||||
DeviceCalibrationController deviceCalibrationController = Get.find();
|
||||
BlueteethBindController blueteethBindController = Get.find();
|
||||
int flag = 0; //默认没有开始校准过
|
||||
bool exit = false;
|
||||
int flag = 0; //默认没有开始校准过 0没有开始
|
||||
bool exit = false;
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -86,7 +86,6 @@ class _CalibrationPageState extends State<CalibrationPage> {
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: returnIconButtomAddCallback(() {
|
||||
|
||||
if (flag != 0) {
|
||||
try {
|
||||
showConfirmDialog(
|
||||
@@ -114,7 +113,7 @@ class _CalibrationPageState extends State<CalibrationPage> {
|
||||
if (exit) {
|
||||
Get.back();
|
||||
}
|
||||
},enableBack:exit ),
|
||||
}, enableBack: exit),
|
||||
),
|
||||
if (widget.type == 1)
|
||||
Positioned(
|
||||
@@ -561,11 +560,11 @@ class _CalibrationPageState extends State<CalibrationPage> {
|
||||
borderRadius:
|
||||
AppConstants().button_container_radius, // 圆角半径
|
||||
onTap: () async {
|
||||
flag = 1;
|
||||
if (deviceCalibrationController.complete) {
|
||||
showConfirmDialog(
|
||||
context, Container(), "校准已经完成,是否重新开始校准?",
|
||||
onConfirm: () {
|
||||
flag = 1;
|
||||
BlueteethBindController
|
||||
blueteethBindController = Get.find();
|
||||
deviceCalibrationController.process.value = 0;
|
||||
@@ -723,6 +722,7 @@ class _CalibrationPageState extends State<CalibrationPage> {
|
||||
return;
|
||||
});
|
||||
} else {
|
||||
flag = 1;
|
||||
BlueteethBindController
|
||||
blueteethBindController = Get.find();
|
||||
String serviceAddress =
|
||||
|
||||
@@ -369,55 +369,56 @@ class _DeviceSharePageState extends State<DeviceSharePage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 379.rpx, 0, 0),
|
||||
child: CustomCard(
|
||||
borderRadius:
|
||||
AppConstants().button_container_radius, // 圆角半径
|
||||
onTap: () async {
|
||||
// TopSlideNotification.show(context,
|
||||
// text: "待开发功能".tr);
|
||||
LoginController loginController = Get.find();
|
||||
// loginController.fluwx.share(WeChatShareTextModel(
|
||||
// "太和e护分享链接",
|
||||
// scene: WeChatScene.session));
|
||||
final Uint8List data = await rootBundle.load('assets/img/camera.png').then((bd) => bd.buffer.asUint8List());
|
||||
loginController.fluwx.share(WeChatShareWebPageModel("taihecare://goods?id=123",title: "标题",description: "描述",thumbData: data));
|
||||
},
|
||||
colors: [
|
||||
// 渐变色
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2,
|
||||
],
|
||||
child: Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.66,
|
||||
height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
constraints: BoxConstraints(
|
||||
minWidth: 500.rpx,
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'微信好友一键分享'.tr,
|
||||
style: FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontFamily: 'Inter',
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize, // 自定义字体大小
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 17.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
// Padding(
|
||||
// padding:
|
||||
// EdgeInsetsDirectional.fromSTEB(0, 379.rpx, 0, 0),
|
||||
// child: CustomCard(
|
||||
// borderRadius:
|
||||
// AppConstants().button_container_radius, // 圆角半径
|
||||
// onTap: () async {
|
||||
// // TopSlideNotification.show(context,
|
||||
// // text: "待开发功能".tr);
|
||||
// LoginController loginController = Get.find();
|
||||
// // loginController.fluwx.share(WeChatShareTextModel(
|
||||
// // "太和e护分享链接",
|
||||
// // scene: WeChatScene.session));
|
||||
// final Uint8List data = await rootBundle.load('assets/img/camera.png').then((bd) => bd.buffer.asUint8List());
|
||||
// loginController.fluwx.share(WeChatShareWebPageModel("taihecare://goods?id=123",title: "标题",description: "描述",thumbData: data));
|
||||
// },
|
||||
// colors: [
|
||||
// // 渐变色
|
||||
// themeController.currentColor.sc1,
|
||||
// themeController.currentColor.sc2,
|
||||
// ],
|
||||
// child: Container(
|
||||
// width: MediaQuery.sizeOf(context).width * 0.66,
|
||||
// height: MediaQuery.sizeOf(context).height * 0.055,
|
||||
// constraints: BoxConstraints(
|
||||
// minWidth: 500.rpx,
|
||||
// minHeight: 90.rpx,
|
||||
// ),
|
||||
// child: Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// mainAxisAlignment: MainAxisAlignment.center,
|
||||
// children: [
|
||||
// Text(
|
||||
// '微信好友一键分享'.tr,
|
||||
// style: FlutterFlowTheme.of(context)
|
||||
// .bodyMedium
|
||||
// .override(
|
||||
// color: themeController.currentColor.sc3,
|
||||
// fontFamily: 'Inter',
|
||||
// fontSize: AppConstants()
|
||||
// .normal_text_fontSize, // 自定义字体大小
|
||||
// letterSpacing: 0.0,
|
||||
// ),
|
||||
// ),
|
||||
// ].divide(SizedBox(width: 17.rpx)),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -96,6 +96,7 @@ class _EPageState extends State<LoginPage> {
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
body: SafeArea(
|
||||
top: true,
|
||||
@@ -506,22 +507,20 @@ class _EPageState extends State<LoginPage> {
|
||||
// },
|
||||
onTap: () async {
|
||||
//loginController.model.isIos == true &&
|
||||
if (loginController
|
||||
.model.register_agree ==
|
||||
null ||
|
||||
loginController
|
||||
.model.register_agree !=
|
||||
true) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "登录页.未同意协议".tr,
|
||||
textColor:
|
||||
themeController.currentColor.sc9,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await loginController
|
||||
.wxLoginSendAuth(context);
|
||||
if (loginController.model.register_agree ==
|
||||
null ||
|
||||
loginController.model.register_agree !=
|
||||
true) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "登录页.未同意协议".tr,
|
||||
textColor:
|
||||
themeController.currentColor.sc9,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await loginController
|
||||
.wxLoginSendAuth(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 91.rpx,
|
||||
|
||||
@@ -3,8 +3,11 @@ import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:fluwx/fluwx.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/color/app_uri_status.dart';
|
||||
import 'package:vbvs_app/common/util/CheckNetwork.dart';
|
||||
import 'package:vbvs_app/common/util/CommonVariables.dart';
|
||||
import 'package:vbvs_app/common/util/DailyLogUtils.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
@@ -32,6 +35,60 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
|
||||
CountdownController countdownController = Get.find();
|
||||
LoginController loginController = Get.find();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
// TODO: implement initState
|
||||
super.initState();
|
||||
super.initState();
|
||||
LoginController loginController = Get.find();
|
||||
Fluwx fluwx = loginController.fluwx;
|
||||
if (isiOS) {
|
||||
loginController.model.isIos = true;
|
||||
fluwx.isWeChatInstalled.then((isWeChatInstalled) {
|
||||
debugPrint('is wechat installed: $isWeChatInstalled');
|
||||
if (!isWeChatInstalled) {
|
||||
// TODO ios未安装微信 隐藏微信一键登录按钮
|
||||
loginController.model.isWeChatNotInstalled = false;
|
||||
} else {
|
||||
loginController.model.isWeChatNotInstalled = true;
|
||||
}
|
||||
loginController.updateAll();
|
||||
});
|
||||
}
|
||||
// 微信监听回调
|
||||
loginController.fluwxCancelable = fluwx.addSubscriber((response) async {
|
||||
if (response is WeChatAuthResponse) {
|
||||
debugPrint('state :${response.state} \n code:${response.code}');
|
||||
int errCode = response.errCode ?? -9999;
|
||||
if (errCode == 0) {
|
||||
// TODO 微信登录成功 传递code给后台 再操作逻辑
|
||||
String code = response.code ?? "";
|
||||
//把微信登录返回的code传给后台,剩下的事就交给后台处理
|
||||
//首次未注册的用户引导去手机号填写页面
|
||||
//已注册的用户直接跳转首页
|
||||
if (CommonVariables.isNetWorkOn == false) {
|
||||
showToast("网络未连接,请开启设备网络后重试");
|
||||
return;
|
||||
}
|
||||
ApiResponse msg = await loginController.loginByWechatCode(code);
|
||||
if (msg.code == HttpStatusCodes.ok) {
|
||||
// TODO 操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||||
loginController.fluwxCancelable?.cancel();
|
||||
// 登录成功移出网络检查监听
|
||||
Checknetwork.subscription?.cancel();
|
||||
Get.offAndToNamed("/mianPageBottomChange");
|
||||
}
|
||||
// TODO 操作全部跳转页面前成功以后移除监听,防止重复监听,其他方式登录成功也需要移出监听
|
||||
// fluwxCancelable?.cancel();
|
||||
} else if (errCode == -4) {
|
||||
showToast("用户拒绝授权");
|
||||
} else if (errCode == -2) {
|
||||
showToast("用户取消授权");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
@@ -45,6 +102,7 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
resizeToAvoidBottomInset: false,
|
||||
backgroundColor: Colors.transparent,
|
||||
body: SafeArea(
|
||||
top: true,
|
||||
@@ -55,32 +113,27 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Column(
|
||||
children: [
|
||||
SizedBox(
|
||||
height: 66.rpx,
|
||||
SizedBox(
|
||||
height: 66.rpx,
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent, // 容器背景色
|
||||
highlightColor:
|
||||
themeController.currentColor.sc21, // 点击时的背景色
|
||||
padding: EdgeInsets.zero, // 这里去掉外部的 padding,避免影响点击范围
|
||||
onTap: () {
|
||||
Get.back();
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
16.rpx, 10.rpx, 16.rpx, 10.rpx),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/arrow_left.svg',
|
||||
width: 25.rpx,
|
||||
height: 25.rpx, // 如果 SVG 中没有固定颜色,使用 color 设置
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent, // 容器背景色
|
||||
highlightColor:
|
||||
themeController.currentColor.sc21, // 点击时的背景色
|
||||
padding:
|
||||
EdgeInsets.zero, // 这里去掉外部的 padding,避免影响点击范围
|
||||
onTap: () {
|
||||
Get.back();
|
||||
},
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
16.rpx, 10.rpx, 16.rpx, 10.rpx),
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/arrow_left.svg',
|
||||
width: 25.rpx,
|
||||
height: 25.rpx, // 如果 SVG 中没有固定颜色,使用 color 设置
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
@@ -827,22 +880,20 @@ class _OtherLoginPageState extends State<OtherLoginPage> {
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: () async {
|
||||
//loginController.model.isIos == true &&
|
||||
if (loginController
|
||||
.model.register_agree ==
|
||||
null ||
|
||||
loginController
|
||||
.model.register_agree !=
|
||||
true) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "登录页.未同意协议".tr,
|
||||
textColor:
|
||||
themeController.currentColor.sc9,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await loginController
|
||||
.wxLoginSendAuth(context);
|
||||
if (loginController.model.register_agree ==
|
||||
null ||
|
||||
loginController.model.register_agree !=
|
||||
true) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "登录页.未同意协议".tr,
|
||||
textColor:
|
||||
themeController.currentColor.sc9,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await loginController
|
||||
.wxLoginSendAuth(context);
|
||||
},
|
||||
child: Container(
|
||||
width: 91.rpx,
|
||||
|
||||
@@ -650,8 +650,8 @@ class _MinePageState extends State<MinePage> {
|
||||
// themeController.currentColor.sc2,
|
||||
// );
|
||||
Get.toNamed("/newSleepReportPage",
|
||||
arguments: DateTime.now()
|
||||
.millisecondsSinceEpoch);
|
||||
arguments: {'date':DateTime.now()
|
||||
.millisecondsSinceEpoch,"mac":'aaaaaaeeeeeq','type':1});
|
||||
}
|
||||
},
|
||||
child: Container(
|
||||
@@ -693,7 +693,7 @@ class _MinePageState extends State<MinePage> {
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
'V1.0.2505.20',
|
||||
'V1.0.2505.26',
|
||||
style:
|
||||
FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
|
||||
896
lib/pages/setting/common_mesaage_setting.dart
Normal file
896
lib/pages/setting/common_mesaage_setting.dart
Normal file
@@ -0,0 +1,896 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/ServiceConstant.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/common/util/requestWithLog.dart';
|
||||
import 'package:vbvs_app/component/base/GradientSwitch.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/message/common_message_setting_controller.dart';
|
||||
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
|
||||
|
||||
class CommonMessageSettingPage extends StatefulWidget {
|
||||
CommonMessageSettingPage({super.key});
|
||||
|
||||
@override
|
||||
State<CommonMessageSettingPage> createState() =>
|
||||
_CommonMessageSettingPageState();
|
||||
}
|
||||
|
||||
class _CommonMessageSettingPageState extends State<CommonMessageSettingPage> {
|
||||
final ThemeController themeController = Get.find();
|
||||
CommonMessageSettingController commonMessageSettingController = Get.find();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_fetchDeviceList();
|
||||
}
|
||||
|
||||
Future<void> _fetchDeviceList() async {
|
||||
String serviceAddress = ServiceConstant.service_address;
|
||||
String serviceName = ServiceConstant.server_service;
|
||||
String serviceApi = ServiceConstant.user_setting;
|
||||
String type = "user_message_setting";
|
||||
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}?type=$type";
|
||||
requestWithLog(
|
||||
logTitle: "查询用户消息配置",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data == null || res.data.isEmpty) {
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting": 1,
|
||||
"appSetting": 1,
|
||||
"serviceSetting": 1,
|
||||
"tipSetting": 1,
|
||||
"deviceUpgradeSetting": 1,
|
||||
"deviceIssueSetting": 1,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新用户消息配置",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
requestWithLog(
|
||||
logTitle: "查询用户消息配置",
|
||||
method: MyHttpMethod.get,
|
||||
queryUrl: queryUrl,
|
||||
onSuccess: (res) {
|
||||
if (res.data != null && res.data.isNotEmpty) {
|
||||
var datalist = res.data;
|
||||
commonMessageSettingController.model.setting =
|
||||
datalist['setting'];
|
||||
commonMessageSettingController.model.appSetting =
|
||||
datalist['appSetting'];
|
||||
commonMessageSettingController.model.serviceSetting =
|
||||
datalist['serviceSetting'];
|
||||
commonMessageSettingController.model.tipSetting =
|
||||
datalist['tipSetting'];
|
||||
commonMessageSettingController.model.deviceUpgradeSetting =
|
||||
datalist['deviceUpgradeSetting'];
|
||||
commonMessageSettingController.model.deviceIssueSetting =
|
||||
datalist['deviceIssueSetting'];
|
||||
commonMessageSettingController.updateAll();
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
//
|
||||
},
|
||||
);
|
||||
} else {
|
||||
var datalist = res.data;
|
||||
commonMessageSettingController.model.setting = datalist['setting'];
|
||||
commonMessageSettingController.model.appSetting =
|
||||
datalist['appSetting'];
|
||||
commonMessageSettingController.model.serviceSetting =
|
||||
datalist['serviceSetting'];
|
||||
commonMessageSettingController.model.tipSetting =
|
||||
datalist['tipSetting'];
|
||||
commonMessageSettingController.model.deviceUpgradeSetting =
|
||||
datalist['deviceUpgradeSetting'];
|
||||
commonMessageSettingController.model.deviceIssueSetting =
|
||||
datalist['deviceIssueSetting'];
|
||||
commonMessageSettingController.updateAll();
|
||||
}
|
||||
},
|
||||
onFailure: (res) {
|
||||
print(res);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, bodysize) => GestureDetector(
|
||||
onTap: () => FocusScope.of(context).unfocus(),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
image: DecorationImage(
|
||||
image: AssetImage('assets/img/bgNoImg.png'),
|
||||
fit: BoxFit.fill,
|
||||
),
|
||||
),
|
||||
child: Scaffold(
|
||||
backgroundColor: Colors.transparent,
|
||||
appBar: AppBar(
|
||||
backgroundColor: themeController.currentColor.sc17,
|
||||
automaticallyImplyLeading: false,
|
||||
iconTheme: IconThemeData(
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
titleSpacing: 0,
|
||||
title: Container(
|
||||
width: double.infinity,
|
||||
height: 180.rpx,
|
||||
child: Stack(
|
||||
alignment: Alignment.center,
|
||||
children: [
|
||||
/// 居中标题
|
||||
Text(
|
||||
'消息通知'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'ReadexPro',
|
||||
color: themeController.currentColor.sc3,
|
||||
letterSpacing: 0,
|
||||
fontSize: 30.rpx,
|
||||
),
|
||||
),
|
||||
Positioned(
|
||||
left: 0,
|
||||
child: returnIconButtomAddCallback(() {}),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
actions: [],
|
||||
centerTitle: false,
|
||||
),
|
||||
body: GestureDetector(
|
||||
child: SafeArea(
|
||||
top: true,
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 0, 0.rpx, 0),
|
||||
child: SingleChildScrollView(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 15.rpx, 30.rpx, 15.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"全部消息".tr,
|
||||
style: TextStyle(
|
||||
color:
|
||||
themeController.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? true
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
String serviceAddress =
|
||||
ServiceConstant.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String type = "user_message_setting";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting": val == true ? 1 : 0,
|
||||
"appSetting":
|
||||
commonMessageSettingController
|
||||
.model.appSetting,
|
||||
"serviceSetting":
|
||||
commonMessageSettingController
|
||||
.model.serviceSetting,
|
||||
"tipSetting":
|
||||
commonMessageSettingController
|
||||
.model.tipSetting,
|
||||
"deviceUpgradeSetting":
|
||||
commonMessageSettingController
|
||||
.model.deviceUpgradeSetting,
|
||||
"deviceIssueSetting":
|
||||
commonMessageSettingController
|
||||
.model.deviceIssueSetting,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceList();
|
||||
commonMessageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor: stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 21.rpx, 30.rpx, 0),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(
|
||||
AppConstants().normal_container_radius),
|
||||
),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 40.rpx, 30.rpx, 54.rpx),
|
||||
child: Container(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"APP消息".tr,
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (commonMessageSettingController
|
||||
.model.appSetting ==
|
||||
1
|
||||
? true
|
||||
: false)
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
if (commonMessageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "请先打开全部消息配置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
String serviceAddress =
|
||||
ServiceConstant
|
||||
.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant
|
||||
.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String type =
|
||||
"user_message_setting";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting":
|
||||
commonMessageSettingController
|
||||
.model.setting,
|
||||
"appSetting":
|
||||
val == true ? 1 : 0,
|
||||
"serviceSetting":
|
||||
commonMessageSettingController
|
||||
.model.serviceSetting,
|
||||
"tipSetting":
|
||||
commonMessageSettingController
|
||||
.model.tipSetting,
|
||||
"deviceUpgradeSetting":
|
||||
commonMessageSettingController
|
||||
.model
|
||||
.deviceUpgradeSetting,
|
||||
"deviceIssueSetting":
|
||||
commonMessageSettingController
|
||||
.model
|
||||
.deviceIssueSetting,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceList();
|
||||
commonMessageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController
|
||||
.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor:
|
||||
stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"通用APP消息介绍".tr,
|
||||
style: TextStyle(
|
||||
color:
|
||||
themeController.currentColor.sc4,
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize),
|
||||
),
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"服务号消息".tr,
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (commonMessageSettingController
|
||||
.model
|
||||
.serviceSetting ==
|
||||
1
|
||||
? true
|
||||
: false)
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
if (commonMessageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "请先打开全部消息配置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
String serviceAddress =
|
||||
ServiceConstant
|
||||
.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant
|
||||
.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String type =
|
||||
"user_message_setting";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting":
|
||||
commonMessageSettingController
|
||||
.model.setting,
|
||||
"appSetting":
|
||||
commonMessageSettingController
|
||||
.model.appSetting,
|
||||
"serviceSetting":
|
||||
val == true ? 1 : 0,
|
||||
"tipSetting":
|
||||
commonMessageSettingController
|
||||
.model.tipSetting,
|
||||
"deviceUpgradeSetting":
|
||||
commonMessageSettingController
|
||||
.model
|
||||
.deviceUpgradeSetting,
|
||||
"deviceIssueSetting":
|
||||
commonMessageSettingController
|
||||
.model
|
||||
.deviceIssueSetting,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceList();
|
||||
commonMessageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController
|
||||
.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor:
|
||||
stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
Text(
|
||||
"通用服务号消息介绍".tr,
|
||||
style: TextStyle(
|
||||
color:
|
||||
themeController.currentColor.sc4,
|
||||
fontSize: AppConstants()
|
||||
.normal_text_fontSize),
|
||||
),
|
||||
].divide(SizedBox(
|
||||
height: 49.rpx,
|
||||
)),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// Padding(
|
||||
// padding:
|
||||
// EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0),
|
||||
// child: Container(
|
||||
// width: double.infinity,
|
||||
// constraints: BoxConstraints(
|
||||
// minHeight: 90.rpx,
|
||||
// ),
|
||||
// decoration: BoxDecoration(
|
||||
// color: themeController.currentColor.sc5),
|
||||
// child: Padding(
|
||||
// padding: EdgeInsetsDirectional.fromSTEB(
|
||||
// 30.rpx, 15.rpx, 30.rpx, 15.rpx),
|
||||
// child: Column(
|
||||
// crossAxisAlignment: CrossAxisAlignment.start,
|
||||
// children: [
|
||||
// Row(
|
||||
// mainAxisSize: MainAxisSize.max,
|
||||
// mainAxisAlignment:
|
||||
// MainAxisAlignment.spaceBetween,
|
||||
// children: [
|
||||
// Expanded(
|
||||
// child: Text(
|
||||
// "绑定操作提示".tr,
|
||||
// style: TextStyle(
|
||||
// color: themeController
|
||||
// .currentColor.sc3,
|
||||
// fontSize: AppConstants()
|
||||
// .title_text_fontSize),
|
||||
// ),
|
||||
// ),
|
||||
// Obx(() {
|
||||
// return GradientSwitch(
|
||||
// value: commonMessageSettingController
|
||||
// .model.setting ==
|
||||
// 1
|
||||
// ? (commonMessageSettingController
|
||||
// .model.tipSetting ==
|
||||
// 1
|
||||
// ? true
|
||||
// : false)
|
||||
// : false,
|
||||
// onChanged: (val) {
|
||||
// if (commonMessageSettingController
|
||||
// .model.setting ==
|
||||
// 0) {
|
||||
// TopSlideNotification.show(
|
||||
// context,
|
||||
// text: "请先打开全部消息配置".tr,
|
||||
// textColor: themeController
|
||||
// .currentColor.sc9);
|
||||
// return;
|
||||
// }
|
||||
// String serviceAddress =
|
||||
// ServiceConstant
|
||||
// .service_address;
|
||||
// String serviceName =
|
||||
// ServiceConstant
|
||||
// .server_service;
|
||||
// String serviceApi =
|
||||
// ServiceConstant.user_setting;
|
||||
// String type =
|
||||
// "user_message_setting";
|
||||
// String queryUrl =
|
||||
// "${serviceAddress}${serviceName}${serviceApi}";
|
||||
// var data = {
|
||||
// "type": type,
|
||||
// "setting":
|
||||
// commonMessageSettingController
|
||||
// .model.setting,
|
||||
// "appSetting":
|
||||
// commonMessageSettingController
|
||||
// .model.appSetting,
|
||||
// "serviceSetting":
|
||||
// commonMessageSettingController
|
||||
// .model.serviceSetting,
|
||||
// "tipSetting":
|
||||
// val == true ? 1 : 0,
|
||||
// "deviceUpgradeSetting":
|
||||
// commonMessageSettingController
|
||||
// .model
|
||||
// .deviceUpgradeSetting,
|
||||
// "deviceIssueSetting":
|
||||
// commonMessageSettingController
|
||||
// .model
|
||||
// .deviceIssueSetting,
|
||||
// };
|
||||
// requestWithLog(
|
||||
// logTitle: "更新消息推送状态",
|
||||
// method: MyHttpMethod.put,
|
||||
// queryUrl: queryUrl,
|
||||
// data: data,
|
||||
// onSuccess: (res) {
|
||||
// _fetchDeviceList();
|
||||
// commonMessageSettingController
|
||||
// .updateAll();
|
||||
// });
|
||||
// },
|
||||
// activeGradient: LinearGradient(
|
||||
// colors: [
|
||||
// themeController
|
||||
// .currentColor.sc1,
|
||||
// themeController.currentColor.sc2
|
||||
// ],
|
||||
// ),
|
||||
// activeThumbColor: Colors.white,
|
||||
// inactiveThumbColor:
|
||||
// stringToColor("#A2A4A9"),
|
||||
// inactiveColor:
|
||||
// stringToColor("#161B28"),
|
||||
// );
|
||||
// }),
|
||||
// ],
|
||||
// ),
|
||||
// // Text(
|
||||
// // "绑定操作提示介绍".tr,
|
||||
// // style: TextStyle(
|
||||
// // color:
|
||||
// // themeController.currentColor.sc4,
|
||||
// // fontSize: AppConstants()
|
||||
// // .normal_text_fontSize),
|
||||
// // ),
|
||||
// ].divide(SizedBox(
|
||||
// height: 49.rpx,
|
||||
// )),
|
||||
// )),
|
||||
// ),
|
||||
// ),
|
||||
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 15.rpx, 30.rpx, 15.rpx),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"设备故障通知".tr,
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (commonMessageSettingController
|
||||
.model
|
||||
.deviceUpgradeSetting ==
|
||||
1
|
||||
? true
|
||||
: false)
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
if (commonMessageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "请先打开全部消息配置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
String serviceAddress =
|
||||
ServiceConstant
|
||||
.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant
|
||||
.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String type =
|
||||
"user_message_setting";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting":
|
||||
commonMessageSettingController
|
||||
.model.setting,
|
||||
"appSetting":
|
||||
commonMessageSettingController
|
||||
.model.appSetting,
|
||||
"serviceSetting":
|
||||
commonMessageSettingController
|
||||
.model.serviceSetting,
|
||||
"tipSetting":
|
||||
commonMessageSettingController
|
||||
.model.tipSetting,
|
||||
"deviceUpgradeSetting":
|
||||
val == true ? 1 : 0,
|
||||
"deviceIssueSetting":
|
||||
commonMessageSettingController
|
||||
.model
|
||||
.deviceIssueSetting,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceList();
|
||||
commonMessageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController
|
||||
.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor:
|
||||
stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
// Text(
|
||||
// "绑定操作提示介绍".tr,
|
||||
// style: TextStyle(
|
||||
// color:
|
||||
// themeController.currentColor.sc4,
|
||||
// fontSize: AppConstants()
|
||||
// .normal_text_fontSize),
|
||||
// ),
|
||||
].divide(SizedBox(
|
||||
height: 49.rpx,
|
||||
)),
|
||||
)),
|
||||
),
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 0),
|
||||
child: Container(
|
||||
width: double.infinity,
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 90.rpx,
|
||||
),
|
||||
decoration: BoxDecoration(
|
||||
color: themeController.currentColor.sc5),
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 15.rpx, 30.rpx, 15.rpx),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
"设备升级通知".tr,
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize),
|
||||
),
|
||||
),
|
||||
Obx(() {
|
||||
return GradientSwitch(
|
||||
value: commonMessageSettingController
|
||||
.model.setting ==
|
||||
1
|
||||
? (commonMessageSettingController
|
||||
.model
|
||||
.deviceIssueSetting ==
|
||||
1
|
||||
? true
|
||||
: false)
|
||||
: false,
|
||||
onChanged: (val) {
|
||||
if (commonMessageSettingController
|
||||
.model.setting ==
|
||||
0) {
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: "请先打开全部消息配置".tr,
|
||||
textColor: themeController
|
||||
.currentColor.sc9);
|
||||
return;
|
||||
}
|
||||
String serviceAddress =
|
||||
ServiceConstant
|
||||
.service_address;
|
||||
String serviceName =
|
||||
ServiceConstant
|
||||
.server_service;
|
||||
String serviceApi =
|
||||
ServiceConstant.user_setting;
|
||||
String type =
|
||||
"user_message_setting";
|
||||
String queryUrl =
|
||||
"${serviceAddress}${serviceName}${serviceApi}";
|
||||
var data = {
|
||||
"type": type,
|
||||
"setting":
|
||||
commonMessageSettingController
|
||||
.model.setting,
|
||||
"appSetting":
|
||||
commonMessageSettingController
|
||||
.model.appSetting,
|
||||
"serviceSetting":
|
||||
commonMessageSettingController
|
||||
.model.serviceSetting,
|
||||
"tipSetting":
|
||||
commonMessageSettingController
|
||||
.model.tipSetting,
|
||||
"deviceUpgradeSetting":
|
||||
commonMessageSettingController
|
||||
.model
|
||||
.deviceUpgradeSetting,
|
||||
"deviceIssueSetting":
|
||||
val == true ? 1 : 0,
|
||||
};
|
||||
requestWithLog(
|
||||
logTitle: "更新消息推送状态",
|
||||
method: MyHttpMethod.put,
|
||||
queryUrl: queryUrl,
|
||||
data: data,
|
||||
onSuccess: (res) {
|
||||
_fetchDeviceList();
|
||||
commonMessageSettingController
|
||||
.updateAll();
|
||||
});
|
||||
},
|
||||
activeGradient: LinearGradient(
|
||||
colors: [
|
||||
themeController
|
||||
.currentColor.sc1,
|
||||
themeController.currentColor.sc2
|
||||
],
|
||||
),
|
||||
activeThumbColor: Colors.white,
|
||||
inactiveThumbColor:
|
||||
stringToColor("#A2A4A9"),
|
||||
inactiveColor:
|
||||
stringToColor("#161B28"),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
// Text(
|
||||
// "绑定操作提示介绍".tr,
|
||||
// style: TextStyle(
|
||||
// color:
|
||||
// themeController.currentColor.sc4,
|
||||
// fontSize: AppConstants()
|
||||
// .normal_text_fontSize),
|
||||
// ),
|
||||
].divide(SizedBox(
|
||||
height: 49.rpx,
|
||||
)),
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ class _DataShowWidgetState extends State<DataShowWidget> {
|
||||
children: [
|
||||
// 放入传入的 widget1
|
||||
Container(
|
||||
width: MediaQuery.sizeOf(context).width * 0.4, // 固定宽度
|
||||
width: MediaQuery.sizeOf(context).width * 0.35, // 固定宽度
|
||||
decoration: BoxDecoration(),
|
||||
child: Align(
|
||||
alignment: widget.alignment == MainAxisAlignment.start
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'dart:ui' as ui;
|
||||
|
||||
class DotBarChart extends StatefulWidget {
|
||||
final List<Map<String, dynamic>> showLabel;
|
||||
@@ -39,7 +40,6 @@ class _DotBarChartState extends State<DotBarChart> {
|
||||
void _showTooltip(BuildContext context, Map<String, dynamic> data,
|
||||
Offset position, double dotY) {
|
||||
_removeOverlay();
|
||||
|
||||
final RenderBox renderBox = context.findRenderObject() as RenderBox;
|
||||
final Offset globalPosition = renderBox.localToGlobal(position);
|
||||
|
||||
@@ -55,11 +55,6 @@ class _DotBarChartState extends State<DotBarChart> {
|
||||
color: themeController.currentColor.sc5,
|
||||
borderRadius: BorderRadius.circular(8.rpx),
|
||||
boxShadow: [
|
||||
// BoxShadow(
|
||||
// color: Colors.black.withOpacity(0.6),
|
||||
// blurRadius: 10.rpx,
|
||||
// offset: Offset(0, 4.rpx),
|
||||
// ),
|
||||
BoxShadow(
|
||||
color: Colors.black.withOpacity(0.5),
|
||||
blurRadius: 12.rpx,
|
||||
@@ -92,7 +87,6 @@ class _DotBarChartState extends State<DotBarChart> {
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
Overlay.of(context)?.insert(_overlayEntry!);
|
||||
}
|
||||
|
||||
@@ -103,7 +97,6 @@ class _DotBarChartState extends State<DotBarChart> {
|
||||
int maxTimes = widget.showLabel
|
||||
.map((e) => e['times'] ?? 0)
|
||||
.reduce((a, b) => a > b ? a : b);
|
||||
|
||||
int yMax = (maxTimes / 10).ceil() * 10;
|
||||
if (yMax == 0) yMax = 10;
|
||||
|
||||
@@ -113,23 +106,35 @@ class _DotBarChartState extends State<DotBarChart> {
|
||||
int displayMax = step * maxSteps;
|
||||
List<int> yLabels = List.generate(maxSteps + 1, (index) => step * index);
|
||||
|
||||
DateFormat fullFormat = DateFormat('HH:mm');
|
||||
DateFormat hourFormat = DateFormat('H');
|
||||
DateTime startDate = DateTime.fromMillisecondsSinceEpoch(widget.startTime);
|
||||
DateTime endDate = DateTime.fromMillisecondsSinceEpoch(widget.endTime);
|
||||
|
||||
int maxXLabels = 11;
|
||||
int totalPoints = widget.showLabel.length;
|
||||
List<int> xLabelIndices = [];
|
||||
// Generate hourly timestamps
|
||||
List<int> hourlyTimestamps = [];
|
||||
DateTime currentHour = DateTime(
|
||||
startDate.year, startDate.month, startDate.day, startDate.hour);
|
||||
while (currentHour.isBefore(endDate) ||
|
||||
currentHour.isAtSameMomentAs(endDate)) {
|
||||
hourlyTimestamps.add(currentHour.millisecondsSinceEpoch);
|
||||
currentHour = currentHour.add(const Duration(hours: 1));
|
||||
}
|
||||
|
||||
if (totalPoints <= maxXLabels) {
|
||||
xLabelIndices = List.generate(totalPoints, (i) => i);
|
||||
} else {
|
||||
xLabelIndices.add(0);
|
||||
int middleCount = maxXLabels - 2;
|
||||
double stepX = (totalPoints - 1) / (middleCount + 1);
|
||||
for (int i = 1; i <= middleCount; i++) {
|
||||
xLabelIndices.add((stepX * i).round());
|
||||
// Calculate positions for hourly labels
|
||||
List<Map<String, dynamic>> hourLabels = [];
|
||||
if (widget.showLabel.isNotEmpty) {
|
||||
int firstDataTime = widget.showLabel.first['time'];
|
||||
int lastDataTime = widget.showLabel.last['time'];
|
||||
double totalDuration = (lastDataTime - firstDataTime).toDouble();
|
||||
|
||||
for (int timestamp in hourlyTimestamps) {
|
||||
if (timestamp >= firstDataTime && timestamp <= lastDataTime) {
|
||||
double position = (timestamp - firstDataTime) / totalDuration;
|
||||
hourLabels.add({
|
||||
'time': timestamp,
|
||||
'position': position,
|
||||
});
|
||||
}
|
||||
}
|
||||
xLabelIndices.add(totalPoints - 1);
|
||||
}
|
||||
|
||||
double yAxisWidth = 36.rpx;
|
||||
@@ -225,19 +230,14 @@ class _DotBarChartState extends State<DotBarChart> {
|
||||
drawableHeight * (1 - times / displayMax);
|
||||
|
||||
return Positioned(
|
||||
left: x - 20.rpx, // Increase touch area
|
||||
top: y - 20.rpx, // Increase touch area
|
||||
left: x - 20.rpx,
|
||||
top: y - 20.rpx,
|
||||
child: GestureDetector(
|
||||
onTap: () {
|
||||
setState(() {
|
||||
selectedIndex = index;
|
||||
});
|
||||
_showTooltip(
|
||||
context,
|
||||
data,
|
||||
Offset(x, y),
|
||||
y,
|
||||
);
|
||||
_showTooltip(context, data, Offset(x, y), y);
|
||||
},
|
||||
child: Container(
|
||||
width: 40.rpx,
|
||||
@@ -259,33 +259,15 @@ class _DotBarChartState extends State<DotBarChart> {
|
||||
padding: EdgeInsets.only(left: yAxisWidth),
|
||||
child: SizedBox(
|
||||
height: xAxisHeight,
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: List.generate(widget.showLabel.length, (index) {
|
||||
String label = '';
|
||||
if (xLabelIndices.contains(index)) {
|
||||
DateTime dt = DateTime.fromMillisecondsSinceEpoch(
|
||||
widget.showLabel[index]['time']);
|
||||
if (index == 0 || index == totalPoints - 1) {
|
||||
label = fullFormat.format(dt);
|
||||
} else {
|
||||
label = dt.hour.toString();
|
||||
}
|
||||
}
|
||||
return Expanded(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.only(top: 14.rpx),
|
||||
child: Text(
|
||||
label,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 18.rpx,
|
||||
color: themeController.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}),
|
||||
child: CustomPaint(
|
||||
size: Size(double.infinity, xAxisHeight),
|
||||
painter: _XAxisPainter(
|
||||
hourLabels: hourLabels,
|
||||
textColor: themeController.currentColor.sc4,
|
||||
fontSize: 18.rpx,
|
||||
startTime: widget.startTime,
|
||||
endTime: widget.endTime,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -328,7 +310,6 @@ class _DotBarChartPainter extends CustomPainter {
|
||||
|
||||
double thresholdY =
|
||||
yAxisTopPadding + drawableHeight * (1 - threshold / yMax);
|
||||
|
||||
drawDashedLine(
|
||||
canvas,
|
||||
Offset(0, thresholdY),
|
||||
@@ -339,7 +320,6 @@ class _DotBarChartPainter extends CustomPainter {
|
||||
);
|
||||
|
||||
final double dotRadius = 13.rpx;
|
||||
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
int times = data[i]['times'] ?? 0;
|
||||
double x = horizontalPadding + i * xStep;
|
||||
@@ -357,10 +337,8 @@ class _DotBarChartPainter extends CustomPainter {
|
||||
..style = PaintingStyle.stroke
|
||||
..color = Colors.white
|
||||
..strokeWidth = 3.rpx;
|
||||
|
||||
canvas.drawCircle(Offset(x, y), dotRadius + 1.rpx, borderPaint);
|
||||
}
|
||||
|
||||
canvas.drawCircle(Offset(x, y), dotRadius, dotPaint);
|
||||
}
|
||||
|
||||
@@ -376,7 +354,6 @@ class _DotBarChartPainter extends CustomPainter {
|
||||
|
||||
for (int i = 0; i < yLabelsCount; i++) {
|
||||
double y = yAxisTopPadding + i * (drawableHeight / (yLabelsCount - 1));
|
||||
|
||||
if (i == yLabelsCount - 1) {
|
||||
canvas.drawLine(Offset(0, y), Offset(size.width, y), solidLinePaint);
|
||||
} else {
|
||||
@@ -392,8 +369,14 @@ class _DotBarChartPainter extends CustomPainter {
|
||||
}
|
||||
}
|
||||
|
||||
void drawDashedLine(Canvas canvas, Offset start, Offset end, Paint paint,
|
||||
double dashWidth, double gapWidth) {
|
||||
void drawDashedLine(
|
||||
Canvas canvas,
|
||||
Offset start,
|
||||
Offset end,
|
||||
Paint paint,
|
||||
double dashWidth,
|
||||
double gapWidth,
|
||||
) {
|
||||
double dx = start.dx;
|
||||
final double y = start.dy;
|
||||
while (dx < end.dx) {
|
||||
@@ -406,3 +389,65 @@ class _DotBarChartPainter extends CustomPainter {
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
|
||||
}
|
||||
|
||||
class _XAxisPainter extends CustomPainter {
|
||||
final List<Map<String, dynamic>> hourLabels;
|
||||
final Color textColor;
|
||||
final double fontSize;
|
||||
final int startTime;
|
||||
final int endTime;
|
||||
|
||||
_XAxisPainter({
|
||||
required this.hourLabels,
|
||||
required this.textColor,
|
||||
required this.fontSize,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final textStyle = TextStyle(
|
||||
color: textColor,
|
||||
fontSize: fontSize,
|
||||
);
|
||||
final textPainter = TextPainter(
|
||||
textDirection: ui.TextDirection.ltr,
|
||||
textAlign: TextAlign.center,
|
||||
);
|
||||
|
||||
// Draw start time (leftmost)
|
||||
final startText = DateFormat('HH:mm')
|
||||
.format(DateTime.fromMillisecondsSinceEpoch(startTime));
|
||||
final startTextSpan = TextSpan(text: startText, style: textStyle);
|
||||
textPainter.text = startTextSpan;
|
||||
textPainter.layout();
|
||||
textPainter.paint(canvas, Offset(0, 14.rpx));
|
||||
|
||||
// Draw end time (rightmost)
|
||||
final endText = DateFormat('HH:mm')
|
||||
.format(DateTime.fromMillisecondsSinceEpoch(endTime));
|
||||
final endTextSpan = TextSpan(text: endText, style: textStyle);
|
||||
textPainter.text = endTextSpan;
|
||||
textPainter.layout();
|
||||
textPainter.paint(canvas, Offset(size.width - textPainter.width, 14.rpx));
|
||||
|
||||
// Draw hourly labels in between
|
||||
for (var label in hourLabels) {
|
||||
final position = label['position'] * size.width;
|
||||
final time = DateTime.fromMillisecondsSinceEpoch(label['time']);
|
||||
final hourText = DateFormat('h').format(time);
|
||||
final textSpan = TextSpan(text: hourText, style: textStyle);
|
||||
textPainter.text = textSpan;
|
||||
textPainter.layout();
|
||||
final offset = Offset(
|
||||
position - textPainter.width / 2,
|
||||
14.rpx, // Padding from bottom
|
||||
);
|
||||
textPainter.paint(canvas, offset);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
|
||||
}
|
||||
|
||||
48
lib/pages/sleep_report/chart/GradientLine.dart
Normal file
48
lib/pages/sleep_report/chart/GradientLine.dart
Normal file
@@ -0,0 +1,48 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class GradientLine extends StatelessWidget {
|
||||
final double height;
|
||||
final Color color;
|
||||
|
||||
const GradientLine({
|
||||
Key? key,
|
||||
this.height = 4.0,
|
||||
required this.color,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) {
|
||||
return CustomPaint(
|
||||
size: Size(constraints.maxWidth, height),
|
||||
painter: _GradientLinePainter(color: color),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class _GradientLinePainter extends CustomPainter {
|
||||
final Color color;
|
||||
|
||||
_GradientLinePainter({required this.color});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final Paint paint = Paint()
|
||||
..shader = LinearGradient(
|
||||
colors: [
|
||||
color.withOpacity(0.0), // 左端透明
|
||||
color.withOpacity(1.0), // 中间最深
|
||||
color.withOpacity(0.0), // 右端透明
|
||||
],
|
||||
stops: [0.0, 0.5, 1.0],
|
||||
).createShader(Rect.fromLTWH(0, 0, size.width, size.height));
|
||||
|
||||
canvas.drawRect(Rect.fromLTWH(0, 0, size.width, size.height), paint);
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => false;
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
|
||||
class SegmentData {
|
||||
final Color color;
|
||||
@@ -63,6 +62,7 @@ class SegmentedCircleWithCenterWidget extends StatelessWidget {
|
||||
final double strokeWidth;
|
||||
final double gapAngle;
|
||||
final Widget centerWidget;
|
||||
final int trend;
|
||||
|
||||
const SegmentedCircleWithCenterWidget({
|
||||
Key? key,
|
||||
@@ -70,6 +70,7 @@ class SegmentedCircleWithCenterWidget extends StatelessWidget {
|
||||
this.strokeWidth = 6.0,
|
||||
this.gapAngle = 4.0,
|
||||
required this.centerWidget,
|
||||
required this.trend,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
@@ -87,16 +88,27 @@ class SegmentedCircleWithCenterWidget extends StatelessWidget {
|
||||
),
|
||||
centerWidget, // 放置自定义的中心 Widget
|
||||
Positioned(
|
||||
bottom: 200.rpx,
|
||||
right: 60.rpx, // 放置在右侧
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/score_down.svg',
|
||||
width: 14.rpx,
|
||||
height: 22.rpx,
|
||||
color: themeController.currentColor.sc9,
|
||||
_getTrendIcon(trend),
|
||||
width: trend != 0 ? 14.rpx : 18.rpx,
|
||||
height: trend != 0 ? 22.rpx : 6.rpx,
|
||||
// color: themeController.currentColor.sc9,
|
||||
),
|
||||
),
|
||||
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String _getTrendIcon(int? trend) {
|
||||
switch (trend) {
|
||||
case 0:
|
||||
return 'assets/img/icon/score_equal.svg';
|
||||
case 1:
|
||||
return 'assets/img/icon/score_up.svg';
|
||||
default:
|
||||
return 'assets/img/icon/score_down.svg';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:fl_chart/fl_chart.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
|
||||
class SleepRadarChart extends StatelessWidget {
|
||||
final Map<String, double> today;
|
||||
final Map<String, double> yesterday;
|
||||
final List<Map<String, dynamic>> data;
|
||||
|
||||
const SleepRadarChart({
|
||||
Key? key,
|
||||
required this.today,
|
||||
required this.yesterday,
|
||||
}) : super(key: key);
|
||||
const SleepRadarChart({Key? key, required this.data}) : super(key: key);
|
||||
|
||||
// const SleepRadarChart({
|
||||
// Key? key,
|
||||
// required this.today,
|
||||
// required this.yesterday,
|
||||
// }) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -27,74 +30,48 @@ class SleepRadarChart extends StatelessWidget {
|
||||
}
|
||||
|
||||
Widget _buildRadarChart() {
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.3,
|
||||
child: RadarChart(
|
||||
RadarChartData(
|
||||
dataSets: [
|
||||
// 今日数据
|
||||
RadarDataSet(
|
||||
dataEntries: [
|
||||
RadarEntry(value: today['type1']!), // 呼吸暂停
|
||||
RadarEntry(value: today['type2']!), // 入睡时间
|
||||
RadarEntry(value: today['type3']!), // 离床次数
|
||||
RadarEntry(value: today['type4']!), // 深睡比例
|
||||
RadarEntry(value: today['type5']!), // 睡眠时长
|
||||
],
|
||||
borderColor: stringToColor("#00C1AA"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
// 昨日数据
|
||||
RadarDataSet(
|
||||
dataEntries: [
|
||||
RadarEntry(value: yesterday['type1']!), // 呼吸暂停
|
||||
RadarEntry(value: yesterday['type2']!), // 入睡时间
|
||||
RadarEntry(value: yesterday['type3']!), // 离床次数
|
||||
RadarEntry(value: yesterday['type4']!), // 深睡比例
|
||||
RadarEntry(value: yesterday['type5']!), // 睡眠时长
|
||||
],
|
||||
borderColor: stringToColor("#FFD251"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
],
|
||||
radarBackgroundColor: stringToColor("#343844"),
|
||||
radarBorderData:
|
||||
BorderSide(color: themeController.currentColor.sc4, width: 1),
|
||||
radarShape: RadarShape.polygon,
|
||||
titlePositionPercentageOffset: 0.2,
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
color: themeController.currentColor.sc3),
|
||||
getTitle: (index, angle) {
|
||||
switch (index) {
|
||||
case 0:
|
||||
return RadarChartTitle(text: '呼吸暂停');
|
||||
case 1:
|
||||
return RadarChartTitle(text: '入睡时间');
|
||||
case 2:
|
||||
return RadarChartTitle(text: '离床次数');
|
||||
case 3:
|
||||
return RadarChartTitle(text: '深睡比例');
|
||||
case 4:
|
||||
return RadarChartTitle(text: '睡眠时长');
|
||||
default:
|
||||
return const RadarChartTitle(text: '');
|
||||
}
|
||||
},
|
||||
tickCount: 5,
|
||||
ticksTextStyle:
|
||||
const TextStyle(color: Colors.transparent, fontSize: 10),
|
||||
// ticksColor: Colors.grey.shade300,
|
||||
gridBorderData: BorderSide(color: Colors.transparent, width: 1),
|
||||
tickBorderData:
|
||||
BorderSide(color: themeController.currentColor.sc4, width: 1),
|
||||
),
|
||||
swapAnimationDuration: const Duration(milliseconds: 400),
|
||||
return AspectRatio(
|
||||
aspectRatio: 1.3,
|
||||
child: RadarChart(
|
||||
RadarChartData(
|
||||
dataSets: [
|
||||
// 今日数据
|
||||
RadarDataSet(
|
||||
dataEntries: data.map((e) => RadarEntry(value: (e['t'] as num).toDouble())).toList(),
|
||||
borderColor: stringToColor("#00C1AA"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
// 昨日数据
|
||||
RadarDataSet(
|
||||
dataEntries: data.map((e) => RadarEntry(value: (e['y'] as num).toDouble())).toList(),
|
||||
borderColor: stringToColor("#FFD251"),
|
||||
borderWidth: 2,
|
||||
fillColor: Colors.transparent,
|
||||
entryRadius: 0,
|
||||
),
|
||||
],
|
||||
radarBackgroundColor: stringToColor("#343844"),
|
||||
radarBorderData: BorderSide(
|
||||
color: themeController.currentColor.sc4, width: 0.5.rpx),
|
||||
radarShape: RadarShape.polygon,
|
||||
titlePositionPercentageOffset: 0.2,
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
color: themeController.currentColor.sc3),
|
||||
getTitle: (index, angle) {
|
||||
return RadarChartTitle(text: data[index]['name'] ?? '未知'.tr);
|
||||
},
|
||||
tickCount: 5,
|
||||
ticksTextStyle: const TextStyle(color: Colors.transparent, fontSize: 10),
|
||||
gridBorderData: BorderSide(color: Colors.transparent, width: 1),
|
||||
tickBorderData: BorderSide(
|
||||
color: themeController.currentColor.sc4, width: 0.5.rpx),
|
||||
),
|
||||
);
|
||||
}
|
||||
swapAnimationDuration: const Duration(milliseconds: 400),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
273
lib/pages/sleep_report/chart/SnoreWaveform.dart
Normal file
273
lib/pages/sleep_report/chart/SnoreWaveform.dart
Normal file
@@ -0,0 +1,273 @@
|
||||
import 'dart:ui' as ui;
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
|
||||
class SnoreChartContainer extends StatelessWidget {
|
||||
final List<dynamic> snoreValues;
|
||||
final List<dynamic> barData;
|
||||
final List<dynamic> showLabel;
|
||||
final int startTime;
|
||||
final int endTime;
|
||||
|
||||
const SnoreChartContainer({
|
||||
required this.snoreValues,
|
||||
required this.barData,
|
||||
required this.showLabel,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
SnoreBarOverlay(
|
||||
barData: barData,
|
||||
showLabel: showLabel,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
),
|
||||
Container(height: 32.rpx),
|
||||
Container(
|
||||
height: 23.rpx,
|
||||
child: SnoreWaveform(
|
||||
snoreValues: snoreValues,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SnoreBarOverlay extends StatelessWidget {
|
||||
final List<dynamic> barData;
|
||||
final List<dynamic> showLabel; // ✅ 加入
|
||||
final int startTime;
|
||||
final int endTime;
|
||||
|
||||
const SnoreBarOverlay({
|
||||
required this.barData,
|
||||
required this.showLabel, // ✅ 加入
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
const double barHeight = 50;
|
||||
return SizedBox(
|
||||
height: barHeight,
|
||||
child: CustomPaint(
|
||||
size: Size(double.infinity, barHeight),
|
||||
painter: SnoreBarPainter(
|
||||
barData: barData,
|
||||
showLabel: showLabel, // ✅ 加入
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SnoreBarPainter extends CustomPainter {
|
||||
final List<dynamic> barData;
|
||||
final List<dynamic> showLabel; // ✅ 加入
|
||||
final int startTime;
|
||||
final int endTime;
|
||||
|
||||
SnoreBarPainter({
|
||||
required this.barData,
|
||||
required this.showLabel, // ✅ 加入
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final double width = size.width;
|
||||
final double height = size.height;
|
||||
final double pixelPerMs = width / (endTime - startTime);
|
||||
|
||||
for (var item in barData) {
|
||||
final int st = item['st'];
|
||||
final int et = item['et'];
|
||||
final int type = item['type'];
|
||||
|
||||
// 查找匹配的颜色
|
||||
final match = showLabel.firstWhere(
|
||||
(e) => e['type'] == type,
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
Color barColor = Colors.transparent;
|
||||
if (match != null) {
|
||||
final dynamic colorStr = match['color'];
|
||||
if (colorStr != null && colorStr.toString().isNotEmpty) {
|
||||
barColor = stringToColor(colorStr);
|
||||
}
|
||||
}
|
||||
|
||||
final Paint barPaint = Paint()
|
||||
..color = barColor
|
||||
..style = PaintingStyle.fill;
|
||||
|
||||
final double leftX = (st - startTime) * pixelPerMs;
|
||||
final double rightX = (et - startTime) * pixelPerMs;
|
||||
final double barWidth = rightX - leftX;
|
||||
|
||||
final double barHeight = (type + 5).toDouble() * 8;
|
||||
final double top = height - barHeight;
|
||||
|
||||
final rect = Rect.fromLTWH(leftX, top, barWidth, barHeight);
|
||||
canvas.drawRect(rect, barPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
|
||||
}
|
||||
|
||||
class SnoreWaveform extends StatelessWidget {
|
||||
final List<dynamic> snoreValues;
|
||||
final int startTime;
|
||||
final int endTime;
|
||||
|
||||
const SnoreWaveform({
|
||||
required this.snoreValues,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
super.key,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SizedBox(
|
||||
height: 150,
|
||||
child: CustomPaint(
|
||||
size: Size(double.infinity, 150),
|
||||
painter: SnoreWaveformPainter(
|
||||
snoreValues: snoreValues,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SnoreWaveformPainter extends CustomPainter {
|
||||
final List<dynamic> snoreValues;
|
||||
final int startTime;
|
||||
final int endTime;
|
||||
|
||||
SnoreWaveformPainter({
|
||||
required this.snoreValues,
|
||||
required this.startTime,
|
||||
required this.endTime,
|
||||
});
|
||||
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
final double width = size.width;
|
||||
final double height = size.height;
|
||||
final double centerY = height / 2;
|
||||
final double totalDuration = (endTime - startTime).toDouble();
|
||||
final double pixelPerMs = width / totalDuration;
|
||||
|
||||
final Paint wavePaint = Paint()
|
||||
..color = stringToColor("#8E7DEF")
|
||||
..strokeWidth = 1.5
|
||||
..style = PaintingStyle.stroke;
|
||||
|
||||
final Path upperPath = Path();
|
||||
final Path lowerPath = Path();
|
||||
const double scaleY = 0.5; //波形图比例
|
||||
|
||||
for (int i = 0; i < snoreValues.length; i++) {
|
||||
final timestamp = snoreValues[i]["st"];
|
||||
final value = snoreValues[i]["value"]?.toDouble() ?? 0;
|
||||
|
||||
final x = (timestamp - startTime) * pixelPerMs;
|
||||
final y = centerY - value * scaleY;
|
||||
final yMirror = centerY + value * scaleY;
|
||||
|
||||
if (i == 0) {
|
||||
upperPath.moveTo(x, y);
|
||||
lowerPath.moveTo(x, yMirror);
|
||||
} else {
|
||||
upperPath.lineTo(x, y);
|
||||
lowerPath.lineTo(x, yMirror);
|
||||
}
|
||||
}
|
||||
|
||||
canvas.drawPath(upperPath, wavePaint);
|
||||
canvas.drawPath(lowerPath, wavePaint);
|
||||
|
||||
final Paint axisPaint = Paint()
|
||||
..color = Colors.grey
|
||||
..strokeWidth = 0.5;
|
||||
|
||||
// 画中心线
|
||||
canvas.drawLine(Offset(0, centerY), Offset(width, centerY), axisPaint);
|
||||
|
||||
// 时间刻度绘制
|
||||
final textPainter = TextPainter(
|
||||
textAlign: TextAlign.center,
|
||||
textDirection: ui.TextDirection.ltr,
|
||||
);
|
||||
|
||||
final int hourMs = 60 * 60 * 1000;
|
||||
|
||||
// 循环绘制整点小时标签(不包含终点)
|
||||
for (int t = startTime; t < endTime; t += hourMs) {
|
||||
double x = (t - startTime) * pixelPerMs;
|
||||
|
||||
DateTime dt = DateTime.fromMillisecondsSinceEpoch(t);
|
||||
String label;
|
||||
if (t == startTime) {
|
||||
label = DateFormat('HH:mm').format(dt); // 起点显示 HH:mm
|
||||
} else {
|
||||
label = DateFormat('h').format(dt); // 中间显示小时,不带前导0
|
||||
}
|
||||
|
||||
textPainter.text = TextSpan(
|
||||
text: label,
|
||||
style: TextStyle(fontSize: 10, color: Colors.grey),
|
||||
);
|
||||
textPainter.layout();
|
||||
textPainter.paint(
|
||||
canvas,
|
||||
Offset(x - textPainter.width / 2, height + 20.rpx),
|
||||
);
|
||||
}
|
||||
|
||||
// 单独绘制终点时间标签,确保显示具体时分
|
||||
{
|
||||
double x = (endTime - startTime) * pixelPerMs;
|
||||
DateTime dt = DateTime.fromMillisecondsSinceEpoch(endTime);
|
||||
String label = DateFormat('HH:mm').format(dt);
|
||||
|
||||
textPainter.text = TextSpan(
|
||||
text: label,
|
||||
style: TextStyle(fontSize: 10, color: Colors.grey),
|
||||
);
|
||||
textPainter.layout();
|
||||
textPainter.paint(
|
||||
canvas,
|
||||
Offset(x - textPainter.width / 2, height + 20.rpx),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
bool shouldRepaint(covariant CustomPainter oldDelegate) => true;
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/AdviceComponnetWidget.dart';
|
||||
|
||||
class AIAdviceWidget extends StatefulWidget {
|
||||
AIAdviceWidget({super.key});
|
||||
var sleepReport;
|
||||
AIAdviceWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<AIAdviceWidget> createState() => _AIAdviceWidgetState();
|
||||
@@ -33,32 +34,12 @@ class _AIAdviceWidgetState extends State<AIAdviceWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List advices = [
|
||||
{
|
||||
"title": "调整作息时间",
|
||||
"description": "确保每天在相同的时间上床并醒来。保持规律的作息可以帮助调整你的生物钟,改善睡眠质量。",
|
||||
},
|
||||
{
|
||||
"title": "减少睡前刺激",
|
||||
"description": "避免在睡前使用电子设备,如手机、电脑等,减少屏幕时间,以防影响你的睡眠质量。",
|
||||
},
|
||||
{
|
||||
"title": "创造理想睡眠环境",
|
||||
"description": "确保卧室安静、黑暗且舒适。调节室温,并避免过于嘈杂或明亮的环境,帮助你快速入睡。",
|
||||
},
|
||||
{
|
||||
"title": "避免摄入咖啡因和酒精",
|
||||
"description": "避免在睡前几小时内摄入咖啡、茶、酒精等饮品,因为这些物质可能会干扰你的睡眠。",
|
||||
},
|
||||
{
|
||||
"title": "增加日间活动",
|
||||
"description": "适量的日间运动可以帮助提高睡眠质量,但要避免睡前剧烈运动,以免影响入睡。",
|
||||
},
|
||||
{
|
||||
"title": "放松身心",
|
||||
"description": "睡前可以进行一些放松活动,如深呼吸、冥想或听轻音乐,这有助于减轻压力并促进良好的睡眠。",
|
||||
},
|
||||
];
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['sugges'] == null ||
|
||||
widget.sleepReport['sugges'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
List advices = widget.sleepReport['sugges'];
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
@@ -126,8 +107,8 @@ class _AIAdviceWidgetState extends State<AIAdviceWidget> {
|
||||
child: Column(
|
||||
children: advices.map<Widget>((advice) {
|
||||
return AdviceComponnetWidget(
|
||||
title: advice["title"],
|
||||
description: advice["description"],
|
||||
title: advice["q"],
|
||||
description: advice["s"],
|
||||
).paddingOnly(bottom: 0.rpx); // 在每个组件下方添加间隔
|
||||
}).toList(),
|
||||
),
|
||||
|
||||
@@ -9,7 +9,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/DotBarChart.dart';
|
||||
|
||||
class BreathPauseWidget extends StatefulWidget {
|
||||
BreathPauseWidget({super.key});
|
||||
var sleepReport;
|
||||
BreathPauseWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<BreathPauseWidget> createState() => _BreathPauseWidgetState();
|
||||
@@ -33,33 +34,30 @@ class _BreathPauseWidgetState extends State<BreathPauseWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['asp'] == null ||
|
||||
widget.sleepReport['asp'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// List data = widget.sleepReport['asp'];
|
||||
// var showLabel = [
|
||||
// {"time": 1744547251000, "times": 20},
|
||||
// {"time": 1744550851000, "times": 50},
|
||||
// {"time": 1744554451000, "times": 20},
|
||||
// {"time": 1744558051000, "times": 30},
|
||||
// {"time": 1744561651000, "times": 20},
|
||||
// {"time": 1744565251000, "times": 10},
|
||||
// {"time": 1744568851000, "times": 20},
|
||||
// {"time": 1744572451000, "times": 20},
|
||||
// {"time": 1744583251000, "times": 100},
|
||||
// {"time": 1744586851000, "times": 20},
|
||||
// {"time": 1744547251000, "times": 25},
|
||||
// {"time": 1744550851000, "times": 27},
|
||||
// {"time": 1744554451000, "times": 40},
|
||||
// {"time": 1744558051000, "times": 28},
|
||||
// {"time": 1744561651000, "times": 15},
|
||||
// {"time": 1744565251000, "times": 48},
|
||||
// {"time": 1744568851000, "times": 25},
|
||||
// {"time": 1744572451000, "times": 17},
|
||||
// {"time": 1744583251000, "times": 35},
|
||||
// {"time": 1744586851000, "times": 40},
|
||||
// ];
|
||||
var showLabel = [
|
||||
{"time": 1744547251000, "times": 25},
|
||||
{"time": 1744550851000, "times": 27},
|
||||
{"time": 1744554451000, "times": 40},
|
||||
{"time": 1744558051000, "times": 28},
|
||||
{"time": 1744561651000, "times": 15},
|
||||
{"time": 1744565251000, "times": 48},
|
||||
{"time": 1744568851000, "times": 25},
|
||||
{"time": 1744572451000, "times": 17},
|
||||
{"time": 1744583251000, "times": 35},
|
||||
{"time": 1744586851000, "times": 40},
|
||||
];
|
||||
var threshold = 40;
|
||||
var startTime = 1744641151000;
|
||||
var endTime = 1744677151000;
|
||||
List data = widget.sleepReport['asp'];
|
||||
var showLabel = convertAspData(data);
|
||||
var threshold = 30;
|
||||
var startTime = widget.sleepReport['startTime'];
|
||||
var endTime = widget.sleepReport['endTime'];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -138,4 +136,13 @@ class _BreathPauseWidgetState extends State<BreathPauseWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertAspData(List data) {
|
||||
return data.map<Map<String, dynamic>>((item) {
|
||||
return {
|
||||
'time': item['st'],
|
||||
'times': item['value'],
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
69
lib/pages/sleep_report/component/BreatheCard.dart
Normal file
69
lib/pages/sleep_report/component/BreatheCard.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/home_page/SleepDataModuleWidget.dart';
|
||||
|
||||
class BreatheCard extends StatefulWidget {
|
||||
var sleepReport;
|
||||
BreatheCard({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<BreatheCard> createState() => _BreatheCardState();
|
||||
}
|
||||
|
||||
class _BreatheCardState extends State<BreatheCard> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List data = widget.sleepReport['brs'] ?? [];
|
||||
|
||||
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: Wrap(
|
||||
spacing: 23.rpx, // 横向间距(左右间距如需加可设置)
|
||||
runSpacing: 25.rpx, // 每行之间的垂直间距
|
||||
children: List.generate(data.length, (index) {
|
||||
final item = data[index];
|
||||
return SizedBox(
|
||||
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
|
||||
child: SleepDataModuleWidget(data: item),
|
||||
// child: Container(
|
||||
// width: 20,
|
||||
// height: 20,
|
||||
// color: Colors.red,
|
||||
// ),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
166
lib/pages/sleep_report/component/BreathePauseNewWidget.dart
Normal file
166
lib/pages/sleep_report/component/BreathePauseNewWidget.dart
Normal file
@@ -0,0 +1,166 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/LineChartByRange.dart';
|
||||
|
||||
class BreathePauseNewWidget extends StatefulWidget {
|
||||
var sleepReport;
|
||||
BreathePauseNewWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<BreathePauseNewWidget> createState() => _SnoreViewWidgetWidgetState();
|
||||
}
|
||||
|
||||
class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> data =
|
||||
(widget.sleepReport['asp'] as List).cast<Map<String, dynamic>>();
|
||||
List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
|
||||
var startTime = widget.sleepReport['startTime'];
|
||||
var endTime = widget.sleepReport['endTime'];
|
||||
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, 0.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(
|
||||
"呼吸暂停监测介绍。",
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 32.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: LineChartByRange(
|
||||
showLabel: showLabel,
|
||||
startTime: startTime,
|
||||
endTime: endTime,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 52.rpx,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertToShowLabel(
|
||||
List<Map<String, dynamic>> data) {
|
||||
if (data.isEmpty) return [];
|
||||
|
||||
data.sort((a, b) => a['st'].compareTo(b['st'])); // 确保时间有序
|
||||
|
||||
List<Map<String, dynamic>> result = [];
|
||||
|
||||
int startTime = data[0]['st'];
|
||||
int endTime = data[0]['st'];
|
||||
int currentValue = data[0]['value'];
|
||||
|
||||
for (int i = 1; i < data.length; i++) {
|
||||
final item = data[i];
|
||||
final st = item['st'];
|
||||
final value = item['value'];
|
||||
|
||||
if (value == currentValue) {
|
||||
endTime = st;
|
||||
} else {
|
||||
result.add({
|
||||
"startTime": startTime,
|
||||
"endTime": endTime,
|
||||
"times": currentValue,
|
||||
});
|
||||
startTime = st;
|
||||
endTime = st;
|
||||
currentValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加最后一段
|
||||
result.add({
|
||||
"startTime": startTime,
|
||||
"endTime": endTime,
|
||||
"times": currentValue,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/TimeSeriesChart.dart';
|
||||
|
||||
class BreatheStandardWidget extends StatefulWidget {
|
||||
BreatheStandardWidget({super.key});
|
||||
var sleepReport;
|
||||
BreatheStandardWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<BreatheStandardWidget> createState() => _BreatheStandardWidgetState();
|
||||
@@ -34,17 +35,29 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final now = DateTime.now();
|
||||
final startTime = now.subtract(Duration(hours: 5)).millisecondsSinceEpoch;
|
||||
final endTime = now.millisecondsSinceEpoch;
|
||||
final dataPoints = [
|
||||
TimeSeriesPoint(startTime + Duration(minutes: 10).inMilliseconds, 50),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 1).inMilliseconds, 120),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 2).inMilliseconds, 80),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 3).inMilliseconds, 180),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 4).inMilliseconds, 30),
|
||||
TimeSeriesPoint(endTime - Duration(minutes: 10).inMilliseconds, 150),
|
||||
];
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
final startTime = widget.sleepReport['startTime'];
|
||||
final endTime = widget.sleepReport['endTime'];
|
||||
List<Map<String, dynamic>> data =
|
||||
(widget.sleepReport['brbc'] as List).cast<Map<String, dynamic>>();
|
||||
// final dataPoints = [
|
||||
// TimeSeriesPoint(12121, 50),
|
||||
// TimeSeriesPoint(1212, 120),
|
||||
// TimeSeriesPoint(121, 80),
|
||||
// TimeSeriesPoint(1212, 180),
|
||||
// TimeSeriesPoint(1212, 30),
|
||||
// TimeSeriesPoint(1212, 150),
|
||||
// ];
|
||||
final dataPoints = data.map((item) {
|
||||
final x = item['st'] as int;
|
||||
final y = (item['value'] as num).toDouble(); // 安全地转换为 double
|
||||
return TimeSeriesPoint(x, y);
|
||||
}).toList();
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
|
||||
@@ -7,12 +7,11 @@ import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/AdviceComponnetWidget.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/RadarChart.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/SleepRadarChart.dart';
|
||||
|
||||
class CompareSleepWidget extends StatefulWidget {
|
||||
CompareSleepWidget({super.key});
|
||||
var sleepReport;
|
||||
CompareSleepWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<CompareSleepWidget> createState() => _CompareSleepWidgetState();
|
||||
@@ -36,20 +35,37 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var today = {
|
||||
"type1": 40.0,
|
||||
"type2": 80.0,
|
||||
"type3": 60.0,
|
||||
"type4": 70.0,
|
||||
"type5": 100.0
|
||||
};
|
||||
var yesterday = {
|
||||
"type1": 40.0,
|
||||
"type2": 90.0,
|
||||
"type3": 50.0,
|
||||
"type4": 70.0,
|
||||
"type5": 30.0
|
||||
};
|
||||
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();
|
||||
|
||||
// var today = {
|
||||
// "type1": 40.0,
|
||||
// "type2": 80.0,
|
||||
// "type3": 60.0,
|
||||
// "type4": 70.0,
|
||||
// "type5": 100.0
|
||||
// };
|
||||
// var yesterday = {
|
||||
// "type1": 40.0,
|
||||
// "type2": 90.0,
|
||||
// "type3": 50.0,
|
||||
// "type4": 70.0,
|
||||
// "type5": 30.0
|
||||
// };
|
||||
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(
|
||||
@@ -128,8 +144,9 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
child: SleepRadarChart(
|
||||
today: today,
|
||||
yesterday: yesterday,
|
||||
// today: today,
|
||||
// yesterday: yesterday,
|
||||
data: data,
|
||||
),
|
||||
),
|
||||
// 在左侧添加一个 Text
|
||||
|
||||
@@ -9,57 +9,59 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/HorizontalBarChart.dart';
|
||||
|
||||
class DiseasePercentsWidget extends StatefulWidget {
|
||||
DiseasePercentsWidget({super.key});
|
||||
var sleepReport;
|
||||
DiseasePercentsWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<DiseasePercentsWidget> createState() => _DiseasePercentsWidgetState();
|
||||
}
|
||||
|
||||
class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
|
||||
var showLabel = [
|
||||
{
|
||||
"key": 1,
|
||||
"name": "心脏病",
|
||||
"color": stringToColor("#00C1AA"),
|
||||
"percent": 45,
|
||||
"explain": "心脏病是指心脏的结构或功能异常,可能导致心脏无法有效地泵血。"
|
||||
},
|
||||
{
|
||||
"key": 2,
|
||||
"name": "高血压",
|
||||
"color": stringToColor("#00C1AA"),
|
||||
"percent": 32,
|
||||
"explain": "高血压是指血液在动脉中流动时对血管壁施加的压力过高。"
|
||||
},
|
||||
{
|
||||
"key": 3,
|
||||
"name": "糖尿病",
|
||||
"color": stringToColor("#00C1AA"),
|
||||
"percent": 50,
|
||||
"explain": "糖尿病是一种代谢性疾病,导致血糖水平异常升高。"
|
||||
},
|
||||
{
|
||||
"key": 4,
|
||||
"name": "甲亢",
|
||||
"color": stringToColor("#FF7159"),
|
||||
"percent": 80,
|
||||
"explain": "甲亢是指甲状腺分泌过多的甲状腺激素,导致新陈代谢加速。"
|
||||
},
|
||||
{
|
||||
"key": 5,
|
||||
"name": "消化系统",
|
||||
"color": stringToColor("#00C1AA"),
|
||||
"percent": 12,
|
||||
"explain": "消化系统是身体中处理食物的机构,是造成疾病和疾病症状的来源。",
|
||||
},
|
||||
{
|
||||
"key": 6,
|
||||
"name": "呼吸系统",
|
||||
"color": stringToColor("#00C1AA"),
|
||||
"percent": 62,
|
||||
"explain": "呼吸系统是负责气体交换的器官系统,包括鼻、喉、气管和肺等。",
|
||||
},
|
||||
];
|
||||
// var showLabel = [
|
||||
// {
|
||||
// "key": 1,
|
||||
// "name": "心脏病",
|
||||
// "color": stringToColor("#00C1AA"),
|
||||
// "percent": 45,
|
||||
// "explain": "心脏病是指心脏的结构或功能异常,可能导致心脏无法有效地泵血。"
|
||||
// },
|
||||
// {
|
||||
// "key": 2,
|
||||
// "name": "高血压",
|
||||
// "color": stringToColor("#00C1AA"),
|
||||
// "percent": 32,
|
||||
// "explain": "高血压是指血液在动脉中流动时对血管壁施加的压力过高。"
|
||||
// },
|
||||
// {
|
||||
// "key": 3,
|
||||
// "name": "糖尿病",
|
||||
// "color": stringToColor("#00C1AA"),
|
||||
// "percent": 50,
|
||||
// "explain": "糖尿病是一种代谢性疾病,导致血糖水平异常升高。"
|
||||
// },
|
||||
// {
|
||||
// "key": 4,
|
||||
// "name": "甲亢",
|
||||
// "color": stringToColor("#FF7159"),
|
||||
// "percent": 80,
|
||||
// "explain": "甲亢是指甲状腺分泌过多的甲状腺激素,导致新陈代谢加速。"
|
||||
// },
|
||||
// {
|
||||
// "key": 5,
|
||||
// "name": "消化系统",
|
||||
// "color": stringToColor("#00C1AA"),
|
||||
// "percent": 12,
|
||||
// "explain": "消化系统是身体中处理食物的机构,是造成疾病和疾病症状的来源。",
|
||||
// },
|
||||
// {
|
||||
// "key": 6,
|
||||
// "name": "呼吸系统",
|
||||
// "color": stringToColor("#00C1AA"),
|
||||
// "percent": 62,
|
||||
// "explain": "呼吸系统是负责气体交换的器官系统,包括鼻、喉、气管和肺等。",
|
||||
// },
|
||||
// ];
|
||||
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
@@ -77,6 +79,13 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['cdri'] == null ||
|
||||
widget.sleepReport['cdri'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
List diseaseData = widget.sleepReport['cdri'];
|
||||
var showLabel = convertDiseaseData(diseaseData);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -107,7 +116,7 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
// 你的点击逻辑
|
||||
showTipDialog(
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
@@ -149,4 +158,23 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertDiseaseData(List data) {
|
||||
return data.asMap().entries.map<Map<String, dynamic>>((entry) {
|
||||
final index = entry.key;
|
||||
final item = entry.value;
|
||||
|
||||
return {
|
||||
"key": item["id"],
|
||||
"name": item["name"],
|
||||
"color": item["id"] == 40004
|
||||
? stringToColor("#FF7159") // 特殊颜色处理
|
||||
: stringToColor("#00C1AA"),
|
||||
"percent": item["value"],
|
||||
"explain": (item["tips"] != null && (item["tips"] as String).trim().isNotEmpty)
|
||||
? item["tips"]
|
||||
: '未知数据'.tr,
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/DataShowWidget.dart';
|
||||
|
||||
class HeartChangeWidget extends StatefulWidget {
|
||||
HeartChangeWidget({super.key});
|
||||
var sleepReport;
|
||||
HeartChangeWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<HeartChangeWidget> createState() => _HeartChangeWidgetState();
|
||||
@@ -33,72 +34,80 @@ class _HeartChangeWidgetState extends State<HeartChangeWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['hrvs'] == null ||
|
||||
widget.sleepReport['hrvs'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List dataList = widget.sleepReport['hrvs'];
|
||||
//0上升 1下降 2持平
|
||||
List data = [
|
||||
{
|
||||
"name": "心脏总能量",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 0,
|
||||
"desc": "心脏总能量介绍"
|
||||
},
|
||||
{
|
||||
"name": "心率减速力",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 1,
|
||||
"desc": "心率减速力介绍"
|
||||
},
|
||||
{
|
||||
"name": "迷走神经张力指数",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 2,
|
||||
"desc": "迷走神经张力指数介绍"
|
||||
},
|
||||
{
|
||||
"name": "交感神经张力指数",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 0,
|
||||
"desc": "交感神经张力指数介绍"
|
||||
},
|
||||
{
|
||||
"name": "自主神经张力指数",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 2,
|
||||
"desc": "自主神经张力指数介绍"
|
||||
},
|
||||
{
|
||||
"name": "血管舒张指数",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 1,
|
||||
"desc": "血管舒张指数介绍"
|
||||
},
|
||||
{
|
||||
"name": "SDNN",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 0,
|
||||
"desc": "SDNN介绍"
|
||||
},
|
||||
{
|
||||
"name": "PNN50",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 1,
|
||||
"desc": "PNN50介绍"
|
||||
},
|
||||
{
|
||||
"name": "RMSSD",
|
||||
"value": 5262,
|
||||
"range": "2055-6000",
|
||||
"change": 2,
|
||||
"desc": "RMSSD介绍"
|
||||
},
|
||||
];
|
||||
// List data = [
|
||||
// {
|
||||
// "name": "心脏总能量",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 0,
|
||||
// "desc": "心脏总能量介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "心率减速力",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 1,
|
||||
// "desc": "心率减速力介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "迷走神经张力指数",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 2,
|
||||
// "desc": "迷走神经张力指数介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "交感神经张力指数",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 0,
|
||||
// "desc": "交感神经张力指数介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "自主神经张力指数",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 2,
|
||||
// "desc": "自主神经张力指数介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "血管舒张指数",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 1,
|
||||
// "desc": "血管舒张指数介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "SDNN",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 0,
|
||||
// "desc": "SDNN介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "PNN50",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 1,
|
||||
// "desc": "PNN50介绍"
|
||||
// },
|
||||
// {
|
||||
// "name": "RMSSD",
|
||||
// "value": 5262,
|
||||
// "range": "2055-6000",
|
||||
// "change": 2,
|
||||
// "desc": "RMSSD介绍"
|
||||
// },
|
||||
// ];
|
||||
List<Map<String, dynamic>> data = transformHrvData(dataList);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -313,4 +322,18 @@ class _HeartChangeWidgetState extends State<HeartChangeWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> transformHrvData(List<dynamic> originalData) {
|
||||
return originalData.map((item) {
|
||||
return {
|
||||
"name": item["name"] ?? "未知指标".tr,
|
||||
"value": (item["value"] is num) ? item["value"].toDouble() : 0.0,
|
||||
"range": item["range"] ?? "0-0",
|
||||
"change": item["trend"] ?? 0,
|
||||
"desc": item["tips"]?.toString().isNotEmpty == true
|
||||
? item["tips"].toString()
|
||||
: "未知数据".tr
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/FatigueCircleIndicator.dart';
|
||||
|
||||
class HeartHealthWidget extends StatefulWidget {
|
||||
HeartHealthWidget({super.key});
|
||||
var sleepReport;
|
||||
HeartHealthWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<HeartHealthWidget> createState() => _HeartHealthWidgetState();
|
||||
@@ -34,20 +35,14 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var showLabel = [
|
||||
{
|
||||
"name": "焦虑抑郁",
|
||||
"color": Color(0xFF4CAF50),
|
||||
"percent": "7%",
|
||||
"explain": "低风险"
|
||||
},
|
||||
{
|
||||
"name": "过度疲劳",
|
||||
"color": stringToColor("#FF7159"),
|
||||
"percent": "69%",
|
||||
"explain": "高风险"
|
||||
},
|
||||
];
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['mha'] == null ||
|
||||
widget.sleepReport['mha'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List data = widget.sleepReport['mha'];
|
||||
var showLabel = convertMentalHealthData(data);
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -115,22 +110,10 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
FatigueCircleIndicator(
|
||||
data: {
|
||||
"name": "焦虑抑郁",
|
||||
"color": stringToColor("#00C1AA"),
|
||||
"percent": 7,
|
||||
"explain": "低风险",
|
||||
"bottomColor": Colors.grey,
|
||||
},
|
||||
data: showLabel[0],
|
||||
),
|
||||
FatigueCircleIndicator(
|
||||
data: {
|
||||
"name": "过度疲劳",
|
||||
"color": stringToColor("#FF7159"),
|
||||
"percent": 69,
|
||||
"explain": "高风险",
|
||||
"bottomColor": Colors.grey,
|
||||
},
|
||||
data: showLabel[1],
|
||||
),
|
||||
].divide(SizedBox(
|
||||
width: 110.rpx,
|
||||
@@ -145,4 +128,25 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertMentalHealthData(List data) {
|
||||
return data.map<Map<String, dynamic>>((item) {
|
||||
final String? colorStr = item['color'];
|
||||
final int value = item['value'] ?? 0;
|
||||
final String explain =
|
||||
(item['tips'] != null && (item['tips'] as String).trim().isNotEmpty)
|
||||
? item['tips']
|
||||
: '高风险';
|
||||
|
||||
return {
|
||||
'name': item['name'],
|
||||
'color': colorStr != null && colorStr.isNotEmpty
|
||||
? stringToColor(colorStr)
|
||||
: stringToColor("#00C1AA"), // 默认红色
|
||||
'percent': value,
|
||||
'explain': explain,
|
||||
"bottomColor": Colors.grey,
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/ScatterPlotChart.dart';
|
||||
|
||||
class HeartPointWidget extends StatefulWidget {
|
||||
HeartPointWidget({super.key});
|
||||
var sleepReport;
|
||||
HeartPointWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<HeartPointWidget> createState() => _HeartPointWidgetState();
|
||||
@@ -36,17 +37,39 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<ScatterSpot> data = List.generate(200, (index) {
|
||||
// 随机生成 x 和 y 值,范围都在 0-1400 之间
|
||||
double x = Random().nextDouble() * 1400; // x 值在 0-1400 范围
|
||||
double y = Random().nextDouble() * 1400; // y 值也在 0-1400 范围
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['hrsp'] == null ||
|
||||
widget.sleepReport['hrsp'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
// List rawData = widget.sleepReport['hrsp'];
|
||||
// List<ScatterSpot> data = List.generate(200, (index) {
|
||||
// // 随机生成 x 和 y 值,范围都在 0-1400 之间
|
||||
// double x = Random().nextDouble() * 1400; // x 值在 0-1400 范围
|
||||
// double y = Random().nextDouble() * 1400; // y 值也在 0-1400 范围
|
||||
|
||||
// 返回 ScatterSpot,使用圆点绘制器自定义大小和颜色
|
||||
return ScatterSpot(
|
||||
x,
|
||||
y,
|
||||
);
|
||||
});
|
||||
// // 返回 ScatterSpot,使用圆点绘制器自定义大小和颜色
|
||||
// return ScatterSpot(
|
||||
// x,
|
||||
// y,
|
||||
// );
|
||||
// });
|
||||
double maxX = 0;
|
||||
double maxY = 0;
|
||||
|
||||
List<ScatterSpot> data = [];
|
||||
List rawData = widget.sleepReport['hrsp'];
|
||||
try {
|
||||
data = rawData.map<ScatterSpot>((item) {
|
||||
double x = (item['st'] ?? 0).toDouble();
|
||||
double y = (item['value'] ?? 0).toDouble();
|
||||
if (x > maxX) maxX = x;
|
||||
if (y > maxY) maxY = y;
|
||||
return ScatterSpot(x, y);
|
||||
}).toList();
|
||||
} catch (e) {
|
||||
print(e);
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
@@ -120,8 +143,8 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
|
||||
),
|
||||
child: ScatterPlotChart(
|
||||
points: data,
|
||||
xMax: 1400, // x轴最大值
|
||||
yMax: 1400, // y轴最大值
|
||||
xMax: maxX.toInt(), // x轴最大值
|
||||
yMax: maxY.toInt(), // y轴最大值
|
||||
pointColor: stringToColor("#00C1AA"), // 点的颜色
|
||||
divisions: 7, // 刻度分割数量
|
||||
),
|
||||
|
||||
69
lib/pages/sleep_report/component/HeartRateCard.dart
Normal file
69
lib/pages/sleep_report/component/HeartRateCard.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/home_page/SleepDataModuleWidget.dart';
|
||||
|
||||
class HeartRateCard extends StatefulWidget {
|
||||
var sleepReport;
|
||||
HeartRateCard({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<HeartRateCard> createState() => _HeartRateCardState();
|
||||
}
|
||||
|
||||
class _HeartRateCardState extends State<HeartRateCard> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List data = widget.sleepReport['hrs'] ?? [];
|
||||
|
||||
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: Wrap(
|
||||
spacing: 23.rpx, // 横向间距(左右间距如需加可设置)
|
||||
runSpacing: 25.rpx, // 每行之间的垂直间距
|
||||
children: List.generate(data.length, (index) {
|
||||
final item = data[index];
|
||||
return SizedBox(
|
||||
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
|
||||
child: SleepDataModuleWidget(data: item),
|
||||
// child: Container(
|
||||
// width: 20,
|
||||
// height: 20,
|
||||
// color: Colors.red,
|
||||
// ),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/TimeSeriesChart.dart';
|
||||
|
||||
class HeartRateStandardWidget extends StatefulWidget {
|
||||
HeartRateStandardWidget({super.key});
|
||||
var sleepReport;
|
||||
HeartRateStandardWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<HeartRateStandardWidget> createState() =>
|
||||
@@ -35,17 +36,22 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final now = DateTime.now();
|
||||
final startTime = now.subtract(Duration(hours: 5)).millisecondsSinceEpoch;
|
||||
final endTime = now.millisecondsSinceEpoch;
|
||||
final dataPoints = [
|
||||
TimeSeriesPoint(startTime + Duration(minutes: 10).inMilliseconds, 50),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 1).inMilliseconds, 120),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 2).inMilliseconds, 80),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 3).inMilliseconds, 180),
|
||||
TimeSeriesPoint(startTime + Duration(hours: 4).inMilliseconds, 30),
|
||||
TimeSeriesPoint(endTime - Duration(minutes: 10).inMilliseconds, 150),
|
||||
];
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
final startTime = widget.sleepReport['startTime'];
|
||||
final endTime = widget.sleepReport['endTime'];
|
||||
List<Map<String, dynamic>> data =
|
||||
(widget.sleepReport['hrbc'] as List).cast<Map<String, dynamic>>();
|
||||
final dataPoints = data.map((item) {
|
||||
final x = item['st'] as int;
|
||||
final y = (item['value'] as num).toDouble(); // 安全地转换为 double
|
||||
return TimeSeriesPoint(x, y);
|
||||
}).toList();
|
||||
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
|
||||
@@ -9,7 +9,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
|
||||
|
||||
class SkinPercentWidget extends StatefulWidget {
|
||||
SkinPercentWidget({super.key});
|
||||
var sleepReport;
|
||||
SkinPercentWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<SkinPercentWidget> createState() => _SkinPercentWidgetState();
|
||||
@@ -33,6 +34,31 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['sicp'] == null ||
|
||||
widget.sleepReport['sicp'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
int id = 100001;
|
||||
List data = widget.sleepReport['sicp'];
|
||||
final target = data.firstWhere(
|
||||
(element) => element['id'] == id,
|
||||
orElse: () => null, // 如果没有找到,返回 null(你也可以抛异常或用 {} 替代)
|
||||
);
|
||||
|
||||
if (target == null) {
|
||||
return Container();
|
||||
}
|
||||
List<Map<String, dynamic>> showLabel = [];
|
||||
if (target != null && target['type'] is List) {
|
||||
showLabel = (target['type'] as List).map<Map<String, dynamic>>((item) {
|
||||
return {
|
||||
'key': item['type'],
|
||||
'name': item['name'],
|
||||
'color': stringToColor(item['color']),
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -62,7 +88,7 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
|
||||
14.rpx, 0.rpx, 14.rpx, 0), //
|
||||
borderRadius: 0.rpx, // 圆形点击区域
|
||||
onTap: () {
|
||||
showTipDialog(
|
||||
showTipDialog(
|
||||
context,
|
||||
Container(
|
||||
child: Text(
|
||||
@@ -97,13 +123,8 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: StatusBarWithIndicator(
|
||||
selectKey: 2,
|
||||
showLabel: [
|
||||
{"key": 1, "name": "正常", "color": Color(0xFF4CAF50)},
|
||||
{"key": 2, "name": "一般", "color": Color(0xFF8BC34A)},
|
||||
{"key": 3, "name": "注意", "color": Color(0xFFFFC107)},
|
||||
{"key": 4, "name": "警告", "color": Color(0xFFF44336)},
|
||||
],
|
||||
selectKey: target['value'],
|
||||
showLabel: showLabel,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
69
lib/pages/sleep_report/component/SleepCard.dart
Normal file
69
lib/pages/sleep_report/component/SleepCard.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/home_page/SleepDataModuleWidget.dart';
|
||||
|
||||
class SleepCard extends StatefulWidget {
|
||||
var sleepReport;
|
||||
SleepCard({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<SleepCard> createState() => _SleepCardState();
|
||||
}
|
||||
|
||||
class _SleepCardState extends State<SleepCard> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List data = widget.sleepReport['bs'] ?? [];
|
||||
|
||||
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: Wrap(
|
||||
spacing: 23.rpx, // 横向间距(左右间距如需加可设置)
|
||||
runSpacing: 25.rpx, // 每行之间的垂直间距
|
||||
children: List.generate(data.length, (index) {
|
||||
final item = data[index];
|
||||
return SizedBox(
|
||||
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
|
||||
child: SleepDataModuleWidget(data: item),
|
||||
// child: Container(
|
||||
// width: 20,
|
||||
// height: 20,
|
||||
// color: Colors.red,
|
||||
// ),
|
||||
);
|
||||
}),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutterflow_ui/flutterflow_ui.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
@@ -6,7 +7,8 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/SegmentedCirclePainter.dart';
|
||||
|
||||
class SleepScoreWidget extends StatefulWidget {
|
||||
const SleepScoreWidget({super.key});
|
||||
var sleepReport;
|
||||
SleepScoreWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<SleepScoreWidget> createState() => _SleepScoreWidgetState();
|
||||
@@ -30,12 +32,21 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
List<Map<String, dynamic>> showLabel = [
|
||||
{"level": 1, "name": "优秀(≥85)", "color": Color(0xFF4CAF50)},
|
||||
{"level": 2, "name": "良好(75~84)", "color": Color(0xFF8BC34A)},
|
||||
{"level": 3, "name": "合格(60~74)", "color": Color(0xFFFFC107)},
|
||||
{"level": 4, "name": "注意(<60)", "color": Color(0xFFF44336)},
|
||||
];
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
// List<Map<String, dynamic>> showLabel = [
|
||||
// {"level": 1, "name": "优秀(≥85)", "color": Color(0xFF4CAF50)},
|
||||
// {"level": 2, "name": "良好(75~84)", "color": Color(0xFF8BC34A)},
|
||||
// {"level": 3, "name": "合格(60~74)", "color": Color(0xFFFFC107)},
|
||||
// {"level": 4, "name": "注意(<60)", "color": Color(0xFFF44336)},
|
||||
// ];
|
||||
List showLabel = widget.sleepReport['score']['type'];
|
||||
List stages = widget.sleepReport['score']['stages'];
|
||||
List<SegmentData> segments = parseSegments(widget.sleepReport);
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
// decoration: BoxDecoration(color: Colors.green),
|
||||
@@ -57,7 +68,7 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'30天平均分',
|
||||
'30天平均分'.tr,
|
||||
style: TextStyle(
|
||||
color: Color(0xFFD3D3D3),
|
||||
fontSize: 26.rpx,
|
||||
@@ -65,7 +76,7 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'79',
|
||||
'${widget.sleepReport['score']?['avg']}',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 48.rpx,
|
||||
@@ -79,12 +90,13 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
child: Container(
|
||||
decoration: BoxDecoration(),
|
||||
child: SegmentedCircleWithCenterWidget(
|
||||
segments: [
|
||||
SegmentData(color: Colors.red, value: 30),
|
||||
SegmentData(color: Colors.green, value: 20),
|
||||
SegmentData(color: Colors.blue, value: 40),
|
||||
SegmentData(color: Colors.orange, value: 10),
|
||||
],
|
||||
// segments: [
|
||||
// SegmentData(color: Colors.red, value: 30),
|
||||
// SegmentData(color: Colors.green, value: 20),
|
||||
// SegmentData(color: Colors.blue, value: 40),
|
||||
// SegmentData(color: Colors.orange, value: 10),
|
||||
// ],
|
||||
segments: segments,
|
||||
strokeWidth: 8,
|
||||
gapAngle: 8,
|
||||
centerWidget: Container(
|
||||
@@ -92,14 +104,14 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
"睡眠评分",
|
||||
"睡眠评分".tr,
|
||||
style: TextStyle(
|
||||
color: stringToColor("#FFFFFF"),
|
||||
fontSize:
|
||||
AppConstants().normal_text_fontSize),
|
||||
),
|
||||
Text(
|
||||
"65",
|
||||
'${widget.sleepReport['score']?['score']}',
|
||||
style: TextStyle(
|
||||
color: stringToColor("#FF9F66"),
|
||||
fontSize: 100.rpx),
|
||||
@@ -107,6 +119,7 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
],
|
||||
),
|
||||
),
|
||||
trend: widget.sleepReport['score']?['trend'],
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -117,7 +130,7 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Text(
|
||||
'睡眠等级',
|
||||
'睡眠等级'.tr,
|
||||
style: TextStyle(
|
||||
color: Color(0xFFD3D3D3),
|
||||
fontSize: 26.rpx,
|
||||
@@ -125,7 +138,7 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'合格',
|
||||
'${getSleepLevel(widget.sleepReport)}',
|
||||
style: TextStyle(
|
||||
color: stringToColor("#FF9F66"),
|
||||
fontSize: 48.rpx,
|
||||
@@ -153,13 +166,13 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
width: 20.rpx,
|
||||
height: 20.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: item["color"],
|
||||
color: stringToColor("${item["color"]}"),
|
||||
borderRadius: BorderRadius.circular(10.rpx),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 17.rpx),
|
||||
Text(
|
||||
item["name"],
|
||||
item["name"] + '(' + item['range'] + ")",
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.rpx,
|
||||
@@ -175,4 +188,54 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
//获取睡眠等级
|
||||
String getSleepLevel(sleepReport) {
|
||||
if (sleepReport == null ||
|
||||
sleepReport['score'] == null ||
|
||||
sleepReport['score']['level'] == null ||
|
||||
sleepReport['score']['type'] == null) {
|
||||
return "未知数据".tr;
|
||||
}
|
||||
|
||||
int level = sleepReport['score']['level'];
|
||||
List<dynamic> typeList = sleepReport['score']['type'];
|
||||
|
||||
// 在 typeList 中查找 level 匹配的项
|
||||
var matched = typeList.firstWhere(
|
||||
(item) => item['level'] == level,
|
||||
orElse: () => null,
|
||||
);
|
||||
|
||||
if (matched != null && matched['name'] != null) {
|
||||
return matched['name'];
|
||||
}
|
||||
return "未知数据".tr;
|
||||
}
|
||||
|
||||
List<SegmentData> parseSegments(Map sleepReport) {
|
||||
try {
|
||||
List stages = sleepReport['score']['stages'] ?? [];
|
||||
List typeList = sleepReport['sleepData']['type'] ?? [];
|
||||
|
||||
Map<int, Color> typeColorMap = {
|
||||
for (var item in typeList)
|
||||
if (item['type'] != null && item['color'] != null)
|
||||
item['type']: stringToColor(item['color'])
|
||||
};
|
||||
|
||||
// 构造 segments 列表
|
||||
List<SegmentData> segments = stages.map<SegmentData>((stage) {
|
||||
int type = stage['type'];
|
||||
double value = (stage['per'] ?? 0).toDouble();
|
||||
Color color = typeColorMap[type] ?? Colors.grey; // fallback 灰色
|
||||
|
||||
return SegmentData(color: color, value: value);
|
||||
}).toList();
|
||||
|
||||
return segments;
|
||||
} catch (e) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
388
lib/pages/sleep_report/component/SleepView.dart
Normal file
388
lib/pages/sleep_report/component/SleepView.dart
Normal file
@@ -0,0 +1,388 @@
|
||||
import 'package:ef/ef.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:vbvs_app/common/color/appConstants.dart';
|
||||
import 'package:vbvs_app/common/util/FitTool.dart';
|
||||
import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
|
||||
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/GradientLine.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/SnoreWaveform.dart';
|
||||
|
||||
//睡眠规律性
|
||||
class SleepViewWidget extends StatefulWidget {
|
||||
var sleepReport;
|
||||
SleepViewWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<SleepViewWidget> createState() => _SleepViewWidgetState();
|
||||
}
|
||||
|
||||
class _SleepViewWidgetState extends State<SleepViewWidget> {
|
||||
@override
|
||||
void setState(VoidCallback callback) {
|
||||
super.setState(callback);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
// List showLabel = widget.sleepReport['sleepData']['type'];
|
||||
List showLabel = widget.sleepReport['sleepData']['type']
|
||||
.where((item) => item['show'] != false)
|
||||
.toList();
|
||||
|
||||
// final snoreValues = generateSnoreValues(
|
||||
// widget.sleepReport['startTime'],
|
||||
// widget.sleepReport['endTime'],
|
||||
// );
|
||||
List snoreValues = widget.sleepReport['ssp'];
|
||||
Map time = MyUtils.diffHoursMinutesMap(
|
||||
widget.sleepReport['startTime'], widget.sleepReport['endTime']);
|
||||
int hour = time['hours'];
|
||||
int minutes = time['minutes'];
|
||||
// List stages = [
|
||||
// {"et": 1748011592746, "st": 1748010870326, "type": 1},
|
||||
// {"et": 1748013519534, "st": 1748011593746, "type": 2},
|
||||
// {"et": 1748013639534, "st": 1748013520534, "type": 1},
|
||||
// {"et": 1748014183143, "st": 1748013640534, "type": 2},
|
||||
// {"et": 1748014363143, "st": 1748014184143, "type": 1},
|
||||
// {"et": 1748014423143, "st": 1748014364143, "type": 2},
|
||||
// {"et": 1748014541143, "st": 1748014424143, "type": 1},
|
||||
// {"et": 1748015439477, "st": 1748014542143, "type": 0},
|
||||
// {"et": 1748018470415, "st": 1748015440477, "type": 1},
|
||||
// {"et": 1748019755726, "st": 1748018471415, "type": 2},
|
||||
// {"et": 1748020123225, "st": 1748019756726, "type": 1},
|
||||
// {"et": 1748021138809, "st": 1748020124225, "type": 2},
|
||||
// {"et": 1748021535809, "st": 1748021139809, "type": 1},
|
||||
// {"et": 1748021776809, "st": 1748021536809, "type": 2},
|
||||
// {"et": 1748022140117, "st": 1748021777809, "type": 1},
|
||||
// {"et": 1748022320117, "st": 1748022141117, "type": 2},
|
||||
// {"et": 1748022996627, "st": 1748022321117, "type": 1},
|
||||
// {"et": 1748023439627, "st": 1748022997627, "type": 2},
|
||||
// {"et": 1748023812173, "st": 1748023440627, "type": 1},
|
||||
// {"et": 1748023895173, "st": 1748023813173, "type": 2},
|
||||
// {"et": 1748024692483, "st": 1748023896173, "type": 1},
|
||||
// {"et": 1748024960483, "st": 1748024693483, "type": 2},
|
||||
// {"et": 1748025678983, "st": 1748024961483, "type": 1},
|
||||
// {"et": 1748026351585, "st": 1748025679983, "type": 2},
|
||||
// {"et": 1748027131585, "st": 1748026352585, "type": 1},
|
||||
// {"et": 1748027209585, "st": 1748027132585, "type": 2},
|
||||
// {"et": 1748027487864, "st": 1748027210585, "type": 1},
|
||||
// {"et": 1748027967864, "st": 1748027488864, "type": 3},
|
||||
// {"et": 1748028182371, "st": 1748027968864, "type": 1},
|
||||
// {"et": 1748028372371, "st": 1748028183371, "type": 2},
|
||||
// {"et": 1748029109981, "st": 1748028373371, "type": 1},
|
||||
// {"et": 1748029958223, "st": 1748029110981, "type": 2},
|
||||
// {"et": 1748030792223, "st": 1748029959223, "type": 1},
|
||||
// {"et": 1748030874723, "st": 1748030793223, "type": 2},
|
||||
// {"et": 1748032042305, "st": 1748030875723, "type": 1},
|
||||
// {"et": 1748032170305, "st": 1748032043305, "type": 2},
|
||||
// {"et": 1748033387611, "st": 1748032171305, "type": 1},
|
||||
// {"et": 1748033967118, "st": 1748033388611, "type": 2},
|
||||
// {"et": 1748034087118, "st": 1748033968118, "type": 1},
|
||||
// {"et": 1748034147118, "st": 1748034088118, "type": 2},
|
||||
// {"et": 1748034327118, "st": 1748034148118, "type": 1},
|
||||
// {"et": 1748034930672, "st": 1748034328118, "type": 2},
|
||||
// {"et": 1748035230672, "st": 1748034931672, "type": 1},
|
||||
// {"et": 1748035353974, "st": 1748035231672, "type": 2},
|
||||
// {"et": 1748036710471, "st": 1748035354974, "type": 1},
|
||||
// {"et": 1748037126471, "st": 1748036711471, "type": 2},
|
||||
// {"et": 1748037310051, "st": 1748037127471, "type": 1},
|
||||
// {"et": 1748037380051, "st": 1748037311051, "type": 2},
|
||||
// {"et": 1748038881358, "st": 1748037381051, "type": 1},
|
||||
// {"et": 1748038962867, "st": 1748038882358, "type": 0},
|
||||
// {"et": 1748039291867, "st": 1748038963867, "type": 1},
|
||||
// {"et": 1748039684867, "st": 1748039292867, "type": 0}
|
||||
// ];
|
||||
List stages = widget.sleepReport['sleepData']['stages'];
|
||||
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(
|
||||
"睡眠规律性介绍。",
|
||||
style: TextStyle(
|
||||
fontSize: 26.rpx,
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
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,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 83.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.end,
|
||||
children: [
|
||||
// 左侧 - 入睡时间
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/img/moon.png",
|
||||
width: 43.rpx,
|
||||
height: 43.rpx,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
SizedBox(height: 33.rpx),
|
||||
Container(
|
||||
height: 40.rpx,
|
||||
child: Text(
|
||||
"${MyUtils.formatToHHmm(widget.sleepReport['startTime'])}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.rpx),
|
||||
Text(
|
||||
"入睡时间".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
|
||||
// 中间 - 渐变线 + 时间
|
||||
Expanded(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
height: 43.rpx,
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
GradientLine(
|
||||
height: 1,
|
||||
color: Colors.white60,
|
||||
),
|
||||
],
|
||||
)),
|
||||
SizedBox(height: 33.rpx), // 与图标对齐
|
||||
Text.rich(
|
||||
TextSpan(
|
||||
children: [
|
||||
TextSpan(
|
||||
text: "$hour",
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc2, // 小时数字颜色
|
||||
fontSize: 36.rpx, // 小时数字字号
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: "小时",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize,
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: "$minutes",
|
||||
style: TextStyle(
|
||||
color: themeController
|
||||
.currentColor.sc2, // 小时数字颜色
|
||||
fontSize: 36.rpx, // 分钟数字字号
|
||||
),
|
||||
),
|
||||
TextSpan(
|
||||
text: "分钟",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().title_text_fontSize,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
SizedBox(height: 20.rpx),
|
||||
Text(
|
||||
"睡眠时长".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
// 右侧 - 起床时间图标
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Image.asset(
|
||||
"assets/img/sun.png",
|
||||
width: 43.rpx,
|
||||
height: 43.rpx,
|
||||
fit: BoxFit.cover,
|
||||
),
|
||||
SizedBox(height: 33.rpx),
|
||||
Container(
|
||||
height: 40.rpx,
|
||||
child: Text(
|
||||
"${MyUtils.formatToHHmm(widget.sleepReport['endTime'])}",
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc3,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 20.rpx),
|
||||
Text(
|
||||
"起床时间".tr,
|
||||
style: TextStyle(
|
||||
color: themeController.currentColor.sc4,
|
||||
fontSize: AppConstants().normal_text_fontSize,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 49.rpx,
|
||||
),
|
||||
Padding(
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(26.rpx, 0.rpx, 26.rpx, 0.rpx),
|
||||
child: SnoreChartContainer(
|
||||
snoreValues: snoreValues,
|
||||
barData: stages,
|
||||
startTime: widget.sleepReport['startTime'],
|
||||
endTime: widget.sleepReport['endTime'],
|
||||
showLabel: showLabel,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
height: 70.rpx,
|
||||
),
|
||||
Wrap(
|
||||
spacing: 55.rpx,
|
||||
runSpacing: 20.rpx,
|
||||
children: showLabel.map<Widget>((item) {
|
||||
return Container(
|
||||
padding: EdgeInsets.all(5.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
width: 20.rpx,
|
||||
height: 20.rpx,
|
||||
decoration: BoxDecoration(
|
||||
color: item["color"] == null || item["color"] == ""
|
||||
? Colors.transparent
|
||||
: stringToColor(item["color"]),
|
||||
borderRadius: BorderRadius.circular(10.rpx),
|
||||
),
|
||||
),
|
||||
SizedBox(width: 17.rpx),
|
||||
Text(
|
||||
item["name"],
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 24.rpx,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> generateSnoreValues(int startTime, int endTime) {
|
||||
final int count = 100;
|
||||
final int interval = ((endTime - startTime) / count).floor();
|
||||
|
||||
return List.generate(count, (index) {
|
||||
final timestamp = startTime + interval * index;
|
||||
final value =
|
||||
(2 + 1 * (index % 7) / 6.0) * (index % 2 == 0 ? 1 : -1); // 示例上下对称波动
|
||||
return {
|
||||
"timestamp": timestamp,
|
||||
"value": double.parse(value.toStringAsFixed(2)),
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/LineChartByRange.dart';
|
||||
|
||||
class SnoreViewWidgetWidget extends StatefulWidget {
|
||||
SnoreViewWidgetWidget({super.key});
|
||||
var sleepReport;
|
||||
SnoreViewWidgetWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<SnoreViewWidgetWidget> createState() => _SnoreViewWidgetWidgetState();
|
||||
@@ -33,17 +34,17 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
var showLabel = [
|
||||
{"startTime": 1744644751000, "endTime": 1744648351000, "times": 25},
|
||||
{"startTime": 1744650031000, "endTime": 1744653631000, "times": 27},
|
||||
{"startTime": 1744655011000, "endTime": 1744662211000, "times": 60},
|
||||
// {"startTime": 1744657291000, "endTime": 1744657411000, "times": 28},
|
||||
// {"startTime": 1744661011000, "endTime": 1744661131000, "times": 15},
|
||||
// {"startTime": 1744668331000, "endTime": 1744668511000, "times": 48},
|
||||
// {"startTime": 1744673431000, "endTime": 1744673551000, "times": 25},
|
||||
];
|
||||
var startTime = 1744641151000;
|
||||
var endTime = 1744677151000;
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport is! Map ||
|
||||
widget.sleepReport.isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> data =
|
||||
(widget.sleepReport['ssp'] as List).cast<Map<String, dynamic>>();
|
||||
List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
|
||||
var startTime = widget.sleepReport['startTime'];
|
||||
var endTime = widget.sleepReport['endTime'];
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -121,4 +122,45 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
List<Map<String, dynamic>> convertToShowLabel(
|
||||
List<Map<String, dynamic>> data) {
|
||||
if (data.isEmpty) return [];
|
||||
|
||||
data.sort((a, b) => a['st'].compareTo(b['st'])); // 确保时间有序
|
||||
|
||||
List<Map<String, dynamic>> result = [];
|
||||
|
||||
int startTime = data[0]['st'];
|
||||
int endTime = data[0]['st'];
|
||||
int currentValue = data[0]['value'];
|
||||
|
||||
for (int i = 1; i < data.length; i++) {
|
||||
final item = data[i];
|
||||
final st = item['st'];
|
||||
final value = item['value'];
|
||||
|
||||
if (value == currentValue) {
|
||||
endTime = st;
|
||||
} else {
|
||||
result.add({
|
||||
"startTime": startTime,
|
||||
"endTime": endTime,
|
||||
"times": currentValue,
|
||||
});
|
||||
startTime = st;
|
||||
endTime = st;
|
||||
currentValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加最后一段
|
||||
result.add({
|
||||
"startTime": startTime,
|
||||
"endTime": endTime,
|
||||
"times": currentValue,
|
||||
});
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,8 @@ import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/chart/StatusBarWithIndicator.dart';
|
||||
|
||||
class ZiZhuShenJingPercentWidget extends StatefulWidget {
|
||||
ZiZhuShenJingPercentWidget({super.key});
|
||||
var sleepReport;
|
||||
ZiZhuShenJingPercentWidget({super.key, required this.sleepReport});
|
||||
|
||||
@override
|
||||
State<ZiZhuShenJingPercentWidget> createState() =>
|
||||
@@ -35,6 +36,32 @@ class _ZiZhuShenJingPercentWidgetState
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.sleepReport == null ||
|
||||
widget.sleepReport['sicp'] == null ||
|
||||
widget.sleepReport['sicp'].isEmpty) {
|
||||
return Container();
|
||||
}
|
||||
int id = 100000;
|
||||
List data = widget.sleepReport['sicp'];
|
||||
final target = data.firstWhere(
|
||||
(element) => element['id'] == id,
|
||||
orElse: () => null, // 如果没有找到,返回 null(你也可以抛异常或用 {} 替代)
|
||||
);
|
||||
|
||||
if (target == null) {
|
||||
return Container();
|
||||
}
|
||||
List<Map<String, dynamic>> showLabel = [];
|
||||
if (target != null && target['type'] is List) {
|
||||
showLabel = (target['type'] as List).map<Map<String, dynamic>>((item) {
|
||||
return {
|
||||
'key': item['type'],
|
||||
'name': item['name'],
|
||||
'color': stringToColor(item['color']),
|
||||
};
|
||||
}).toList();
|
||||
}
|
||||
|
||||
return Container(
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
@@ -99,13 +126,8 @@ class _ZiZhuShenJingPercentWidgetState
|
||||
padding:
|
||||
EdgeInsetsDirectional.fromSTEB(30.rpx, 0.rpx, 30.rpx, 0.rpx),
|
||||
child: StatusBarWithIndicator(
|
||||
selectKey: 3,
|
||||
showLabel: [
|
||||
{"key": 1, "name": "正常", "color": Color(0xFF4CAF50)},
|
||||
{"key": 2, "name": "一般", "color": Color(0xFF8BC34A)},
|
||||
{"key": 3, "name": "注意", "color": Color(0xFFFFC107)},
|
||||
{"key": 4, "name": "警告", "color": Color(0xFFF44336)},
|
||||
],
|
||||
selectKey: target['value'],
|
||||
showLabel: showLabel,
|
||||
),
|
||||
),
|
||||
SizedBox(
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -255,6 +255,57 @@ class _SettingPageState extends State<SettingPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent, // 容器背景色
|
||||
highlightColor: themeController
|
||||
.currentColor.sc21, // 点击时的背景色
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
||||
onTap: () {
|
||||
print('点击了容器');
|
||||
Get.toNamed("/commonMessageSettingPage");
|
||||
},
|
||||
child: Container(
|
||||
child: Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
40.rpx, 30.rpx, 40.rpx, 30.rpx),
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
mainAxisAlignment:
|
||||
MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Text(
|
||||
'消息通知'.tr,
|
||||
style:
|
||||
FlutterFlowTheme.of(context)
|
||||
.bodyMedium
|
||||
.override(
|
||||
fontFamily: 'Inter',
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
fontSize: AppConstants()
|
||||
.title_text_fontSize,
|
||||
letterSpacing: 0.0,
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(width: 22.rpx)),
|
||||
),
|
||||
SvgPicture.asset(
|
||||
'assets/img/icon/arrow_right.svg',
|
||||
width: 8.rpx,
|
||||
height:
|
||||
14.rpx, // 如果 SVG 中没有固定颜色,可以这样设置
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent, // 容器背景色
|
||||
highlightColor: themeController
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:vbvs_app/common/util/MyUtils.dart';
|
||||
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
|
||||
import 'package:vbvs_app/controller/user_info_controller.dart';
|
||||
import 'package:vbvs_app/pages/device/BodyDeviceWidget.dart';
|
||||
import 'package:vbvs_app/pages/device/component/MessageSetting.dart';
|
||||
import 'package:vbvs_app/pages/device/device_detail.dart';
|
||||
import 'package:vbvs_app/pages/device/instant_body_page.dart';
|
||||
import 'package:vbvs_app/pages/device/message_review_page.dart';
|
||||
@@ -31,6 +32,7 @@ import 'package:vbvs_app/pages/repair/apply_repair_page.dart';
|
||||
import 'package:vbvs_app/pages/repair/apply_repair_success.dart';
|
||||
import 'package:vbvs_app/pages/repair/repair_detail_page.dart';
|
||||
import 'package:vbvs_app/pages/repair/repair_list_page.dart';
|
||||
import 'package:vbvs_app/pages/setting/common_mesaage_setting.dart';
|
||||
import 'package:vbvs_app/pages/setting/language_setting.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/new_sleep_report_page.dart';
|
||||
import 'package:vbvs_app/pages/sleep_report/sleep_report_page.dart';
|
||||
@@ -48,13 +50,15 @@ var routes = {
|
||||
"/messagePage": (contxt) => MessagePage(),
|
||||
"/minePage": (contxt) => MinePage(),
|
||||
"/mianPageBottomChange": (contxt) => MainPageBottomChange(),
|
||||
"/loginPage": (contxt) => LoginPage(),
|
||||
// "/loginPage": (contxt) => LoginPage(),
|
||||
// "/otherLoginPage": (contxt) => OtherLoginPage(),
|
||||
"/loginPage": (contxt) => OtherLoginPage(),
|
||||
// "/otherLoginPage": (contxt) => OtherLoginPage(),
|
||||
"/deviceType": (contxt, {arguments}) => DeviceTypePage(),
|
||||
"/blueteethDevice": (contxt) => BlueteethDevicePage(),
|
||||
"/personPage": (contxt) => PersonPage(),
|
||||
"/bindDeviceSuccess": (contxt) => BindDeviceSuccess(),
|
||||
"/wifiPage": (contxt, {arguments}) => WifiPage(type: arguments),
|
||||
"/otherLoginPage": (contxt) => OtherLoginPage(),
|
||||
"/updateUserPage": (contxt) => UpdateUserPage(),
|
||||
"/settingPage": (contxt) => SettingPage(),
|
||||
"/aboutUsPage": (contxt) => AboutUsPage(),
|
||||
@@ -77,13 +81,18 @@ var routes = {
|
||||
"/followPage": (contxt) => FollowPage(),
|
||||
"/repairListPage": (contxt) => RepairListPage(),
|
||||
"/newSleepReportPage": (contxt, {arguments}) =>
|
||||
NewSleepReportPage(date: arguments),
|
||||
NewSleepReportPage(data: arguments),
|
||||
"/userSchemePage": (contxt) => UserSchemePage(),
|
||||
"/privacyPage": (contxt) => PrivacySchemePage(),
|
||||
"/repairDetailPage": (contxt, {arguments}) =>
|
||||
RepairDetailPage(data: arguments),
|
||||
"/applyRepairSuccess": (contxt) => ApplyRepairSuccess(),
|
||||
"/messageReviewPage": (contxt,{arguments}) => MessageReviewPage(data: arguments),
|
||||
"/messageReviewPage": (contxt, {arguments}) =>
|
||||
MessageReviewPage(data: arguments),
|
||||
"/messageSettingPage": (contxt, {arguments}) =>
|
||||
MessageSettingPage(data: arguments),
|
||||
"/commonMessageSettingPage": (contxt) =>
|
||||
CommonMessageSettingPage(),
|
||||
};
|
||||
|
||||
var onGenerateRoute = (RouteSettings settings) {
|
||||
|
||||
Reference in New Issue
Block a user