日报周报月报
This commit is contained in:
@@ -193,7 +193,7 @@ Widget WeekDataWidget(
|
||||
offset,
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
color: Color(0xFFFFFFFF).withOpacity(0.6),
|
||||
color: Color(0xFFFFFFFF).withOpacity(0.06),
|
||||
fontSize: 18.rpx),
|
||||
);
|
||||
},
|
||||
|
||||
@@ -88,7 +88,7 @@ class AvgSleepScoreWidget extends StatelessWidget {
|
||||
Text(
|
||||
sleepReport['score']?['max']?.toString() ?? '--',
|
||||
style: TextStyle(
|
||||
color: stringToColor("#FF9F66"),
|
||||
color: Colors.white,
|
||||
fontSize: 48.rpx,
|
||||
),
|
||||
),
|
||||
|
||||
@@ -37,6 +37,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
final GlobalKey heartRateCardKey = GlobalKey();
|
||||
final GlobalKey breatheCardKey = GlobalKey();
|
||||
final ScrollController _scrollController = ScrollController();
|
||||
final RxBool isRightLimit = false.obs;
|
||||
|
||||
@override
|
||||
void didUpdateWidget(NewSleepReportPage oldWidget) {
|
||||
@@ -590,176 +591,180 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
child: getTimeWidget(),
|
||||
),
|
||||
),
|
||||
if (widget.data['person_show'] == null ||
|
||||
widget.data['person_show'] != false)
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 30.rpx, 51.rpx),
|
||||
child: ClickableContainer(
|
||||
backgroundColor:
|
||||
widget.data['backgroundColor'] != null
|
||||
? widget.data['backgroundColor']
|
||||
: themeController.currentColor.sc5,
|
||||
highlightColor:
|
||||
themeController.currentColor.sc5, // 或你希望的点击水波纹颜色
|
||||
borderRadius: AppConstants()
|
||||
.normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'姓名'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
if (widget.data['person_show'] == null ||
|
||||
widget.data['person_show'] != false)
|
||||
Padding(
|
||||
padding: EdgeInsetsDirectional.fromSTEB(
|
||||
30.rpx, 0.rpx, 30.rpx, 51.rpx),
|
||||
child: ClickableContainer(
|
||||
backgroundColor:
|
||||
widget.data['backgroundColor'] != null
|
||||
? widget.data['backgroundColor']
|
||||
: themeController.currentColor.sc5,
|
||||
highlightColor: themeController
|
||||
.currentColor.sc5, // 或你希望的点击水波纹颜色
|
||||
borderRadius: AppConstants()
|
||||
.normal_container_radius, // 如果你想加圆角可以设置 eg. 12.rpx
|
||||
padding: EdgeInsets.zero,
|
||||
onTap: () {},
|
||||
child: Row(
|
||||
mainAxisSize: MainAxisSize.max,
|
||||
children: [
|
||||
Flexible(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'姓名'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'年龄'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
Text(
|
||||
'年龄'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
(widget.data['person']?['name']
|
||||
?.toString()
|
||||
.trim()
|
||||
.isNotEmpty ??
|
||||
false)
|
||||
? widget
|
||||
.data['person']!['name']
|
||||
.toString()
|
||||
: '未知数据'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
(widget.data['person']?['name']
|
||||
?.toString()
|
||||
.trim()
|
||||
.isNotEmpty ??
|
||||
false)
|
||||
? widget
|
||||
.data['person']!['name']
|
||||
.toString()
|
||||
: '未知数据'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'${MyUtils.getAgeByDate(MyUtils.formatBirthdayTime(widget.data['person']?['birthday'])) ?? '未知数据'.tr}',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
Text(
|
||||
'${MyUtils.getAgeByDate(MyUtils.formatBirthdayTime(widget.data['person']?['birthday'])) ?? '未知数据'.tr}',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
]
|
||||
.divide(SizedBox(width: 33.rpx))
|
||||
.addToStart(SizedBox(width: 37.rpx)),
|
||||
),
|
||||
]
|
||||
.addToStart(SizedBox(height: 36.rpx))
|
||||
.addToEnd(SizedBox(height: 36.rpx)),
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
]
|
||||
.divide(SizedBox(width: 33.rpx))
|
||||
.addToStart(
|
||||
SizedBox(width: 37.rpx)),
|
||||
),
|
||||
]
|
||||
.addToStart(SizedBox(height: 36.rpx))
|
||||
.addToEnd(SizedBox(height: 36.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
Flexible(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'设备ID'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
Flexible(
|
||||
flex: 3,
|
||||
child: Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.end,
|
||||
children: [
|
||||
Text(
|
||||
'设备ID'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
Text(
|
||||
'体重'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
Text(
|
||||
'体重'.tr,
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc4,
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${widget.data['code'] ?? '未知数据'.tr}',
|
||||
// "D11250300003",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
Column(
|
||||
crossAxisAlignment:
|
||||
CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
'${widget.data['code'] ?? '未知数据'.tr}',
|
||||
// "D11250300003",
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
),
|
||||
Text(
|
||||
'${widget.data['person']?['weight'] ?? '未知数据'.tr}kg',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
Text(
|
||||
'${widget.data['person']?['weight'] ?? '未知数据'.tr}kg',
|
||||
style: TextStyle(
|
||||
fontFamily: 'Inter',
|
||||
fontSize: 26.rpx,
|
||||
letterSpacing: 0.0,
|
||||
color: themeController
|
||||
.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
]
|
||||
.divide(SizedBox(width: 33.rpx))
|
||||
.addToStart(SizedBox(width: 37.rpx)),
|
||||
),
|
||||
]
|
||||
.addToStart(SizedBox(height: 36.rpx))
|
||||
.addToEnd(SizedBox(height: 36.rpx)),
|
||||
].divide(SizedBox(height: 34.rpx)),
|
||||
),
|
||||
]
|
||||
.divide(SizedBox(width: 33.rpx))
|
||||
.addToStart(
|
||||
SizedBox(width: 37.rpx)),
|
||||
),
|
||||
]
|
||||
.addToStart(SizedBox(height: 36.rpx))
|
||||
.addToEnd(SizedBox(height: 36.rpx)),
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
(sleepReport.value == null || sleepReport.value.isEmpty)
|
||||
? Container(
|
||||
child: NullDataWidget(),
|
||||
@@ -778,7 +783,6 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
)),
|
||||
);
|
||||
}),
|
||||
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -829,6 +833,7 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
}
|
||||
|
||||
void onLeftArrowTap() {
|
||||
isRightLimit.value = false;
|
||||
if (type == 1) {
|
||||
sleepReportController.selectedDate.value =
|
||||
selectedDate.subtract(const Duration(days: 1));
|
||||
@@ -877,53 +882,89 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
}
|
||||
|
||||
void onRightArrowTap() {
|
||||
final now = DateTime.now();
|
||||
final today = DateTime(now.year, now.month, now.day);
|
||||
DateTime targetDate = selectedDate;
|
||||
|
||||
|
||||
|
||||
if (type == 1) {
|
||||
sleepReportController.selectedDate.value =
|
||||
selectedDate.add(const Duration(days: 1));
|
||||
final nextDate = selectedDate.add(const Duration(days: 1));
|
||||
if (!nextDate.isAfter(today)) {
|
||||
targetDate = nextDate;
|
||||
} else {
|
||||
isRightLimit.value = true;
|
||||
return;
|
||||
}
|
||||
} else if (type == 2) {
|
||||
sleepReportController.selectedDate.value =
|
||||
selectedDate.add(const Duration(days: 7));
|
||||
final currentWeekday = today.weekday; // 1=周一,7=周日
|
||||
final currentWeekEnd = today.add(Duration(days: 7 - currentWeekday));
|
||||
final nextWeek = selectedDate.add(const Duration(days: 7));
|
||||
|
||||
if (!nextWeek.isAfter(currentWeekEnd)) {
|
||||
targetDate = nextWeek;
|
||||
} else {
|
||||
isRightLimit.value = true;
|
||||
return;
|
||||
}
|
||||
} else if (type == 3) {
|
||||
sleepReportController.selectedDate.value = DateTime(
|
||||
final currentMonthEnd = DateTime(today.year, today.month + 1, 0);
|
||||
final nextMonth = DateTime(
|
||||
selectedDate.year,
|
||||
selectedDate.month + 1,
|
||||
selectedDate.day,
|
||||
);
|
||||
|
||||
if (!nextMonth.isAfter(currentMonthEnd)) {
|
||||
final correctedDay = DateTime(
|
||||
nextMonth.year,
|
||||
nextMonth.month + 1,
|
||||
0,
|
||||
).day;
|
||||
|
||||
targetDate = DateTime(
|
||||
nextMonth.year,
|
||||
nextMonth.month,
|
||||
nextMonth.day > correctedDay ? correctedDay : nextMonth.day,
|
||||
);
|
||||
} else {
|
||||
isRightLimit.value = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
calendarController.selectedDate.value =
|
||||
sleepReportController.selectedDate.value;
|
||||
String data = MyUtils.formatDate(calendarController.selectedDate.value!);
|
||||
|
||||
// 👉 更新数据并请求
|
||||
sleepReportController.selectedDate.value = targetDate;
|
||||
calendarController.selectedDate.value = targetDate;
|
||||
|
||||
String data = MyUtils.formatDate(targetDate);
|
||||
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) {
|
||||
if (MainPageBBottomChange.getCurrentIndex() != null) {
|
||||
if (MainPageBBottomChange.getCurrentIndex() == 1) {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!,
|
||||
textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
} else {
|
||||
TopSlideNotification.show(context,
|
||||
text: res.msg!, textColor: themeController.currentColor.sc9);
|
||||
}
|
||||
sleepReportController.sleepReport.value = {};
|
||||
sleepReportController.updateAll();
|
||||
print(res);
|
||||
});
|
||||
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) {
|
||||
final msg = res.msg!;
|
||||
TopSlideNotification.show(
|
||||
context,
|
||||
text: msg,
|
||||
textColor: themeController.currentColor.sc9,
|
||||
);
|
||||
sleepReportController.sleepReport.value = {};
|
||||
sleepReportController.updateAll();
|
||||
},
|
||||
);
|
||||
|
||||
sleepReportController.updateAll();
|
||||
calendarController.updateAll();
|
||||
}
|
||||
|
||||
|
||||
void onChangeArrowTap() {
|
||||
void onChangeArrowTap() {
|
||||
if (type == 1) {
|
||||
sleepReportController.selectedDate.value =
|
||||
selectedDate.subtract(const Duration(days: 1));
|
||||
@@ -971,8 +1012,6 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
calendarController.updateAll();
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@@ -985,9 +1024,9 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
padding: EdgeInsets.all(10.rpx),
|
||||
borderRadius: 8.rpx,
|
||||
onTap: onLeftArrowTap,
|
||||
child: SizedBox(
|
||||
width: 9.rpx,
|
||||
height: 14.rpx,
|
||||
child: Container(
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/arrow_left.svg',
|
||||
color: themeController.currentColor.sc3,
|
||||
@@ -1004,21 +1043,36 @@ class _NewSleepReportPageState extends State<NewSleepReportPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: themeController.currentColor.sc3,
|
||||
padding: EdgeInsets.all(10.rpx),
|
||||
borderRadius: 8.rpx,
|
||||
onTap: onRightArrowTap,
|
||||
child: SizedBox(
|
||||
width: 9.rpx,
|
||||
height: 14.rpx,
|
||||
child: SvgPicture.asset(
|
||||
'assets/img/icon/arrow_right.svg',
|
||||
color: themeController.currentColor.sc3,
|
||||
),
|
||||
),
|
||||
),
|
||||
// ClickableContainer(
|
||||
// backgroundColor: Colors.transparent,
|
||||
// highlightColor: themeController.currentColor.sc3,
|
||||
// padding: EdgeInsets.all(10.rpx),
|
||||
// borderRadius: 8.rpx,
|
||||
// onTap: onRightArrowTap,
|
||||
// child: Container(
|
||||
// width: 30.rpx,
|
||||
// height: 30.rpx,
|
||||
// child: SvgPicture.asset(
|
||||
// 'assets/img/icon/arrow_right.svg',
|
||||
// color: themeController.currentColor.sc3,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
Obx(() => ClickableContainer(
|
||||
backgroundColor: Colors.transparent,
|
||||
highlightColor: themeController.currentColor.sc3,
|
||||
padding: EdgeInsets.all(10.rpx),
|
||||
borderRadius: 8.rpx,
|
||||
onTap: isRightLimit.value ? () {} : onRightArrowTap,
|
||||
child: Container(
|
||||
width: 30.rpx,
|
||||
height: 30.rpx,
|
||||
child: SvgPicture.asset('assets/img/icon/arrow_right.svg',
|
||||
color: isRightLimit.value
|
||||
? Color(0xFF929699)
|
||||
: Color(0xFFFFFFFF)),
|
||||
),
|
||||
))
|
||||
],
|
||||
),
|
||||
ClickableContainer(
|
||||
|
||||
Reference in New Issue
Block a user