1414 lines
57 KiB
Dart
1414 lines
57 KiB
Dart
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/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/tool/ClickableContainer.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/pages/common/selectDialog.dart';
|
|
import 'package:vbvs_app/pages/person/select_time.dart';
|
|
|
|
getContentById(data, BuildContext context) {
|
|
try {
|
|
String serviceAddress = ServiceConstant.service_address;
|
|
String serviceName = ServiceConstant.server_service;
|
|
String serviceApi = ServiceConstant.user_setting;
|
|
String mac = data['device']['mac'];
|
|
String type = "user_device_message_setting_$mac";
|
|
String queryUrl = "${serviceAddress}${serviceName}${serviceApi}";
|
|
CommonMessageSettingController commonMessageSettingController = Get.find();
|
|
MessageSettingController messageSettingController = Get.find();
|
|
int id = data['id'];
|
|
Map<String, dynamic>? userConfig = messageSettingController
|
|
.model.device_type_setting
|
|
.firstWhere((item) => item['id'] == id, orElse: () => null);
|
|
// 3. 如果没找到用户配置,再从 messageType 中查找默认配置
|
|
Map<String, dynamic>? defaultConfig;
|
|
// 在 messageType 的 real 数组中查找
|
|
defaultConfig = messageSettingController.messageType['real']
|
|
?.firstWhere((item) => item['id'] == id, orElse: () => null);
|
|
|
|
// 如果在 real 中没找到,在 report 数组中查找
|
|
if (defaultConfig == null) {
|
|
defaultConfig = messageSettingController.messageType['report']
|
|
?.firstWhere((item) => item['id'] == id, orElse: () => null);
|
|
}
|
|
if (id == 100001) {
|
|
//心率异常
|
|
// 1. 优先从 device_type_setting 中查找用户配置
|
|
int min = 40; // 默认值
|
|
int max = 105; // 默认值
|
|
int interval = 600; // 默认值
|
|
// 2. 如果找到了用户配置,使用用户配置中的 max 值
|
|
if (userConfig != null) {
|
|
print('找到用户配置: $userConfig');
|
|
// 获取 max 值
|
|
if (userConfig['max'] != null) {
|
|
max = userConfig['max'] is int
|
|
? userConfig['max']
|
|
: int.tryParse(userConfig['max'].toString()) ?? 60;
|
|
}
|
|
if (userConfig['min'] != null) {
|
|
min = userConfig['min'] is int
|
|
? userConfig['min']
|
|
: int.tryParse(userConfig['min'].toString()) ?? 60;
|
|
}
|
|
if (userConfig['interval'] != null) {
|
|
interval = userConfig['interval'] is int
|
|
? userConfig['interval']
|
|
: int.tryParse(userConfig['interval'].toString()) ?? 60;
|
|
}
|
|
} else {
|
|
// 如果找到了默认配置
|
|
if (defaultConfig != null) {
|
|
print('找到默认配置: $defaultConfig');
|
|
|
|
// 获取 max 值
|
|
if (defaultConfig['max'] != null) {
|
|
max = defaultConfig['max'] is int
|
|
? defaultConfig['max']
|
|
: int.tryParse(defaultConfig['max'].toString()) ?? 60;
|
|
}
|
|
if (defaultConfig['min'] != null) {
|
|
min = defaultConfig['min'] is int
|
|
? defaultConfig['min']
|
|
: int.tryParse(defaultConfig['min'].toString()) ?? 60;
|
|
}
|
|
if (defaultConfig['interval'] != null) {
|
|
interval = defaultConfig['interval'] is int
|
|
? defaultConfig['interval']
|
|
: int.tryParse(defaultConfig['interval'].toString()) ?? 60;
|
|
}
|
|
} else {
|
|
throw '未找到默认配置, 请检查配置文件';
|
|
}
|
|
}
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(30.rpx, 20.rpx, 30.rpx, 20.rpx),
|
|
child: Column(
|
|
children: [
|
|
/// --- 心率小于 ---
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final currentScore = min;
|
|
final initialScore = currentScore != null
|
|
? int.tryParse(currentScore.toString()) ?? 40
|
|
: 40;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showScorePickerDialog(
|
|
context,
|
|
title: "心率小于".tr,
|
|
initialHeight: initialScore,
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['min'] = selectedScore; // 根据你的业务逻辑,布尔值转成 1/0
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"max": defaultConfig!['max'],
|
|
"min": selectedScore,
|
|
"interval": defaultConfig!['interval'],
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
// fetchDeviceMessageSetting();
|
|
messageSettingController.updateAll();
|
|
});
|
|
},
|
|
min: 10,
|
|
max: 140,
|
|
);
|
|
});
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"心率小于".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
"$min".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
/// --- 心率大于 ---
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final currentScore = max;
|
|
final initialScore = currentScore != null
|
|
? int.tryParse(currentScore.toString()) ?? 105
|
|
: 105;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showScorePickerDialog(
|
|
context,
|
|
title: "心率大于".tr,
|
|
initialHeight: initialScore,
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['max'] = selectedScore; // 根据你的业务逻辑,布尔值转成 1/0
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"max": selectedScore,
|
|
"min": defaultConfig!['min'],
|
|
"interval": defaultConfig!['interval'],
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
// fetchDeviceMessageSetting();
|
|
messageSettingController.updateAll();
|
|
});
|
|
},
|
|
min: 10,
|
|
max: 140,
|
|
);
|
|
});
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"心率大于".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
"$max".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
/// --- 提醒类型 ---
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final currentScore = interval;
|
|
final initialScore = currentScore != null
|
|
? int.tryParse(currentScore.toString()) ?? 600
|
|
: 600;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showIntervalPickerDialog(
|
|
unit: "分钟/次".tr,
|
|
context,
|
|
title: "提醒类型".tr,
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['interval'] =
|
|
selectedScore; // 根据你的业务逻辑,布尔值转成 1/0
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"max": defaultConfig!['max'],
|
|
"min": defaultConfig!['min'],
|
|
"interval": selectedScore,
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
// fetchDeviceMessageSetting();
|
|
messageSettingController.updateAll();
|
|
});
|
|
},
|
|
initialValue: initialScore,
|
|
options: [60, 300, 600],
|
|
);
|
|
});
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"提醒类型".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
"${getShowInternal(id, interval)}".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
} else if (id == 100002) {
|
|
// 呼吸异常
|
|
|
|
int min = 8; // 默认
|
|
int max = 25; // 默认
|
|
int interval = 600; // 默认
|
|
|
|
// 若有用户配置
|
|
if (userConfig != null) {
|
|
if (userConfig['max'] != null) {
|
|
max = userConfig['max'] is int
|
|
? userConfig['max']
|
|
: int.tryParse(userConfig['max'].toString()) ?? max;
|
|
}
|
|
|
|
if (userConfig['min'] != null) {
|
|
min = userConfig['min'] is int
|
|
? userConfig['min']
|
|
: int.tryParse(userConfig['min'].toString()) ?? min;
|
|
}
|
|
|
|
if (userConfig['interval'] != null) {
|
|
interval = userConfig['interval'] is int
|
|
? userConfig['interval']
|
|
: int.tryParse(userConfig['interval'].toString()) ?? interval;
|
|
}
|
|
}
|
|
// 若无用户配置 → 用默认配置
|
|
else if (defaultConfig != null) {
|
|
if (defaultConfig['max'] != null) {
|
|
max = defaultConfig['max'] is int
|
|
? defaultConfig['max']
|
|
: int.tryParse(defaultConfig['max'].toString()) ?? max;
|
|
}
|
|
|
|
if (defaultConfig['min'] != null) {
|
|
min = defaultConfig['min'] is int
|
|
? defaultConfig['min']
|
|
: int.tryParse(defaultConfig['min'].toString()) ?? min;
|
|
}
|
|
|
|
if (defaultConfig['interval'] != null) {
|
|
interval = defaultConfig['interval'] is int
|
|
? defaultConfig['interval']
|
|
: int.tryParse(defaultConfig['interval'].toString()) ?? interval;
|
|
}
|
|
} else {
|
|
throw '未找到默认配置,请检查配置文件';
|
|
}
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(30.rpx, 20.rpx, 30.rpx, 20.rpx),
|
|
child: Column(
|
|
children: [
|
|
/// ---- 呼吸小于 ----
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final initialScore = min;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showScorePickerDialog(
|
|
context,
|
|
title: "呼吸小于".tr,
|
|
initialHeight: initialScore,
|
|
min: 5,
|
|
max: 50,
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
|
|
if (configIndex != -1) {
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['min'] = selectedScore;
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"max": defaultConfig!['max'],
|
|
"min": selectedScore,
|
|
"interval": defaultConfig['interval'],
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
|
|
requestWithLog(
|
|
logTitle: "更新呼吸异常配置",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
messageSettingController.updateAll();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: _buildRow("呼吸小于", "$min"),
|
|
),
|
|
|
|
/// ---- 呼吸大于 ----
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final initialScore = max;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showScorePickerDialog(
|
|
context,
|
|
title: "呼吸大于".tr,
|
|
initialHeight: initialScore,
|
|
min: 5,
|
|
max: 50,
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
|
|
if (configIndex != -1) {
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['max'] = selectedScore;
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"max": selectedScore,
|
|
"min": defaultConfig!['min'],
|
|
"interval": defaultConfig['interval'],
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
|
|
requestWithLog(
|
|
logTitle: "更新呼吸异常配置",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
messageSettingController.updateAll();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: _buildRow("呼吸大于", "$max"),
|
|
),
|
|
|
|
/// ---- 提醒类型 ----
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final initialScore = interval;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showIntervalPickerDialog(
|
|
unit: "分钟/次".tr,
|
|
context,
|
|
title: "提醒类型".tr,
|
|
initialValue: initialScore,
|
|
options: [60, 300, 600],
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
|
|
if (configIndex != -1) {
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['interval'] = selectedScore;
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"max": defaultConfig!['max'],
|
|
"min": defaultConfig['min'],
|
|
"interval": selectedScore,
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
|
|
requestWithLog(
|
|
logTitle: "更新呼吸异常配置",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
messageSettingController.updateAll();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: _buildRow("提醒类型", "${getShowInternal(id, interval)}"),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
} else if (id == 100003) {
|
|
// 离床超时
|
|
// 1. 优先从 device_type_setting 中查找用户配置
|
|
int interval = 600; // 默认值
|
|
int duration = 300; // 默认值
|
|
|
|
// 2. 如果找到了用户配置,使用用户配置中的值
|
|
if (userConfig != null) {
|
|
print('找到用户配置: $userConfig');
|
|
|
|
// 获取 interval 值
|
|
if (userConfig['interval'] != null) {
|
|
interval = userConfig['interval'] is int
|
|
? userConfig['interval']
|
|
: int.tryParse(userConfig['interval'].toString()) ?? 600;
|
|
}
|
|
|
|
// 获取 duration 值
|
|
if (userConfig['duration'] != null) {
|
|
duration = userConfig['duration'] is int
|
|
? userConfig['duration']
|
|
: int.tryParse(userConfig['duration'].toString()) ?? 300;
|
|
}
|
|
} else {
|
|
// 如果找到了默认配置
|
|
if (defaultConfig != null) {
|
|
print('找到默认配置: $defaultConfig');
|
|
|
|
// 获取 interval 值
|
|
if (defaultConfig['interval'] != null) {
|
|
interval = defaultConfig['interval'] is int
|
|
? defaultConfig['interval']
|
|
: int.tryParse(defaultConfig['interval'].toString()) ?? 600;
|
|
}
|
|
|
|
// 获取 duration 值
|
|
if (defaultConfig['duration'] != null) {
|
|
duration = defaultConfig['duration'] is int
|
|
? defaultConfig['duration']
|
|
: int.tryParse(defaultConfig['duration'].toString()) ?? 300;
|
|
}
|
|
} else {
|
|
throw '未找到默认配置, 请检查配置文件';
|
|
}
|
|
}
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(40.rpx, 20.rpx, 40.rpx, 20.rpx),
|
|
child: Column(
|
|
children: [
|
|
/// --- 离床时长 ---
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final currentDuration = duration;
|
|
final initialDuration = currentDuration != null
|
|
? int.tryParse(currentDuration.toString()) ?? 300
|
|
: 300;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showIntervalPickerDialog(
|
|
options: [60, 300, 600],
|
|
unit: "分钟".tr,
|
|
context,
|
|
title: "离床时长".tr,
|
|
initialValue: initialDuration,
|
|
onConfirm: (int selectedDuration) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['duration'] = selectedDuration;
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"duration": selectedDuration,
|
|
"interval": defaultConfig?['interval'] ?? 600,
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
messageSettingController.updateAll();
|
|
});
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"离床时间大于".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
"${formatDuration(duration)}".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
|
|
/// --- 提醒类型 ---
|
|
ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 30.rpx, 0, 30.rpx),
|
|
onTap: () {
|
|
final currentScore = interval;
|
|
final initialScore = currentScore != null
|
|
? int.tryParse(currentScore.toString()) ?? 600
|
|
: 600;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showIntervalPickerDialog(
|
|
unit: "分钟".tr,
|
|
context,
|
|
title: "提醒类型".tr,
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]
|
|
['interval'] = selectedScore;
|
|
} else {
|
|
messageSettingController.model.device_type_setting
|
|
.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"duration": defaultConfig?['duration'] ?? 300,
|
|
"interval": selectedScore,
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting": messageSettingController
|
|
.model.device_type_setting,
|
|
};
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
messageSettingController.updateAll();
|
|
});
|
|
},
|
|
initialValue: initialScore,
|
|
options: [60, 300, 600],
|
|
);
|
|
});
|
|
},
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
"提醒类型".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
"${getShowInternal(id, interval)}".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
} else if (id == 100004) {
|
|
// 未卧床
|
|
// 1. 优先从 device_type_setting 中查找用户配置
|
|
String time = "23:00"; // 默认值
|
|
// 2. 如果找到了用户配置,使用用户配置中的 time 值
|
|
if (userConfig != null) {
|
|
print('找到用户配置: $userConfig');
|
|
// 获取 time 值
|
|
if (userConfig['time'] != null) {
|
|
time = userConfig['time'].toString();
|
|
}
|
|
} else {
|
|
// 如果找到了默认配置
|
|
if (defaultConfig != null) {
|
|
print('找到默认配置: $defaultConfig');
|
|
|
|
// 获取 time 值
|
|
if (defaultConfig['time'] != null) {
|
|
time = defaultConfig['time'].toString();
|
|
}
|
|
} else {
|
|
throw '未找到默认配置, 请检查配置文件';
|
|
}
|
|
}
|
|
|
|
// 将时间字符串转换为数组格式 [小时, 分钟]
|
|
List<int> parseTimeToArray(String timeStr) {
|
|
try {
|
|
List<String> parts = timeStr.split(':');
|
|
if (parts.length >= 2) {
|
|
return [int.tryParse(parts[0]) ?? 23, int.tryParse(parts[1]) ?? 0];
|
|
}
|
|
} catch (e) {
|
|
print('时间解析错误: $e');
|
|
}
|
|
return [23, 0]; // 默认值
|
|
}
|
|
|
|
// 将数组格式转换为时间字符串
|
|
String formatTimeFromArray(List<int> timeArr) {
|
|
return "${timeArr[0].toString().padLeft(2, '0')}:${timeArr[1].toString().padLeft(2, '0')}";
|
|
}
|
|
|
|
// 初始化时间数组
|
|
List<int> currentTimeArr = parseTimeToArray(time);
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(40.rpx, 20.rpx, 40.rpx, 20.rpx),
|
|
child: ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0, 0.rpx),
|
|
onTap: () {
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showTHDayTimeSelectionDialog(
|
|
context,
|
|
dayTimeArr: currentTimeArr,
|
|
title: "未卧床时间大于".tr,
|
|
checkChange: (List<int> selectedTime) {
|
|
// 格式化时间为字符串
|
|
String formattedTime = formatTimeFromArray(selectedTime);
|
|
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]['time'] =
|
|
formattedTime;
|
|
} else {
|
|
messageSettingController.model.device_type_setting.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"time": formattedTime,
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting":
|
|
messageSettingController.model.device_type_setting,
|
|
};
|
|
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
messageSettingController.updateAll();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: Container(
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
0.rpx, 30.rpx, 0.rpx, 30.rpx),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Text(
|
|
"未卧床时间大于".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
letterSpacing: 0.0,
|
|
),
|
|
),
|
|
].divide(SizedBox(width: 22.rpx)),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Text(
|
|
time.tr, // 显示配置的时间
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
letterSpacing: 0.0,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
].divide(SizedBox(height: 60.rpx)),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
} else if (id == 100005) {
|
|
// 未起床
|
|
// 1. 优先从 device_type_setting 中查找用户配置
|
|
String time = "7:00"; // 默认值
|
|
|
|
// 2. 如果找到了用户配置,使用用户配置中的 time 值
|
|
if (userConfig != null) {
|
|
print('找到用户配置: $userConfig');
|
|
|
|
// 获取 time 值
|
|
if (userConfig['time'] != null) {
|
|
time = userConfig['time'].toString();
|
|
}
|
|
} else {
|
|
// 如果找到了默认配置
|
|
if (defaultConfig != null) {
|
|
print('找到默认配置: $defaultConfig');
|
|
|
|
// 获取 time 值
|
|
if (defaultConfig['time'] != null) {
|
|
time = defaultConfig['time'].toString();
|
|
}
|
|
} else {
|
|
throw '未找到默认配置, 请检查配置文件';
|
|
}
|
|
}
|
|
|
|
// 将时间字符串转换为数组格式 [小时, 分钟]
|
|
List<int> parseTimeToArray(String timeStr) {
|
|
try {
|
|
List<String> parts = timeStr.split(':');
|
|
if (parts.length >= 2) {
|
|
return [int.tryParse(parts[0]) ?? 23, int.tryParse(parts[1]) ?? 0];
|
|
}
|
|
} catch (e) {
|
|
print('时间解析错误: $e');
|
|
}
|
|
return [23, 0]; // 默认值
|
|
}
|
|
|
|
// 将数组格式转换为时间字符串
|
|
String formatTimeFromArray(List<int> timeArr) {
|
|
return "${timeArr[0].toString().padLeft(2, '0')}:${timeArr[1].toString().padLeft(2, '0')}";
|
|
}
|
|
|
|
// 初始化时间数组
|
|
List<int> currentTimeArr = parseTimeToArray(time);
|
|
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding:
|
|
EdgeInsetsDirectional.fromSTEB(40.rpx, 20.rpx, 40.rpx, 20.rpx),
|
|
child: ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0, 0.rpx, 0, 0.rpx),
|
|
onTap: () {
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showTHDayTimeSelectionDialog(
|
|
context,
|
|
dayTimeArr: currentTimeArr,
|
|
title: "未起床时间大于".tr, // 修改标题为"未起床时间大于"
|
|
checkChange: (List<int> selectedTime) {
|
|
// 格式化时间为字符串
|
|
String formattedTime = formatTimeFromArray(selectedTime);
|
|
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]['time'] =
|
|
formattedTime;
|
|
} else {
|
|
messageSettingController.model.device_type_setting.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"time": formattedTime,
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting":
|
|
messageSettingController.model.device_type_setting,
|
|
};
|
|
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
messageSettingController.updateAll();
|
|
},
|
|
);
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: Container(
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
0.rpx, 30.rpx, 0.rpx, 30.rpx),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Text(
|
|
"未起床时间大于".tr, // 修改为"未起床时间大于"
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
letterSpacing: 0.0,
|
|
),
|
|
),
|
|
].divide(SizedBox(width: 22.rpx)),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Text(
|
|
time.tr, // 显示配置的时间
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
letterSpacing: 0.0,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
].divide(SizedBox(height: 60.rpx)),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
} else if (id == 200001) {
|
|
// 1. 优先从 device_type_setting 中查找用户配置
|
|
int score = 50; // 默认值
|
|
// 2. 如果找到了用户配置,使用用户配置中的 max 值
|
|
if (userConfig != null) {
|
|
print('找到用户配置: $userConfig');
|
|
// 获取 max 值
|
|
if (userConfig['max'] != null) {
|
|
score = userConfig['max'] is int
|
|
? userConfig['max']
|
|
: int.tryParse(userConfig['max'].toString()) ?? score;
|
|
print('从用户配置获取睡眠得分阈值: $score');
|
|
}
|
|
} else {
|
|
// 如果找到了默认配置
|
|
if (defaultConfig != null) {
|
|
print('找到默认配置: $defaultConfig');
|
|
|
|
// 获取 max 值
|
|
if (defaultConfig['max'] != null) {
|
|
score = defaultConfig['max'] is int
|
|
? defaultConfig['max']
|
|
: int.tryParse(defaultConfig['max'].toString()) ?? score;
|
|
print('从默认配置获取睡眠得分阈值: $score');
|
|
}
|
|
} else {
|
|
print('未找到 id 为 $id 的任何配置,使用默认值: $score');
|
|
}
|
|
}
|
|
print('最终睡眠得分阈值: $score');
|
|
// 这里可以继续使用 score 变量...
|
|
return Container(
|
|
decoration: BoxDecoration(
|
|
color: themeController.currentColor.sc5,
|
|
borderRadius:
|
|
BorderRadius.circular(AppConstants().normal_container_radius),
|
|
),
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
40.rpx,
|
|
20.rpx, // 第一个元素顶部有20.rpx间距
|
|
40.rpx,
|
|
20.rpx),
|
|
child: ClickableContainer(
|
|
backgroundColor: Colors.transparent,
|
|
highlightColor: themeController.currentColor.sc21,
|
|
padding: EdgeInsetsDirectional.fromSTEB(0.rpx, 0.rpx, 0.rpx, 0.rpx),
|
|
onTap: () async {
|
|
final currentScore = score;
|
|
final initialScore = currentScore != null
|
|
? int.tryParse(currentScore.toString()) ?? score
|
|
: score;
|
|
FocusScope.of(context).requestFocus(FocusNode());
|
|
Future.delayed(const Duration(milliseconds: 250), () {
|
|
showScorePickerDialog(
|
|
unit: "分".tr,
|
|
context,
|
|
title: "选择分数".tr,
|
|
initialHeight: initialScore,
|
|
onConfirm: (int selectedScore) {
|
|
int configIndex = messageSettingController
|
|
.model.device_type_setting
|
|
.indexWhere((item) => item['id'] == id);
|
|
if (configIndex != -1) {
|
|
// 更新找到的配置项
|
|
messageSettingController
|
|
.model.device_type_setting[configIndex]['max'] =
|
|
selectedScore; // 根据你的业务逻辑,布尔值转成 1/0
|
|
} else {
|
|
messageSettingController.model.device_type_setting.add({
|
|
"id": id,
|
|
"setting": 1,
|
|
"max": selectedScore,
|
|
"appSetting": 1,
|
|
"serviceSetting": 1,
|
|
});
|
|
}
|
|
var data = {
|
|
"type": type,
|
|
"setting": messageSettingController.model.setting,
|
|
"device_type_setting":
|
|
messageSettingController.model.device_type_setting,
|
|
};
|
|
requestWithLog(
|
|
logTitle: "更新消息推送状态",
|
|
method: MyHttpMethod.put,
|
|
queryUrl: queryUrl,
|
|
data: data,
|
|
onSuccess: (res) {
|
|
// fetchDeviceMessageSetting();
|
|
messageSettingController.updateAll();
|
|
});
|
|
},
|
|
);
|
|
});
|
|
},
|
|
child: Container(
|
|
child: Padding(
|
|
padding: EdgeInsetsDirectional.fromSTEB(
|
|
0.rpx, 30.rpx, 0.rpx, 30.rpx),
|
|
child: Column(
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
Text(
|
|
// "${((data["report"] as List)[i]["name"] ?? "")}".tr,
|
|
"睡眠报告评分小于".tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
letterSpacing: 0.0,
|
|
),
|
|
),
|
|
].divide(SizedBox(width: 22.rpx)),
|
|
),
|
|
Row(
|
|
mainAxisSize: MainAxisSize.max,
|
|
children: [
|
|
// 可以根据需要显示其他数据
|
|
Text(
|
|
"${score}".tr +
|
|
"分".tr, // 这里可以显示其他信息,比如: (data["real"] as List)[i]["value"] ?? ""
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
letterSpacing: 0.0,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
),
|
|
].divide(SizedBox(height: 60.rpx)),
|
|
)),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
} else {
|
|
return Container();
|
|
}
|
|
} catch (e) {
|
|
ef.log("获取内容失败-->$e");
|
|
return Container();
|
|
}
|
|
}
|
|
|
|
// 辅助函数:格式化持续时间(秒转分钟)
|
|
String formatDuration(int seconds) {
|
|
if (seconds < 60) {
|
|
return "${seconds}" + "秒".tr;
|
|
} else {
|
|
int minutes = seconds ~/ 60;
|
|
return "${minutes}" + "分钟".tr;
|
|
}
|
|
}
|
|
|
|
Widget _buildRow(String title, String value) {
|
|
return Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
title.tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: AppConstants().title_text_fontSize,
|
|
),
|
|
),
|
|
Row(
|
|
children: [
|
|
Text(
|
|
value.tr,
|
|
style: TextStyle(
|
|
fontFamily: 'Inter',
|
|
color: themeController.currentColor.sc3,
|
|
fontSize: 26.rpx,
|
|
),
|
|
),
|
|
SvgPicture.asset(
|
|
'assets/img/icon/arrow_right.svg',
|
|
width: 8.rpx,
|
|
height: 15.rpx,
|
|
color: themeController.currentColor.sc3,
|
|
),
|
|
].divide(SizedBox(width: 28.rpx)),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
|
|
getShowInternal(int id, int interval) {
|
|
String str = "";
|
|
if (id == 100001) {
|
|
String prefix = "间隔报警".tr;
|
|
// interval 秒 -> 转换成分钟
|
|
int minutes = (interval / 60).round();
|
|
str = "${prefix}(${minutes}" + "分钟/次".tr + ")";
|
|
}
|
|
if (id == 100002) {
|
|
String prefix = "间隔报警".tr;
|
|
// interval 秒 -> 转换成分钟
|
|
int minutes = (interval / 60).round();
|
|
str = "${prefix}(${minutes}" + "分钟/次".tr + ")";
|
|
}
|
|
if (id == 100003) {
|
|
String prefix = "间隔报警".tr;
|
|
// interval 秒 -> 转换成分钟
|
|
int minutes = (interval / 60).round();
|
|
str = "${prefix}(${minutes}" + "分钟".tr + ")";
|
|
}
|
|
return str;
|
|
}
|