更新睡眠报告

This commit is contained in:
wyf
2025-05-28 21:14:04 +08:00
parent 98cd7f4e6a
commit b34737dbe8
46 changed files with 1580 additions and 974 deletions

View File

@@ -8,12 +8,17 @@ import 'package:vbvs_app/common/color/app_uri_status.dart';
import 'package:vbvs_app/common/util/FitTool.dart';
import 'package:vbvs_app/controller/setting/language/language_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/language/AppLanguage.dart';
import 'package:vbvs_app/model/api_response.dart';
ThemeController themeController = Get.find();
LanguageController languageController = Get.find();
class MyUtils {
static String formatDate(DateTime dateTime) {
return "${dateTime.year}-${dateTime.month}-${dateTime.day.toString().padLeft(2, '0')}";
}
static String formatToDate(int timestamp) {
final dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
return "${dateTime.year}-${dateTime.month}-${dateTime.day.toString().padLeft(2, '0')}";
@@ -171,10 +176,16 @@ class MyUtils {
DateTime target = DateTime(date.year, date.month, date.day);
if (target == today) {
return '今日';
return '今日'.tr;
}
List<String> weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
String currentLanguageCode = AppLanguage().getCurrentLanguageCode();
if (currentLanguageCode != null) {
if (currentLanguageCode != "zh_CN") {
weekdays = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
}
}
const List<String> weekdays = ['周日', '周一', '周二', '周三', '周四', '周五', '周六'];
return weekdays[date.weekday % 7]; // Dart中星期日是7要映射到索引0
}
@@ -197,6 +208,23 @@ class MyUtils {
return '$dateStr $weekStr';
}
static String getFormatEnglishDate(int millis) {
final date = DateTime.fromMillisecondsSinceEpoch(millis);
const weekdays = [
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday'
];
final weekday = weekdays[date.weekday - 1];
final formattedDate =
'${date.year}/${date.month.toString().padLeft(2, '0')}/${date.day.toString().padLeft(2, '0')}';
return '$weekday, $formattedDate';
}
}
Color stringToColor(String hexColor) {

View File

@@ -11,33 +11,50 @@ import 'package:vbvs_app/component/home_page/SleepDateWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
class DynamicReportDetailWidget extends StatelessWidget {
class DynamicReportDetailWidget extends StatefulWidget {
final List<SleepDateWidget> sleepDateWidgets;
final List<SleepDataModuleWidget> sleepDataModuleWidgets;
final ThemeController themeController = Get.find();
final Map targetDevice;
late ScrollController _scrollController;
DynamicReportDetailWidget({
const DynamicReportDetailWidget({
Key? key,
required this.sleepDateWidgets,
required this.sleepDataModuleWidgets,
required this.targetDevice,
});
}) : super(key: key);
@override
State<DynamicReportDetailWidget> createState() =>
_DynamicReportDetailWidgetState();
}
class _DynamicReportDetailWidgetState extends State<DynamicReportDetailWidget> {
final ThemeController themeController = Get.find();
final ScrollController _scrollController = ScrollController();
bool _hasScrolled = false;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
Future.delayed(Duration(milliseconds: 100), () {
if (!_hasScrolled &&
_scrollController.hasClients &&
_scrollController.position.maxScrollExtent > 0) {
_scrollController.animateTo(
_scrollController.position.maxScrollExtent,
duration: Duration(milliseconds: 300),
curve: Curves.easeOut,
);
_hasScrolled = true;
}
});
});
}
@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(
@@ -53,10 +70,8 @@ class DynamicReportDetailWidget extends StatelessWidget {
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
_buildHeader(context, targetDevice),
SizedBox(
height: 33.rpx,
),
_buildHeader(context, widget.targetDevice),
SizedBox(height: 33.rpx),
_buildSleepDateWidgets(),
SizedBox(height: 20.rpx),
_buildSleepDataModuleWidgets(),
@@ -68,88 +83,81 @@ class DynamicReportDetailWidget extends StatelessWidget {
}
Widget _buildHeader(BuildContext context, Map targetDevice) {
return Container(
width: double.infinity,
child: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: themeController.currentColor.sc3.withOpacity(0.2),
borderRadius: 0,
padding: EdgeInsets.zero,
onTap: () async {
await Get.toNamed("/bodyDevice", arguments: targetDevice);
},
child: Text(
'${targetDevice['person']?['name'] == null ? '未命名'.tr : targetDevice['person']['name']}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
),
),
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: themeController.currentColor.sc3.withOpacity(0.2),
borderRadius: 0,
padding: EdgeInsets.zero,
onTap: () async {
await Get.toNamed("/bodyDevice", arguments: targetDevice);
},
child: Text(
'${targetDevice['person']?['name'] == null ? '未命名'.tr : targetDevice['person']['name']}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 30.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: themeController.currentColor.sc3,
borderRadius: 0,
padding: EdgeInsets.zero,
onTap: () {
String mac = targetDevice['mac'];
List<SleepDateWidget> selectedWidgets = sleepDateWidgets
.where(
(widget) => widget.isSelected == true,
)
.toList();
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: themeController.currentColor.sc3,
borderRadius: 0,
padding: EdgeInsets.zero,
onTap: () {
String mac = targetDevice['mac'];
List<SleepDateWidget> selectedWidgets = widget.sleepDateWidgets
.where((w) => w.isSelected == true)
.toList();
if (selectedWidgets.isNotEmpty) {
DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
int.parse(selectedWidgets[0].time!));
String time = MyUtils.formatBindTime(dateTime);
String sleepReportUrl =
"${ServiceConstant.sleep_report_url}?mac=${mac}&token=${ServiceConstant.sleep_token}&date=${time}";
"${ServiceConstant.sleep_report_url}?mac=$mac&token=${ServiceConstant.sleep_token}&date=$time";
Get.toNamed("/sleepReportPage", arguments: sleepReportUrl);
},
child: Row(
mainAxisSize: MainAxisSize.max,
children: [
Text(
'首页.报告详情'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
),
}
},
child: Row(
children: [
Text(
'首页.报告详情'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
),
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 6.rpx, 0, 0.rpx),
child: SvgPicture.asset(
'assets/img/icon/arrow_right.svg',
width: 14.rpx,
height: 14.rpx,
color: themeController.currentColor.sc3,
),
Padding(
padding: EdgeInsetsDirectional.fromSTEB(0, 6.rpx, 0, 0.rpx),
child: SvgPicture.asset(
'assets/img/icon/arrow_right.svg',
width: 14.rpx,
height: 14.rpx,
color: themeController.currentColor.sc3,
),
),
].divide(SizedBox(width: 22.rpx)),
),
),
].divide(SizedBox(width: 22.rpx)),
),
],
),
),
],
);
}
Widget _buildSleepDateWidgets() {
return Container(
width: double.infinity,
decoration: BoxDecoration(),
child: SingleChildScrollView(
controller: _scrollController, // ⭐️ 关键点
controller: _scrollController,
scrollDirection: Axis.horizontal,
child: Row(
mainAxisSize: MainAxisSize.max,
children: sleepDateWidgets
children: widget.sleepDateWidgets
.map((widget) => widget)
.toList()
.divide(SizedBox(width: 20.rpx)),
@@ -159,15 +167,13 @@ class DynamicReportDetailWidget extends StatelessWidget {
}
Widget _buildSleepDataModuleWidgets() {
bool hasData = sleepDataModuleWidgets.length > 0;
if (!hasData) {
if (widget.sleepDataModuleWidgets.isEmpty) {
return Container(
height: 200.rpx,
alignment: Alignment.center,
child: Text(
'暂无数据'.tr,
style: FlutterFlowTheme.of(Get.context!).bodyMedium.override(
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 28.rpx,
color: themeController.currentColor.sc4,
@@ -182,8 +188,7 @@ class DynamicReportDetailWidget extends StatelessWidget {
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
mainAxisSize: MainAxisSize.max,
children: sleepDataModuleWidgets
children: widget.sleepDataModuleWidgets
.map((widget) => widget)
.toList()
.divide(SizedBox(width: 14.rpx)),

View File

@@ -1,11 +1,14 @@
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: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/controller/sleep/sleep_report_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
import 'package:vbvs_app/pages/device_bind/componnet/bind_dialog.dart';
class SleepDataModuleWidget extends StatefulWidget {
final Map<String, dynamic> data;
@@ -37,11 +40,192 @@ class _SleepDataModuleWidgetState extends State<SleepDataModuleWidget> {
ThemeController themeController = Get.find();
return ClickableContainer(
backgroundColor: themeController.currentColor.sc5,
highlightColor: themeController.currentColor.sc3,
highlightColor: themeController.currentColor.sc21,
borderRadius: 20.rpx,
padding: EdgeInsetsDirectional.fromSTEB(18.rpx, 18.rpx, 18.rpx, 22.rpx),
padding: EdgeInsetsDirectional.fromSTEB(18.rpx, 10.rpx, 18.rpx, 10.rpx),
onTap: () {
print('点击了离床次数卡片');
if (widget.data['showTip'] != null && widget.data['showTip'] == true) {
final String itemLevel = widget.data['code'] ?? '';
SleepReportController sleepReportController = Get.find();
var report = sleepReportController.sleepReport;
List<Map<String, dynamic>> levelGroups = [];
if (report != null) {
var colorMap =
Map<String, dynamic>.from(report.value['info']['color']);
var levelMap =
Map<String, dynamic>.from(report.value['info']['level']);
for (var prefix in ['G', 'R', 'Y']) {
List<String> keys =
colorMap.keys.where((k) => k.startsWith(prefix)).toList();
keys.sort(); // G1, G2, G3
List<Map<String, dynamic>> items = keys.map((k) {
return {
"key": k,
"color": colorMap[k],
"level": levelMap[k] ?? "未知",
};
}).toList();
levelGroups.add({
"levelName": items.first['level'], // 默认同组level一致
"items": items,
});
}
}
showTipDialog(
backgroundColor: stringToColor("#FFFFFF"),
context,
Column(
children: [
Text(
"${widget.data['name']}",
style: TextStyle(
color: stringToColor("#333333"),
fontSize: 36.rpx,
),
),
SizedBox(
height: 17.rpx,
),
Text(
(widget.data['tips']?.toString().trim().isNotEmpty ?? false)
? widget.data['tips'].toString()
: "未知数据".tr,
style: TextStyle(
color: stringToColor("#C8CBD2"),
fontSize: 26.rpx,
),
),
SizedBox(
height: 37.rpx,
),
Text(
"${widget.data['value']}",
style: TextStyle(
color: stringToColor("${widget.data['color']}"),
fontSize: 60.rpx,
),
),
SizedBox(
height: 81.rpx,
),
IntrinsicHeight(
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
for (int i = 0; i < levelGroups.length; i++) ...[
// 每个 levelGroup 区域
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
// Level 名称
Text(
levelGroups[i]['levelName'],
style: TextStyle(
fontSize: 30.rpx,
color: stringToColor("#333333"),
fontWeight: FontWeight.bold,
),
),
SizedBox(height: 38.rpx),
// 颜色圆点 + key包一层和 svg 分离)
Row(
mainAxisAlignment:
MainAxisAlignment.spaceAround,
crossAxisAlignment:
CrossAxisAlignment.start, // 上对齐,避免撑高分割线
children:
levelGroups[i]['items'].map<Widget>((item) {
final bool isSelected =
(item['key'] == itemLevel);
return Column(
children: [
// 颜色圆点 + key参与分割线高度
Column(
children: [
Container(
width: 20.rpx,
height: 20.rpx,
decoration: BoxDecoration(
color:
stringToColor(item['color']),
shape: BoxShape.circle,
),
),
SizedBox(height: 30.rpx),
Text(
item['key'],
style: TextStyle(
color: stringToColor("#333333"),
fontSize: 20.rpx,
),
),
],
),
// svg 箭头(不影响分割线高度)
SizedBox(height: 20.rpx),
isSelected
? SvgPicture.asset(
'assets/img/icon/triangle.svg',
width: 18.rpx,
height: 18.rpx,
color: themeController
.currentColor.sc9,
)
: SizedBox(height: 18.rpx),
],
);
}).toList(),
),
],
),
),
// 分割线(只和主要内容等高)
if (i != levelGroups.length - 1)
Container(
width: 1.rpx,
color: stringToColor("${widget.data['color']}"),
margin: EdgeInsets.symmetric(horizontal: 10.rpx),
),
]
],
),
),
SizedBox(
height: 71.rpx,
),
RichText(
text: TextSpan(
children: [
TextSpan(
text: "当前属于".tr, // 第一部分文本
style: TextStyle(
color: Colors.black, // 你想要的样式
fontSize: 30.rpx,
),
),
TextSpan(
text: itemLevel, // 第二部分文本
style: TextStyle(
color: stringToColor("${widget.data['color']}"),
fontSize: 30.rpx,
),
),
],
),
),
],
),
);
}
},
child: Container(
// width: MediaQuery.sizeOf(context).width * 0.267,
@@ -78,7 +262,7 @@ class _SleepDataModuleWidgetState extends State<SleepDataModuleWidget> {
'${widget.data['value']}',
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 40.rpx,
fontSize: 36.rpx,
letterSpacing: 0.0,
color: themeController.currentColor.sc3,
),
@@ -120,7 +304,7 @@ class _SleepDataModuleWidgetState extends State<SleepDataModuleWidget> {
alignment: Alignment.center,
constraints: BoxConstraints(
minWidth: 43.rpx,
minHeight: 36.rpx,
minHeight: 25.rpx,
),
child: Text(
'${widget.data['level']}',

View File

@@ -122,7 +122,7 @@ class _TopSlideNotificationState extends State<TopSlideNotification>
@override
Widget build(BuildContext context) {
return Positioned(
top: 0,
top: 140.rpx,
left: 0,
right: 0,
child: SlideTransition(
@@ -130,7 +130,7 @@ class _TopSlideNotificationState extends State<TopSlideNotification>
child: Material(
color: stringToColor("#000000").withOpacity(0.8),
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 20.0),
padding: EdgeInsets.symmetric(vertical: 20.rpx),
child: Container(
child: Text(
widget.text,

View File

@@ -26,7 +26,7 @@ class BlueteethBindModel {
@JsonKey(ignore: true)
List<BleDeviceData>? betDevicelist = []; //网络状态
@JsonKey(ignore: true)
List? blelist = [];//蓝牙扫描的原始数据
List? blelist = []; //蓝牙扫描的原始数据
List bindArr = ["", "", ""];
String connectedWifiName = "";
@@ -67,14 +67,16 @@ class BlueteethBindController extends GetControllerEx<BlueteethBindModel> {
RxString scanMac = "".obs;
RxString? currentDeviceMac = "".obs;
RxString? cid = "".obs ;
RxString? cid = "".obs;
RxString search = "".obs;//搜索关键字
RxString search = "".obs; //搜索关键字
RxInt connectStatus = 0.obs;
RxMap selectWifi = {}.obs; //正在连接wifi信息
int returnPage = 0;//0返回首页 1.返回设备列表
// 安全展示 TopSlideNotification
void safeShowNotification(String msg) {
try {

View File

@@ -46,6 +46,8 @@ class BodyDeviceController extends GetControllerEx<BodyDeviceModel> {
String wifiMac = "";
Future<ApiResponse> getDeviceNum() async {
try {
ApiResponse apiResponse = ApiResponse(code: -1, msg: "设备.设备列表请求失败".tr);

View File

@@ -119,10 +119,10 @@ class LoginController extends GetControllerEx<LoginModel> {
Future<ApiResponse> getCode(BuildContext context) async {
ApiResponse apiResponse = ApiResponse(code: -1, msg: "其他手机登录页.发送失败".tr);
try {
if (model.register_agree == null || model.register_agree != true) {
apiResponse.msg = "登录页.未同意协议".tr;
return apiResponse;
}
// if (model.register_agree == null || model.register_agree != true) {
// apiResponse.msg = "登录页.未同意协议".tr;
// return apiResponse;
// }
if (model.phone == null || model.phone!.isEmpty) {
apiResponse.msg = "其他手机登录页.请输入手机号".tr;
return apiResponse;

View File

@@ -50,7 +50,7 @@ class MessageController extends GetControllerEx<MessageModel> {
String serviceApi = ServiceConstant.message_list;
String messageType = "app_system";
if (model.type == 1) {
messageType = "app_body";
messageType = "app_vsm";
} else {
messageType = "app_system";
}

View File

@@ -98,4 +98,8 @@ class AppLanguage extends Translations {
final parts = _currentLanguageCode.split('-');
return Locale(parts[0], parts.length > 1 ? parts[1] : null);
}
bool isChinese() {
return _currentLanguageCode == "zh_CN";
}
}

View File

@@ -11,6 +11,7 @@ import 'package:vbvs_app/component/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
import 'package:vbvs_app/controller/device/body_device_controller.dart';
import 'package:vbvs_app/controller/home/home_controller.dart';
import 'package:vbvs_app/controller/theme_controller/ThemeController.dart';
@@ -117,6 +118,9 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
borderRadius: 0.rpx,
onTap: () {
_hidePopup();
BlueteethBindController blueteethBindController =
Get.find();
blueteethBindController.returnPage = 1;
Get.toNamed("/deviceType");
},
child: Container(
@@ -187,7 +191,9 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
}
Future<void> _fetchDeviceList() async {
await bodyDeviceController.getDeviceList().then((apiResponse) {
await bodyDeviceController
.getDeviceList(key: bodyDeviceController.keyWord.value)
.then((apiResponse) {
if (apiResponse.code != HttpStatusCodes.ok) {
TopSlideNotification.show(
Get.context!,
@@ -240,6 +246,7 @@ class _BodyDevicePageState extends State<BodyDeviceWidget> {
),
),
child: Scaffold(
resizeToAvoidBottomInset: false,
backgroundColor: Colors.transparent,
appBar: AppBar(
backgroundColor: themeController.currentColor.sc17,

View File

@@ -1040,8 +1040,7 @@ class _DeviceDataComponentWidgetState extends State<DeviceDataComponentWidget> {
Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
Expanded(
// 使用 Expanded 来占据屏幕宽度
Expanded(
child: CustomCard(
borderRadius: AppConstants().button_container_radius,
onTap: () async {

View File

@@ -91,7 +91,7 @@ class _ReviewMessageWidgetWidgetState extends State<ReviewMessageWidgetWidget> {
);
}
Widget _buildInfoItem(BuildContext context, String label) {
Widget _buildInfoItem(BuildContext context, label) {
return Container(
constraints: BoxConstraints(
minHeight: 62.rpx,
@@ -101,7 +101,7 @@ class _ReviewMessageWidgetWidgetState extends State<ReviewMessageWidgetWidget> {
child: Text(
overflow: TextOverflow.ellipsis,
maxLines: 1,
label.tr,
"${label}",
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
@@ -113,7 +113,7 @@ class _ReviewMessageWidgetWidgetState extends State<ReviewMessageWidgetWidget> {
);
}
Widget _buildValueItem(BuildContext context, String value) {
Widget _buildValueItem(BuildContext context, value) {
return Container(
constraints: BoxConstraints(
minHeight: 62.rpx,
@@ -123,7 +123,7 @@ class _ReviewMessageWidgetWidgetState extends State<ReviewMessageWidgetWidget> {
child: Text(
overflow: TextOverflow.ellipsis,
maxLines: 1,
value,
"${value}",
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,

View File

@@ -1,12 +1,15 @@
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/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/controller/message/message_review_controller.dart';
import 'package:vbvs_app/model/api_response.dart';
import 'package:vbvs_app/pages/device/component/ReviewMessageWidgetWidget.dart';
class MessageReviewPage extends StatefulWidget {
@@ -23,7 +26,7 @@ class _MessageReviewPageState extends State<MessageReviewPage> {
@override
void initState() {
super.initState();
loadData();
loadData(widget.data);
}
@override
@@ -277,60 +280,17 @@ class _MessageReviewPageState extends State<MessageReviewPage> {
);
}
Future<void> loadData() async {
Future<void> loadData(data) async {
//todo 请求历史体征数据
// String serviceAddress = ServiceConstant.service_address;
// String serviceName = ServiceConstant.server_service;
// String serviceApi = ServiceConstant.submit_repair;
// String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
// ApiResponse apiResponse = await requestWithLog(
// logTitle: "查询报修数据", method: MyHttpMethod.get, queryUrl: queryUrl);
// 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'},
// ],
// }
// },
// ];
String serviceAddress = ServiceConstant.service_address;
String serviceName = ServiceConstant.server_service;
String serviceApi = ServiceConstant.message_list;
String queryUrl =
"${serviceAddress}${serviceName}${serviceApi}?type=app_vsm&mac=${data['mac']}";
ApiResponse apiResponse = await requestWithLog(
logTitle: "查询消息回看数据", method: MyHttpMethod.get, queryUrl: queryUrl);
messageReviewController.messageList.value = apiResponse.data;
messageReviewController.updateAll();
}
Widget _buildMessageListView(List dataList) {

View File

@@ -268,7 +268,13 @@ class _EPageState extends State<BindDeviceSuccess> {
borderRadius:
AppConstants().button_container_radius, // 圆角半径
onTap: () {
Get.offAllNamed("/mianPageBottomChange");
BlueteethBindController blueteethBindController =
Get.find();
if (blueteethBindController.returnPage == 0) {
Get.offAllNamed("/mianPageBottomChange");
} else {
Get.offAllNamed("/bodyDevice");
}
},
colors: [
// 渐变色

View File

@@ -862,9 +862,11 @@ void showWifiDialog(
void showTipDialog(
BuildContext context,
Widget widget,
// String title,
) {
Widget widget, {
Color? backgroundColor, // 新增可选参数
}
// String title,
) {
ThemeController themeController = Get.find();
BlueteethBindController blueteethBindController = Get.find();
@@ -877,7 +879,8 @@ void showTipDialog(
blurSigma: 3.0,
child: Container(
decoration: BoxDecoration(
color: themeController.currentColor.sc17,
color:
backgroundColor ?? themeController.currentColor.sc17, // 使用默认颜色
borderRadius: BorderRadius.circular(20.0),
),
padding: EdgeInsetsDirectional.fromSTEB(64.rpx, 0, 64.rpx, 0),

View File

@@ -92,6 +92,10 @@ class _CalibrationPageState extends State<CalibrationPage> {
context, Container(), "校准未完成提示".tr,
onConfirm: () async {
exit = true;
if (widget.type == 2) {
Get.back();
return;
}
await Get.toNamed("/personPage");
print("object");
deviceCalibrationController.process.value = 0;

View File

@@ -426,14 +426,18 @@ class _EPageState extends State<DeviceTypePage> {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: themeController.currentColor.sc3,
fontSize: 30.rpx,
letterSpacing: 0.0,
),
Expanded(
child: Text(
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
color: themeController.currentColor.sc3,
fontSize: 30.rpx,
letterSpacing: 0.0,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),
),
ClipRRect(
borderRadius: BorderRadius.circular(8.rpx),

View File

@@ -163,7 +163,7 @@ class _DeviceTypeListPageState extends State<DeviceTypeListPage> {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
Expanded(child: Text(
title,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
@@ -171,7 +171,9 @@ class _DeviceTypeListPageState extends State<DeviceTypeListPage> {
fontSize: 30.rpx,
letterSpacing: 0.0,
),
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
),),
ClipRRect(
borderRadius: BorderRadius.circular(8.rpx),
// child: Image.asset(

View File

@@ -31,6 +31,7 @@ class _MessageWidgetWidgetState extends State<MessageWidgetWidget> {
@override
Widget build(BuildContext context) {
var messageInfo = widget.data;
print(messageInfo);
return Stack(
children: [
ClickableContainer(
@@ -97,63 +98,63 @@ class _MessageWidgetWidgetState extends State<MessageWidgetWidget> {
],
),
),
Positioned(
bottom: 46.rpx,
right: 20.rpx,
child: Container(
width: 123.rpx,
height: 47.rpx,
child: CustomCard(
borderRadius: AppConstants().button_container_radius, // 直角
colors: messageInfo['status'] == 1
? [
themeController.currentColor.sc1,
themeController.currentColor.sc2
]
: [themeController.currentColor.sc4], // 单色背景
enableAnimation: true, // 有点击缩放动画
enableGradient: false, // 不用渐变
onTap: () {
if (messageInfo['status'] == 1) {
showConfirmDialog(context, Container(), "是否确认接受该设备".tr,
onConfirm: () async {
ApiResponse apiResponse = await deviceShareController
.confirmShare(messageInfo['data']['shareCode']);
if (apiResponse.code == HttpStatusCodes.ok) {
TopSlideNotification.show(
context,
text: apiResponse.msg!,
textColor: themeController.currentColor.sc2,
);
messageController.getMessageList();
messageController.updateAll();
} else {
TopSlideNotification.show(
context,
text: apiResponse.msg!,
textColor: themeController.currentColor.sc9,
);
messageController.getMessageList();
messageController.updateAll();
}
}, onCancel: () {});
}
},
child: Center(
child: Text(
getMessageStatus(messageInfo['status']),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: Colors.white,
),
if (messageInfo['type'] == 'app_system')
Positioned(
bottom: 46.rpx,
right: 20.rpx,
child: Container(
width: 123.rpx,
height: 47.rpx,
child: CustomCard(
borderRadius: AppConstants().button_container_radius, // 直角
colors: messageInfo['status'] == 1
? [
themeController.currentColor.sc1,
themeController.currentColor.sc2
]
: [themeController.currentColor.sc4], // 单色背景
enableAnimation: true, // 有点击缩放动画
enableGradient: false, // 不用渐变
onTap: () {
if (messageInfo['status'] == 1) {
showConfirmDialog(context, Container(), "是否确认接受该设备".tr,
onConfirm: () async {
ApiResponse apiResponse = await deviceShareController
.confirmShare(messageInfo['data']['shareCode']);
if (apiResponse.code == HttpStatusCodes.ok) {
TopSlideNotification.show(
context,
text: apiResponse.msg!,
textColor: themeController.currentColor.sc2,
);
messageController.getMessageList();
messageController.updateAll();
} else {
TopSlideNotification.show(
context,
text: apiResponse.msg!,
textColor: themeController.currentColor.sc9,
);
messageController.getMessageList();
messageController.updateAll();
}
}, onCancel: () {});
}
},
child: Center(
child: Text(
getMessageStatus(messageInfo['status']),
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,
letterSpacing: 0.0,
color: Colors.white,
),
),
),
),
),
),
),
],
);
}
@@ -180,7 +181,7 @@ class _MessageWidgetWidgetState extends State<MessageWidgetWidget> {
);
}
Widget _buildValueItem(BuildContext context, String value) {
Widget _buildValueItem(BuildContext context, value) {
return Container(
constraints: BoxConstraints(
minHeight: 62.rpx,
@@ -190,7 +191,7 @@ class _MessageWidgetWidgetState extends State<MessageWidgetWidget> {
child: Text(
overflow: TextOverflow.ellipsis,
maxLines: 1,
value,
"${value}",
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Inter',
fontSize: 26.rpx,

View File

@@ -1,6 +1,10 @@
import 'package:ef/ef.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';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
import 'package:vbvs_app/controller/user_info_controller.dart';
@@ -20,13 +24,64 @@ class _EPageState extends State<EPage> {
builder: (context, boxConstraints) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
child: Scaffold(
appBar: AppBar(
backgroundColor: themeController.currentColor.sc17,
// backgroundColor: Colors.transparent,
automaticallyImplyLeading: false,
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
titleSpacing: 0,
// leading: returnIconButtom,
title: Container(
width: double.infinity,
height: 180.rpx,
child: Stack(
alignment: Alignment.center,
children: [
/// 居中标题
Text(
'小e'.tr,
style: FlutterFlowTheme.of(context).bodyMedium.override(
fontFamily: 'Readex Pro',
color: themeController.currentColor.sc3,
letterSpacing: 0,
fontSize: 30.rpx,
),
),
/// 左边返回按钮
// Positioned(
// left: 0,
// child: returnIconButtom,
// ),
],
),
),
actions: [],
centerTitle: false,
),
backgroundColor: Colors.transparent,
body: SafeArea(
top: true,
child: Text("小e",
style: TextStyle(
fontSize: AppConstants().normal_text_fontSize,
color: Colors.white)),
child: Column(children: [
Expanded(
child: ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: Colors.transparent,
padding: EdgeInsets.all(0.rpx),
onTap: () {
TopSlideNotification.show(context, text: "待开发功能".tr);
},
child: Container(
// child: widget.webView,
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/img/xiaoe.png'), // 本地图片
fit: BoxFit.fill, // 填满整个 Container
),
),
),
)),
]),
),
),
),

View File

@@ -74,6 +74,7 @@ class _FollowPageState extends State<FollowPage> {
actions: [],
centerTitle: false,
),
body: SafeArea(
top: true,
child: Padding(

View File

@@ -13,6 +13,7 @@ import 'package:vbvs_app/component/home_page/SleepDateWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/CustomCard.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/device/blueteeth_bind_controller.dart';
import 'package:vbvs_app/controller/device/body_device_controller.dart';
import 'package:vbvs_app/controller/home/home_controller.dart';
import 'package:vbvs_app/controller/main_bottom/global_controller.dart';
@@ -127,6 +128,9 @@ class _HomePageState extends State<HomePage> {
onTap: () {
_popupEntry?.remove();
_popupEntry = null;
BlueteethBindController blueteethBindController =
Get.find();
blueteethBindController.returnPage = 0;
Get.toNamed("/deviceType");
},
child: Container(

View File

@@ -92,10 +92,10 @@ class _MessagePageState extends State<MessagePage> {
backgroundColor: themeController.currentColor.sc17,
automaticallyImplyLeading: false,
iconTheme: IconThemeData(color: themeController.currentColor.sc3),
toolbarHeight: 140.rpx,
// toolbarHeight: 140.rpx,
titleSpacing: 0,
title: Padding(
padding: EdgeInsetsDirectional.fromSTEB(40.rpx, 0, 0, 0),
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 0, 0.rpx, 0),
child: Container(
width: double.infinity,
height: 140.rpx,

View File

@@ -693,7 +693,7 @@ class _MinePageState extends State<MinePage> {
mainAxisSize: MainAxisSize.max,
children: [
Text(
'V1.0.2505.26',
'V1.0.2505.28',
style:
FlutterFlowTheme.of(context)
.bodyMedium

View File

@@ -38,7 +38,7 @@ class _UpdatePageState extends State<UpdatePersonPage> {
@override
void initState() {
super.initState();
personController.dateTime = null;
// personController.dateTime = null;
personController.getDiseaseData().then((apiResponse) {
if (apiResponse.code != HttpStatusCodes.ok) {
TopSlideNotification.show(

View File

@@ -11,6 +11,8 @@ class TimeSeriesChart extends StatelessWidget {
final double yMin;
final double yMax;
final List<TimeSeriesPoint> dataPoints;
final double actYMin;
final double actYMax;
TimeSeriesChart({
required this.startTime,
@@ -18,6 +20,8 @@ class TimeSeriesChart extends StatelessWidget {
required this.yMin,
required this.yMax,
required this.dataPoints,
required this.actYMin,
required this.actYMax,
});
@override
@@ -147,7 +151,7 @@ class TimeSeriesChart extends StatelessWidget {
return Padding(
padding: EdgeInsets.only(right: 14.rpx),
child: Text(
yMin.toStringAsFixed(0),
"${actYMin.toStringAsFixed(0)}",
style: TextStyle(
fontSize: 18.rpx,
color: themeController.currentColor.sc4,
@@ -161,7 +165,8 @@ class TimeSeriesChart extends StatelessWidget {
return Padding(
padding: EdgeInsets.only(right: 14.rpx),
child: Text(
midValue.toStringAsFixed(0),
"${((actYMax + actYMin) / 2).toStringAsFixed(0)}",
// "${midValue}",
style: TextStyle(
fontSize: 18.rpx,
color: themeController.currentColor.sc4,
@@ -175,7 +180,7 @@ class TimeSeriesChart extends StatelessWidget {
return Padding(
padding: EdgeInsets.only(right: 14.rpx),
child: Text(
yMax.toStringAsFixed(0),
"${actYMax.toStringAsFixed(0)}",
style: TextStyle(
fontSize: 18.rpx,
color: themeController.currentColor.sc4,

View File

@@ -52,6 +52,7 @@ class _BreatheCardState extends State<BreatheCard> {
runSpacing: 25.rpx, // 每行之间的垂直间距
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: SleepDataModuleWidget(data: item),

View File

@@ -105,9 +105,18 @@ class _SnoreViewWidgetWidgetState extends State<BreathePauseNewWidget> {
SizedBox(
height: 32.rpx,
),
Row(
children: [
Text(
"".tr,
style: TextStyle(
color: stringToColor("#FFFFFF"), fontSize: 18.rpx),
),
],
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0.rpx, 0.rpx),
child: LineChartByRange(
showLabel: showLabel,
startTime: startTime,

View File

@@ -59,6 +59,48 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
return TimeSeriesPoint(x, y);
}).toList();
List<Map<String, dynamic>> brs =
(widget.sleepReport['brs'] as List).cast<Map<String, dynamic>>();
//307 平均呼吸
//305 基准呼吸
//308 最低呼吸
//309 最高呼吸
// 307 平均呼吸
Map<String, dynamic>? avgBreath = brs.firstWhere(
(element) => element['id'] == 307,
orElse: () => {},
);
// 305 基准呼吸
Map<String, dynamic>? baseBreath = brs.firstWhere(
(element) => element['id'] == 305,
orElse: () => {},
);
// 308 最低呼吸
Map<String, dynamic>? minBreath = brs.firstWhere(
(element) => element['id'] == 308,
orElse: () => {},
);
// 309 最高呼吸
Map<String, dynamic>? maxBreath = brs.firstWhere(
(element) => element['id'] == 309,
orElse: () => {},
);
String range = baseBreath['range'] ?? '';
int min = 0;
int max = 0;
if (range.isNotEmpty && range.contains('~')) {
List<String> parts = range.split('~');
if (parts.length == 2) {
min = int.tryParse(parts[0]) ?? 0;
max = int.tryParse(parts[1]) ?? 0;
}
}
return Container(
width: double.infinity,
decoration: BoxDecoration(
@@ -76,7 +118,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"呼吸基准".tr,
"呼吸数据".tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize),
@@ -92,7 +134,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
context,
Container(
child: Text(
"呼吸基准介绍".tr,
"呼吸数据介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
@@ -139,7 +181,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围(8~20)',
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
@@ -158,6 +200,8 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMax: max.toDouble(),
actYMin: min.toDouble(),
),
),
Padding(
@@ -169,7 +213,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"平均呼吸",
"${avgBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -179,14 +223,14 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"12",
"${avgBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
),
Text(
"次/分钟",
"${avgBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -201,7 +245,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"基准呼吸",
"${baseBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -213,7 +257,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"15",
"${baseBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -222,7 +266,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${baseBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -239,7 +283,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"最低呼吸",
"${minBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -251,7 +295,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"11",
"${minBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -260,7 +304,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${minBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -277,7 +321,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
Column(
children: [
Text(
"最高呼吸",
"${maxBreath['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -289,7 +333,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"18",
"${maxBreath['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -298,7 +342,7 @@ class _BreatheStandardWidgetState extends State<BreatheStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${maxBreath['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:

View File

@@ -169,7 +169,7 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
SizedBox(width: 13.rpx), // 文字和容器之间的间距
// 文字
Text(
'今日数据', // 文字内容
'今日数据'.tr, // 文字内容
style: TextStyle(
fontSize: 18.rpx, // 文字大小
color:
@@ -190,7 +190,7 @@ class _CompareSleepWidgetState extends State<CompareSleepWidget> {
SizedBox(width: 13.rpx), // 文字和容器之间的间距
// 文字
Text(
'昨日数据', // 文字内容
'昨日数据'.tr, // 文字内容
style: TextStyle(
fontSize: 18.rpx, // 文字大小
color:

View File

@@ -61,7 +61,7 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
// "explain": "呼吸系统是负责气体交换的器官系统,包括鼻、喉、气管和肺等。",
// },
// ];
@override
void setState(VoidCallback callback) {
super.setState(callback);
@@ -84,7 +84,7 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
widget.sleepReport['cdri'].isEmpty) {
return Container();
}
List diseaseData = widget.sleepReport['cdri'];
List diseaseData = widget.sleepReport['cdri'];
var showLabel = convertDiseaseData(diseaseData);
return Container(
width: double.infinity,
@@ -120,7 +120,7 @@ class _DiseasePercentsWidgetState extends State<DiseasePercentsWidget> {
context,
Container(
child: Text(
"慢性病风险指数介绍",
"慢性病风险指数介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
@@ -158,23 +158,24 @@ 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();
}
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();
}
}

View File

@@ -76,7 +76,7 @@ class _HeartHealthWidgetState extends State<HeartHealthWidget> {
context,
Container(
child: Text(
"心理健康评估介绍",
"心理健康评估介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -104,7 +104,7 @@ class _HeartPointWidgetState extends State<HeartPointWidget> {
context,
Container(
child: Text(
"心率散点图介绍",
"心率散点图介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -52,6 +52,7 @@ class _HeartRateCardState extends State<HeartRateCard> {
runSpacing: 25.rpx, // 每行之间的垂直间距
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: SleepDataModuleWidget(data: item),

View File

@@ -46,13 +46,52 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
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();
final dataPoints = data.map((item) {
final x = item['st'] as int;
final y = (item['value'] as num).toDouble(); // 安全地转换为 double
return TimeSeriesPoint(x, y);
}).toList();
List<Map<String, dynamic>> hrs =
(widget.sleepReport['hrs'] as List).cast<Map<String, dynamic>>();
//206 平均心率
//202 基准心率
//207 最低心率
//208 最高心率
// 找 id == 206 的元素(平均心率)
Map<String, dynamic>? avgHeartRate = hrs.firstWhere(
(element) => element['id'] == 206,
orElse: () => {},
);
// 找 id == 202 的元素(基准心率)
Map<String, dynamic>? baseHeartRate = hrs.firstWhere(
(element) => element['id'] == 202,
orElse: () => {},
);
// 找 id == 207 的元素(最低心率)
Map<String, dynamic>? minHeartRate = hrs.firstWhere(
(element) => element['id'] == 207,
orElse: () => {},
);
// 找 id == 208 的元素(最高心率)
Map<String, dynamic>? maxHeartRate = hrs.firstWhere(
(element) => element['id'] == 208,
orElse: () => {},
);
String range = baseHeartRate['range'] ?? '';
int min = 0;
int max = 0;
if (range.isNotEmpty && range.contains('~')) {
List<String> parts = range.split('~');
if (parts.length == 2) {
min = int.tryParse(parts[0]) ?? 0;
max = int.tryParse(parts[1]) ?? 0;
}
}
return Container(
width: double.infinity,
decoration: BoxDecoration(
@@ -70,7 +109,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
"心率基准".tr,
"心率数据".tr,
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize: AppConstants().title_text_fontSize),
@@ -86,7 +125,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
context,
Container(
child: Text(
"心率基准介绍".tr,
"心率数据介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,
@@ -133,7 +172,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
SizedBox(width: 15.rpx), // 圆球和文字之间的间隔
// 文字
Text(
'正常范围(50~80)',
'正常范围'.tr + "${range}",
style: TextStyle(
fontSize:
AppConstants().smaller_text_fontSize, // 文字的大小
@@ -142,6 +181,18 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
),
],
),
// Container(
// // color: Colors.red,
// width: double.infinity,
// // height: 300.rpx,
// child: TimeSeriesChart(
// startTime: startTime,
// endTime: endTime,
// yMin: min.toDouble(),
// yMax: max.toDouble(),
// dataPoints: dataPoints,
// ),
// ),
Container(
// color: Colors.red,
width: double.infinity,
@@ -152,6 +203,8 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
yMin: 50,
yMax: 150,
dataPoints: dataPoints,
actYMin: min.toDouble(),
actYMax: max.toDouble(),
),
),
Padding(
@@ -163,7 +216,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"平均心率",
"${avgHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -173,14 +226,14 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"89",
"${avgHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
AppConstants().normal_text_fontSize),
),
Text(
"次/分钟",
"${avgHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -195,7 +248,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"基准心率",
"${baseHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -207,7 +260,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"80",
"${baseHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -216,7 +269,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${baseHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -233,7 +286,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"最低心率",
"${minHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -245,7 +298,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"68",
"${minHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -254,7 +307,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${minHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -271,7 +324,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
Column(
children: [
Text(
"最高心率",
"${maxHeartRate['name']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:
@@ -283,7 +336,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
Text(
"98",
"${maxHeartRate['value']}",
style: TextStyle(
color: themeController.currentColor.sc2,
fontSize:
@@ -292,7 +345,7 @@ class _HeartRateStandardWidgetState extends State<HeartRateStandardWidget> {
overflow: TextOverflow.ellipsis,
),
Text(
"次/分钟",
"${maxHeartRate['unit']}",
style: TextStyle(
color: themeController.currentColor.sc3,
fontSize:

View File

@@ -92,7 +92,7 @@ class _SkinPercentWidgetState extends State<SkinPercentWidget> {
context,
Container(
child: Text(
"皮肤指数介绍",
"皮肤指数介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -52,6 +52,7 @@ class _SleepCardState extends State<SleepCard> {
runSpacing: 25.rpx, // 每行之间的垂直间距
children: List.generate(data.length, (index) {
final item = data[index];
item['showTip'] = true;
return SizedBox(
width: (MediaQuery.of(context).size.width - 160.rpx) / 3,
child: SleepDataModuleWidget(data: item),

View File

@@ -67,12 +67,16 @@ class _SleepScoreWidgetState extends State<SleepScoreWidget> {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
'30天平均分'.tr,
style: TextStyle(
color: Color(0xFFD3D3D3),
fontSize: 26.rpx,
letterSpacing: 0.0,
Container(
constraints: BoxConstraints(maxWidth: 150.rpx),
child: Text(
'30天平均分'.tr,
style: TextStyle(
color: Color(0xFFD3D3D3),
fontSize: 26.rpx,
letterSpacing: 0.0,
),
maxLines: 1,
),
),
Text(

View File

@@ -47,69 +47,13 @@ class _SleepViewWidgetState extends State<SleepViewWidget> {
.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,

View File

@@ -43,6 +43,10 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
List<Map<String, dynamic>> data =
(widget.sleepReport['ssp'] as List).cast<Map<String, dynamic>>();
List<Map<String, dynamic>> showLabel = convertToShowLabel(data);
// List<Map<String, dynamic>> showLabel = [
// // {'startTime': 1748275800344, "endTime": 1748283000000, "times": 4},
// {'startTime': 1748293800000, "endTime": 1748294400000, "times": 7},
// ];
var startTime = widget.sleepReport['startTime'];
var endTime = widget.sleepReport['endTime'];
return Container(
@@ -105,9 +109,18 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
SizedBox(
height: 32.rpx,
),
Row(
children: [
Text(
"".tr,
style: TextStyle(
color: stringToColor("#FFFFFF"), fontSize: 18.rpx),
),
],
),
Padding(
padding:
EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
EdgeInsetsDirectional.fromSTEB(0.rpx, 40.rpx, 0.rpx, 0.rpx),
child: LineChartByRange(
showLabel: showLabel,
startTime: startTime,
@@ -132,13 +145,14 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
List<Map<String, dynamic>> result = [];
int startTime = data[0]['st'];
int endTime = data[0]['st'];
int endTime = data[0]['et'];
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'];
final et = item['et'];
if (value == currentValue) {
endTime = st;
@@ -149,7 +163,7 @@ class _SnoreViewWidgetWidgetState extends State<SnoreViewWidgetWidget> {
"times": currentValue,
});
startTime = st;
endTime = st;
endTime = et;
currentValue = value;
}
}

View File

@@ -95,7 +95,7 @@ class _ZiZhuShenJingPercentWidgetState
context,
Container(
child: Text(
"自主神经平衡指数监测介绍",
"自主神经平衡指数监测介绍".tr,
style: TextStyle(
fontSize: 26.rpx,
color: themeController.currentColor.sc3,

View File

@@ -6,9 +6,12 @@ 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/NullDataComponentWidget.dart';
import 'package:vbvs_app/component/tool/ClickableContainer.dart';
import 'package:vbvs_app/component/tool/TopSlideNotification.dart';
import 'package:vbvs_app/controller/date/CalendarController.dart';
import 'package:vbvs_app/controller/sleep/sleep_report_controller.dart';
import 'package:vbvs_app/language/AppLanguage.dart';
import 'package:vbvs_app/pages/common/selectDialog.dart';
import 'package:vbvs_app/pages/sleep_report/component/AIAdviceWidget.dart';
import 'package:vbvs_app/pages/sleep_report/component/BreatheCard.dart';
@@ -55,17 +58,22 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
sleepReportController.model.type = 1;
}
String date = MyUtils.formatToDate(widget.data['date']);
// String date = '2025-5-27';
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"http://192.168.1.80:9898/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${date}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!, textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
super.initState();
@@ -78,6 +86,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
@override
Widget build(BuildContext context) {
double lineWidth = 115.rpx;
return LayoutBuilder(
builder: (context, bodySize) => GestureDetector(
onTap: () => FocusScope.of(context).unfocus(),
@@ -152,54 +161,52 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
Row(
mainAxisSize: MainAxisSize.max,
children: [
Obx(() {
return ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor: themeController
.currentColor.sc3,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
sleepReportController.model.type =
1;
sleepReportController.updateAll();
},
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width:
115.rpx, // 固定宽度为 160.rpx
alignment:
Alignment.center, // 文字居中
child: Text(
'日报'.tr,
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color: sleepReportController
.model
.type ==
1
? themeController
.currentColor
.sc2
: themeController
.currentColor
.sc3,
),
),
ClickableContainer(
backgroundColor: Colors.transparent,
highlightColor:
themeController.currentColor.sc3,
borderRadius: 8.rpx,
padding: EdgeInsets.all(0),
onTap: () async {
sleepReportController.model.type =
1;
sleepReportController.updateAll();
},
child: Column(
mainAxisSize: MainAxisSize.max,
children: [
Container(
width: 115.rpx, // 固定宽度为 160.rpx
alignment:
Alignment.center, // 文字居中
child: Text(
'日报'.tr,
style: FlutterFlowTheme.of(
context)
.bodyMedium
.override(
fontFamily: 'Inter',
fontSize: AppConstants()
.title_text_fontSize,
letterSpacing: 0.0,
color:
sleepReportController
.model
.type ==
1
? themeController
.currentColor
.sc2
: themeController
.currentColor
.sc3,
),
),
SizedBox(height: 10.rpx),
],
),
);
}),
),
SizedBox(height: 10.rpx),
],
),
),
// Obx(() {
// return ClickableContainer(
@@ -299,33 +306,28 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
// }),
],
),
Obx(() {
double lineWidth = 115.rpx;
return AnimatedPositioned(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
bottom: 0,
left:
sleepReportController.model.type ==
1
? 0
: sleepReportController
.model.type ==
2
? 115.rpx
: 230.rpx,
child: Container(
width: lineWidth,
height: 4.rpx,
decoration: BoxDecoration(
color: themeController
.currentColor.sc2,
borderRadius:
BorderRadius.circular(2.rpx),
),
AnimatedPositioned(
duration: Duration(milliseconds: 300),
curve: Curves.easeInOut,
bottom: 0,
left: sleepReportController.model.type ==
1
? 0
: sleepReportController.model.type ==
2
? 115.rpx
: 230.rpx,
child: Container(
width: lineWidth,
height: 4.rpx,
decoration: BoxDecoration(
color:
themeController.currentColor.sc2,
borderRadius:
BorderRadius.circular(2.rpx),
),
);
}),
),
),
],
),
// Padding(
@@ -353,10 +355,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
child: Padding(
padding: EdgeInsetsDirectional.fromSTEB(
30.rpx, 32.rpx, 30.rpx, 32.rpx),
child: Obx(() {
var date = sleepReportController.selectedDate;
return getTimeWidget();
}),
child: getTimeWidget(),
),
),
Padding(
@@ -430,7 +429,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
),
),
Text(
'2022-02-02',
'69',
style:
FlutterFlowTheme.of(context)
.bodyMedium
@@ -703,23 +702,42 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
Widget getTimeWidget() {
final selectedDate = sleepReportController.selectedDate.value!;
final type = sleepReportController.model.type;
bool isChinese = AppLanguage().isChinese();
String displayText = '';
if (type == 1) {
// 日报
displayText =
MyUtils.getFormatChineseTime(selectedDate.millisecondsSinceEpoch);
} else if (type == 2) {
// 周报
final startOfWeek =
selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
displayText =
'${MyUtils.getFormatChineseTime(startOfWeek.millisecondsSinceEpoch, showWeekday: false)}-${MyUtils.getFormatChineseTime(endOfWeek.millisecondsSinceEpoch, showWeekday: false)}';
} else if (type == 3) {
// 月报
displayText =
'${selectedDate.year}${selectedDate.month.toString().padLeft(2, '0')}';
if (isChinese) {
if (type == 1) {
// 日报
displayText =
MyUtils.getFormatChineseTime(selectedDate.millisecondsSinceEpoch);
} else if (type == 2) {
// 周报
final startOfWeek =
selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
displayText =
'${MyUtils.getFormatChineseTime(startOfWeek.millisecondsSinceEpoch, showWeekday: false)}-${MyUtils.getFormatChineseTime(endOfWeek.millisecondsSinceEpoch, showWeekday: false)}';
} else if (type == 3) {
// 月报
displayText =
'${selectedDate.year}${selectedDate.month.toString().padLeft(2, '0')}';
}
} else {
if (type == 1) {
// Daily Report
displayText =
MyUtils.getFormatEnglishDate(selectedDate.millisecondsSinceEpoch);
} else if (type == 2) {
// Weekly Report
final startOfWeek =
selectedDate.subtract(Duration(days: selectedDate.weekday - 1));
final endOfWeek = startOfWeek.add(const Duration(days: 6));
displayText =
'${MyUtils.getFormatEnglishDate(startOfWeek.millisecondsSinceEpoch)} - ${MyUtils.getFormatEnglishDate(endOfWeek.millisecondsSinceEpoch)}';
} else if (type == 3) {
// Monthly Report
displayText =
'${_getEnglishMonthName(selectedDate.month)} ${selectedDate.year}';
}
}
void onLeftArrowTap() {
@@ -738,6 +756,26 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
}
calendarController.selectedDate.value =
sleepReportController.selectedDate.value;
// String date = MyUtils.formatToDate(widget.data['date']);
String data = MyUtils.formatDate(calendarController.selectedDate.value!);
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!, textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
}
@@ -758,6 +796,24 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
}
calendarController.selectedDate.value =
sleepReportController.selectedDate.value;
String data = MyUtils.formatDate(calendarController.selectedDate.value!);
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!, textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
}
@@ -823,6 +879,26 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
onDateSelected: (newDate) {
sleepReportController.selectedDate.value = newDate;
calendarController.selectedDate.value = newDate;
String data =
MyUtils.formatDate(calendarController.selectedDate.value!);
requestWithLog(
logTitle: "查询睡眠报告",
method: MyHttpMethod.get,
queryUrl:
"https://sleepdata.he-info.com/api/analysis/sleep/analysis?mac=${widget.data['mac']}&time=${data}&type=${sleepReportController.model.type}",
onSuccess: (res) {
print(res);
sleepReportController.sleepReport.value = res.data;
sleepReportController.updateAll();
},
onFailure: (res) {
TopSlideNotification.show(context,
text: res.msg!,
textColor: themeController.currentColor.sc9);
sleepReportController.sleepReport.value = {};
sleepReportController.updateAll();
print(res);
});
sleepReportController.updateAll();
calendarController.updateAll();
},
@@ -841,4 +917,22 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
],
);
}
static String _getEnglishMonthName(int month) {
const monthNames = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',
'October',
'November',
'December'
];
return monthNames[month - 1];
}
}

View File

@@ -153,7 +153,7 @@ class _SettingPageState extends State<SettingPage> {
mainAxisSize: MainAxisSize.max,
children: [
Text(
'深色',
'深色'.tr,
style:
FlutterFlowTheme.of(context)
.bodyMedium